Home | History | Annotate | Download | only in widget
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.settings.widget;
     18 
     19 import android.content.res.Resources;
     20 import android.text.SpannableStringBuilder;
     21 
     22 /**
     23  * Axis along a {@link ChartView} that knows how to convert between raw point
     24  * and screen coordinate systems.
     25  */
     26 public interface ChartAxis {
     27 
     28     /** Set range of raw values this axis should cover. */
     29     public boolean setBounds(long min, long max);
     30     /** Set range of screen points this axis should cover. */
     31     public boolean setSize(float size);
     32 
     33     /** Convert raw value into screen point. */
     34     public float convertToPoint(long value);
     35     /** Convert screen point into raw value. */
     36     public long convertToValue(float point);
     37 
     38     /**
     39      * Build label that describes given raw value. If the label is rounded for
     40      * display, return the rounded value.
     41      */
     42     public long buildLabel(Resources res, SpannableStringBuilder builder, long value);
     43 
     44     /** Return list of tick points for drawing a grid. */
     45     public float[] getTickPoints();
     46 
     47     /**
     48      * Test if given raw value should cause the axis to grow or shrink;
     49      * returning positive value to grow and negative to shrink.
     50      */
     51     public int shouldAdjustAxis(long value);
     52 
     53 }
     54