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 acceptsAxisScalePolicyTransformationand subtypes.
- All Implemented Interfaces:
IAxis<T>,java.beans.PropertyChangeListener,java.io.Serializable,java.util.EventListener
public abstract class AAxisTransformation<T extends AxisScalePolicyTransformation> extends AAxis<T>
Base class for Axis implementations that transform the scale for changed display.Note that instances of this implementations will only accept subtypes of
AxisScalePolicyTransformationfor the methodAAxis.setAxisScalePolicy(IAxisScalePolicy).- Version:
- $Revision: 1.32 $
- Author:
- Achim Westermann
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAAxisTransformation.XDataAccessorAn accessor for the x axis of a chart.protected classAAxisTransformation.YDataAccessorAccesses 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
Fields Modifier and Type Field Description protected longm_outputErrorTstampInternal 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
Constructors Constructor Description AAxisTransformation()Creates a default instance that will use aLabelFormatterAutoUnitsfor formatting labels.AAxisTransformation(IAxisLabelFormatter formatter, T scalePolicy)Creates an instance that will the given label formatter for formatting labels.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected AAxis.AChart2DDataAccessorcreateAccessor(Chart2D chart, int dimension, int position)Template method to create the properimplementation.AAxis.AChart2DDataAccessordoublegetMaxTransformed()Returns the transformed max with additional error treatment in case of empty traces.doublegetMinTransformed()Returns the transformed min with additional error treatment in case of empty traces.doublegetScaledValue(double absolute)Scales the given absolute value into a value between 0 and 1.0 (if it is in the range of the data).voidscaleTrace(ITrace2D trace)Overridden to incorporate transformation.abstract doubletransform(double in)Template method for performing the axis transformation.doubletranslateMousePosition(java.awt.event.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.doubletranslatePxToValue(int pixel)Transforms the given pixel value (which has to be a awt value likeMouseEvent.getY()into the chart value.abstract doubleuntransform(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
-
-
-
-
Constructor Detail
-
AAxisTransformation
public AAxisTransformation()
Creates a default instance that will use aLabelFormatterAutoUnitsfor formatting labels.
-
AAxisTransformation
public AAxisTransformation(IAxisLabelFormatter formatter, T scalePolicy)
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 Detail
-
createAccessor
protected AAxis.AChart2DDataAccessor createAccessor(Chart2D chart, int dimension, int position)
Description copied from class:AAxisTemplate method to create the properimplementation.AAxis.AChart2DDataAccessor- Specified by:
createAccessorin classAAxis<T extends AxisScalePolicyTransformation>- Parameters:
chart- the chart to access.dimension-orChart2D.X.Chart2D.Yposition-,Chart2D.CHART_POSITION_BOTTOM,Chart2D.CHART_POSITION_LEFTorChart2D.CHART_POSITION_RIGHT.Chart2D.CHART_POSITION_TOP- Returns:
- the proper
implementation.AAxis.AChart2DDataAccessor - See Also:
AAxis.createAccessor(info.monitorenter.gui.chart.Chart2D, int, int)
-
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:
AAxis.getMax()
-
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:
AAxis.getMin()
-
getScaledValue
public final double getScaledValue(double absolute)
Description copied from interface:IAxisScales 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:
IAxis.getScaledValue(double)
-
scaleTrace
public void scaleTrace(ITrace2D trace)
Overridden to incorporate transformation.- Specified by:
scaleTracein interfaceIAxis<T extends AxisScalePolicyTransformation>- Overrides:
scaleTracein classAAxis<T extends AxisScalePolicyTransformation>- Parameters:
trace- the trace to scale.- See Also:
IAxis.scaleTrace(info.monitorenter.gui.chart.ITrace2D)
-
transform
public abstract double transform(double in) throws java.lang.IllegalArgumentExceptionTemplate 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:
java.lang.IllegalArgumentException- if scaling is impossible (due to some mathematical transformation in implementations likeAxisLog10
-
translateMousePosition
public final double translateMousePosition(java.awt.event.MouseEvent mouseEvent) throws java.lang.IllegalArgumentExceptionDescription copied from class:AAxisReturns 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:
translateMousePositionin 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:
java.lang.IllegalArgumentException- if the given mouse event is out of the current graphics context (not a mouse event of the chart component).- See Also:
AAxis.translateMousePosition(java.awt.event.MouseEvent)
-
translatePxToValue
public double translatePxToValue(int pixel)
Description copied from interface:IAxisTransforms 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:
translatePxToValuein interfaceIAxis<T extends AxisScalePolicyTransformation>- Overrides:
translatePxToValuein 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:
AAxis.translatePxToValue(int)
-
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;
-
-