1 25 package info.monitorenter.gui.chart.axis; 26 27 import info.monitorenter.gui.chart.AAxis; 28 import info.monitorenter.gui.chart.labelformatters.ALabelFormatter; 29 import info.monitorenter.util.Range; 30 31 import java.awt.event.MouseEvent ; 32 33 43 public abstract class AAxisTransformation extends AAxis { 44 45 52 public AAxisTransformation() { 53 super(); 54 } 55 56 62 public AAxisTransformation(final ALabelFormatter formatter) { 63 super(formatter); 64 } 65 66 69 protected final double getScaledValue(final double absolute) { 70 double result; 71 Range range = this.getRange(); 72 double scaler = range.getExtent(); 73 74 result = (transform(absolute) - range.getMin()); 75 result = result / scaler; 76 if (result == Double.NaN || Double.isInfinite(result)) { 77 result = 0; 78 } 79 return result; 80 } 81 82 96 protected abstract double transform(final double in); 97 98 110 protected abstract double untransform(final double in); 111 112 115 protected final double translateMousePosition(final MouseEvent mouseEvent) 116 throws IllegalArgumentException { 117 return this.untransform(this.getAccessor().translateMousePosition(mouseEvent)); 118 } 119 120 123 public double getMax() { 124 return this.transform(super.getMax()); 125 } 126 127 130 public double getMin() { 131 return this.transform(super.getMin()); 132 } 133 } 134 | Popular Tags |