info.monitorenter.gui.chart
Class Chart2D

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by info.monitorenter.gui.chart.Chart2D
All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible
Direct Known Subclasses:
ZoomableChart

public class Chart2D
extends JPanel
implements PropertyChangeListener

Chart2D is a component for displaying the data contained in a ITrace2D. It inherits many features from javax.swing.JPanel and allows specific configuration.
In order to simplify the use of it, the scaling, labeling and choosing of display- range is done automatically which flattens the free configuration.

There are several default settings that may be changed in Chart2D

Demo- code:

       
   ...
   Chart2D test = new Chart2D();
   JFrame frame = new JFrame("Chart2D- Debug");
            
   frame.setSize(400,200);
   frame.setVisible(true);
   ITrace2D atrace = new Trace2DLtd(100);
   ...
   <further configuration of trace>
   ...
   test.addTrace(atrace);
   ....
   while(expression){
     atrace.addPoint(adouble,bdouble);
     ....
   }
 

PropertyChangeEvents

PropertyChangeListener instances may be added via Container.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener). They inherit the properties to listen from Container.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener). Additionally more PropertyChangeEvents are triggered.

As the set of traces inside this class is a collection (and no single property) the PropertyChangeEvent fired for a change of properties property will contain a reference to the Chart2D instance as well as the ITrace2D (if involved in the change).

getPropertyName() getSource() getOldValue() getNewValue() occurence
PROPERTY_ADD_REMOVE_TRACE Chart2D null ITrace2D if a new instance is added.
PROPERTY_ADD_REMOVE_TRACE Chart2D ITrace2D null if an instance is deleted.
PROPERTY_BACKGROUND_COLOR Chart2D Color Color if a change of the background color occurs.
PROPERTY_AXIS_X Chart2D IAxis IAxis if a new axis is set in x dimension.
PROPERTY_AXIS_Y Chart2D IAxis IAxis if a new axis is set in y dimension.
PROPERTY_GRID_COLOR Chart2D Color Color if a change of the grid color occurs.
PROPERTY_PAINTLABELS Chart2D Boolean Boolean if a change of the paint labels flag occurs.

Version:
$Revision: 1.84 $
Author:
Achim Westermann
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String[] AXIX_CONSTANT_NAMES
          Speaking names for axis constants - used for debugging only.
protected static boolean DEBUG_SCALING
          A package wide switch for debugging problems with scaling.
static boolean DEBUG_THREADING
          A package wide switch for debugging problems with multithreading.
static String PROPERTY_ADD_REMOVE_TRACE
          The bean property constant identifying a change of the internal set of ITrace2D instances.
static String PROPERTY_AXIS_X
          The bean property constant identifying a change of the internal IAxis instance for the x dimension.
static String PROPERTY_AXIS_Y
          The bean property constant identifying a change of the internal IAxis instance for the y dimension.
static String PROPERTY_BACKGROUND_COLOR
          The bean property constant identifying a change of the background color.
static String PROPERTY_FONT
           The bean property constant identifying a change of the font.
static String PROPERTY_FOREGROUND_COLOR
          The bean property constant identifying a change of the foreground color.
static String PROPERTY_GRID_COLOR
          The bean property constant identifying a change of the grid color.
static String PROPERTY_PAINTLABELS
          The bean property constant identifying a change of the paint labels flag.
static int X
          Constant describing the x axis (needed for scaling).
static int X_Y
          Constant describing the x and y axis (needed for scaling).
static int Y
          Constant describing the y axis (needed for scaling).
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Chart2D()
          Creates a new chart.
 
Method Summary
 void addTrace(ITrace2D points)
          Adds the trace to this chart.
 JToolTip createToolTip()
           
 void destroy()
          Destroys the chart.
protected  void finalize()
          Cleanup when this instance is dropped.
protected  double findMaxX()
          Searches for the maximum x value of all contained ITraces.
protected  double findMaxY()
          Searches for the maximum y value of all contained ITraces.
protected  double findMinX()
          Searches for the minimum x value of all contained ITraces.
