Class Chart2D
- All Implemented Interfaces:
ImageObserver,MenuContainer,Printable,PropertyChangeListener,Serializable,Iterable<ITrace2D>,EventListener,Accessible
- Direct Known Subclasses:
ZoomableChart
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
- The display range is chosen always big enough to show every
TracePoint2Dcontained in the allITrace2dinstances connected. This is because theIAxisof the chart (for x and y) use by default aRangePolicyUnbounded. To change this, get the axis of the chart to change (viagetAxisX(),getAxisY()) and invokeIAxis.setRangePolicy(IRangePolicy)with the desired view port behavior. - During the
paint()operation everyTracePoint2Dis taken from theITrace2D- instance exactly in the order, it's iterator returns them. From everyTracePoint2Dthen a line is drawn to the next.
Unordered traces may cause a weird display. Choose the right implementation ofITrace2Dto avoid this. To change this line painting behavior you can use custom renderers at the level of traces viaITrace2D.addTracePainter(ITracePainter)orITrace2D.setTracePainter(ITracePainter). - If no scaling is chosen, no grids will be painted. See:
This allows saving of many computations.IAxis.setPaintScale(boolean) - The distance of the scalepoints is always big enough to display the labels fully without overwriting each other.
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() |
occurrence |
|---|---|---|---|---|
PROPERTY_BACKGROUND_COLOR |
Chart2D |
Color |
Color |
if a change of the background color occurs. |
PROPERTY_AXIS_X |
Chart2D |
null | IAxis |
if a new axis is added in x dimension (addAxisXBottom(AAxis), @link
addAxisXTop(AAxis)). |
PROPERTY_AXIS_X |
Chart2D |
IAxis |
null | if an axis is removed in x dimension (removeAxisXBottom(IAxis),
removeAxisXTop(IAxis)). |
PROPERTY_AXIS_Y |
Chart2D |
null | IAxis |
if a new axis is added in y dimension (addAxisYLeft(AAxis),
addAxisYRight(AAxis)). |
PROPERTY_AXIS_X_BOTTOM_REPLACE |
Chart2D |
IAxis |
IAxis |
if a axis is replaced in bottom x dimension (
setAxisXBottom(AAxis, int)). |
PROPERTY_AXIS_X_TOP_REPLACE |
Chart2D |
IAxis |
IAxis |
if a axis is replaced in top x dimension (
setAxisXTop(AAxis, int)). |
PROPERTY_AXIS_Y_LEFT_REPLACE |
Chart2D |
IAxis |
IAxis |
if a axis is replaced in left y dimension (
setAxisYLeft(AAxis, int)). |
PROPERTY_AXIS_Y_RIGHT_REPLACE |
Chart2D |
IAxis |
IAxis |
if a axis is replaced in right y dimension (
setAxisYRight(AAxis, int) ). |
PROPERTY_GRID_COLOR |
Chart2D |
Color |
Color |
if a change of the grid color occurs. |
PROPERTY_ADD_REMOVE_TRACE |
Chart2D |
ITrace2D |
ITrace2D |
If a change of the traces occurs. If the old value is null a new trace has been added. If the new value is null, oldvalue trace has been removed. If both are null this is a bug. |
PROPERTY_PAINTLABELS |
Chart2D |
Boolean |
Boolean |
if a change of the paint labels flag occurs. |
PROPERTY_TOOLTIP_TYPE |
Chart2D |
IToolTipType |
IToolTipType |
if a change of the tool tip type occurs. |
PROPERTY_POINT_HIGHLIGHTING_ENABLED |
Chart2D |
Boolean |
Boolean |
if point highlighting is enabled/disabled. |
ITrace2D.PROPERTY_POINT_HIGHLIGHTERS_CHANGED |
Chart2D |
IPointPainter |
null | if a point highlighter was added to any of the currently contained traces. |
ITrace2D.PROPERTY_POINT_HIGHLIGHTERS_CHANGED |
Chart2D |
null | IPointPainter |
if a point highlighter was removed from any of the currently contained traces. |
PROPERTY_ANTIALIASING_ENABLED |
Chart2D |
Boolean |
Boolean |
if antialiasing is enabled/disabled. |
PROPERTY_POINTFINDER |
Chart2D |
IPointFinder |
IPointFinder |
if setPointFinder(IPointFinder) caused a change. |
- Version:
- $Revision: 1.142.2.1 $
- Author:
- Achim Westermann
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumTypes of tool tip.static enumTypes of tool tip.Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String[]Speaking names for axis constants - used for debugging only.static final intConstant describing the bottom side of the chart.static final intConstant describing the left side of the chart.static final intConstant describing the right side of the chart.static final intConstant describing the top side of the chart.static final booleanA package wide switch for debugging problems with highlighting.static final booleanA package wide switch for debugging problems with scaling.static final booleanA package wide switch for debugging problems with multithreading.protected intChart - wide setting for the ms to give a repaint operation time for collecting several repaint requests into one (performance versus update speed).static final StringThe bean propertyconstantidentifying a change of traces.static final StringThe bean propertyconstantidentifying a change of the antialiasing enabled state.static final StringThe bean propertyconstantidentifying a change of the internalinstance for the x dimension.IAxisstatic final StringThe bean propertyconstantidentifying a replacement of an internalinstance for the bottom x dimension.IAxisstatic final StringThe bean propertyconstantidentifying a replacement of an internalinstance for the top x dimension.IAxisstatic final StringThe bean propertyconstantidentifying a change of the internalinstance for the y dimension.IAxisstatic final StringThe bean propertyconstantidentifying a replacement of an internalinstance for the left y dimension.IAxisstatic final StringThe bean propertyconstantidentifying a replacement of an internalinstance for the right y dimension.IAxisstatic final StringThe bean propertyconstantidentifying a change of the background color.static final StringThe bean propertyconstantidentifying a change of the font.static final StringThe bean propertyconstantidentifying a change of the foreground color.static final StringThe bean propertyconstantidentifying a change of the grid color.static final StringThe bean propertyconstantidentifying a change of the paint labels flag.static final StringThe bean propertyconstantidentifying a change of the point highlighting enabled state.static final StringThe bean propertyconstantidentifying a change of the internalinstance used to find the nearest point corresponding to mouse events over the chart.IPointFinderstatic final StringThe bean propertyconstantidentifying a change of the tool tip type ({Chart2D).setToolTipType(IToolTipType)static final intConstant describing the x axis (needed for scaling).static final intConstant describing the x and y axis (needed for scaling).static final intConstant describing the y axis (needed for scaling).Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAxisXBottom(AAxis<?> axisX) Adds the given x axis to the list of internal bottom x axes.voidaddAxisXTop(AAxis<?> axisX) Adds the given x axis to the list of internal top x axes.voidaddAxisYLeft(AAxis<?> axisY) Adds the given y axis to the list of internal left y axes.voidaddAxisYRight(AAxis<?> axisY) Adds the given y axis to the list of internal right y axes.final voidConvenience method that adds the trace to this chart with relation to the first bottom x axis and the first left y axis.final voidAdds the trace to this chart with relation to the given x axis and y axis.voiddestroy()Destroys the chart.booleanenablePointHighlighting(boolean onoff) Switches point highlighting on or off depending on the given argument.protected voidfinalize()Cleanup when this instance is dropped.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.getAxes()Returns the painter for the ticks of the axis.final IAxis<?>getAxisX()Returns the first bottom axis for the x dimension.IAxis<?>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.final IAxis<?>getAxisY()Returns the first left axis for the y dimension.IAxis<?>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.final ColorReturns the color of the grid.intintReturns the chart - wide setting for the ms to give a repaint operation time for collecting several repaint requests into one (performance vs.getNearestPointEuclid(int mouseEventX, int mouseEventY) Returns the nearestto the given mouse event's screen coordinates in Euclid distance.ITracePoint2DReturns the nearestto the given mouse event's screen coordinates in Euclid distance.MouseEventgetNearestPointManhattan(int mouseEventX, int mouseEventY) Returns the nearestto the given mouse event's screen coordinates in Manhattan distance.ITracePoint2DReturns the nearestto the given mouse event's screen coordinates in Manhattan distance.MouseEventReturns the point finder used to find the nearest point corresponding to a mouse event.getSize()Overridden to allow full - page printing.final Chart2DReturns the chart that will be synchronized for finding the start coordinate of this chart to draw in x dimension ().getXChartStart()final StringgetToolTipText(MouseEvent event) Returns the type of tool tip shown.Returns the trace point creator of this chart.Returns the set of traces that are currently rendered by this instance.intgetWidth()final intReturns the width of the X axis in px.final intReturns the x coordinate of the chart's right edge in px.final intReturns the x coordinate of the chart's left edge in px.final intReturns the y coordinate of the upper edge of the chart's display area in px.intReturns the y coordinate of the chart's lower edge in px.booleanReturns true if highlighting of the nearest point to the cursor is enabled.final booleanReturns true if labels for each chart are painted below it, false else.protected booleanReturns the requestedRepaint.final booleanReturns true if chart coordinates are drawn as tool tips.final booleanReturns whether antialiasing is used.booleanisVisible(ITracePoint2D point) Returns true if the given point is in the visible drawing area of the Chart2D.iterator()Returns anIteratorover the containedITrace2Dinstances.voidThis method is just overridden to ensure a lock on this instance and then a lock onjust as it has to be done in that order inComponent.getTreeLock().addTrace(ITrace2D, IAxis, IAxis)protected voidA basic rule of a JComponent is:
Never invoke this method directly.intprint(Graphics graphics, PageFormat pageFormat, int pageIndex) voidReceives allfrom all instances the chart registers itself as aPropertyChangeEvent.PropertyChangeListenerConvenience method to remove all traces from this chart.booleanremoveAxisXBottom(IAxis<?> axisX) Removes the given x axis from the list of internal bottom x axes.booleanremoveAxisXTop(IAxis<?> axisX) Removes the given x axis from the list of internal top x axes.booleanremoveAxisYLeft(IAxis<?> axisY) Removes the given y axis from the list of internal left y axes.booleanremoveAxisYRight(IAxis<?> axisY) Removes the given y axis from the list of internal right y axes.final booleanremoveTrace(ITrace2D points) Removes the given instance from thisChart2Dif it is contained.voidrepaint()Deprecated.voidrepaint(int x, int y, int width, int height) Deprecated.voidrepaint(long tm) Deprecated.voidrepaint(long tm, int x, int y, int width, int height) Deprecated.voidDeprecated.voidOnly intended for.Chart2DActionPrintSingletonvoidsetAxisTickPainter(IAxisTickPainter tickPainter) Sets the axis tick painter.Deprecated.useinstead.setAxisXBottom(AAxis, int)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.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.Deprecated.useinstead.setAxisYLeft(AAxis, int)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.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.final voidsetGridColor(Color gridclr) Set the grid color to use.voidsetMinPaintLatency(int minPaintLatency) Sets the ms to give a repaint operation time for collecting several repaint requests into one (performance vs.voidsetPaintLabels(boolean paintLabels) Decide whether labels for each chart are painted below it.voidsetPointFinder(IPointFinder pointFinder) Sets the point finder used to find the nearest point corresponding to a mouse event.final voidsetRequestedRepaint(boolean requestedRepaint) Sets the requestedRepaint.voidsetSynchronizedXStartChart(Chart2D synchronizedXStartChart) Sets the chart that will be synchronized for finding the start coordinate of this chart to draw in x dimension ().getXChartStart()final voidsetToolTipCoords(boolean toolTipCoords) Deprecated.usewithsetToolTipType(IToolTipType)instead.Chart2D.ToolTipType.DATAVALUESfinal voidsetToolTipType(IToolTipType toolTipType) Sets the type of tool tip to use.voidsetTracePointProvider(ITracePointProvider tracePointProvider) Sets the trace point creator of this chart.final voidsetUseAntialiasing(boolean useAntialiasing) Sets whether antialiasing is used.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).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).toString()translateMousePosition(MouseEvent mouseEvent) Deprecated.this method is a candidate for wrong behavior when using multiple axes.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, 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, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods 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, transferFocusDownCycle, validate, validateTreeMethods 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, getPropertyChangeListeners, getPropertyChangeListeners, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
AXIX_CONSTANT_NAMES
Speaking names for axis constants - used for debugging only. -
CHART_POSITION_BOTTOM
public static final int CHART_POSITION_BOTTOMConstant describing the bottom side of the chart.- See Also:
-
CHART_POSITION_LEFT
public static final int CHART_POSITION_LEFTConstant describing the left side of the chart.- See Also:
-
CHART_POSITION_RIGHT
public static final int CHART_POSITION_RIGHTConstant describing the right side of the chart.- See Also:
-
CHART_POSITION_TOP
public static final int CHART_POSITION_TOPConstant describing the top side of the chart.- See Also:
-
DEBUG_SCALING
public static final boolean DEBUG_SCALINGA package wide switch for debugging problems with scaling. Set to false the compiler will remove the debugging statements.- See Also:
-
DEBUG_HIGHLIGHTING
public static final boolean DEBUG_HIGHLIGHTINGA package wide switch for debugging problems with highlighting. Set to false the compiler will remove the debugging statements.- See Also:
-
DEBUG_THREADING
public static final boolean DEBUG_THREADINGA package wide switch for debugging problems with multithreading. Set to false the compiler will remove the debugging statements.- See Also:
-
PROPERTY_ANTIALIASING_ENABLED
The bean propertyconstantidentifying a change of the antialiasing enabled state.Use this constant to register a
PropertyChangeListenerwith theChart2D.- See Also:
-
PROPERTY_AXIS_X
The bean propertyconstantidentifying a change of the internalinstance for the x dimension.IAxisUse this constant to register a
PropertyChangeListenerwith theChart2D.See the class description for property change events fired.
- See Also:
-
PROPERTY_AXIS_X_BOTTOM_REPLACE
The bean propertyconstantidentifying a replacement of an internalinstance for the bottom x dimension.IAxisUse this constant to register a
PropertyChangeListenerwith theChart2D.See the class description for property change events fired.
- See Also:
-
PROPERTY_AXIS_X_TOP_REPLACE
The bean propertyconstantidentifying a replacement of an internalinstance for the top x dimension.IAxisUse this constant to register a
PropertyChangeListenerwith theChart2D.See the class description for property change events fired.
- See Also:
-
PROPERTY_AXIS_Y
The bean propertyconstantidentifying a change of the internalinstance for the y dimension.IAxisUse this constant to register a
PropertyChangeListenerwith theChart2D.See the class description for property change events fired.
- See Also:
-
PROPERTY_AXIS_Y_LEFT_REPLACE
The bean propertyconstantidentifying a replacement of an internalinstance for the left y dimension.IAxisUse this constant to register a
PropertyChangeListenerwith theChart2D.See the class description for property change events fired.
- See Also:
-
PROPERTY_AXIS_Y_RIGHT_REPLACE
The bean propertyconstantidentifying a replacement of an internalinstance for the right y dimension.IAxisUse this constant to register a
PropertyChangeListenerwith theChart2D.See the class description for property change events fired.
- See Also:
-
PROPERTY_BACKGROUND_COLOR
The bean propertyconstantidentifying a change of the background color.
Use this constant to register aPropertyChangeListenerwith theChart2D.The property change events for this change are constructed and fired by the superclass
Containerso this constant is just for clarification of the String that is related to that property.- See Also:
-
PROPERTY_FONT
The bean propertyconstantidentifying a change of the font.
Use this constant to register a
PropertyChangeListenerwith theChart2D.The property change events for this change are constructed and fired by the superclass
Containerso this constant is just for clarification of the String that is related to that property.- See Also:
-
PROPERTY_FOREGROUND_COLOR
The bean propertyconstantidentifying a change of the foreground color.
Use this constant to register aPropertyChangeListenerwith theChart2D.The property change events for this change are constructed and fired by the superclass
Containerso this constant is just for clarification of the String that is related to that property.- See Also:
-
PROPERTY_GRID_COLOR
The bean propertyconstantidentifying a change of the grid color.Use this constant to register a
PropertyChangeListenerwith theChart2D.- See Also:
-
PROPERTY_ADD_REMOVE_TRACE
The bean propertyconstantidentifying a change of traces.Use this constant to register a
PropertyChangeListenerwith theChart2D.- See Also:
-
PROPERTY_PAINTLABELS
The bean propertyconstantidentifying a change of the paint labels flag.Use this constant to register a
PropertyChangeListenerwith theChart2D.- See Also:
-
PROPERTY_POINT_HIGHLIGHTING_ENABLED
The bean propertyconstantidentifying a change of the point highlighting enabled state.Use this constant to register a
PropertyChangeListenerwith theChart2D.- See Also:
-
PROPERTY_POINTFINDER
The bean propertyconstantidentifying a change of the internalinstance used to find the nearest point corresponding to mouse events over the chart.IPointFinderUse this constant to register a
PropertyChangeListenerwith theChart2D.See the class description for property change events fired.
- See Also:
-
PROPERTY_TOOLTIP_TYPE
The bean propertyconstantidentifying a change of the tool tip type ({Chart2D).setToolTipType(IToolTipType)
Use this constant to register a
PropertyChangeListenerwith theChart2D.The property change events for this change are constructed and fired by the superclass
Containerso this constant is just for clarification of the String that is related to that property.- See Also:
-
X
public static final int XConstant describing the x axis (needed for scaling).- See Also:
-
X_Y
public static final int X_YConstant describing the x and y axis (needed for scaling).- See Also:
-
Y
public static final int YConstant describing the y axis (needed for scaling).- See Also:
-
m_minPaintLatency
protected int m_minPaintLatencyChart - wide setting for the ms to give a repaint operation time for collecting several repaint requests into one (performance versus update speed).
-
-
Constructor Details
-
Chart2D
public Chart2D()Creates a new chart.
-
-
Method Details
-
addAxisXBottom
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
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
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
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.
-
addTrace
Convenience method that adds the trace to this chart with relation to the first bottom x axis and the first left y axis. It will be painted (if it'sITrace2D.isVisible()returns true) in this chart.This method will trigger a
PropertyChangeEventbeing fired on all instances registered byContainer.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)(registered withStringargumentIAxis.PROPERTY_ADD_REMOVE_TRACE) on the internal bottom x axis and left y axis.- Parameters:
points- the trace to add.- See Also:
-
addTrace
Adds the trace to this chart with relation to the given x axis and y axis. It will be painted (if it'sITrace2D.isVisible()returns true) in this chart.This method will trigger a
PropertyChangeEventbeing fired on all instances registered byContainer.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)(registered withStringargumentIAxis.PROPERTY_ADD_REMOVE_TRACE) on the axis of this chart.The given x and y axis will be responsible for computation of the scale of this trace.
- Parameters:
points- the trace to add.xAxis- the x axis responsible for the scale of this trace - it has to be contained in this chart or an exception will be thrown.yAxis- the y axis responsible for the scale of this trace - it has to be contained in this chart or an exception will be thrown.- See Also:
-
createToolTip
- Overrides:
createToolTipin classJComponent- See Also:
-
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.
-
enablePointHighlighting
public boolean enablePointHighlighting(boolean onoff) Switches point highlighting on or off depending on the given argument.Turning off this removes a
and therefore avoids receiving a lot of mouse events which will result in potentially very expensive (many traces with many points) computations to find the nearest point corresponding to the mouse pointer. So dropping the point highlighting feature may result in much better real time performance.MouseMotionListenerKeep in mind that the view part of point highlighting is configured by configuring the point highlighters for your traces:
.ITrace2D.addPointHighlighter(IPointPainter)This method might trigger a
PropertyChangeEventbeing fired on all instances registered byContainer.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)(registered withStringargumentPROPERTY_POINT_HIGHLIGHTING_ENABLED).- Parameters:
onoff- if true the closest point to the cursor will be highlighted, if false you might gain performance by having this feature turned off!- Returns:
- true if a change of this state did take place (you did not call this at least twice with the same argument).
- See Also:
-
finalize
Cleanup when this instance is dropped. -
findAxesOfTrace
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 innullon 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
-
getAxesXBottom
-
getAxesXTop
-
getAxesYLeft
-
getAxesYRight
-
getAxisTickPainter
Returns the painter for the ticks of the axis.- Returns:
- Returns the painter for the ticks of the axis.
-
getAxisX
Returns the first bottom axis for the x dimension.- Returns:
- the first bottom axis for the x dimension.
-
getAxisX
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
Returns the first left axis for the y dimension.- Returns:
- the first left axis for the y dimension.
-
getAxisY
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
Returns the color of the grid.- Returns:
- the color of the grid.
-
getHeight
public int getHeight()- Overrides:
getHeightin classJComponent- See Also:
-
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
Returns the nearestto the given mouse event's screen coordinates in Euclid distance.ITracePoint2DThis 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
to the given mouse event's screen coordinates.ITracePoint2D
-
getNearestPointEuclid
Returns the nearestto the given mouse event's screen coordinates in Euclid distance.MouseEventThis 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
to the given mouse event's screen coordinates orMouseEventnullif the chart is empty.
-
getNearestPointManhattan
Returns the nearestto the given mouse event's screen coordinates in Manhattan distance.ITracePoint2DThis 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
to the given mouse event's screen coordinates.ITracePoint2D
-
getNearestPointManhattan
Returns the nearestto the given mouse event's screen coordinates in Manhattan distance.MouseEventThis 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
to the given mouse event's screen coordinates orMouseEventnullif the chart is empty.
-
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.
-
getPreferredSize
- Overrides:
getPreferredSizein classJComponent- See Also:
-
getSize
Overridden to allow full - page printing. -
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
- Overrides:
getToolTipTextin classJComponent- See Also:
-
getToolTipType
Returns the type of tool tip shown.- Returns:
- the type of tool tip shown.
- See Also:
-
getTracePointProvider
Returns the trace point creator of this chart.- Returns:
- the trace point creator of this chart.
-
getTraces
Returns the set of traces that are currently rendered by this instance.The instances are collected from all underlying axes. The resulting
is not an original set. Therefore modification methods likeSetorSet.add(Object)will not have any effect on the setup of this chart.Set.clear()- Returns:
- the set of traces that are currently rendered by this instance.
-
getWidth
public int getWidth()- Overrides:
getWidthin classJComponent- See Also:
-
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.
-
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.
-
isUseAntialiasing
public final boolean isUseAntialiasing()Returns whether antialiasing is used.- Returns:
- whether antialiasing is used.
-
isVisible
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.
-
iterator
Returns anIteratorover the containedITrace2Dinstances. -
paint
This method is just overridden to ensure a lock on this instance and then a lock onjust as it has to be done in that order inComponent.getTreeLock().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:
paintin classJComponent- See Also:
-
paintComponent
A basic rule of a JComponent is:
Never invoke this method directly.
See the description offor details.JComponent.paintComponent(java.awt.Graphics)If you do invoke this method you may encounter performance issues, flickering UI and even deadlocks.
- Overrides:
paintComponentin classJComponent- Parameters:
g- the graphics context to use.
-
print
- Specified by:
printin interfacePrintable- Throws:
PrinterException- See Also:
-
propertyChange
Receives allfrom all instances the chart registers itself as aPropertyChangeEvent.PropertyChangeListener- Specified by:
propertyChangein interfacePropertyChangeListener- Parameters:
evt- the property change event that was fired.- See Also:
-
removeAllTraces
Convenience method to remove all traces from this chart.This method is broken down to every axis contained in the trace and will fire a
for thePropertyChangeEventPropertyChangeEvent.getPropertyName()for every single trace removed toIAxis.PROPERTY_ADD_REMOVE_TRACEof the corresponding axes.PropertyChangeListener- Returns:
- a non-original-backed set of distinct traces that was contained in this chart before.
-
removeAxisXBottom
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
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
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
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.
-
removeTrace
Removes the given instance from thisChart2Dif it is contained.This method will trigger a
PropertyChangeEventbeing fired on all instances registered byContainer.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)(registered withStringargumentIAxis.PROPERTY_ADD_REMOVE_TRACEon the internal axes).- Parameters:
points- the trace to remove.- Returns:
- true if the given trace was removed successfully, false else.
- See Also:
-
repaint
Deprecated. -
repaint
Deprecated. -
repaint
Deprecated. -
repaint
Deprecated.- Overrides:
repaintin classJComponent- See Also:
-
repaint
Deprecated.- Overrides:
repaintin classJComponent- See Also:
-
resetPrintMode
public void resetPrintMode()Only intended for.Chart2DActionPrintSingleton -
setAxisTickPainter
Sets the axis tick painter.- Parameters:
tickPainter- The axis tick painter to set.
-
setAxisX
Deprecated.useinstead.setAxisXBottom(AAxis, int)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
instance that was used at position 0.IAxis - See Also:
-
setAxisXBottom
Sets the bottom x axis on the given position to use and replaces the old one on that place.This method delegates to
and also usesaddAxisXBottom(AAxis)in case a bottom x axis was configured at the position. So the eventsremoveAxisXBottom(IAxis)will be fired for remove and add.PROPERTY_AXIS_XFurthermore this method uses "replace - semantics". The
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 propertyITrace2Dis fired.PROPERTY_AXIS_X_BOTTOM_REPLACENote that
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.PropertyChangeListeners
Before the state of the old axis is transferred they will receivewithPropertyChangeListener.propertyChange(PropertyChangeEvent)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 eventPROPERTY_AXIS_X_BOTTOM_REPLACEevent 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!PROPERTY_AXIS_X- 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
Sets the top x axis on the given position to use and replaces the old one on that place.This method delegates to
and also usesaddAxisXBottom(AAxis)in case a top x axis was configured on the position. So the eventsremoveAxisXBottom(IAxis)will be fired for remove and add.PROPERTY_AXIS_XFurthermore this method uses "replace - semantics". The
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 propertyITrace2Dis fired.PROPERTY_AXIS_Y_LEFT_REPLACENote that
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.PropertyChangeListeners
Before the state of the old axis is transferred they will receivewithPropertyChangeListener.propertyChange(PropertyChangeEvent)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 eventPROPERTY_AXIS_X_TOP_REPLACEevent 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!PROPERTY_AXIS_X- 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
Deprecated.useinstead.setAxisYLeft(AAxis, int)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
instance that was used at position 0.AAxis - See Also:
-
setAxisYLeft
Sets the left y axis on the given position to use and replaces the old one on that place.This method delegates to
and also usesaddAxisYLeft(AAxis)in case an axis was configured on the position. So the eventsremoveAxisYLeft(IAxis)will be fired for remove and add.PROPERTY_AXIS_YFurthermore this method uses "replace - semantics". The
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 propertyITrace2Dis fired.PROPERTY_AXIS_Y_LEFT_REPLACENote that
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.PropertyChangeListeners
Before the state of the old axis is transferred they will receivewithPropertyChangeListener.propertyChange(PropertyChangeEvent)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 eventPROPERTY_AXIS_Y_LEFT_REPLACEevent 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!PROPERTY_AXIS_Y- 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
Sets the right y axis on the given position to use and replaces the old one on that place.This method delegates to
and also usesaddAxisYRight(AAxis)in case an axis was configured on the position. So the eventsremoveAxisYRight(IAxis)will be fired for remove and add.PROPERTY_AXIS_YFurthermore this method uses "replace - semantics". The
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 propertyITrace2Dis fired.PROPERTY_AXIS_Y_RIGHT_REPLACENote that
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.PropertyChangeListeners
Before the state of the old axis is transferred they will receivewithPropertyChangeListener.propertyChange(PropertyChangeEvent)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 eventPROPERTY_AXIS_Y_RIGHT_REPLACEevent 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!PROPERTY_AXIS_Y- 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
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.
-
setPointFinder
Sets the point finder used to find the nearest point corresponding to a mouse event.- Parameters:
pointFinder- the point finder used to find the nearest point corresponding to a mouse event.- See Also:
-
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 ofms.getMinPaintLatency()Methods
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).repaint(),repaint(long),repaint(Rectangle),repaint(int, int, int, int)andrepaint(long, int, int, int, int)Only the internal timer may invoke the methods mentioned above.
- Parameters:
requestedRepaint- the requestedRepaint to set.
-
setSynchronizedXStartChart
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
Deprecated.usewithsetToolTipType(IToolTipType)instead.Chart2D.ToolTipType.DATAVALUESSet whether 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.
-
setToolTipType
Sets the type of tool tip to use.Use
to turn of tool tips.Chart2D.ToolTipType.NONE- Parameters:
toolTipType- one of the availableconstants.Chart2D.ToolTipType- See Also:
-
setTracePointProvider
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
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 invokesnapShot(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
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
-
translateMousePosition
@Deprecated public 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.
-
setRequestedRepaint(boolean).