if(x > 20) {
double val = (x-offsetX)/scaleX / getTransform().getScaleX();
double modifiedValue = modifyHorizontalValue(val);
- String str = formatValue(modifiedValue);
+ String str = formatValue(modifiedValue, getMaxDigits());
FontMetrics fm = g.getFontMetrics();
Rectangle2D r = fm.getStringBounds(str, g);
if((x-r.getWidth()/2) > previousText) {
if(y > 20) {
double val = (y-offsetY)/scaleY / getTransform().getScaleY();
double modifiedValue = modifyVerticalValue(val);
- String str = formatValue(modifiedValue);
+ String str = formatValue(modifiedValue, getMaxDigits());
FontMetrics fm = g.getFontMetrics();
Rectangle2D r = fm.getStringBounds(str, g);
if(y-1+r.getHeight()/2 > previousText) {
private static final transient String[] SI_UNIT_LARGE_PREFIXES = {
"k", "M", "G", "T", "P", "E", "Z", "Y"
};
+
+ protected int getMaxDigits() {
+ return MAX_DIGITS;
+ }
- public static String formatValue(double value) {
+ public static String formatValue(double value, int maxDigits) {
int magnitude = (int) Math.round(Math.log10(value));
//System.out.println("magnitude: " + magnitude + ", " + value);
- int allowedDecimals = MAX_DIGITS;
+ int allowedDecimals = maxDigits;
allowedDecimals -= Math.abs(magnitude);
if (allowedDecimals < 0)
allowedDecimals = 0;