protected  double findMinY()
          Searches for the minimum y value of all contained ITraces.
 IAxisTickPainter getAxisTickPainter()
          Returns the painter for the ticks of the axis.
 IAxis getAxisX()
          Returns the axis for the x dimension.
 IAxis getAxisY()
          Returns the axis for the y dimension.
 Color getGridColor()
          Returns the color of the grid.
 double getMaxX()
          Returns the maximum x-value of all contained ITrace2D instances.
 double getMaxY()
          Returns the maximum y-value of all contained ITrace2D instances.
 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).
 double getMinX()
          Returns the minimum x-value of all contained ITrace2D instances.
 double getMinY()
          Returns the minimum y-value of all contained ITrace2D instances.
 double getOffsetX()
          Returns the minimum x-value displayed by this chart.
 Chart2D getSynchronizedXStartChart()
          Returns the chart that will be synchronized for finding the start coordinate of this chart to draw in x dimension (getXChartStart()).
 String getToolTipText(MouseEvent event)
           
 Set getTraces()
          Returns the internal set of traces that are currently rendered by this instance.
 int getXChartEnd()
          Returns the x coordinate of the chart's right edge in px.
 int getXChartStart()
          Returns the x coordinate of the chart's left edge in px.
 int getYChartEnd()
          Returns the y coordinate of the upper edge of the chart's display area in px.
 int getYChartStart()
          Returns the y coordinate of the chart's lower edge in px.
protected  boolean isDirtyScaling()
          Returns true if the bounds of all TracePoint2D instances of all internal ITrace2D instances have changed since all points have been normalized to a value between 0 and 1.
protected  boolean isDirtyScaling(int axis)
          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.
 boolean isPaintLabels()
           Returns true if labels for each chart are painted below it, false else.
protected  boolean isRequestedRepaint()
          Returns the requestedRepaint.
 boolean isToolTipCoords()
          Returns true if chart coordinates are drawn as tool tips.
 Iterator iterator()
          Returns an Iterator over the contained ITrace2D instances.
 void paint(Graphics g)
          A basic rule of a JComponent is:
Never invoke this method directly.
 void propertyChange(PropertyChangeEvent evt)
           Called from ATrace2D.setZIndex(Integer) to show that property ITrace2D.PROPERTY_ZINDEX has changed.
 void removeTrace(ITrace2D points)
           Removes the given instance from this Chart2D if it is contained.
 void repaint()
          Deprecated. use setRequestedRepaint(boolean).
 void repaint(int x, int y, int width, int height)
          Deprecated. use setRequestedRepaint(boolean).
 void repaint(long tm)
          Deprecated. use setRequestedRepaint(boolean).
 void repaint(long tm, int x, int y, int width, int height)
          Deprecated. use setRequestedRepaint(boolean).
 void repaint(Rectangle r)
          Deprecated. use setRequestedRepaint(boolean).
 void setAxisTickPainter(IAxisTickPainter tickPainter)
          Sets the axis tick painter.
 void setAxisX(AAxis axisX)
          Set the x axis to use.
 void setAxisY(AAxis axisY)
          Set the y axis to use.
 void setBackground(Color bg)
           
 void setForeground(Color fg)
           
 void setGridColor(Color gridclr)
           Set the grid color to use.
 void setMinPaintLatency(int minPaintLatency)
          Sets the ms to give a repaint operation time for collecting several repaint requests into one (performance vs. update speed).
 void setPaintLabels(boolean paintLabels)
           Decide wether labels for each chart are painted below it.
 void setRequestedRepaint(boolean requestedRepaint)
          Sets the requestedRepaint.
 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()).
 void setToolTipCoords(boolean toolTipCoords)
          Set wether this component should display the chart coordinates as a tool tip.
 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).
 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).
 String toString()
           
 TracePoint2D translateMousePosition(MouseEvent mouseEvent)
          Returns the translation of the mouse event coordinates of the given mouse event to the value within the chart.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AXIX_CONSTANT_NAMES

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


DEBUG_SCALING

protected 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_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_ADD_REMOVE_TRACE

public static final String PROPERTY_ADD_REMOVE_TRACE
The bean property constant identifying a change of the internal set of ITrace2D instances.

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

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_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_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_GRID_COLOR

public static final String PROPERTY_GRID_COLOR
The bean property constant identifying a change of the grid color.

Use this constant to register a PropertyChangeListener with the Chart2D.

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

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

addTrace

public final void addTrace(ITrace2D points)
Adds the trace to this chart. It will be painted (if it's ITrace2D.isVisible() returns true) in this chart.

This method will trigger a PropertyChangeEvent being fired on all instances registered by Container.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener) (registered with String argument PROPERTY_ADD_REMOVE_TRACE).

