Methods Summary |
---|
private void | computeValues()
int targetNbLevels = nbPixels / pixelsPerLevel;
if(targetNbLevels < 1)
targetNbLevels = 1;
scaleFactor = max / targetNbLevels;
powFactor = 1;
while(scaleFactor >= 10) {
powFactor = 10 * powFactor;
scaleFactor = scaleFactor / 10;
}
if(scaleFactor >= 5)
scaleFactor = 5;
else if(scaleFactor >= 2)
scaleFactor = 2;
else
scaleFactor = 1;
nbLevels = max / (scaleFactor * powFactor) + 1;
displayedMax = scaleFactor * powFactor * nbLevels;
|
public int | getMax()
return this.max;
|
public int[] | getScaleValues()
int[] result = new int[nbLevels+1];
for(int i = 0 ; i < nbLevels + 1 ; i++) {
result[i] = i * scaleFactor * powFactor;
}
return result;
|
public int | getScaledValue(int value)
return(int)( ((long)value * nbPixels) / displayedMax );
|
public void | setMax(int max)
this.max = max;
if(max < 1)
max = 1;
computeValues();
|
public void | setNbPixels(int nbPixels)
this.nbPixels = nbPixels;
if(nbPixels < 1)
nbPixels = 1;
computeValues();
|