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 (see IAxis.setAxisScalePolicy(IAxisScalePolicy)).
All Implemented Interfaces:
IAxis<T>, PropertyChangeListener, Serializable, EventListener
Direct Known Subclasses:
AAxisTransformation, AxisInverse, AxisLinear

public abstract class AAxis<T extends IAxisScalePolicy> extends Object implements IAxis<T>, PropertyChangeListener
The base class for an axis of the Chart2D.

Normally - as the design and interaction of an Axis with the Chart2DD is very fine-grained - it is not instantiated by users of jchart2d: It is automatically instantiated by the constructor of Chart2D. It then may be retrieved from the Chart2D by the methods Chart2D.getAxisX() and Chart2D.getAxisY() for further configuration.

Version:
$Revision: 1.61 $
Author:
Achim Westermann
See Also:
  • Field Details

    • DEBUG

      public static final boolean DEBUG
      Debugging flag for sysouts.
      See Also:
    • m_accessor

      protected AAxis<T extends IAxisScalePolicy>.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:
    • 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:
    • m_needsFullRescale

      protected boolean m_needsFullRescale
      Flag to detect if a re-scaling has to be done.

      It is set to false in scale() which is triggered from the painting Thread. Whenever a bound change is detected in propertyChange(PropertyChangeEvent) this is set to true.

      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 Details

    • AAxis

      public AAxis()
      Default constructor that uses a LabelFormatterAutoUnits for 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 Details

    • getAxisScalePolicy

      public IAxisScalePolicy getAxisScalePolicy()
      Description copied from interface: IAxis
      Returns the axis scale policy which controls the position and distance of the ticks to draw.

      Specified by:
      getAxisScalePolicy in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      the axis scale policy which controls the position and distance of the ticks to draw.
      See Also:
    • setAxisScalePolicy

      public IAxisScalePolicy setAxisScalePolicy(T axisScalePolicy)
      The default used is AxisScalePolicyAutomaticBestFit.

      Specified by:
      setAxisScalePolicy in interface IAxis<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:
    • getDimensionString

      public String getDimensionString()
      Description copied from interface: IAxis
      Returns the String constant for the dimension this axis stands for in the chart.

      Specified by:
      getDimensionString in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      "X", "Y" or null if not assigned to a Chart2D.
      See Also:
    • addPropertyChangeListener

      public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
      Description copied from interface: IAxis
      Add a listener for the given property.

      The following PropertyChangeEvent types should be fired to listeners:

      getPropertyName() getSource() getOldValue() getNewValue()
      IAxis.PROPERTY_ADD_REMOVE_TRACE IAxis that changed null - a new trace was added. ITrace2D, the new trace.
      IAxis.PROPERTY_ADD_REMOVE_TRACE IAxis that changed ITrace2D, the old trace. null - the trace was removed.
      IAxis.PROPERTY_RANGEPOLICY IAxis that changed IRangePolicy, the old value. IRangePolicy, the new value.
      IAxis.PROPERTY_PAINTGRID IAxis that changed Boolean, the old value. Boolean, the new value.
      IAxis.PROPERTY_LABELFORMATTER IAxis that changed IAxisLabelFormatter, the old value or null if there was no formatter before. IAxisLabelFormatter, the new value.
      IAxis.PROPERTY_AXIS_SCALE_POLICY_CHANGED IAxis that changed IAxisScalePolicy, the old value. IAxisScalePolicy, the new value.

      Specified by:
      addPropertyChangeListener in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      propertyName - the property to be informed about changes.
      listener - the listener that will be informed.
      See Also:
    • addTrace

      public boolean addTrace(ITrace2D trace)
      Description copied from interface: IAxis
      Adds 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:
      addTrace in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      trace - the trace to add.
      Returns:
      true if the trace was added, false else.
      See Also:
    • createAccessor

      protected abstract AAxis<T>.AChart2DDataAccessor createAccessor(Chart2D chart, int dimension, int position)
      Template method to create the proper AAxis.AChart2DDataAccessor implementation.

      Parameters:
      chart - the chart to access.
      dimension - Chart2D.X or Chart2D.Y.
      position - Chart2D.CHART_POSITION_BOTTOM, Chart2D.CHART_POSITION_LEFT, Chart2D.CHART_POSITION_RIGHT or Chart2D.CHART_POSITION_TOP.
      Returns:
      the proper AAxis.AChart2DDataAccessor implementation.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      See Also:
    • 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 ITrace2D.PROPERTY_MAX_X or ITrace2D.PROPERTY_MAX_Y with a value lower than the internal stored maximum.

      Performance breakdown is avoided because all ITrace2D implementations 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 ITrace2D.PROPERTY_MAX_X or ITrace2D.PROPERTY_MAX_Y with a value lower than the internal stored minimum.

      Performance breakdown is avoided because all ITrace2D implementations cache their max and min values.

      Returns:
      the minimum value of all traces for the dimension this axis works in.
    • getAccessor

      public AAxis<T>.AChart2DDataAccessor getAccessor()
      Returns the accessor to the chart.

      Specified by:
      getAccessor in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      the accessor to the chart.
    • getAxisPosition

      public int getAxisPosition()
      Description copied from interface: IAxis
      Returns the constant for the position of this axis for the chart.

      Specified by:
      getAxisPosition in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      Chart2D.CHART_POSITION_LEFT, Chart2D.CHART_POSITION_RIGHT, Chart2D.CHART_POSITION_TOP, Chart2D.CHART_POSITION_BOTTOM or -1 if this axis is not assigned to a chart.
      See Also:
    • getAxisTitle

      public IAxis.AxisTitle getAxisTitle()
      Description copied from interface: IAxis
      Returns the title of this axis.

      Specified by:
      getAxisTitle in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      the axis title used.
      See Also:
    • getDimension

      public int getDimension()
      Description copied from interface: IAxis
      Returns the constant for the dimension this axis stands for in the chart.

      Specified by:
      getDimension in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      Chart2D.X, Chart2D.Y or -1 if this axis is not assigned to a chart.
      See Also:
    • getFormatter

      public final IAxisLabelFormatter getFormatter()
      Description copied from interface: IAxis
      Returns the formatter for labels.

      Specified by:
      getFormatter in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      Returns the formatter.
    • getHeight

      public final int getHeight(Graphics g2d)
      Description copied from interface: IAxis
      Returns 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:invalid input: '<'/br/> 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:
      getHeight in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      g2d - needed for font metric information.
      Returns:
      the height in pixel this axis needs to paint itself.
      See Also:
    • getMajorTickSpacing

      public double getMajorTickSpacing()
      Description copied from interface: IAxis
      Get the major tick spacing for label generation.

      Specified by:
      getMajorTickSpacing in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      the major tick spacing for label generation.
      See Also:
    • getMax

      public double getMax()
      Description copied from interface: IAxis
      Returns the maximum value from all traces of this axis with respect to the installed range policy.

      Specified by:
      getMax in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      the maximum value from all traces of this axis with respect to the installed range policy.
      See Also:
    • getMaxValue

      public double getMaxValue()
      Description copied from interface: IAxis
      Returns the maximum value of all TracePoint2D instances in all ITrace2D instances in this axis regardless of the configured IRangePolicy (see IAxis.setRangePolicy(IRangePolicy)). The returned value is either in x or y dimension - depending on the dimension this axis is working in for the chart.

      Specified by:
      getMaxValue in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      the maximum value of all TracePoint2D instances in all ITrace2D instances in this axis regardless of the configured IRangePolicy (see IAxis.setRangePolicy(IRangePolicy)).
      See Also:
    • getMin

      public double getMin()
      Description copied from interface: IAxis
      Returns the minimum value of all traces of this axis with respect to the installed range policy.

      Specified by:
      getMin in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      the minimum value of all traces of this axis with respect to the installed range policy.
      See Also:
    • getMinorTickSpacing

      public double getMinorTickSpacing()
      Get the minor tick spacing for label generation.

      Specified by:
      getMinorTickSpacing in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      he minor tick spacing for label generation.
      See Also:
    • getMinValue

      public double getMinValue()
      Description copied from interface: IAxis
      Returns the minimum value of all TracePoint2D instances in all ITrace2D instances in this axis regardless of the configured IRangePolicy (see IAxis.setRangePolicy(IRangePolicy)). The returned value is either in x or y dimension - depending on the dimension this axis is working in for the chart.

      Specified by:
      getMinValue in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      the minimum value of all TracePoint2D instances in all ITrace2D instances in this axis regardless of the configured IRangePolicy (see IAxis.setRangePolicy(IRangePolicy)).
      See Also:
    • getPixelXLeft

      public final int getPixelXLeft()
      Description copied from interface: IAxis
      Returns 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 Chart2D.paint(java.awt.Graphics) invocation.

      Specified by:
      getPixelXLeft in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      the left pixel coordinate of this axis in the graphic context of the current paint operation.
      See Also:
    • getPixelXRight

      public final int getPixelXRight()
      Description copied from interface: IAxis
      Returns 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 Chart2D.paint(java.awt.Graphics) invocation.

      Specified by:
      getPixelXRight in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      the right pixel coordinate of this axis in the graphic context of the current paint operation.
      See Also:
    • getPixelYBottom

      public final int getPixelYBottom()
      Description copied from interface: IAxis
      Returns 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 Chart2D.paint(java.awt.Graphics) invocation.

      Specified by:
      getPixelYBottom in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      the bottom pixel coordinate of this axis in the graphic context of the current paint operation.
      See Also:
    • getPixelYTop

      public final int getPixelYTop()
      Description copied from interface: IAxis
      Returns 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 Chart2D.paint(java.awt.Graphics) invocation.

      Specified by:
      getPixelYTop in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      the top pixel coordinate of this axis in the graphic context of the current paint operation.
      See Also:
    • getPropertyChangeListeners

      public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
      Description copied from interface: IAxis
      Returns an array of all the listeners that were added to the this instance with IAxis.addPropertyChangeListener(String, PropertyChangeListener).

      Specified by:
      getPropertyChangeListeners in interface IAxis<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:
    • 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 internal IRangePolicy is taken into account.

      Specified by:
      getRange in interface IAxis<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:
    • getRangePolicy

      public IRangePolicy getRangePolicy()
      Returns the range policy of this axis.

      Specified by:
      getRangePolicy in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      the range policy of this axis.
    • getTitle

      @Deprecated public final String getTitle()
      Deprecated.
      Description copied from interface: IAxis
      Returns the title or null if there was no title configured before.

      Specified by:
      getTitle in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      the title or null if there was no title configured before.
      See Also:
    • getTitlePainter

      @Deprecated public final IAxisTitlePainter getTitlePainter()
      Deprecated.
      this method might be dropped because the painter should be of no concern.
      Description copied from interface: IAxis
      Returns the instance that will paint the title of this axis.

      Specified by:
      getTitlePainter in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      the instance that will paint the title of this axis.
      See Also:
    • getTraces

      public Set<ITrace2D> getTraces()
      Description copied from interface: IAxis
      Returns a Set<ITrace2D> with all traces covered by this axis.

      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:
      getTraces in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      a Set<ITrace2D> with all traces covered by this axis.
      See Also:
    • 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 this Axis.

      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 ITrace2D instances changes.

      This 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(Graphics g2d)
      Description copied from interface: IAxis
      Returns 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:invalid input: '<'/br/> 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:
      getWidth in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      g2d - needed for font metric information.
      Returns:
      the width in pixel this axis needs to paint itself.
      See Also:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • hasTrace

      public final boolean hasTrace(ITrace2D trace)
      Description copied from interface: IAxis
      Returns true if this axis is responsible for rendering the scale of the given trace (IAxis.addTrace(ITrace2D) was called on this instance with the given trace).

      Specified by:
      hasTrace in interface IAxis<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 (IAxis.addTrace(ITrace2D) was called on this instance with the given trace).
      See Also:
    • 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:
      initPaintIteration in interface IAxis<T extends IAxisScalePolicy>
    • isDirtyScaling

      public final boolean isDirtyScaling()
      Description copied from interface: IAxis
      Returns true if the bounds in the given dimension of all TracePoint2D instances of all internal ITrace2D instances 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:
      isDirtyScaling in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      true if the bounds in the given dimension of all TracePoint2D instances of all internal ITrace2D instances 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:
    • isPaintGrid

      public final boolean isPaintGrid()
      Returns whether the x grid is painted or not.

      Specified by:
      isPaintGrid in interface IAxis<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:
      isPaintScale in interface IAxis<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:
      isStartMajorTick in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      true if scale values start from major ticks.
      See Also:
    • isVisible

      public boolean isVisible()
      Check if this axis is visible, i.e. needs to be painted on the chart.

      Specified by:
      isVisible in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      true if this axis has to be painted on the chart.
    • paint

      public void paint(Graphics g2d)
      Description copied from interface: IAxis
      Renders the axis line along with title, scale, scale labels and unit label.

      This should only be called from Chart2D, all other uses may cause damaged UI or deadlocks.

      Specified by:
      paint in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      g2d - the graphics context to use.
      See Also:
    • paintTitle

      public int paintTitle(Graphics g2d)
      Description copied from interface: IAxis
      Routine for painting the title of this axis.

      Intended for Chart2D only!!!

      Specified by:
      paintTitle in interface IAxis<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:
    • propertyChange

      public void propertyChange(PropertyChangeEvent evt)
      Receives all PropertyChangeEvent from all instances the chart registers itself as a PropertyChangeListener .

      Specified by:
      propertyChange in interface PropertyChangeListener
      Parameters:
      evt - the property change event that was fired.
      See Also:
    • removeAllTraces

      public final Set<ITrace2D> removeAllTraces()
      Description copied from interface: IAxis
      Convenience method for removing all contained ITrace2D instances of this axis.

      Implementations should fire a PropertyChangeEvent for the PropertyChangeEvent.getPropertyName() IAxis.PROPERTY_ADD_REMOVE_TRACE for every single trace removed. This is done best by delegating this call to several calls to IAxis.removeTrace(ITrace2D).

      Specified by:
      removeAllTraces in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      a shallow copy of the set of traces that were contained before.
      See Also:
    • removeAxisTitle

      public IAxis.AxisTitle removeAxisTitle()
      Description copied from interface: IAxis
      Removes the title of this axis.

      Prefer this method instead of IAxis.getAxisTitle() if you want to drop the axis title as this method also "unlistens" this axis from it's title.

      Specified by:
      removeAxisTitle in interface IAxis<T extends IAxisScalePolicy>
      Returns:
      the removed title.
      See Also:
    • removePropertyChangeListener

      public void removePropertyChangeListener(String property, PropertyChangeListener listener)
      Description copied from interface: IAxis
      Remove a PropertyChangeListener for a specific property. If listener was added more than once to the same event source for the specified property, it will be notified one less time after being removed. If propertyName is null, no exception is thrown and no action is taken. If listener is null, or was never added for the specified property, no exception is thrown and no action is taken.
      Specified by:
      removePropertyChangeListener in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      property - The name of the property that was listened on.
      listener - The PropertyChangeListener to be removed.
      See Also:
    • removeTrace

      public boolean removeTrace(ITrace2D trace)
      Description copied from interface: IAxis
      Removes the given trace from this axis.

      A PropertyChangeEvent for the PropertyChangeEvent.getPropertyName() IAxis.PROPERTY_ADD_REMOVE_TRACE has to be fired on the registered PropertyChangeListener for the trace removed.

      Specified by:
      removeTrace in interface IAxis<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:
    • scalePoint

      protected final void scalePoint(ITracePoint2D point)
      Internally rescales the given ITracePoint2D in the dimension this axis works in.

      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: IAxis
      Scales all ITrace2D instances in the dimension represented by this axis.

      This method is not deadlock - safe and should be called by the Chart2D only!

      Specified by:
      scale in interface IAxis<T extends IAxisScalePolicy>
      See Also:
    • scaleTrace

      public void scaleTrace(ITrace2D trace)
      Description copied from interface: IAxis
      Scales the given ITrace2D in the dimension represented by this axis.

      This method is not deadlock - safe and should be called by the Chart2D only!

      Specified by:
      scaleTrace in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      trace - the trace to scale.
      See Also:
    • setAccessor

      protected final void setAccessor(AAxis<T>.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_BOTTOM or -1 if this axis is not assigned to a chart.
    • setAxisTitle

      public void setAxisTitle(IAxis.AxisTitle axisTitle)
      Description copied from interface: IAxis
      Sets the title of this axis.

      Specified by:
      setAxisTitle in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      axisTitle - the axis title to use.
      See Also:
    • 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 Chart2D only!. Please do not use this from anywhere in your code. It allows to

      Parameters:
      chart - the chart to register itself with this axis.
      dimension - Chart2D.X or Chart2D.Y.
      position - Chart2D.CHART_POSITION_BOTTOM, Chart2D.CHART_POSITION_LEFT, Chart2D.CHART_POSITION_RIGHT or Chart2D.CHART_POSITION_TOP.
    • setFormatter

      public void setFormatter(IAxisLabelFormatter formatter)
      Sets the formatter to use for labels.

      Specified by:
      setFormatter in interface IAxis<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 the Chart2Dinvalid input: '<'. 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:
      setMajorTickSpacing in interface IAxis<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 the Chart2Dinvalid input: '<'. 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:
      setMinorTickSpacing in interface IAxis<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:
      setPaintGrid in interface IAxis<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:
      setPaintScale in interface IAxis<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: IAxis
      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.

      This must only be called from the Chart2D itself!

      Specified by:
      setPixelXLeft in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      pixelXLeft - the left pixel coordinate of this axis in the graphic context of the current paint operation.
      See Also:
    • setPixelXRight

      public final void setPixelXRight(int pixelXRight)
      Description copied from interface: IAxis
      Sets the right pixel of this axis coordinate in the graphic context of the current paint operation.

      This must only be called from the Chart2D itself!

      Specified by:
      setPixelXRight in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      pixelXRight - the right pixel coordinate of this axis in the graphic context of the current paint operation.
      See Also:
    • setPixelYBottom

      public final void setPixelYBottom(int pixelYBottom)
      Description copied from interface: IAxis
      Sets the bottom pixel of this axis coordinate in the graphic context of the current paint operation.

      This must only be called from the Chart2D itself!

      Specified by:
      setPixelYBottom in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      pixelYBottom - the bottom pixel coordinate of this axis in the graphic context of the current paint operation.
      See Also:
    • setPixelYTop

      public final void setPixelYTop(int pixelYTop)
      Description copied from interface: IAxis
      Sets the top pixel of this axis coordinate in the graphic context of the current paint operation.

      This must only be called from the Chart2D itself!

      Specified by:
      setPixelYTop in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      pixelYTop - the top pixel coordinate of this axis in the graphic context of the current paint operation.
      See Also:
    • 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:
      setRange in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      range - Range to use for filtering the view to the the connected Axis.
      See Also:
    • ensureInitialized

      protected final void ensureInitialized()
      Ensures that no deadlock / NPE due to a missing internal chart reference may occur.

      Throws:
      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 ( Range.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.

      A property change event for IAxis.PROPERTY_RANGEPOLICY is fired and receives listeners if a change took place.

      Specified by:
      setRangePolicy in interface IAxis<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:
      setStartMajorTick in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      majorTick - true if scale values shall start with a major tick.
      See Also:
    • setTitle

      @Deprecated public final String setTitle(String title)
      Deprecated.
      Description copied from interface: IAxis
      Sets the title of this axis will be painted by the {IAxisTitlePainter} of this instance.

      Specified by:
      setTitle in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      title - the title to set.
      Returns:
      the previous Title or null if there was no title configured before.
      See Also:
    • setTitlePainter

      @Deprecated public final IAxisTitlePainter setTitlePainter(IAxisTitlePainter painter)
      Deprecated.
      Sets the title painter of this axis which is by default AxisTitlePainterDefault .

      Specified by:
      setTitlePainter in interface IAxis<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:
      setVisible in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      visible - true to show, false to hide
    • translateMousePosition

      public double translateMousePosition(MouseEvent mouseEvent) throws IllegalArgumentException
      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!

      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).
    • translatePxToValue

      public double translatePxToValue(int pixel)
      Description copied from interface: IAxis
      Transforms the given pixel value (which has to be a awt value like MouseEvent.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 interface IAxis<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:
    • translateValueToPx

      public final int translateValueToPx(double value)
      Description copied from interface: IAxis
      Transforms the given chart data value into the corresponding awt pixel value for the chart.

      Specified by:
      translateValueToPx in interface IAxis<T extends IAxisScalePolicy>
      Parameters:
      value - a chart data value.
      Returns:
      the awt pixel value corresponding to the chart data value.
      See Also: