Chart2D
info.monitorenter.gui.chart

Class Chart2D

    • Field Detail

      • AXIX_CONSTANT_NAMES

        public static final String[] AXIX_CONSTANT_NAMES
        Speaking names for axis constants - used for debugging only.
      • DEBUG_SCALING

        public static final boolean DEBUG_SCALING
        A package wide switch for debugging problems with scaling. Set to false the compiler will remove the debugging statements.
        See Also:
        Constant Field Values
      • DEBUG_HIGHLIGHTING

        public static final boolean DEBUG_HIGHLIGHTING
        A package wide switch for debugging problems with highlighting. Set to false the compiler will remove the debugging statements.
        See Also:
        Constant Field Values
      • DEBUG_THREADING

        public static final boolean DEBUG_THREADING
        A package wide switch for debugging problems with multithreading. Set to false the compiler will remove the debugging statements.
        See Also:
        Constant Field Values
      • PROPERTY_ANTIALIASING_ENABLED

        public static final String PROPERTY_ANTIALIASING_ENABLED
        The bean property constant identifying a change of the antialiasing enabled state.

        Use this constant to register a PropertyChangeListener with the Chart2D.

        See Also:
        Constant Field Values
      • PROPERTY_AXIS_X

        public static final String PROPERTY_AXIS_X
        The bean property constant identifying a change of the internal IAxis instance for the x dimension.

        Use this constant to register a PropertyChangeListener with the Chart2D.

        See the class description for property change events fired.

        See Also:
        Constant Field Values
      • PROPERTY_AXIS_X_BOTTOM_REPLACE

        public static final String PROPERTY_AXIS_X_BOTTOM_REPLACE
        The bean property constant identifying a replacement of an internal IAxis instance for the bottom x dimension.

        Use this constant to register a PropertyChangeListener with the Chart2D.

        See the class description for property change events fired.

        See Also:
        Constant Field Values
      • PROPERTY_AXIS_X_TOP_REPLACE

        public static final String PROPERTY_AXIS_X_TOP_REPLACE
        The bean property constant identifying a replacement of an internal IAxis instance for the top x dimension.

        Use this constant to register a PropertyChangeListener with the Chart2D.

        See the class description for property change events fired.

        See Also:
        Constant Field Values
      • PROPERTY_AXIS_Y

        public static final String PROPERTY_AXIS_Y
        The bean property constant identifying a change of the internal IAxis instance for the y dimension.

        Use this constant to register a PropertyChangeListener with the Chart2D.

        See the class description for property change events fired.

        See Also:
        Constant Field Values
      • PROPERTY_AXIS_Y_LEFT_REPLACE

        public static final String PROPERTY_AXIS_Y_LEFT_REPLACE
        The bean property constant identifying a replacement of an internal IAxis instance for the left y dimension.

        Use this constant to register a PropertyChangeListener with the Chart2D.

        See the class description for property change events fired.

        See Also:
        Constant Field Values
      • PROPERTY_AXIS_Y_RIGHT_REPLACE

        public static final String PROPERTY_AXIS_Y_RIGHT_REPLACE
        The bean property constant identifying a replacement of an internal IAxis instance for the right y dimension.

        Use this constant to register a PropertyChangeListener with the Chart2D.

        See the class description for property change events fired.

        See Also:
        Constant Field Values
      • PROPERTY_BACKGROUND_COLOR

        public static final String PROPERTY_BACKGROUND_COLOR
        The bean property constant identifying a change of the background color.
        Use this constant to register a PropertyChangeListener with the Chart2D.

        The property change events for this change are constructed and fired by the superclass Container so this constant is just for clarification of the String that is related to that property.

        See Also:
        Constant Field Values
      • PROPERTY_FONT

        public static final String PROPERTY_FONT
        The bean property constant identifying a change of the font.

        Use this constant to register a PropertyChangeListener with the Chart2D.

        The property change events for this change are constructed and fired by the superclass Container so this constant is just for clarification of the String that is related to that property.

        See Also:
        Constant Field Values
      • PROPERTY_FOREGROUND_COLOR

        public static final String PROPERTY_FOREGROUND_COLOR
        The bean property constant identifying a change of the foreground color.
        Use this constant to register a PropertyChangeListener with the Chart2D.

        The property change events for this change are constructed and fired by the superclass Container so this constant is just for clarification of the String that is related to that property.

        See Also:
        Constant Field Values
      • PROPERTY_PAINTLABELS

        public static final String PROPERTY_PAINTLABELS
        The bean property constant identifying a change of the paint labels flag.

        Use this constant to register a PropertyChangeListener with the Chart2D.

        See Also:
        Constant Field Values
      • PROPERTY_POINT_HIGHLIGHTING_ENABLED

        public static final String PROPERTY_POINT_HIGHLIGHTING_ENABLED
        The bean property constant identifying a change of the point highlighting enabled state.

        Use this constant to register a PropertyChangeListener with the Chart2D.

        See Also:
        Constant Field Values
      • PROPERTY_POINTFINDER

        public static final String PROPERTY_POINTFINDER
        The bean property constant identifying a change of the internal IPointFinder instance used to find the nearest point corresponding to mouse events over the chart.

        Use this constant to register a PropertyChangeListener with the Chart2D.

        See the class description for property change events fired.

        See Also:
        Constant Field Values
      • PROPERTY_TOOLTIP_TYPE

        public static final String PROPERTY_TOOLTIP_TYPE
        The bean property constant identifying a change of the tool tip type ({Chart2DsetToolTipType(IToolTipType)).

        Use this constant to register a PropertyChangeListener with the Chart2D.

        The property change events for this change are constructed and fired by the superclass Container so this constant is just for clarification of the String that is related to that property.

        See Also:
        Constant Field Values
      • X

        public static final int X
        Constant describing the x axis (needed for scaling).
        See Also:
        Constant Field Values
      • X_Y

        public static final int X_Y
        Constant describing the x and y axis (needed for scaling).
        See Also:
        Constant Field Values
      • Y

        public static final int Y
        Constant describing the y axis (needed for scaling).
        See Also:
        Constant Field Values
    • Constructor Detail

      • Chart2D

        public Chart2D()
        Creates a new chart.

    • Method Detail

      • addAxisXBottom

        public void addAxisXBottom(AAxis<?> axisX)
        Adds the given x axis to the list of internal bottom x axes.

        The given axis must not be contained before (e.g. as right y axis or bottom x axis...).

        Parameters:
        axisX - the additional bottom x axis.
      • addAxisXTop

        public void addAxisXTop(AAxis<?> axisX)
        Adds the given x axis to the list of internal top x axes.

        The given axis must not be contained before (e.g. as right y axis or bottom x axis...).

        Parameters:
        axisX - the additional top x axis.
      • addAxisYLeft

        public void addAxisYLeft(AAxis<?> axisY)
        Adds the given y axis to the list of internal left y axes.

        The given axis must not be contained before (e.g. as right y axis or bottom x axis...).

        Parameters:
        axisY - the additional left y axis.
      • addAxisYRight

        public void addAxisYRight(AAxis<?> axisY)
        Adds the given y axis to the list of internal right y axes.

        The given axis must not be contained before (e.g. as right y axis or bottom x axis...).

        Parameters:
        axisY - the additional right y axis.
      • destroy

        public void destroy()
        Destroys the chart.

        This method is only of interest if you have an application that dynamically adds and removes charts. So if you use the same Chart2D object(s) during the applications lifetime there is no need to use this method.

      • findAxesOfTrace

        public IAxis<?>[] findAxesOfTrace(ITrace2D trace)
        Returns an array with the x (position 0) and the y axis (position 1) of the given trace if it is correctly set up. If the given trace is not set up correctly with this chart a missing axis in one dimension will be reflected in null on the corresponding position

        Parameters:
        trace - the trace to find the axes of.
        Returns:
        an array with the x (position 0) and the y axis (position 1) of the given trace if it is correctly set up.
      • getAxes

        public final List<IAxis<?>> getAxes()
        Returns the List<IAxis> with all axes of the chart.

        Returns:
        the List<IAxis> with all axes of the chart
      • getAxesXBottom

        public final List<IAxis<?>> getAxesXBottom()
        Returns the List<IAxis> with instances that are painted in x dimension on the bottom of the chart.

        Caution! The original list is returned so modifications of it will cause unpredictable side effects.

        Returns:
        the List<IAxis> with instances that are painted in x dimension on the bottom of the chart.
      • getAxesXTop

        public final List<IAxis<?>> getAxesXTop()
        Returns the List<IAxis> with instances that are painted in x dimension on top of the chart.

        Caution! The original list is returned so modifications of it will cause unpredictable side effects.

        Returns:
        the List<IAxis> with instances that are painted in x dimension on top of the chart.
      • getAxesYLeft

        public final List<IAxis<?>> getAxesYLeft()
        Returns the List<IAxis> with instances that are painted in y dimension on the left side of the chart.

        Caution! The original list is returned so modifications of it will cause unpredictable side effects.

        Returns:
        the List<IAxis> with instances that are painted in y dimension on the left side of the chart.
      • getAxesYRight

        public final List<IAxis<?>> getAxesYRight()
        Returns the List<IAxis> with instances that are painted in y dimension on the right side of the chart.

        Caution! The original list is returned so modifications of it will cause unpredictable side effects.

        Returns:
        the List<IAxis> with instances that are painted in y dimension on the right side of the chart.
      • getAxisTickPainter

        public IAxisTickPainter getAxisTickPainter()
        Returns the painter for the ticks of the axis.

        Returns:
        Returns the painter for the ticks of the axis.
      • getAxisX

        public final IAxis<?> getAxisX()
        Returns the first bottom axis for the x dimension.

        Returns:
        the first bottom axis for the x dimension.
      • getAxisX

        public IAxis<?> getAxisX(ITrace2D trace)
        Returns the x axis that the given trace belongs to or null if this trace does not belong to any x axis of this chart.

        Parameters:
        trace - the trace to find the corresponding x axis of this chart for.
        Returns:
        the x axis that the given trace belongs to or null if this trace does not belong to any x axis of this chart.
      • getAxisY

        public final IAxis<?> getAxisY()
        Returns the first left axis for the y dimension.

        Returns:
        the first left axis for the y dimension.
      • getAxisY

        public IAxis<?> getAxisY(ITrace2D trace)
        Returns the y axis that the given trace belongs to or null if this trace does not belong to any y axis of this chart.

        Parameters:
        trace - the trace to find the corresponding y axis of this chart for.
        Returns:
        the y axis that the given trace belongs to or null if this trace does not belong to any y axis of this chart.
      • getGridColor

        public final Color getGridColor()
        Returns the color of the grid.

        Returns:
        the color of the grid.
      • getMinPaintLatency

        public int getMinPaintLatency()
        Returns the chart - wide setting for the ms to give a repaint operation time for collecting several repaint requests into one (performance vs. update speed).

        Returns:
        the setting for the ms to give a repaint operation time for collecting several repaint requests into one (performance vs. update speed).
      • getNearestPointEuclid

        public ITracePoint2D getNearestPointEuclid(int mouseEventX,                                  int mouseEventY)
        Returns the nearest ITracePoint2D to the given mouse event's screen coordinates in Euclid distance.

        This method is expensive and should not be used when rendering fast changing charts with many points.

        Using the Manhattan distance is much faster than Euclid distance as it only includes basic addition an absolute value for computation per point (vs. square root, addition and quadrature for Euclid distance). However the euclid distance spans a circle for the nearest points which is visually more normal for end users than the Manhattan distance which forms a rhombus and reaches far distances in only one dimension.

        Parameters:
        mouseEventX - the x pixel value relative to the chart (e.g.: MouseEvent.getY()).
        mouseEventY - the y pixel value relative to the chart (e.g.: MouseEvent.getY()).
        Returns:
        the nearest ITracePoint2D to the given mouse event's screen coordinates.
      • getNearestPointEuclid

        public ITracePoint2D getNearestPointEuclid(MouseEvent me)
        Returns the nearest MouseEvent to the given mouse event's screen coordinates in Euclid distance.

        This method is expensive and should not be used when rendering fast changing charts with many points.

        Note that the given mouse event should be an event fired on this chart component. Else results will point to the nearest point of the chart in the direction of the mouse event's position.

        Using the Manhattan distance is much faster than Euclid distance as it only includes basic addition an absolute value for computation per point (vs. square root, addition and quadrature for Euclid distance). However the euclid distance spans a circle for the nearest points which is visually more normal for end users than the Manhattan distance which forms a rhombus and reaches far distances in only one dimension.

        Parameters:
        me - a mouse event fired on this component.
        Returns:
        nearest MouseEvent to the given mouse event's screen coordinates or null if the chart is empty.
      • getNearestPointManhattan

        public ITracePoint2D getNearestPointManhattan(int mouseEventX,                                     int mouseEventY)
        Returns the nearest ITracePoint2D to the given mouse event's screen coordinates in Manhattan distance.

        This method is expensive and should not be used when rendering fast changing charts with many points.

        Using the Manhattan distance is much faster than Euclid distance as it only includes basic addition an absolute value for computation per point (vs. square root, addition and quadrature for Euclid distance). However the euclid distance spans a circle for the nearest points which is visually more normal for end users than the Manhattan distance which forms a rhombus and reaches far distances in only one dimension.

        Parameters:
        mouseEventX - the x pixel value relative to the chart (e.g.: MouseEvent.getY()).
        mouseEventY - the y pixel value relative to the chart (e.g.: MouseEvent.getY()).
        Returns:
        the nearest ITracePoint2D to the given mouse event's screen coordinates.
      • getNearestPointManhattan

        public ITracePoint2D getNearestPointManhattan(MouseEvent me)
        Returns the nearest MouseEvent to the given mouse event's screen coordinates in Manhattan distance.

        This method is expensive and should not be used when rendering fast changing charts with many points.

        Note that the given mouse event should be an event fired on this chart component. Else results will point to the nearest point of the chart in the direction of the mouse event's position.

        Using the Manhattan distance is much faster than Euclid distance as it only includes basic addition an absolute value for computation per point (vs. square root, addition and quadrature for Euclid distance). However the euclid distance spans a circle for the nearest points which is visually more normal for end users than the Manhattan distance which forms a rhombus and reaches far distances in only one dimension.

        Parameters:
        me - a mouse event fired on this component.
        Returns:
        nearest MouseEvent to the given mouse event's screen coordinates or null if the chart is empty.
      • getPointFinder

        public IPointFinder getPointFinder()
        Returns the point finder used to find the nearest point corresponding to a mouse event.

        Returns:
        the point finder used to find the nearest point corresponding to a mouse event.
      • getSynchronizedXStartChart

        public final Chart2D getSynchronizedXStartChart()
        Returns the chart that will be synchronized for finding the start coordinate of this chart to draw in x dimension ( getXChartStart() ).

        This feature is used to allow two separate charts to be painted stacked in y dimension (one below the other) that have different x start coordinates (because of different y labels that shift that value) with an equal starting x value (thus be comparable visually if their x values match).

        Returns:
        the chart that will be synchronized for finding the start coordinate of this chart to draw in x dimension ( getXChartStart()).
      • getTracePointProvider

        public ITracePointProvider getTracePointProvider()
        Returns the trace point creator of this chart.

        Returns:
        the trace point creator of this chart.
      • getTraces

        public final SortedSet<ITrace2D> getTraces()
        Returns the set of traces that are currently rendered by this instance.

        The instances are collected from all underlying axes. The resulting Set is not an original set. Therefore modification methods like Set.add(Object) or Set.clear() will not have any effect on the setup of this chart.

        Returns:
        the set of traces that are currently rendered by this instance.
      • getXAxisWidth

        public final int getXAxisWidth()
        Returns the width of the X axis in px.

        Returns:
        Returns the width of the X axis in px.
      • getXChartEnd

        public final int getXChartEnd()
        Returns the x coordinate of the chart's right edge in px.

        Returns:
        the x coordinate of the chart's right edge in px.
      • getXChartStart

        public final int getXChartStart()
        Returns the x coordinate of the chart's left edge in px.

        Returns:
        Returns the x coordinate of the chart's left edge in px.
      • getYChartEnd

        public final int getYChartEnd()
        Returns the y coordinate of the upper edge of the chart's display area in px.

        Pixel coordinates in awt / swing start from top and increase towards the bottom.

        Returns:
        The y coordinate of the upper edge of the chart's display area in px.
      • getYChartStart

        public int getYChartStart()
        Returns the y coordinate of the chart's lower edge in px.

        Pixel coordinates in awt / swing start from top and increase towards the bottom.

        Returns:
        Returns the y coordinate of the chart's lower edge in px.
      • isEnabledPointHighlighting

        public boolean isEnabledPointHighlighting()
        Returns true if highlighting of the nearest point to the cursor is enabled.

        Returns:
        true if highlighting of the nearest point to the cursor is enabled.
      • isPaintLabels

        public final boolean isPaintLabels()
        Returns true if labels for each chart are painted below it, false else.

        Returns:
        Returns if labels are painted.
      • isToolTipCoords

        public final boolean isToolTipCoords()
        Returns true if chart coordinates are drawn as tool tips.

        Returns:
        true if chart coordinates are drawn as tool tips.
      • isUseAntialiasing

        public final boolean isUseAntialiasing()
        Returns whether antialiasing is used.

        Returns:
        whether antialiasing is used.
      • isVisible

        public boolean isVisible(ITracePoint2D point)
        Returns true if the given point is in the visible drawing area of the Chart2D.

        If the point is null false will be returned.

        This only works if the point argument has been scaled already.

        Parameters:
        point - the point to test.
        Returns:
        true if the given point is in the visible drawing area of the Chart2D.
      • paint

        public void paint(Graphics g)
        This method is just overridden to ensure a lock on this instance and then a lock on Component.getTreeLock() just as it has to be done in that order in addTrace(ITrace2D, IAxis, IAxis).

        More info: This lock is needed to ensure a lock on the tree is acquired before a lock to the chart. Method addTrace has a code path that might descend into ChartPanel where Container.getComponents() (in method containsTraceLabel()) will require the tree lock after having already acquired the chart lock -> deadlock between paint thread and addTrace thread when using ChartPanel.

        Overrides:
        paint in class JComponent
        See Also:
        JComponent.paint(java.awt.Graphics)
      • removeAxisXBottom

        public boolean removeAxisXBottom(IAxis<?> axisX)
        Removes the given x axis from the list of internal bottom x axes.

        The given axis should be contained before or false will be returned.

        Parameters:
        axisX - the bottom x axis to remove.
        Returns:
        true if the given axis was successfully removed or false if it was not configured as a bottom x axis before or could not be removed for another reason.
      • removeAxisXTop

        public boolean removeAxisXTop(IAxis<?> axisX)
        Removes the given x axis from the list of internal top x axes.

        The given axis should be contained before or false will be returned.

        Parameters:
        axisX - the top x axis to remove.
        Returns:
        true if the given axis was successfully removed or false if it was not configured as a top x axis before or could not be removed for another reason.
      • removeAxisYLeft

        public boolean removeAxisYLeft(IAxis<?> axisY)
        Removes the given y axis from the list of internal left y axes.

        The given axis should be contained before or false will be returned.

        Parameters:
        axisY - the left y axis to remove.
        Returns:
        true if the given axis was successfully removed or false if it was not configured as a left y axis before or could not be removed for another reason.
      • removeAxisYRight

        public boolean removeAxisYRight(IAxis<?> axisY)
        Removes the given y axis from the list of internal right y axes.

        The given axis should be contained before or false will be returned.

        Parameters:
        axisY - the right y axis to remove.
        Returns:
        true if the given axis was successfully removed or false if it was not configured as a right y axis before or could not be removed for another reason.
      • setAxisTickPainter

        public void setAxisTickPainter(IAxisTickPainter tickPainter)
        Sets the axis tick painter.

        Parameters:
        tickPainter - The axis tick painter to set.
      • setAxisX

        @Deprecatedpublic List<IAxis<?>> setAxisX(AAxis<?> axisX)
        Deprecated. use setAxisXBottom(AAxis, int) instead.
        Sets the first bottom x axis to use.

        This is compatibility support for the API of jchart2d prior to 3.0.0 where only one x axis was supported.

        Parameters:
        axisX - the first bottom x axis to use.
        Returns:
        a copied List with the previous bottom x IAxis instance that was used at position 0.
        See Also:
        setAxisXBottom(AAxis, int)
      • setAxisXBottom

        public IAxis<?> setAxisXBottom(AAxis<?> axisX,                      int position)
        Sets the bottom x axis on the given position to use and replaces the old one on that place.

        This method delegates to addAxisXBottom(AAxis) and also uses removeAxisXBottom(IAxis) in case a bottom x axis was configured at the position. So the events PROPERTY_AXIS_X will be fired for remove and add.

        Furthermore this method uses "replace - semantics". The ITrace2D instances contained in the previous x bottom axis will be implanted to this new axis. Also the title and stuff like grid settings will be transferred. For this an event with property PROPERTY_AXIS_X_BOTTOM_REPLACE is fired.

        Note that PropertyChangeListeners of the axis will not be transferred silently to the new axis but have to handle their unregistering from the old axis / registering to the new axis from outside to give them the chance to manage their state transitions by themselves.
        Before the state of the old axis is transferred they will receive PropertyChangeListener.propertyChange(PropertyChangeEvent) with PROPERTY_AXIS_X_BOTTOM_REPLACE as code and the old and new axis as values and have the change to change their peer to listen on thus receiving the change events generated on the new axis. At the moment the replace event is sent they will already have received the event PROPERTY_AXIS_X event for the removal: So be careful not to react on that first event by removing your listener from the axis as you then will not receive the replace event!

        Parameters:
        axisX - the first bottom x axis to use.
        position - the index of the axis on bottom x dimension (starting from 0).
        Returns:
        the previous axis on that bottom x position or null.
      • setAxisXTop

        public IAxis<?> setAxisXTop(AAxis<?> axisX,                   int position)
        Sets the top x axis on the given position to use and replaces the old one on that place.

        This method delegates to addAxisXBottom(AAxis) and also uses removeAxisXBottom(IAxis) in case a top x axis was configured on the position. So the events PROPERTY_AXIS_X will be fired for remove and add.

        Furthermore this method uses "replace - semantics". The ITrace2D instances contained in the previous x top axis will be implanted to this new axis. Also the title and stuff like grid settings will be transferred. For this an event with property PROPERTY_AXIS_Y_LEFT_REPLACE is fired.

        Note that PropertyChangeListeners of the axis will not be transferred silently to the new axis but have to handle their unregistering from the old axis / registering to the new axis from outside to give them the chance to manage their state transitions by themselves.
        Before the state of the old axis is transferred they will receive PropertyChangeListener.propertyChange(PropertyChangeEvent) with PROPERTY_AXIS_X_TOP_REPLACE as code and the old and new axis as values and have the change to change their peer to listen on thus receiving the change events generated on the new axis. At the moment the replace event is sent they will already have received the event PROPERTY_AXIS_X event for the removal: So be careful not to react on that first event by removing your listener from the axis as you then will not receive the replace event!

        Parameters:
        axisX - the top x axis to use.
        position - the index of the axis on top x dimension (starting from 0).
        Returns:
        the previous axis on that bottom x position.
      • setAxisY

        @Deprecatedpublic List<IAxis<?>> setAxisY(AAxis<?> axisY)
        Deprecated. use setAxisYLeft(AAxis, int) instead.
        Sets the first and only left y axis to use.

        This is compatibility support for the API of jchart2d prior to 3.0.0 where only one y axis was supported.

        Parameters:
        axisY - the first left y axis to use.
        Returns:
        a copied List with the previous left y AAxis instance that was used at position 0.
        See Also:
        setAxisYLeft(AAxis, int)
      • setAxisYLeft

        public IAxis<?> setAxisYLeft(AAxis<?> axisY,                    int position)
        Sets the left y axis on the given position to use and replaces the old one on that place.

        This method delegates to addAxisYLeft(AAxis) and also uses removeAxisYLeft(IAxis) in case an axis was configured on the position. So the events PROPERTY_AXIS_Y will be fired for remove and add.

        Furthermore this method uses "replace - semantics". The ITrace2D instances contained in the previous left y axis will be implanted to this new axis. Also the title and stuff like grid settings will be transferred. For this an event with property PROPERTY_AXIS_Y_LEFT_REPLACE is fired.

        Note that PropertyChangeListeners of the axis will not be transferred silently to the new axis but have to handle their unregistering from the old axis / registering to the new axis from outside to give them the chance to manage their state transitions by themselves.
        Before the state of the old axis is transferred they will receive PropertyChangeListener.propertyChange(PropertyChangeEvent) with PROPERTY_AXIS_Y_LEFT_REPLACE as code and the old and new axis as values and have the change to change their peer to listen on thus receiving the change events generated on the new axis. At the moment the replace event is sent they will already have received the event PROPERTY_AXIS_Y event for the removal: So be careful not to react on that first event by removing your listener from the axis as you then will not receive the replace event!

        Parameters:
        axisY - the left y axis to use.
        position - the index of the axis on left y dimension (starting from 0).
        Returns:
        the previous axis on that bottom x position.
      • setAxisYRight

        public IAxis<?> setAxisYRight(AAxis<?> axisY,                     int position)
        Sets the right y axis on the given position to use and replaces the old one on that place.

        This method delegates to addAxisYRight(AAxis) and also uses removeAxisYRight(IAxis) in case an axis was configured on the position. So the events PROPERTY_AXIS_Y will be fired for remove and add.

        Furthermore this method uses "replace - semantics". The ITrace2D instances contained in the previous right y axis will be implanted to this new axis. Also the title and stuff like grid settings will be transferred. For this an event with property PROPERTY_AXIS_Y_RIGHT_REPLACE is fired.

        Note that PropertyChangeListeners of the axis will not be transferred silently to the new axis but have to handle their unregistering from the old axis / registering to the new axis from outside to give them the chance to manage their state transitions by themselves.
        Before the state of the old axis is transferred they will receive PropertyChangeListener.propertyChange(PropertyChangeEvent) with PROPERTY_AXIS_Y_RIGHT_REPLACE as code and the old and new axis as values and have the change to change their peer to listen on thus receiving the change events generated on the new axis. At the moment the replace event is sent they will already have received the event PROPERTY_AXIS_Y event for the removal: So be careful not to react on that first event by removing your listener from the axis as you then will not receive the replace event!

        Parameters:
        axisY - the right y axis to use.
        position - the index of the axis on right y dimension (starting from 0).
        Returns:
        the previous axis on that bottom x position.
      • setGridColor

        public final void setGridColor(Color gridclr)
        Set the grid color to use.

        Parameters:
        gridclr - the grid color to use.
      • setMinPaintLatency

        public void setMinPaintLatency(int minPaintLatency)
        Sets the ms to give a repaint operation time for collecting several repaint requests into one (performance vs. update speed).

        Parameters:
        minPaintLatency - the setting for the ms to give a repaint operation time for collecting several repaint requests into one (performance vs. update speed).
      • setPaintLabels

        public void setPaintLabels(boolean paintLabels)
        Decide whether labels for each chart are painted below it. If set to true this will be done, else labels will be omitted.

        Parameters:
        paintLabels - the value for paintLabels to set.
      • setRequestedRepaint

        public final void setRequestedRepaint(boolean requestedRepaint)
        Sets the requestedRepaint.

        Internal method to request a repaint that guarantees that two invocations of will always have at least have an interval of getMinPaintLatency() ms.

        Methods repaint(), repaint(long), repaint(Rectangle), repaint(int, int, int, int) and repaint(long, int, int, int, int) must not be called from application code that has to inform the UI to update the chart directly or a performance problem may arise as java awt / swing implementation does not guarantee to collapse several repaint requests into a single one but prefers to issue many paint invocations causing a high CPU load in realtime scenarios (adding several 100 points per second to a chart).

        Only the internal timer may invoke the methods mentioned above.

        Parameters:
        requestedRepaint - the requestedRepaint to set.
      • setSynchronizedXStartChart

        public void setSynchronizedXStartChart(Chart2D synchronizedXStartChart)
        Sets the chart that will be synchronized for finding the start coordinate of this chart to draw in x dimension ( getXChartStart() ).

        This feature is used to allow two separate charts to be painted stacked in y dimension (one below the other) that have different x start coordinates (because of different y labels that shift that value) with an equal starting x value (thus be comparable visually if their x values match).

        Parameters:
        synchronizedXStartChart - the chart that will be synchronized for finding the start coordinate of this chart to draw in x dimension ( getXChartStart()).
      • setTracePointProvider

        public void setTracePointProvider(ITracePointProvider tracePointProvider)
        Sets the trace point creator of this chart.

        Null assignment attempts will raise an AssertionError.

        Parameters:
        tracePointProvider - the trace point creator of this chart to set.
      • setUseAntialiasing

        public final void setUseAntialiasing(boolean useAntialiasing)
        Sets whether antialiasing is used.

        Parameters:
        useAntialiasing - true if antialiasing should be used.
      • snapShot

        public BufferedImage snapShot()
        Returns a BufferedImage with the current width and height of the chart filled with the Chart2D's graphics that may be written to a file or OutputStream by using: ImageIO.write(java.awt.image.RenderedImage, java.lang.String, java.io.File) .

        If the width and height of this chart is zero (this happens when the chart has not been JComponent.setVisible(boolean), the chart was not integrated into layout correctly or the chart's dimenision was set to this value, a default of width 600 and height 400 will temporarily be set (syncrhonized), the image will be rendered, the old dimension will be reset and the image will be returned.
        If you want to paint offscreen images (without displayed chart) prefer invoke snapShot(int, int) instead.

        Returns:
        a BufferedImage of the Chart2D's graphics that may be written to a file or OutputStream.
      • snapShot

        public BufferedImage snapShot(int width,                     int height)
        Returns a BufferedImage with the given width and height that is filled with tChart2D's graphics that may be written to a file or OutputStream by using: ImageIO.write(java.awt.image.RenderedImage, java.lang.String, java.io.File) .

        Parameters:
        width - the width of the image to create.
        height - the height of the image to create.
        Returns:
        a BufferedImage of the Chart2D's graphics that may be written to a file or OutputStream.
      • translateMousePosition

        @Deprecatedpublic ITracePoint2D translateMousePosition(MouseEvent mouseEvent)                                     throws IllegalArgumentException
        Deprecated. this method is a candidate for wrong behavior when using multiple axes.
        Returns the translation of the mouse event coordinates of the given mouse event to the value within the chart.

        Note that the mouse event has to be an event fired on this component!

        Note that the returned tracepoint is not a real trace point of a trace but just used as a container here.

        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 or null if no calculations could be performed as the chart was not painted before.
        Throws:
        IllegalArgumentException - if the given mouse event does not belong to this component.

SCaVis 2.1 © jWork.ORG