Parameters:
points - the trace to add.
See Also:
PROPERTY_ADD_REMOVE_TRACE

createToolTip

public JToolTip createToolTip()
Overrides:
createToolTip in class JComponent
See Also:
JComponent.createToolTip()

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.


finalize

protected void finalize()
                 throws Throwable
Cleanup when this instance is dropped.

The internal painter thread is stoppped.

Overrides:
finalize in class Object
Throws:
Throwable - if a finalizer of a superclass fails.
See Also:
Object.finalize()

findMaxX

protected final double findMaxX()
Searches for the maximum x value of all contained ITraces.

This method is triggered when a trace fired a property change for property ITrace2D.PROPERTY_MAX_X with a value lower than the internal stored maximum x.

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

Note that the Chart2D itself does not use this value for painting. It uses AAxis.getRange() which itself accesses this value by accessors and additionally filters the value by it's assigned internal ARangePolicy.

Returns:
the maximum x value of all traces.

findMaxY

protected final double findMaxY()
Searches for the maximum y value of all contained ITraces.

This method is triggered when a trace fired a property change for property ITrace2D.PROPERTY_MAX_Y with a value lower than the internal stored maximum x.

Note that the Chart2D itself does not use this value for painting. It uses AAxis.getRange() which itself accesses this value by accessors and additionally filters the value by it's assigned internal ARangePolicy.

Returns:
the maximum y value of all traces.

findMinX

protected final double findMinX()
Searches for the minimum x value of all contained ITraces.

This method is triggered when a trace fired a property change for property ITrace2D.PROPERTY_MIN_Y with a value lower than the internal stored maximum x.

Note that the Chart2D itself does not use this value for painting. It uses AAxis.getRange() which itself accesses this value by accessors and additionally filters the value by it's assigned internal ARangePolicy.

Returns:
the minimum x value of all traces.

findMinY

protected final double findMinY()
Searches for the minimum y value of all contained ITraces.

This method is triggered when a trace fired a property change for property ITrace2D.PROPERTY_MIN_Y with a value lower than the internal stored maximum x.

Note that the Chart2D itself does not use this value for painting. It uses AAxis.getRange() which itself accesses this value by accessors and additionally filters the value by it's assigned internal ARangePolicy.

Returns:
the minimum y value of all traces.

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 axis for the x dimension.

Returns:
the axis for the x dimension.

getAxisY

public final IAxis getAxisY()
Returns the axis for the y dimension.

Returns:
the axis for the y dimension.

getGridColor

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

Returns:
the color of the grid.

getMaxX

public final double getMaxX()
Returns the maximum x-value of all contained ITrace2D instances.

Returns:
the maximum x-value of all contained ITrace2D instances.

getMaxY

public final double getMaxY()
Returns the maximum y-value of all contained ITrace2D instances.

Returns:
the maximum y-value of all contained ITrace2D instances.

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

getMinX

public final double getMinX()
Returns the minimum x-value of all contained ITrace2D instances.

Returns:
the minimum x-value of all contained ITrace2D instances.
See Also:
getOffsetX()

getMinY

public final double getMinY()
Returns the minimum y-value of all contained ITrace2D instances.

Returns:
the minimum y-value of all contained ITrace2D instances.

getOffsetX

public final double getOffsetX()
Returns the minimum x-value displayed by this chart.

This value is not neccessarily the minimum x-value of all internal ITrace2D instances. Rounding or forced bounds on the internal X - AAxis may have an effect on this value.

Returns:
the minimum x-value displayed by this chart.
See Also:
getMinX()

getSynchronizedXStartChart

public 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()).

getToolTipText

public String getToolTipText(MouseEvent event)
Overrides:
getToolTipText in class JComponent
See Also:
JComponent.getToolTipText(java.awt.event.MouseEvent)

getTraces

public final Set getTraces()
Returns the internal set of traces that are currently rendered by this instance.

Caution: the original internal set is returned. Modifications on the returned set could cause problems.

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

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

isDirtyScaling

protected final boolean isDirtyScaling()
Returns true if the bounds of all TracePoint2D instances of all internal ITrace2D instances have changed since all points have been normalized to a value between 0 and 1.

Returns:
true if the bounds of all TracePoint2D instances of all internal ITrace2D instances have changed since all points have been normalized to a value between 0 and 1.

isDirtyScaling

protected final boolean isDirtyScaling(int axis)
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.

