Package info.monitorenter.gui.chart.axis
Class AAxisTransformation<T extends AxisScalePolicyTransformation>
java.lang.Object
info.monitorenter.gui.chart.axis.AAxis<T>
info.monitorenter.gui.chart.axis.AAxisTransformation<T>
- Type Parameters:
T
- Used to enforce that this instance only acceptsAxisScalePolicyTransformation
and subtypes.
- All Implemented Interfaces:
IAxis<T>
,PropertyChangeListener
,Serializable
,EventListener
Base class for Axis implementations that transform the scale for changed
display.
Note that instances of this implementations will only accept subtypes of
AxisScalePolicyTransformation
for the method
AAxis.setAxisScalePolicy(IAxisScalePolicy)
.
- Version:
- $Revision: 1.32 $
- Author:
- Achim Westermann
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected final class
An accessor for the x axis of a chart.protected final class
Accesses the y axis of theChart2D
.Nested classes/interfaces inherited from class info.monitorenter.gui.chart.axis.AAxis
AAxis.AChart2DDataAccessor
Nested classes/interfaces inherited from interface info.monitorenter.gui.chart.IAxis
IAxis.AxisTitle
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected long
Internal timestamp of the last transformation error reporting.Fields inherited from class info.monitorenter.gui.chart.axis.AAxis
DEBUG, m_accessor, m_formatter, m_majorTickSpacing, m_max, m_min, m_minorTickSpacing, m_needsFullRescale, m_rangePolicy
Fields inherited from interface info.monitorenter.gui.chart.IAxis
PROPERTY_ADD_REMOVE_TRACE, PROPERTY_AXIS_SCALE_POLICY_CHANGED, PROPERTY_LABELFORMATTER, PROPERTY_PAINTGRID, PROPERTY_PAINTSCALE, PROPERTY_RANGEPOLICY
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a default instance that will use aLabelFormatterAutoUnits
for formatting labels.AAxisTransformation
(IAxisLabelFormatter formatter, T scalePolicy) Creates an instance that will the given label formatter for formatting labels. -
Method Summary
Modifier and TypeMethodDescriptionprotected AAxis<T>.AChart2DDataAccessor
createAccessor
(Chart2D chart, int dimension, int position) Template method to create the properAAxis.AChart2DDataAccessor
double
Returns the transformed max with additional error treatment in case of empty traces.double
Returns the transformed min with additional error treatment in case of empty traces.final double
getScaledValue
(double absolute) Scales the given absolute value into a value between 0 and 1.0 (if it is in the range of the data).void
scaleTrace
(ITrace2D trace) Overridden to incorporate transformation.abstract double
transform
(double in) Template method for performing the axis transformation.final double
translateMousePosition
(MouseEvent mouseEvent) Returns the translation of the mouse event coordinates of the given mouse event to the value within the chart for the dimension (x,y) covered by this axis.double
translatePxToValue
(int pixel) Transforms the given pixel value (which has to be a awt value likeMouseEvent.getY()
into the chart value.abstract double
untransform
(double in) Template method for performing the reverse axis transformation.Methods inherited from class info.monitorenter.gui.chart.axis.AAxis
addPropertyChangeListener, addTrace, ensureInitialized, equals, findMax, findMin, getAccessor, getAxisPosition, getAxisScalePolicy, getAxisTitle, getDimension, getDimensionString, getFormatter, getHeight, getMajorTickSpacing, getMax, getMaxValue, getMin, getMinorTickSpacing, getMinValue, getPixelXLeft, getPixelXRight, getPixelYBottom, getPixelYTop, getPropertyChangeListeners, getRange, getRangePolicy, getTitle, getTitlePainter, getTraces, getValueDistanceForPixel, getWidth, hashCode, hasTrace, initPaintIteration, isDirtyScaling, isPaintGrid, isPaintScale, isStartMajorTick, isVisible, paint, paintTitle, propertyChange, removeAllTraces, removeAxisTitle, removePropertyChangeListener, removeTrace, scale, scalePoint, setAccessor, setAxisPosition, setAxisScalePolicy, setAxisTitle, setChart, setFormatter, setMajorTickSpacing, setMinorTickSpacing, setPaintGrid, setPaintScale, setPixelXLeft, setPixelXRight, setPixelYBottom, setPixelYTop, setRange, setRangePolicy, setStartMajorTick, setTitle, setTitlePainter, setVisible, translateValueToPx
-
Field Details
-
m_outputErrorTstamp
protected long m_outputErrorTstampInternal timestamp of the last transformation error reporting.
-
-
Constructor Details
-
AAxisTransformation
public AAxisTransformation()Creates a default instance that will use aLabelFormatterAutoUnits
for formatting labels. -
AAxisTransformation
Creates an instance that will the given label formatter for formatting labels.- Parameters:
formatter
- needed for formatting labels of this axis.scalePolicy
- controls the ticks/labels and their distance.
-
-
Method Details
-
createAccessor
Description copied from class:AAxis
Template method to create the properAAxis.AChart2DDataAccessor
- Specified by:
createAccessor
in classAAxis<T extends AxisScalePolicyTransformation>
- Parameters:
chart
- the chart to access.dimension
-
orChart2D.X
.Chart2D.Y
position
-
,Chart2D.CHART_POSITION_BOTTOM
Chart2D.CHART_POSITION_LEFT
Chart2D.CHART_POSITION_RIGHT
Chart2D.CHART_POSITION_TOP
- Returns:
- the proper
implementation.AAxis.AChart2DDataAccessor
- See Also:
-
getMaxTransformed
public double getMaxTransformed()Returns the transformed max with additional error treatment in case of empty traces.- Returns:
- the transformed max with additional error treatment in case of empty traces.
- See Also:
-
getMinTransformed
public double getMinTransformed()Returns the transformed min with additional error treatment in case of empty traces.- Returns:
- the transformed min with additional error treatment in case of empty traces.
- See Also:
-
getScaledValue
public final double getScaledValue(double absolute) Description copied from interface:IAxis
Scales the given absolute value into a value between 0 and 1.0 (if it is in the range of the data).If the given absolute value is not in the display- range of the
Chart2D
, negative values or values greater than 1.0 may result.- Parameters:
absolute
- a value in the real value range of the corresponding chart.- Returns:
- a value between 0.0 and 1.0 that is mapped to a position within the chart.
- See Also:
-
scaleTrace
Overridden to incorporate transformation.- Specified by:
scaleTrace
in interfaceIAxis<T extends AxisScalePolicyTransformation>
- Overrides:
scaleTrace
in classAAxis<T extends AxisScalePolicyTransformation>
- Parameters:
trace
- the trace to scale.- See Also:
-
transform
Template method for performing the axis transformation.The argument should not be negative, so only normalized values (no chart values but their scaled values or pixel values) should be given here.
- Parameters:
in
- the value to transform.- Returns:
- the transformed value.
- Throws:
IllegalArgumentException
- if scaling is impossible (due to some mathematical transformation in implementations likeAxisLog10
-
translateMousePosition
Description copied from class:AAxis
Returns the translation of the mouse event coordinates of the given mouse event to the value within the chart for the dimension (x,y) covered by this axis.Note that the mouse event has to be an event fired on the correspondinig chart component!
- Overrides:
translateMousePosition
in classAAxis<T extends AxisScalePolicyTransformation>
- Parameters:
mouseEvent
- a mouse event that has been fired on this component.- Returns:
- the translation of the mouse event coordinates of the given mouse event to the value within the chart for the dimension covered by this axis (x or y) or null if no calculations could be performed as the chart was not painted before.
- Throws:
IllegalArgumentException
- if the given mouse event is out of the current graphics context (not a mouse event of the chart component).- See Also:
-
translatePxToValue
public double translatePxToValue(int pixel) Description copied from interface:IAxis
Transforms the given pixel value (which has to be a awt value likeMouseEvent.getY()
into the chart value.Internal use only, the interface does not guarantee that the pixel corresponds to any valid awt pixel value within the chart component.
- Specified by:
translatePxToValue
in interfaceIAxis<T extends AxisScalePolicyTransformation>
- Overrides:
translatePxToValue
in classAAxis<T extends AxisScalePolicyTransformation>
- Parameters:
pixel
- a pixel value of the chart component as used by awt.- Returns:
- the awt pixel value transformed to the chart value.
- See Also:
-
untransform
public abstract double untransform(double in) Template method for performing the reverse axis transformation.This is the counterpart to
transform(double)
.- Parameters:
in
- the transformed value.- Returns:
- the normal value;
-