FileDocCategorySizeDatePackage
GraphableButton.javaAPI DocAndroid 1.5 API1626Wed May 06 22:42:48 BST 2009com.android.settings.battery_history

GraphableButton

public class GraphableButton extends android.widget.Button

Fields Summary
private static final String
TAG
static android.graphics.Paint[]
sPaint
double[]
mValues
Constructors Summary
public GraphableButton(android.content.Context context, android.util.AttributeSet attrs)

        super(context, attrs);
    
Methods Summary
public voidonDraw(android.graphics.Canvas canvas)

        Log.i(TAG, "onDraw: w = " + getWidth() + ", h = " + getHeight());
        
        int xmin = getPaddingLeft();
        int xmax = getWidth() - getPaddingRight();
        int ymin = getPaddingTop();
        int ymax = getHeight() - getPaddingBottom();
        
        int startx = xmin;
        for (int i = 0; i < mValues.length; i++) {
            int endx = xmin + (int) (mValues[i] * (xmax - xmin));
            canvas.drawRect(startx, ymin, endx, ymax, sPaint[i]);
            startx = endx;
        }
        super.onDraw(canvas);
    
public voidsetValues(double[] values, double maxValue)

        mValues = values.clone();
        for (int i = 0; i < values.length; i++) {
            mValues[i] /= maxValue;
        }