Parameters:
axis - one of X or Y.
Returns:
true if the bounds of all TracePoint2D instances of all internal ITrace2D instances have changed since all points have been normalized to a value between 0 and 1.

isPaintLabels

public final boolean isPaintLabels()

Returns true if labels for each chart are painted below it, false else.

Returns:
Returns if labels are painted.

isRequestedRepaint

protected boolean isRequestedRepaint()
Returns the requestedRepaint.

Returns:
the requestedRepaint

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.

iterator

public final Iterator iterator()
Returns an Iterator over the contained ITrace2D instances.

Returns:
an Iterator over the contained ITrace2D instances.

paint

public void paint(Graphics g)
A basic rule of a JComponent is:
Never invoke this method directly.
See the description of JComponent.paint(java.awt.Graphics) for details.

If you do invoke this method you may encounter performance issues, flickering UI and even deadlocks.

Overrides:
paint in class JComponent
Parameters:
g - the graphics context to use.

propertyChange

public void propertyChange(PropertyChangeEvent evt)

Called from ATrace2D.setZIndex(Integer) to show that property ITrace2D.PROPERTY_ZINDEX has changed.

This class adds itself as a PropertyChangeListener to the ATrace2D in method addTrace(ITrace2D).

Also used for properties ITrace2D.PROPERTY_MAX_X, ITrace2D.PROPERTY_MAX_Y. ITrace2D.PROPERTY_MIN_X and ITrace2D.PROPERTY_MIN_Y to adapt to bound changes.

Specified by:
propertyChange in interface PropertyChangeListener
Parameters:
evt - the property change event that was fired.
See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)

removeTrace

public final void removeTrace(ITrace2D points)

Removes the given instance from this Chart2D if it is contained.

This method will trigger a PropertyChangeEvent being fired on all instances registered by Container.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener) (registered with String argument PROPERTY_ADD_REMOVE_TRACE).

Parameters:
points - the trace to remove.
See Also:
PROPERTY_ADD_REMOVE_TRACE

repaint

public void repaint()
Deprecated. use setRequestedRepaint(boolean).

Overrides:
repaint in class Component
See Also:
Component.repaint()

repaint

public void repaint(int x,
                    int y,
                    int width,
                    int height)
Deprecated. use setRequestedRepaint(boolean).

Overrides:
repaint in class Component
See Also:
Component.repaint(int, int, int, int)

repaint

public void repaint(long tm)
Deprecated. use setRequestedRepaint(boolean).

Overrides:
repaint in class Component
See Also:
Component.repaint(long)

repaint

public void repaint(long tm,
                    int x,
                    int y,
                    int width,
                    int height)
Deprecated. use setRequestedRepaint(boolean).

Overrides:
repaint in class JComponent
See Also:
JComponent.repaint(long, int, int, int, int)

repaint

public void repaint(Rectangle r)
Deprecated. use setRequestedRepaint(boolean).

Overrides:
repaint in class JComponent
See Also:
JComponent.repaint(java.awt.Rectangle)

setAxisTickPainter

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

Parameters:
tickPainter - The axis tick painter to set.

setAxisX

public void setAxisX(AAxis axisX)
Set the x axis to use.

Parameters:
axisX - The axisX to set.

setAxisY

public void setAxisY(AAxis axisY)
Set the y axis to use.

Parameters:
axisY - The axisY to set.

setBackground

public void setBackground(Color bg)
Overrides:
setBackground in class JComponent
See Also:
Component.setBackground(java.awt.Color)

setForeground

public void setForeground(Color fg)
Overrides:
setForeground in class JComponent
See Also:
Component.setForeground(java.awt.Color)

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 wether labels for each chart are painted below it. If set to true this will be done, else labels will be ommited.

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

setToolTipCoords

public final void setToolTipCoords(boolean toolTipCoords)
Set wether this component should display the chart coordinates as a tool tip.

This turns on tool tip support (like JComponent.setToolTipText(java.lang.String)) if neccessary.

Parameters:
toolTipCoords - The toolTipCoords to set.

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.
Since:
1.03 - please download versions equal or greater than jchart2d-1.03.jar.

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.
Since:
1.03 - please download versions equal or greater than jchart2d-1.03.jar.

toString

public String toString()
Overrides:
toString in class Component
See Also:
Object.toString()

translateMousePosition

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

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.


Copyright © 2001 - 2007 LGPL, All Rights Footloose.