Class AAxis<T extends IAxisScalePolicy>
- java.lang.Object
-
- info.monitorenter.gui.chart.axis.AAxis<T>
-
- Type Parameters:
T- Subtypes may be more picky which scale policies the accept to disallow incorrect scales: This supports it (seeIAxis.setAxisScalePolicy(IAxisScalePolicy)).
- All Implemented Interfaces:
IAxis<T>,java.beans.PropertyChangeListener,java.io.Serializable,java.util.EventListener
- Direct Known Subclasses:
AAxisTransformation,AxisInverse,AxisLinear
public abstract class AAxis<T extends IAxisScalePolicy> extends java.lang.Object implements IAxis<T>, java.beans.PropertyChangeListener
The base class for an axis of the.Chart2DNormally - as the design and interaction of an
Axiswith theis very fine-grained - it is not instantiated by users of jchart2d: It is automatically instantiated by the constructor ofChart2DDChart2D. It then may be retrieved from theChart2Dby the methodsChart2D.getAxisX()andChart2D.getAxisY()for further configuration.- Version:
- $Revision: 1.61 $
- Author:
- Achim Westermann
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classAAxis.AChart2DDataAccessorAn internal connector class that will connect the axis to the a Chart2D.classAAxis.XDataAccessorAn accessor for the x axis of a chart.protected classAAxis.YDataAccessorAccesses the y axis of theChart2D.-
Nested classes/interfaces inherited from interface info.monitorenter.gui.chart.IAxis
IAxis.AxisTitle
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEBUGDebugging flag for sysouts.protected AAxis.AChart2DDataAccessorm_accessorThe accessor to the Chart2D.protected IAxisLabelFormatterm_formatterFormatting of the labels.protected doublem_majorTickSpacingThe major tick spacing for label generations.protected doublem_maxThe current maximum value for all points in all traces.protected doublem_minThe current minimum value for all points in all traces.protected doublem_minorTickSpacingThe minor tick spacing for label generations.protected booleanm_needsFullRescaleFlag to detect if a re-scaling has to be done.protected IRangePolicym_rangePolicyA plugable range policy.-
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 AAxis()Default constructor that uses aLabelFormatterAutoUnitsfor formatting labels.AAxis(IAxisLabelFormatter formatter, T scalePolicy)Constructor that uses the given label formatter for formatting labels.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)Add a listener for the given property.booleanaddTrace(ITrace2D trace)Adds a trace that belongs to this axis.protected abstract AAxis.AChart2DDataAccessorcreateAccessor(Chart2D chart, int dimension, int position)Template method to create the properimplementation.AAxis.AChart2DDataAccessorprotected voidensureInitialized()Ensures that no deadlock / NPE due to a missing internal chart reference may occur.booleanequals(java.lang.Object obj)protected doublefindMax()Searches for the maximum value of all contained ITraces in the dimension this axis stands for.protected doublefindMin()Searches for the minimum value of all contained ITraces in the dimension this axis stands for.AAxis.AChart2DDataAccessorgetAccessor()Returns the accessor to the chart.intgetAxisPosition()Returns the constant for the position of this axis for the chart.IAxisScalePolicygetAxisScalePolicy()Returns the axis scale policy which controls the position and distance of the ticks to draw.IAxis.AxisTitlegetAxisTitle()Returns the title of this axis.intgetDimension()Returns the constant for the dimension this axis stands for in the chart.java.lang.StringgetDimensionString()Returns the String constant for the dimension this axis stands for in the chart.IAxisLabelFormattergetFormatter()Returns the formatter for labels.intgetHeight(java.awt.Graphics g2d)Returns the height in pixel this axis needs to paint itself.doublegetMajorTickSpacing()Get the major tick spacing for label generation.doublegetMax()Returns the maximum value from all traces of this axis with respect to the installed range policy.doublegetMaxValue()Returns the maximum value of allinstances in allTracePoint2Dinstances in this axis regardless of the configuredITrace2D(seeIRangePolicy).IAxis.setRangePolicy(IRangePolicy)doublegetMin()Returns the minimum value of all traces of this axis with respect to the installed range policy.doublegetMinorTickSpacing()Get the minor tick spacing for label generation.doublegetMinValue()Returns the minimum value of allinstances in allTracePoint2Dinstances in this axis regardless of the configuredITrace2D(seeIRangePolicy).IAxis.setRangePolicy(IRangePolicy)intgetPixelXLeft()Returns the left pixel of this axis coordinate in the graphic context of the current paint operation.intgetPixelXRight()Returns the right pixel coordinate of this axis in the graphic context of the current paint operation.intgetPixelYBottom()Returns the bottom pixel coordinate of this axis in the graphic context of the current paint operation.intgetPixelYTop()Returns the top pixel coordinate of this axis in the graphic context of the current paint operation.java.beans.PropertyChangeListener[]getPropertyChangeListeners(java.lang.String propertyName)Returns an array of all the listeners that were added to the this instance withIAxis.addPropertyChangeListener(String, PropertyChangeListener).RangegetRange()This method is used by the Chart2D to scale it's values during painting.IRangePolicygetRangePolicy()Returns the range policy of this axis.java.lang.StringgetTitle()Deprecated.usegetAxisTitle()and on the resultIAxis.AxisTitle.getTitle().IAxisTitlePaintergetTitlePainter()Deprecated.this method might be dropped because the painter should be of no concern.java.util.Set<ITrace2D>getTraces()Returns awith all traces covered by this axis.Set<ITrace2D>protected doublegetValueDistanceForPixel(int pixel)Returns the value distance on the current chart that exists for the given amount of pixel distance in the given direction of thisAxis.intgetWidth(java.awt.Graphics g2d)Returns the width in pixel this axis needs to paint itself.inthashCode()booleanhasTrace(ITrace2D trace)Returns true if this axis is responsible for rendering the scale of the given trace (was called on this instance with the given trace).IAxis.addTrace(ITrace2D)voidinitPaintIteration()Performs expensive calculations for various values that are used by many calls throughout a paint iterations.booleanisDirtyScaling()Returns true if the bounds in the given dimension of allTracePoint2Dinstances of all internalITrace2Dinstances have changed since all points have been normalized to a value between 0 and 1 or true if this axis has different range since the last call to.IAxis.scale()booleanisPaintGrid()Returns whether the x grid is painted or not.booleanisPaintScale()Returns whether the scale for this axis should be painted or not.booleanisStartMajorTick()Check whether scale values are started from major ticks.booleanisVisible()Check if this axis is visible, i.e.voidpaint(java.awt.Graphics g2d)Renders the axis line along with title, scale, scale labels and unit label.intpaintTitle(java.awt.Graphics g2d)Routine for painting the title of this axis.voidpropertyChange(java.beans.PropertyChangeEvent evt)Receives allfrom all instances the chart registers itself as aPropertyChangeEvent.PropertyChangeListenerjava.util.Set<ITrace2D>removeAllTraces()Convenience method for removing all containedinstances of this axis.ITrace2DIAxis.AxisTitleremoveAxisTitle()Removes the title of this axis.voidremovePropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener listener)Remove a PropertyChangeListener for a specific property.booleanremoveTrace(ITrace2D trace)Removes the given trace from this axis.voidscale()Scales allinstances in the dimension represented by this axis.ITrace2Dprotected voidscalePoint(ITracePoint2D point)Internally rescales the givenin the dimension this axis works in.ITracePoint2DvoidscaleTrace(ITrace2D trace)Scales the givenin the dimension represented by this axis.ITrace2Dprotected voidsetAccessor(AAxis.AChart2DDataAccessor accessor)Sets the accessor to the axis of the chart.protected voidsetAxisPosition(int axisPosition)Sets the axisPosition.IAxisScalePolicysetAxisScalePolicy(T axisScalePolicy)The default used is.AxisScalePolicyAutomaticBestFitvoidsetAxisTitle(IAxis.AxisTitle axisTitle)Sets the title of this axis.voidsetChart(Chart2D chart, int dimension, int position)Callback that allows the chart to register itself with the axis when the axis is added to the chart.voidsetFormatter(IAxisLabelFormatter formatter)Sets the formatter to use for labels.voidsetMajorTickSpacing(double majorTickSpacing)This method sets the major tick spacing for label generation.voidsetMinorTickSpacing(double minorTickSpacing)This method sets the minor tick spacing for label generation.voidsetPaintGrid(boolean grid)Set whether the grid in this dimension should be painted or not.voidsetPaintScale(boolean show)Set if the scale for this axis should be shown.voidsetPixelXLeft(int pixelXLeft)Sets a Range to use for filtering the view to the the connected Axis.voidsetPixelXRight(int pixelXRight)Sets the right pixel of this axis coordinate in the graphic context of the current paint operation.voidsetPixelYBottom(int pixelYBottom)Sets the bottom pixel of this axis coordinate in the graphic context of the current paint operation.voidsetPixelYTop(int pixelYTop)Sets the top pixel of this axis coordinate in the graphic context of the current paint operation.voidsetRange(Range range)Sets a Range to use for filtering the view to the the connected Axis.voidsetRangePolicy(IRangePolicy rangePolicy)Sets the RangePolicy.voidsetStartMajorTick(boolean majorTick)Set wether scale values are started from major ticks.java.lang.StringsetTitle(java.lang.String title)Deprecated.usegetAxisTitle()and on the resultIAxis.AxisTitle.setTitle(String)IAxisTitlePaintersetTitlePainter(IAxisTitlePainter painter)Deprecated.usegetAxisTitle()and on the resultIAxis.AxisTitle.setTitlePainter(IAxisTitlePainter)instead.voidsetVisible(boolean visible)Set the visibility of this axis.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.inttranslateValueToPx(double value)Transforms the given chart data value into the corresponding awt pixel value for the chart.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface info.monitorenter.gui.chart.IAxis
getScaledValue
-
-
-
-
Field Detail
-
DEBUG
public static final boolean DEBUG
Debugging flag for sysouts.- See Also:
- Constant Field Values
-
m_accessor
protected AAxis.AChart2DDataAccessor m_accessor
The accessor to the Chart2D.It determines, which axis (x or y) this instance is representing.
-
m_formatter
protected IAxisLabelFormatter m_formatter
Formatting of the labels.
-
m_majorTickSpacing
protected double m_majorTickSpacing
The major tick spacing for label generations.- See Also:
setMajorTickSpacing(double)
-
m_max
protected double m_max
The current maximum value for all points in all traces.
-
m_min
protected double m_min
The current minimum value for all points in all traces.
-
m_minorTickSpacing
protected double m_minorTickSpacing
The minor tick spacing for label generations.- See Also:
setMinorTickSpacing(double)
-
m_needsFullRescale
protected boolean m_needsFullRescale
Flag to detect if a re-scaling has to be done.It is set to false in
which is triggered from the painting Thread. Whenever a bound change is detected inscale()this is set to true.propertyChange(PropertyChangeEvent)Please remind: In previous versions there was only a test if the bounds had changed since the last scaling. This was not always correct: If in between two paint cycles the bounds were changed and new points added but at the point in time when the 2nd paint cycle starts the bounds would be equal no full rescaling would be performed even if the added points would have been scaled in relation to the changed bounds at their adding time: Bounds checks are not sufficient!
-
m_rangePolicy
protected IRangePolicy m_rangePolicy
A plugable range policy.
-
-
Constructor Detail
-
AAxis
public AAxis()
Default constructor that uses aLabelFormatterAutoUnitsfor formatting labels.
-
AAxis
public AAxis(IAxisLabelFormatter formatter, T scalePolicy)
Constructor that uses 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
-
getAxisScalePolicy
public IAxisScalePolicy getAxisScalePolicy()
Description copied from interface:IAxisReturns the axis scale policy which controls the position and distance of the ticks to draw.- Specified by:
getAxisScalePolicyin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the axis scale policy which controls the position and distance of the ticks to draw.
- See Also:
IAxis.getAxisScalePolicy()
-
setAxisScalePolicy
public IAxisScalePolicy setAxisScalePolicy(T axisScalePolicy)
The default used is.AxisScalePolicyAutomaticBestFit- Specified by:
setAxisScalePolicyin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
axisScalePolicy- the axis scale policy which controls the position and distance of the ticks to draw to use.- Returns:
- the previous axis scale policy that was used before.
- See Also:
IAxis.setAxisScalePolicy(info.monitorenter.gui.chart.IAxisScalePolicy)
-
getDimensionString
public java.lang.String getDimensionString()
Description copied from interface:IAxisReturns the String constant for the dimension this axis stands for in the chart.- Specified by:
getDimensionStringin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- "X", "Y" or
nullif not assigned to a.Chart2D - See Also:
IAxis.getDimensionString()
-
addPropertyChangeListener
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)Description copied from interface:IAxisAdd a listener for the given property.The following
PropertyChangeEventtypes should be fired to listeners:
getPropertyName()getSource()getOldValue()getNewValue()IAxis.PROPERTY_ADD_REMOVE_TRACEthat changedIAxisnull- a new trace was added., the new trace.ITrace2DIAxis.PROPERTY_ADD_REMOVE_TRACEthat changedIAxis, the old trace.ITrace2Dnull- the trace was removed.IAxis.PROPERTY_RANGEPOLICYthat changedIAxis, the old value.IRangePolicy, the new value.IRangePolicyIAxis.PROPERTY_PAINTGRIDthat changedIAxis, the old value.Boolean, the new value.BooleanIAxis.PROPERTY_LABELFORMATTERthat changedIAxis, the old value or null if there was no formatter before.IAxisLabelFormatter, the new value.IAxisLabelFormatterIAxis.PROPERTY_AXIS_SCALE_POLICY_CHANGEDthat changedIAxis, the old value.IAxisScalePolicy, the new value.IAxisScalePolicy- Specified by:
addPropertyChangeListenerin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
propertyName- the property to be informed about changes.listener- the listener that will be informed.- See Also:
IAxis.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
-
addTrace
public boolean addTrace(ITrace2D trace)
Description copied from interface:IAxisAdds a trace that belongs to this axis.Adding a trace that is already contained may be problematic, so an exception should be raised in that case to warn you that your code is doing unnecessary to malicious operations.
- Specified by:
addTracein interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
trace- the trace to add.- Returns:
- true if the trace was added, false else.
- See Also:
IAxis.addTrace(info.monitorenter.gui.chart.ITrace2D)
-
createAccessor
protected abstract AAxis.AChart2DDataAccessor createAccessor(Chart2D chart, int dimension, int position)
Template method to create the properimplementation.AAxis.AChart2DDataAccessor- 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
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object- See Also:
Object.equals(java.lang.Object)
-
findMax
protected final double findMax()
Searches for the maximum value of all contained ITraces in the dimension this axis stands for.This method is triggered when a trace fired a property change for property
orITrace2D.PROPERTY_MAX_Xwith a value lower than the internal stored maximum.ITrace2D.PROPERTY_MAX_YPerformance breakdown is avoided because all
ITrace2Dimplementations cache their max and min values.- Returns:
- the maximum value of all traces for the dimension this axis works in.
-
findMin
protected final double findMin()
Searches for the minimum value of all contained ITraces in the dimension this axis stands for.This method is triggered when a trace fired a property change for property
orITrace2D.PROPERTY_MAX_Xwith a value lower than the internal stored minimum.ITrace2D.PROPERTY_MAX_YPerformance breakdown is avoided because all
ITrace2Dimplementations cache their max and min values.- Returns:
- the minimum value of all traces for the dimension this axis works in.
-
getAccessor
public AAxis.AChart2DDataAccessor getAccessor()
Returns the accessor to the chart.- Specified by:
getAccessorin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the accessor to the chart.
-
getAxisPosition
public int getAxisPosition()
Description copied from interface:IAxisReturns the constant for the position of this axis for the chart.- Specified by:
getAxisPositionin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
Chart2D.CHART_POSITION_LEFT,Chart2D.CHART_POSITION_RIGHT,Chart2D.CHART_POSITION_TOP,Chart2D.CHART_POSITION_BOTTOMor -1 if this axis is not assigned to a chart.- See Also:
IAxis.getAxisPosition()
-
getAxisTitle
public IAxis.AxisTitle getAxisTitle()
Description copied from interface:IAxisReturns the title of this axis.- Specified by:
getAxisTitlein interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the axis title used.
- See Also:
IAxis.getAxisTitle()
-
getDimension
public int getDimension()
Description copied from interface:IAxisReturns the constant for the dimension this axis stands for in the chart.- Specified by:
getDimensionin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
Chart2D.X,Chart2D.Yor -1 if this axis is not assigned to a chart.- See Also:
IAxis.getDimension()
-
getFormatter
public final IAxisLabelFormatter getFormatter()
Description copied from interface:IAxisReturns the formatter for labels.- Specified by:
getFormatterin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- Returns the formatter.
-
getHeight
public final int getHeight(java.awt.Graphics g2d)
Description copied from interface:IAxisReturns the height in pixel this axis needs to paint itself.This includes the axis line, it's ticks and labels and it's title.
Note: For an y axis the hight only includes the overhang it needs on the upper edge for painting a complete lable, not the complete space it needs for the complete line.
- Specified by:
getHeightin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
g2d- needed for font metric information.- Returns:
- the height in pixel this axis needs to paint itself.
- See Also:
IAxis.getHeight(java.awt.Graphics)
-
getMajorTickSpacing
public double getMajorTickSpacing()
Description copied from interface:IAxisGet the major tick spacing for label generation.- Specified by:
getMajorTickSpacingin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the major tick spacing for label generation.
- See Also:
IAxis.getMajorTickSpacing()
-
getMax
public double getMax()
Description copied from interface:IAxisReturns the maximum value from all traces of this axis with respect to the installed range policy.- Specified by:
getMaxin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the maximum value from all traces of this axis with respect to the installed range policy.
- See Also:
IAxis.getMax()
-
getMaxValue
public double getMaxValue()
Description copied from interface:IAxisReturns the maximum value of allinstances in allTracePoint2Dinstances in this axis regardless of the configuredITrace2D(seeIRangePolicy). The returned value is either in x or y dimension - depending on the dimension this axis is working in for the chart.IAxis.setRangePolicy(IRangePolicy)- Specified by:
getMaxValuein interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the maximum value of all
instances in allTracePoint2Dinstances in this axis regardless of the configuredITrace2D(seeIRangePolicy).IAxis.setRangePolicy(IRangePolicy) - See Also:
IAxis.getMaxValue()
-
getMin
public double getMin()
Description copied from interface:IAxisReturns the minimum value of all traces of this axis with respect to the installed range policy.- Specified by:
getMinin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the minimum value of all traces of this axis with respect to the installed range policy.
- See Also:
IAxis.getMin()
-
getMinorTickSpacing
public double getMinorTickSpacing()
Get the minor tick spacing for label generation.- Specified by:
getMinorTickSpacingin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- he minor tick spacing for label generation.
- See Also:
setMinorTickSpacing(double)
-
getMinValue
public double getMinValue()
Description copied from interface:IAxisReturns the minimum value of allinstances in allTracePoint2Dinstances in this axis regardless of the configuredITrace2D(seeIRangePolicy). The returned value is either in x or y dimension - depending on the dimension this axis is working in for the chart.IAxis.setRangePolicy(IRangePolicy)- Specified by:
getMinValuein interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the minimum value of all
instances in allTracePoint2Dinstances in this axis regardless of the configuredITrace2D(seeIRangePolicy).IAxis.setRangePolicy(IRangePolicy) - See Also:
IAxis.getMinValue()
-
getPixelXLeft
public final int getPixelXLeft()
Description copied from interface:IAxisReturns the left pixel of this axis coordinate in the graphic context of the current paint operation.Note that this value is only valid throughout a
invocation.Chart2D.paint(java.awt.Graphics)- Specified by:
getPixelXLeftin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the left pixel coordinate of this axis in the graphic context of the current paint operation.
- See Also:
IAxis.getPixelXLeft()
-
getPixelXRight
public final int getPixelXRight()
Description copied from interface:IAxisReturns the right pixel coordinate of this axis in the graphic context of the current paint operation.Note that this value is only valid throughout a
invocation.Chart2D.paint(java.awt.Graphics)- Specified by:
getPixelXRightin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the right pixel coordinate of this axis in the graphic context of the current paint operation.
- See Also:
IAxis.getPixelXRight()
-
getPixelYBottom
public final int getPixelYBottom()
Description copied from interface:IAxisReturns the bottom pixel coordinate of this axis in the graphic context of the current paint operation.Note that this value is only valid throughout a
invocation.Chart2D.paint(java.awt.Graphics)- Specified by:
getPixelYBottomin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the bottom pixel coordinate of this axis in the graphic context of the current paint operation.
- See Also:
IAxis.getPixelYBottom()
-
getPixelYTop
public final int getPixelYTop()
Description copied from interface:IAxisReturns the top pixel coordinate of this axis in the graphic context of the current paint operation.Note that this value is only valid throughout a
invocation.Chart2D.paint(java.awt.Graphics)- Specified by:
getPixelYTopin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the top pixel coordinate of this axis in the graphic context of the current paint operation.
- See Also:
IAxis.getPixelYTop()
-
getPropertyChangeListeners
public java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String propertyName)
Description copied from interface:IAxisReturns an array of all the listeners that were added to the this instance withIAxis.addPropertyChangeListener(String, PropertyChangeListener).- Specified by:
getPropertyChangeListenersin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
propertyName- The name of the property being listened to.- Returns:
- an array of all the listeners that were added to the this instance
with
IAxis.addPropertyChangeListener(String, PropertyChangeListener). - See Also:
IAxis.getPropertyChangeListeners(java.lang.String)
-
getRange
public final Range getRange()
This method is used by the Chart2D to scale it's values during painting.Caution: This method does not necessarily return the Range configured with
setRange(Range). The internalIRangePolicyis taken into account.- Specified by:
getRangein interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the range corresponding to the upper and lower bound of the values that will be visible on this Axis of the Chart2D.
- See Also:
setRangePolicy(IRangePolicy)
-
getRangePolicy
public IRangePolicy getRangePolicy()
Returns the range policy of this axis.- Specified by:
getRangePolicyin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the range policy of this axis.
-
getTitle
@Deprecated public final java.lang.String getTitle()
Deprecated.usegetAxisTitle()and on the resultIAxis.AxisTitle.getTitle().Description copied from interface:IAxisReturns the title ornullif there was no title configured before.- Specified by:
getTitlein interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the title or
nullif there was no title configured before. - See Also:
IAxis.getTitlePainter()
-
getTitlePainter
@Deprecated public final IAxisTitlePainter getTitlePainter()
Deprecated.this method might be dropped because the painter should be of no concern.Description copied from interface:IAxisReturns the instance that will paint the title of this axis.- Specified by:
getTitlePainterin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the instance that will paint the title of this axis.
- See Also:
IAxis.getTitlePainter()
-
getTraces
public java.util.Set<ITrace2D> getTraces()
Description copied from interface:IAxisReturns awith all traces covered by this axis.Set<ITrace2D>Caution!
The original internal modifiable set is returned for performance reasons and by contract (to allow removing traces) so do not mess with it to avoid ugly unpredictable side effects!- Specified by:
getTracesin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- a
with all traces covered by this axis.Set<ITrace2D> - See Also:
IAxis.getTraces()
-
getValueDistanceForPixel
protected final double getValueDistanceForPixel(int pixel)
Returns the value distance on the current chart that exists for the given amount of pixel distance in the given direction of thisAxis.Depending on the width of the actual Chart2D and the contained values, the relation between displayed distances (pixel) and value distances (the values of the addes
instances changes.ITrace2DThis method calculates depending on the actual painting area of the Chart2D, the shift in value between two points that have a screen distance of the given pixel.
This method is not used by the chart itself but a helper for outside use.- Parameters:
pixel- The desired distance between to scalepoints of the x- axis in pixel.- Returns:
- a scaled (from pixel to internal value-range) and normed (to the factor of the current unit of the axis) value usable to calculate the coords for the scalepoints of the axis.
-
getWidth
public final int getWidth(java.awt.Graphics g2d)
Description copied from interface:IAxisReturns the width in pixel this axis needs to paint itself.This includes the axis line, it's ticks and labels and it's title.
Note: For an x axis the width only includes the overhang it needs on the right edge for painting a complete label, not the complete space it needs for the complete line.
- Specified by:
getWidthin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
g2d- needed for font metric information.- Returns:
- the width in pixel this axis needs to paint itself.
- See Also:
IAxis.getWidth(java.awt.Graphics)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object- See Also:
Object.hashCode()
-
hasTrace
public final boolean hasTrace(ITrace2D trace)
Description copied from interface:IAxisReturns true if this axis is responsible for rendering the scale of the given trace (was called on this instance with the given trace).IAxis.addTrace(ITrace2D)- Specified by:
hasTracein interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
trace- the trace to check for containment.- Returns:
- true if this axis is responsible for rendering the scale of the
given trace (
was called on this instance with the given trace).IAxis.addTrace(ITrace2D) - See Also:
IAxis.hasTrace(info.monitorenter.gui.chart.ITrace2D)
-
initPaintIteration
public void initPaintIteration()
Performs expensive calculations for various values that are used by many calls throughout a paint iterations.These values are constant throughout a paint iteration by the contract that no point is added removed or changed in this period. Because these values are used from many methods it is impossible to calculate them at a "transparent" method that may perform this caching over a paint period without knowledge from outside. The first method called in a paint iteration is called several further times in the iteration. So this is the common hook to invoke before painting a chart.
- Specified by:
initPaintIterationin interfaceIAxis<T extends IAxisScalePolicy>
-
isDirtyScaling
public final boolean isDirtyScaling()
Description copied from interface:IAxisReturns true if the bounds in the given dimension of allTracePoint2Dinstances of all internalITrace2Dinstances have changed since all points have been normalized to a value between 0 and 1 or true if this axis has different range since the last call to.IAxis.scale()- Specified by:
isDirtyScalingin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- true if the bounds in the given dimension of all
TracePoint2Dinstances of all internalITrace2Dinstances have changed since all points have been normalized to a value between 0 and 1 or true if this axis has different range since the last call to.IAxis.scale() - See Also:
IAxis.isDirtyScaling()
-
isPaintGrid
public final boolean isPaintGrid()
Returns whether the x grid is painted or not.- Specified by:
isPaintGridin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- whether the x grid is painted or not.
-
isPaintScale
public final boolean isPaintScale()
Returns whether the scale for this axis should be painted or not.- Specified by:
isPaintScalein interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- whether the scale for this axis should be painted or not.
-
isStartMajorTick
public boolean isStartMajorTick()
Check whether scale values are started from major ticks.- Specified by:
isStartMajorTickin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- true if scale values start from major ticks.
- See Also:
setMajorTickSpacing(double)
-
isVisible
public boolean isVisible()
Check if this axis is visible, i.e. needs to be painted on the chart.- Specified by:
isVisiblein interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- true if this axis has to be painted on the chart.
-
paint
public void paint(java.awt.Graphics g2d)
Description copied from interface:IAxisRenders the axis line along with title, scale, scale labels and unit label.This should only be called from
, all other uses may cause damaged UI or deadlocks.Chart2D- Specified by:
paintin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
g2d- the graphics context to use.- See Also:
IAxis.paint(java.awt.Graphics)
-
paintTitle
public int paintTitle(java.awt.Graphics g2d)
Description copied from interface:IAxisRoutine for painting the title of this axis.Intended for
only!!!Chart2D- Specified by:
paintTitlein interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
g2d- needed for painting.- Returns:
- the width consumed in pixel for y axis, the height consumed in pixel for x axis.
- See Also:
IAxis.paintTitle(java.awt.Graphics)
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
Receives allfrom all instances the chart registers itself as aPropertyChangeEvent.PropertyChangeListener- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener- Parameters:
evt- the property change event that was fired.- See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)
-
removeAllTraces
public final java.util.Set<ITrace2D> removeAllTraces()
Description copied from interface:IAxisConvenience method for removing all containedinstances of this axis.ITrace2DImplementations should fire a
for thePropertyChangeEventPropertyChangeEvent.getPropertyName()for every single trace removed. This is done best by delegating this call to several calls toIAxis.PROPERTY_ADD_REMOVE_TRACE.IAxis.removeTrace(ITrace2D)- Specified by:
removeAllTracesin interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- a shallow copy of the set of traces that were contained before.
- See Also:
IAxis.removeAllTraces()
-
removeAxisTitle
public IAxis.AxisTitle removeAxisTitle()
Description copied from interface:IAxisRemoves the title of this axis.Prefer this method instead of
if you want to drop the axis title as this method also "unlistens" this axis from it's title.IAxis.getAxisTitle()- Specified by:
removeAxisTitlein interfaceIAxis<T extends IAxisScalePolicy>- Returns:
- the removed title.
- See Also:
IAxis.removeAxisTitle()
-
removePropertyChangeListener
public void removePropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener listener)Description copied from interface:IAxisRemove a PropertyChangeListener for a specific property. Iflistenerwas added more than once to the same event source for the specified property, it will be notified one less time after being removed. IfpropertyNameis null, no exception is thrown and no action is taken. Iflisteneris null, or was never added for the specified property, no exception is thrown and no action is taken.- Specified by:
removePropertyChangeListenerin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
property- The name of the property that was listened on.listener- The PropertyChangeListener to be removed.- See Also:
IAxis.removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
-
removeTrace
public boolean removeTrace(ITrace2D trace)
Description copied from interface:IAxisRemoves the given trace from this axis.A
for thePropertyChangeEventPropertyChangeEvent.getPropertyName()has to be fired on the registeredIAxis.PROPERTY_ADD_REMOVE_TRACEfor the trace removed.PropertyChangeListener- Specified by:
removeTracein interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
trace- the trace to remove from this axis.- Returns:
- true if the given trace could be removed from this axis, false else.
- See Also:
IAxis.removeTrace(info.monitorenter.gui.chart.ITrace2D)
-
scalePoint
protected final void scalePoint(ITracePoint2D point)
Internally rescales the givenin the dimension this axis works in.ITracePoint2D- Parameters:
point- the point to scale (between 0.0 and 1.0) according to the internal bounds.
-
scale
public void scale()
Description copied from interface:IAxisScales allinstances in the dimension represented by this axis.ITrace2DThis method is not deadlock - safe and should be called by the
only!Chart2D- Specified by:
scalein interfaceIAxis<T extends IAxisScalePolicy>- See Also:
IAxis.scale()
-
scaleTrace
public void scaleTrace(ITrace2D trace)
Description copied from interface:IAxisScales the givenin the dimension represented by this axis.ITrace2DThis method is not deadlock - safe and should be called by the
only!Chart2D- Specified by:
scaleTracein interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
trace- the trace to scale.- See Also:
IAxis.scaleTrace(info.monitorenter.gui.chart.ITrace2D)
-
setAccessor
protected final void setAccessor(AAxis.AChart2DDataAccessor accessor)
Sets the accessor to the axis of the chart.- Parameters:
accessor- the accessor to the axis of the chart.
-
setAxisPosition
protected final void setAxisPosition(int axisPosition)
Sets the axisPosition.- Parameters:
axisPosition-Chart2D.CHART_POSITION_LEFT,Chart2D.CHART_POSITION_RIGHT,Chart2D.CHART_POSITION_TOP,Chart2D.CHART_POSITION_BOTTOMor -1 if this axis is not assigned to a chart.
-
setAxisTitle
public void setAxisTitle(IAxis.AxisTitle axisTitle)
Description copied from interface:IAxisSets the title of this axis.- Specified by:
setAxisTitlein interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
axisTitle- the axis title to use.- See Also:
IAxis.setAxisTitle(info.monitorenter.gui.chart.IAxis.AxisTitle)
-
setChart
public void setChart(Chart2D chart, int dimension, int position)
Callback that allows the chart to register itself with the axis when the axis is added to the chart.This is intended for
Chart2Donly!. Please do not use this from anywhere in your code. It allows to- Parameters:
chart- the chart to register itself with this axis.dimension-orChart2D.X.Chart2D.Yposition-,Chart2D.CHART_POSITION_BOTTOM,Chart2D.CHART_POSITION_LEFTorChart2D.CHART_POSITION_RIGHT.Chart2D.CHART_POSITION_TOP
-
setFormatter
public void setFormatter(IAxisLabelFormatter formatter)
Sets the formatter to use for labels.- Specified by:
setFormatterin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
formatter- The formatter to set.
-
setMajorTickSpacing
public void setMajorTickSpacing(double majorTickSpacing)
This method sets the major tick spacing for label generation.Only values between 0.0 and 100.0 are allowed.
The number that is passed-in represents the distance, measured in values, between each major tick mark. If you have a trace with a range from 0 to 50 and the major tick spacing is set to 10, you will get major ticks next to the following values: 0, 10, 20, 30, 40, 50.
Note:
Ticks are free of any multiples of 1000. If the chart contains values between 0 an 1000 and configured a tick of 2 the values 0, 200, 400, 600, 800 and 1000 will highly probable to be displayed. This depends on the size (in pixels) of theChart2D<. Of course there is a difference: ticks are used in divisions and multiplications: If the internal values are very low and the ticks are very high, huge rounding errors might occur (division by ticks results in very low values a double cannot hit exactly. So prefer setting ticks between 0 an 10 or - if you know your values are very small (e.g. in nano range [10 -9 ]) use a small value (e.g. 2*10 -9 ).- Specified by:
setMajorTickSpacingin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
majorTickSpacing- the major tick spacing for label generation.
-
setMinorTickSpacing
public void setMinorTickSpacing(double minorTickSpacing)
This method sets the minor tick spacing for label generation.The number that is passed-in represents the distance, measured in values, between each major tick mark. If you have a trace with a range from 0 to 50 and the major tick spacing is set to 10, you will get major ticks next to the following values: 0, 10, 20, 30, 40, 50.
Note:
Ticks are free of any powers of 10. There is no difference between setting a tick to 2, 200 or 20000 because ticks cannot break the rule that every scale label has to be visible. If the chart contains values between 0 an 1000 and configured a tick of 2 the values 0, 200, 400, 600, 800 and 1000 will highly probable to be displayed. This depends on the size (in pixels) of theChart2D<. Of course there is a difference: ticks are used in divisions and multiplications: If the internal values are very low and the ticks are very high, huge rounding errors might occur (division by ticks results in very low values a double cannot hit exactly. So prefer setting ticks between 0 an 10 or - if you know your values are very small (e.g. in nano range [10 -9 ]) use a small value (e.g. 2*10 -9 ).- Specified by:
setMinorTickSpacingin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
minorTickSpacing- the minor tick spacing to set.
-
setPaintGrid
public final void setPaintGrid(boolean grid)
Set whether the grid in this dimension should be painted or not.- Specified by:
setPaintGridin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
grid- true if the grid should be painted or false if not.
-
setPaintScale
public final void setPaintScale(boolean show)
Set if the scale for this axis should be shown.- Specified by:
setPaintScalein interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
show- true if the scale on this axis should be shown, false else.
-
setPixelXLeft
public final void setPixelXLeft(int pixelXLeft)
Description copied from interface:IAxisSets a Range to use for filtering the view to the the connected Axis. Note that it's effect will be affected by the internalIRangePolicy.This must only be called from the
itself!Chart2D- Specified by:
setPixelXLeftin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
pixelXLeft- the left pixel coordinate of this axis in the graphic context of the current paint operation.- See Also:
IAxis.setPixelXLeft(int)
-
setPixelXRight
public final void setPixelXRight(int pixelXRight)
Description copied from interface:IAxisSets the right pixel of this axis coordinate in the graphic context of the current paint operation.This must only be called from the
itself!Chart2D- Specified by:
setPixelXRightin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
pixelXRight- the right pixel coordinate of this axis in the graphic context of the current paint operation.- See Also:
IAxis.setPixelXRight(int)
-
setPixelYBottom
public final void setPixelYBottom(int pixelYBottom)
Description copied from interface:IAxisSets the bottom pixel of this axis coordinate in the graphic context of the current paint operation.This must only be called from the
itself!Chart2D- Specified by:
setPixelYBottomin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
pixelYBottom- the bottom pixel coordinate of this axis in the graphic context of the current paint operation.- See Also:
IAxis.setPixelYBottom(int)
-
setPixelYTop
public final void setPixelYTop(int pixelYTop)
Description copied from interface:IAxisSets the top pixel of this axis coordinate in the graphic context of the current paint operation.This must only be called from the
itself!Chart2D- Specified by:
setPixelYTopin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
pixelYTop- the top pixel coordinate of this axis in the graphic context of the current paint operation.- See Also:
IAxis.setPixelYTop(int)
-
setRange
public final void setRange(Range range)
Sets a Range to use for filtering the view to the the connected Axis. Note that it's effect will be affected by the internal
IRangePolicy.To get full control use:
setRangePolicy(new <AnARangePolicy>(range);- Specified by:
setRangein interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
range- Range to use for filtering the view to the the connected Axis.- See Also:
getRangePolicy(),IRangePolicy.setRange(Range)
-
ensureInitialized
protected final void ensureInitialized()
Ensures that no deadlock / NPE due to a missing internal chart reference may occur.- Throws:
java.lang.IllegalStateException- if this axis is not assigned to a chart.
-
setRangePolicy
public void setRangePolicy(IRangePolicy rangePolicy)
Sets the RangePolicy.
If the given RangePolicy has an unconfigured internal Range (
A property change event forRange.RANGE_UNBOUNDED) the old internal RangePolicy is taken into account:
If the old RangePolicy has a configured Range this is transferred to the new RangePolicy.IAxis.PROPERTY_RANGEPOLICYis fired and receives listeners if a change took place.- Specified by:
setRangePolicyin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
rangePolicy- The rangePolicy to set.
-
setStartMajorTick
public void setStartMajorTick(boolean majorTick)
Set wether scale values are started from major ticks.- Specified by:
setStartMajorTickin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
majorTick- true if scale values shall start with a major tick.- See Also:
setMajorTickSpacing(double)
-
setTitle
@Deprecated public final java.lang.String setTitle(java.lang.String title)
Deprecated.usegetAxisTitle()and on the resultIAxis.AxisTitle.setTitle(String)Description copied from interface:IAxisSets the title of this axis will be painted by the{IAxisTitlePainter}of this instance.- Specified by:
setTitlein interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
title- the title to set.- Returns:
- the previous Title or
nullif there was no title configured before. - See Also:
IAxis.setTitlePainter(IAxisTitlePainter)
-
setTitlePainter
@Deprecated public final IAxisTitlePainter setTitlePainter(IAxisTitlePainter painter)
Deprecated.usegetAxisTitle()and on the resultIAxis.AxisTitle.setTitlePainter(IAxisTitlePainter)instead.Sets the title painter of this axis which is by default.AxisTitlePainterDefault- Specified by:
setTitlePainterin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
painter- the instance that will paint the title of this axis.- Returns:
- the previous title painter of this axis or null if there was none configured before.
-
setVisible
public void setVisible(boolean visible)
Set the visibility of this axis.- Specified by:
setVisiblein interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
visible- true to show, false to hide
-
translateMousePosition
public double translateMousePosition(java.awt.event.MouseEvent mouseEvent) throws java.lang.IllegalArgumentExceptionReturns 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!
- 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).
-
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 IAxisScalePolicy>- 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:
IAxis.translatePxToValue(int)
-
translateValueToPx
public final int translateValueToPx(double value)
Description copied from interface:IAxisTransforms the given chart data value into the corresponding awt pixel value for the chart.- Specified by:
translateValueToPxin interfaceIAxis<T extends IAxisScalePolicy>- Parameters:
value- a chart data value.- Returns:
- the awt pixel value corresponding to the chart data value.
- See Also:
IAxis.translateValueToPx(double)
-
-