Methods Summary |
---|
public void | computeTicks(boolean useGivenEndPoints)
int numTicks = mNumPixels / mPixelsPerTick;
mRangeVal = mMaxVal - mMinVal;
mTickIncrement = mRangeVal / numTicks;
double dlogTickIncrement = Math.log10(mTickIncrement);
int logTickIncrement = (int) Math.floor(dlogTickIncrement);
double scale = Math.pow(10, logTickIncrement);
double scaledTickIncr = mTickIncrement / scale;
if (scaledTickIncr > 5.0)
scaledTickIncr = 10;
else if (scaledTickIncr > 2)
scaledTickIncr = 5;
else if (scaledTickIncr > 1)
scaledTickIncr = 2;
else
scaledTickIncr = 1;
mTickIncrement = scaledTickIncr * scale;
if (!useGivenEndPoints) {
// Round up the max val to the next minor tick
double minorTickIncrement = mTickIncrement / 5;
double dval = mMaxVal / minorTickIncrement;
int ival = (int) dval;
if (ival != dval)
mMaxVal = (ival + 1) * minorTickIncrement;
// Round down the min val to a multiple of tickIncrement
ival = (int) (mMinVal / mTickIncrement);
mMinVal = ival * mTickIncrement;
mMinMajorTick = mMinVal;
} else {
int ival = (int) (mMinVal / mTickIncrement);
mMinMajorTick = ival * mTickIncrement;
if (mMinMajorTick < mMinVal)
mMinMajorTick = mMinMajorTick + mTickIncrement;
}
mRangeVal = mMaxVal - mMinVal;
mPixelsPerRange = (double) mNumPixels / mRangeVal;
|
public double | getMaxVal()
return mMaxVal;
|
public double | getMinMajorTick()
return mMinMajorTick;
|
public double | getMinVal()
return mMinVal;
|
public int | getNumPixels()
return mNumPixels;
|
public double | getPixelsPerRange()
return mPixelsPerRange;
|
public int | getPixelsPerTick()
return mPixelsPerTick;
|
public double | getTickIncrement()
return mTickIncrement;
|
public double | pixelToValue(int pixel)
return mMinVal + (pixel / mPixelsPerRange);
|
public void | setMaxVal(double maxVal)
mMaxVal = maxVal;
|
public void | setMinMajorTick(double minMajorTick)
mMinMajorTick = minMajorTick;
|
public void | setMinVal(double minVal)
mMinVal = minVal;
|
public void | setNumPixels(int numPixels)
mNumPixels = numPixels;
|
public void | setPixelsPerRange(double pixelsPerRange)
mPixelsPerRange = pixelsPerRange;
|
public void | setPixelsPerTick(int pixelsPerTick)
mPixelsPerTick = pixelsPerTick;
|
public void | setTickIncrement(double tickIncrement)
mTickIncrement = tickIncrement;
|
public int | valueToPixel(double value)
return (int) Math.ceil(mPixelsPerRange * (value - mMinVal) - 0.5);
|
public double | valueToPixelFraction(double value)
return mPixelsPerRange * (value - mMinVal);
|