IAxis
info.monitorenter.gui.chart

Interface IAxis<T extends IAxisScalePolicy>

    • Method Detail

      • addTrace

        boolean addTrace(ITrace2D trace)
        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.

        Parameters:
        trace - the trace to add.
        Returns:
        true if the trace was added, false else.
      • getAxisTitle

        IAxis.AxisTitle getAxisTitle()
        Returns the title of this axis.

        Returns:
        the axis title used.
      • removeAxisTitle

        IAxis.AxisTitle removeAxisTitle()
        Removes the title of this axis.

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

        Returns:
        the removed title.
      • getDimension

        int getDimension()
        Returns the constant for the dimension this axis stands for in the chart.

        Returns:
        Chart2D.X, Chart2D.Y or -1 if this axis is not assigned to a chart.
      • getDimensionString

        String getDimensionString()
        Returns the String constant for the dimension this axis stands for in the chart.

        Returns:
        "X", "Y" or null if not assigned to a Chart2D.
      • getFormatter

        IAxisLabelFormatter getFormatter()
        Returns the formatter for labels.

        Returns:
        the formatter for labels.
      • getHeight

        int getHeight(Graphics g2d)
        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:
        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.

        Parameters:
        g2d - needed for font metric information.
        Returns:
        the height in pixel this axis needs to paint itself.
      • getMajorTickSpacing

        double getMajorTickSpacing()
        Get the major tick spacing for label generation.

        Returns:
        the major tick spacing for label generation.
        See Also:
        setMajorTickSpacing(double)
      • getMax

        double getMax()
        Returns the maximum value from all traces of this axis with respect to the installed range policy.

        Returns:
        the maximum value from all traces of this axis with respect to the installed range policy.
      • getMin

        double getMin()
        Returns the minimum value of all traces of this axis with respect to the installed range policy.

        Returns:
        the minimum value of all traces of this axis with respect to the installed range policy.
      • getMinorTickSpacing

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

        Returns:
        the minor tick spacing for label generation.
        See Also:
        setMinorTickSpacing(double)
      • getPixelXLeft

        int getPixelXLeft()
        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.

        Returns:
        the left pixel coordinate of this axis in the graphic context of the current paint operation.
      • getPixelXRight

        int getPixelXRight()
        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.

        Returns:
        the right pixel coordinate of this axis in the graphic context of the current paint operation.
      • getPixelYBottom

        int getPixelYBottom()
        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.

        Returns:
        the bottom pixel coordinate of this axis in the graphic context of the current paint operation.
      • getPixelYTop

        int getPixelYTop()
        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.

        Returns:
        the top pixel coordinate of this axis in the graphic context of the current paint operation.
      • getRange

        Range getRange()
        Returns the range lasting from getMin() to getMax().

        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.

        Returns:
        the range corresponding to the upper and lower bound of the values that will be displayable on this Axis of the Chart2D.
        See Also:
        setRangePolicy(IRangePolicy)
      • getRangePolicy

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

        Returns:
        the range policy of this axis.
      • getScaledValue

        double getScaledValue(double absolute)
        Scales the given absolute value into a value between 0 and 1.0 (if it is in the range of the data).

        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.
      • getAxisScalePolicy

        IAxisScalePolicy getAxisScalePolicy()
        Returns the axis scale policy which controls the position and distance of the ticks to draw.

        Returns:
        the axis scale policy which controls the position and distance of the ticks to draw.
      • setAxisScalePolicy

        IAxisScalePolicy setAxisScalePolicy(T axisScalePolicy)
        Sets the axis scale policy which controls the position and distance of the ticks to draw.

        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.
      • getTitlePainter

        @DeprecatedIAxisTitlePainter getTitlePainter()
        Deprecated. this method might be dropped because the painter should be of no concern.
        Returns the instance that will paint the title of this axis.

        Returns:
        the instance that will paint the title of this axis.
      • getTraces

        Set<ITrace2D> getTraces()
        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!

        Returns:
        a Set<ITrace2D> with all traces covered by this axis.
      • getWidth

        int getWidth(Graphics g2d)
        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:
        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.

        Parameters:
        g2d - needed for font metric information.
        Returns:
        the width in pixel this axis needs to paint itself.
      • hasTrace

        boolean hasTrace(ITrace2D trace)
        Returns true if this axis is responsible for rendering the scale of the given trace (addTrace(ITrace2D) was called on this instance with the given trace).

        Parameters:
        trace - the trace to check for containment.
        Returns:
        true if this axis is responsible for rendering the scale of the given trace (addTrace(ITrace2D) was called on this instance with the given trace).
      • initPaintIteration

        void initPaintIteration()
        Allows to perform 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.

      • isDirtyScaling

        boolean isDirtyScaling()
        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 scale().

        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 scale().
      • isPaintGrid

        boolean isPaintGrid()
        Returns wether the x grid is painted or not.

        Returns:
        wether the x grid is painted or not.
      • isPaintScale

        boolean isPaintScale()
        Returns whether the scale for this axis should be painted or not.

        Returns:
        whether the scale for this axis should be painted or not.
      • isStartMajorTick

        boolean isStartMajorTick()
        Check wether scale values are started from major ticks.

        Returns:
        true if scale values start from major ticks.
        See Also:
        AAxis.setMajorTickSpacing(double)
      • isVisible

        boolean isVisible()
        Check whether this axis is visible, i.e. needs to be painted on the chart
        Returns:
        the visibility state of this axis
      • paint

        void paint(Graphics g2d)
        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.

        Parameters:
        g2d - the graphics context to use.
      • paintTitle

        int paintTitle(Graphics g2d)
        Routine for painting the title of this axis.

        Intended for Chart2D only!!!

        Parameters:
        g2d - needed for painting.
        Returns:
        the width consumed in pixel for y axis, the height consumed in pixel for x axis.
      • removePropertyChangeListener

        void removePropertyChangeListener(String property,                                PropertyChangeListener listener)
        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.
        Parameters:
        property - The name of the property that was listened on.
        listener - The PropertyChangeListener to be removed.
        See Also:
        PropertyChangeSupport.removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
      • scale

        void scale()
        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!

      • scaleTrace

        void scaleTrace(ITrace2D trace)
        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!

        Parameters:
        trace - the trace to scale.
      • setAxisTitle

        void setAxisTitle(IAxis.AxisTitle axisTitle)
        Sets the title of this axis.

        Parameters:
        axisTitle - the axis title to use.
      • setFormatter

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

        Parameters:
        formatter - The formatter to set.
      • setMajorTickSpacing

        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 Chart2D<. 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 ).

        Parameters:
        majorTickSpacing - the major tick spacing for label generation.
      • setMinorTickSpacing

        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 minor tick mark. If you have a trace with a range from 0 to 10 and the minor tick spacing is set to 2, you will get major ticks next to the following values: 0, 2, 4, 6, 8, 10. If a major tick hits the same values the tick will be a major ticks. For this example: if a major tick spacing is set to 5 you will only get minor ticks for: 2, 4, 6, 8.

        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 Chart2D<. 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 ).

        Parameters:
        minorTickSpacing - the minor tick spacing to set.
      • setPaintGrid

        void setPaintGrid(boolean grid)
        Set wether the grid in this dimension should be painted or not.

        A repaint operation for the chart is triggered.

        Parameters:
        grid - true if the grid should be painted or false if not.
      • setPaintScale

        void setPaintScale(boolean show)
        Set if the scale for this axis should be shown.

        Parameters:
        show - true if the scale on this axis should be shown, false else.
      • setPixelXLeft

        void setPixelXLeft(int pixel)
        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!

        Parameters:
        pixel - the left pixel coordinate of this axis in the graphic context of the current paint operation.
      • setPixelXRight

        void setPixelXRight(int pixel)
        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!

        Parameters:
        pixel - the right pixel coordinate of this axis in the graphic context of the current paint operation.
      • setPixelYBottom

        void setPixelYBottom(int pixel)
        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!

        Parameters:
        pixel - the bottom pixel coordinate of this axis in the graphic context of the current paint operation.
      • setPixelYTop

        void setPixelYTop(int pixel)
        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!

        Parameters:
        pixel - the top pixel coordinate of this axis in the graphic context of the current paint operation.
      • setRange

        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);

        Parameters:
        range - Range to use for filtering the view to the the connected Axis.
        See Also:
        getRangePolicy(), IRangePolicy.setRange(Range)
      • setRangePolicy

        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.

        Parameters:
        rangePolicy - The rangePolicy to set.
      • setStartMajorTick

        void setStartMajorTick(boolean majorTick)
        Set wether scale values are started from major ticks.

        Parameters:
        majorTick - true if scale values shall start with a major tick.
        See Also:
        AAxis.setMajorTickSpacing(double)
      • setVisible

        void setVisible(boolean visible)
        Show/hide this axis.

        Parameters:
        visible - true to paint axis, false to hide.
      • translatePxToValue

        double translatePxToValue(int pixel)
        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.

        Parameters:
        pixel - a pixel value of the chart component as used by awt.
        Returns:
        the awt pixel value transformed to the chart value.
      • translateValueToPx

        int translateValueToPx(double value)
        Transforms the given chart data value into the corresponding awt pixel value for the chart.

        Parameters:
        value - a chart data value.
        Returns:
        the awt pixel value corresponding to the chart data value.

SCaVis 2.1 © jWork.ORG