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
TracePoint2D
contained in the allITrace2d
instances connected. This is because theIAxis
of 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 everyTracePoint2D
is taken from theITrace2D
- instance exactly in the order, it's iterator returns them. From everyTracePoint2D
then a line is drawn to the next.
Unordered traces may cause a weird display. Choose the right implementation ofITrace2D
to 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 enum
Types of tool tip.static enum
Types of tool tip.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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String[]
Speaking names for axis constants - used for debugging only.static final int
Constant describing the bottom side of the chart.static final int
Constant describing the left side of the chart.static final int
Constant describing the right side of the chart.static final int
Constant describing the top side of the chart.static final boolean
A package wide switch for debugging problems with highlighting.static final boolean
A package wide switch for debugging problems with scaling.static final boolean
A package wide switch for debugging problems with multithreading.protected int
Chart - wide setting for the ms to give a repaint operation time for collecting several repaint requests into one (performance versus update speed).static final String
The bean propertyconstant
identifying a change of traces.static final String
The bean propertyconstant
identifying a change of the antialiasing enabled state.static final String
The bean propertyconstant
identifying a change of the internal
instance for the x dimension.IAxis
static final String
The bean propertyconstant
identifying a replacement of an internal
instance for the bottom x dimension.IAxis
static final String
The bean propertyconstant
identifying a replacement of an internal
instance for the top x dimension.IAxis
static final String
The bean propertyconstant
identifying a change of the internal
instance for the y dimension.IAxis
static final String
The bean propertyconstant
identifying a replacement of an internal
instance for the left y dimension.IAxis
static final String
The bean propertyconstant
identifying a replacement of an internal
instance for the right y dimension.IAxis
static final String
The bean propertyconstant
identifying a change of the background color.static final String
The bean propertyconstant
identifying a change of the font.static final String
The bean propertyconstant
identifying a change of the foreground color.static final String
The bean propertyconstant
identifying a change of the grid color.static final String
The bean propertyconstant
identifying a change of the paint labels flag.static final String
The bean propertyconstant
identifying a change of the point highlighting enabled state.static final String
The bean propertyconstant
identifying a change of the internal
instance used to find the nearest point corresponding to mouse events over the chart.IPointFinder
static final String
The bean propertyconstant
identifying a change of the tool tip type ({Chart2D
).setToolTipType(IToolTipType)
static final int
Constant describing the x axis (needed for scaling).static final int
Constant describing the x and y axis (needed for scaling).static final int
Constant 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_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, 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
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAxisXBottom
(AAxis<?> axisX) Adds the given x axis to the list of internal bottom x axes.void
addAxisXTop
(AAxis<?> axisX) Adds the given x axis to the list of internal top x axes.void
addAxisYLeft
(AAxis<?> axisY) Adds the given y axis to the list of internal left y axes.void
addAxisYRight
(AAxis<?> axisY) Adds the given y axis to the list of internal right y axes.final void
Convenience method that adds the trace to this chart with relation to the first bottom x axis and the first left y axis.final void
Adds the trace to this chart with relation to the given x axis and y axis.void
destroy()
Destroys the chart.boolean
enablePointHighlighting
(boolean onoff) Switches point highlighting on or off depending on the given argument.protected void
finalize()
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 Color
Returns the color of the grid.int
int
Returns 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 nearest
to the given mouse event's screen coordinates in Euclid distance.ITracePoint2D
Returns the nearest
to the given mouse event's screen coordinates in Euclid distance.MouseEvent
getNearestPointManhattan
(int mouseEventX, int mouseEventY) Returns the nearest
to the given mouse event's screen coordinates in Manhattan distance.ITracePoint2D
Returns the nearest
to the given mouse event's screen coordinates in Manhattan distance.MouseEvent
Returns the point finder used to find the nearest point corresponding to a mouse event.getSize()
Overridden to allow full - page printing.final Chart2D
Returns the chart that will be synchronized for finding the start coordinate of this chart to draw in x dimension (getXChartStart()
final String
getToolTipText
(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.int
getWidth()
final int
Returns the width of the X axis in px.final int
Returns the x coordinate of the chart's right edge in px.final int
Returns the x coordinate of the chart's left edge in px.final int
Returns the y coordinate of the upper edge of the chart's display area in px.int
Returns the y coordinate of the chart's lower edge in px.boolean
Returns true if highlighting of the nearest point to the cursor is enabled.final boolean
Returns true if labels for each chart are painted below it, false else.protected boolean
Returns the requestedRepaint.final boolean
Returns true if chart coordinates are drawn as tool tips.final boolean
Returns whether antialiasing is used.boolean
isVisible
(ITracePoint2D point) Returns true if the given point is in the visible drawing area of the Chart2D.iterator()
Returns anIterator
over the containedITrace2D
instances.void
This method is just overridden to ensure a lock on this instance and then a lock on
just as it has to be done in that order inComponent.getTreeLock()
.addTrace(ITrace2D, IAxis, IAxis)
protected void
A basic rule of a JComponent is:
Never invoke this method directly.int
print
(Graphics graphics, PageFormat pageFormat, int pageIndex) void
Receives all
from all instances the chart registers itself as aPropertyChangeEvent
.PropertyChangeListener
Convenience method to remove all traces from this chart.boolean
removeAxisXBottom
(IAxis<?> axisX) Removes the given x axis from the list of internal bottom x axes.boolean
removeAxisXTop
(IAxis<?> axisX) Removes the given x axis from the list of internal top x axes.boolean
removeAxisYLeft
(IAxis<?> axisY) Removes the given y axis from the list of internal left y axes.boolean
removeAxisYRight
(IAxis<?> axisY) Removes the given y axis from the list of internal right y axes.final boolean
removeTrace
(ITrace2D points) Removes the given instance from thisChart2D
if it is contained.void
repaint()
Deprecated.void
repaint
(int x, int y, int width, int height) Deprecated.void
repaint
(long tm) Deprecated.void
repaint
(long tm, int x, int y, int width, int height) Deprecated.void
Deprecated.void
Only intended for
.Chart2DActionPrintSingleton
void
setAxisTickPainter
(IAxisTickPainter tickPainter) Sets the axis tick painter.Deprecated.use
instead.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.use
instead.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 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.void
setPaintLabels
(boolean paintLabels) Decide whether labels for each chart are painted below it.void
setPointFinder
(IPointFinder pointFinder) Sets the point finder used to find the nearest point corresponding to a mouse event.final 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()
final void
setToolTipCoords
(boolean toolTipCoords) Deprecated.usesetToolTipType(IToolTipType)
instead.Chart2D.ToolTipType.DATAVALUES
final void
setToolTipType
(IToolTipType toolTipType) Sets the type of tool tip to use.void
setTracePointProvider
(ITracePointProvider tracePointProvider) Sets the trace point creator of this chart.final void
setUseAntialiasing
(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, 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, 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, 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, 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, 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, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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 propertyconstant
identifying a change of the antialiasing enabled state.Use this constant to register a
PropertyChangeListener
with theChart2D
.- See Also:
-
PROPERTY_AXIS_X
The bean propertyconstant
identifying a change of the internal
instance for the x dimension.IAxis
Use this constant to register a
PropertyChangeListener
with theChart2D
.See the class description for property change events fired.
- See Also:
-
PROPERTY_AXIS_X_BOTTOM_REPLACE
The bean propertyconstant
identifying a replacement of an internal
instance for the bottom x dimension.IAxis
Use this constant to register a
PropertyChangeListener
with theChart2D
.See the class description for property change events fired.
- See Also:
-
PROPERTY_AXIS_X_TOP_REPLACE
The bean propertyconstant
identifying a replacement of an internal
instance for the top x dimension.IAxis
Use this constant to register a
PropertyChangeListener
with theChart2D
.See the class description for property change events fired.
- See Also:
-
PROPERTY_AXIS_Y
The bean propertyconstant
identifying a change of the internal
instance for the y dimension.IAxis
Use this constant to register a
PropertyChangeListener
with theChart2D
.See the class description for property change events fired.
- See Also:
-
PROPERTY_AXIS_Y_LEFT_REPLACE
The bean propertyconstant
identifying a replacement of an internal
instance for the left y dimension.IAxis
Use this constant to register a
PropertyChangeListener
with theChart2D
.See the class description for property change events fired.
- See Also:
-
PROPERTY_AXIS_Y_RIGHT_REPLACE
The bean propertyconstant
identifying a replacement of an internal
instance for the right y dimension.IAxis
Use this constant to register a
PropertyChangeListener
with theChart2D
.See the class description for property change events fired.
- See Also:
-
PROPERTY_BACKGROUND_COLOR
The bean propertyconstant
identifying a change of the background color.
Use this constant to register aPropertyChangeListener
with theChart2D
.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:
-
PROPERTY_FONT
The bean propertyconstant
identifying a change of the font.
Use this constant to register a
PropertyChangeListener
with theChart2D
.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:
-
PROPERTY_FOREGROUND_COLOR
The bean propertyconstant
identifying a change of the foreground color.
Use this constant to register aPropertyChangeListener
with theChart2D
.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:
-
PROPERTY_GRID_COLOR
The bean propertyconstant
identifying a change of the grid color.Use this constant to register a
PropertyChangeListener
with theChart2D
.- See Also:
-
PROPERTY_ADD_REMOVE_TRACE
The bean propertyconstant
identifying a change of traces.Use this constant to register a
PropertyChangeListener
with theChart2D
.- See Also:
-
PROPERTY_PAINTLABELS
The bean propertyconstant
identifying a change of the paint labels flag.Use this constant to register a
PropertyChangeListener
with theChart2D
.- See Also:
-
PROPERTY_POINT_HIGHLIGHTING_ENABLED
The bean propertyconstant
identifying a change of the point highlighting enabled state.Use this constant to register a
PropertyChangeListener
with theChart2D
.- See Also:
-
PROPERTY_POINTFINDER
The bean propertyconstant
identifying a change of the internal
instance used to find the nearest point corresponding to mouse events over the chart.IPointFinder
Use this constant to register a
PropertyChangeListener
with theChart2D
.See the class description for property change events fired.
- See Also:
-
PROPERTY_TOOLTIP_TYPE
The bean propertyconstant
identifying a change of the tool tip type ({Chart2D
).setToolTipType(IToolTipType)
Use this constant to register a
PropertyChangeListener
with theChart2D
.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:
-
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
PropertyChangeEvent
being fired on all instances registered byContainer.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
(registered withString
argumentIAxis.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
PropertyChangeEvent
being fired on all instances registered byContainer.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
(registered withString
argumentIAxis.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:
createToolTip
in 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.MouseMotionListener
Keep 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
PropertyChangeEvent
being fired on all instances registered byContainer.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
(registered withString
argumentPROPERTY_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 innull
on the corresponding position- Parameters:
trace
- the trace to find the axes of.- Returns:
- an array with the x (position 0) and the y axis (position 1) of the given trace if it is correctly set up.
-
getAxes
-
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:
getHeight
in 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 nearest
to the given mouse event's screen coordinates in Euclid distance.ITracePoint2D
This method is expensive and should not be used when rendering fast changing charts with many points.
Using the Manhattan distance is much faster than Euclid distance as it only includes basic addition an absolute value for computation per point (vs. square root, addition and quadrature for Euclid distance). However the euclid distance spans a circle for the nearest points which is visually more normal for end users than the Manhattan distance which forms a rhombus and reaches far distances in only one dimension.
- Parameters:
mouseEventX
- the x pixel value relative to the chart (e.g.:MouseEvent.getY()
mouseEventY
- the y pixel value relative to the chart (e.g.:MouseEvent.getY()
- Returns:
- the nearest
to the given mouse event's screen coordinates.ITracePoint2D
-
getNearestPointEuclid
Returns the nearest
to the given mouse event's screen coordinates in Euclid distance.MouseEvent
This method is expensive and should not be used when rendering fast changing charts with many points.
Note that the given mouse event should be an event fired on this chart component. Else results will point to the nearest point of the chart in the direction of the mouse event's position.
Using the Manhattan distance is much faster than Euclid distance as it only includes basic addition an absolute value for computation per point (vs. square root, addition and quadrature for Euclid distance). However the euclid distance spans a circle for the nearest points which is visually more normal for end users than the Manhattan distance which forms a rhombus and reaches far distances in only one dimension.
- Parameters:
me
- a mouse event fired on this component.- Returns:
- nearest
to the given mouse event's screen coordinates orMouseEvent
null
if the chart is empty.
-
getNearestPointManhattan
Returns the nearest
to the given mouse event's screen coordinates in Manhattan distance.ITracePoint2D
This method is expensive and should not be used when rendering fast changing charts with many points.
Using the Manhattan distance is much faster than Euclid distance as it only includes basic addition an absolute value for computation per point (vs. square root, addition and quadrature for Euclid distance). However the euclid distance spans a circle for the nearest points which is visually more normal for end users than the Manhattan distance which forms a rhombus and reaches far distances in only one dimension.
- Parameters:
mouseEventX
- the x pixel value relative to the chart (e.g.:MouseEvent.getY()
mouseEventY
- the y pixel value relative to the chart (e.g.:MouseEvent.getY()
- Returns:
- the nearest
to the given mouse event's screen coordinates.ITracePoint2D
-
getNearestPointManhattan
Returns the nearest
to the given mouse event's screen coordinates in Manhattan distance.MouseEvent
This method is expensive and should not be used when rendering fast changing charts with many points.
Note that the given mouse event should be an event fired on this chart component. Else results will point to the nearest point of the chart in the direction of the mouse event's position.
Using the Manhattan distance is much faster than Euclid distance as it only includes basic addition an absolute value for computation per point (vs. square root, addition and quadrature for Euclid distance). However the euclid distance spans a circle for the nearest points which is visually more normal for end users than the Manhattan distance which forms a rhombus and reaches far distances in only one dimension.
- Parameters:
me
- a mouse event fired on this component.- Returns:
- nearest
to the given mouse event's screen coordinates orMouseEvent
null
if 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:
getPreferredSize
in 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:
getToolTipText
in 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
Set
orSet.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:
getWidth
in 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 anIterator
over the containedITrace2D
instances. -
paint
This method is just overridden to ensure a lock on this instance and then a lock on
just 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:
paint
in classJComponent
- See Also:
-
paintComponent
A basic rule of a JComponent is:
Never invoke this method directly.
See the description ofJComponent.paintComponent(java.awt.Graphics)
If you do invoke this method you may encounter performance issues, flickering UI and even deadlocks.
- Overrides:
paintComponent
in classJComponent
- Parameters:
g
- the graphics context to use.
-
print
- Specified by:
print
in interfacePrintable
- Throws:
PrinterException
- See Also:
-
propertyChange
Receives all
from all instances the chart registers itself as aPropertyChangeEvent
.PropertyChangeListener
- Specified by:
propertyChange
in 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 thePropertyChangeEvent
PropertyChangeEvent.getPropertyName()
for every single trace removed toIAxis.PROPERTY_ADD_REMOVE_TRACE
of 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 thisChart2D
if it is contained.This method will trigger a
PropertyChangeEvent
being fired on all instances registered byContainer.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
(registered withString
argumentIAxis.PROPERTY_ADD_REMOVE_TRACE
on 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:
repaint
in classJComponent
- See Also:
-
repaint
Deprecated.- Overrides:
repaint
in 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.use
instead.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_X
Furthermore 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 propertyITrace2D
is fired.PROPERTY_AXIS_X_BOTTOM_REPLACE
Note 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.PropertyChangeListener
s
Before the state of the old axis is transferred they will receive
withPropertyChangeListener.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_REPLACE
event for the removal: So be careful not to react on that first event by removing your listener from the axis as you then will not receive the replace event!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_X
Furthermore 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 propertyITrace2D
is fired.PROPERTY_AXIS_Y_LEFT_REPLACE
Note 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.PropertyChangeListener
s
Before the state of the old axis is transferred they will receive
withPropertyChangeListener.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_REPLACE
event for the removal: So be careful not to react on that first event by removing your listener from the axis as you then will not receive the replace event!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.use
instead.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_Y
Furthermore 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 propertyITrace2D
is fired.PROPERTY_AXIS_Y_LEFT_REPLACE
Note 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.PropertyChangeListener
s
Before the state of the old axis is transferred they will receive
withPropertyChangeListener.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_REPLACE
event for the removal: So be careful not to react on that first event by removing your listener from the axis as you then will not receive the replace event!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_Y
Furthermore 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 propertyITrace2D
is fired.PROPERTY_AXIS_Y_RIGHT_REPLACE
Note 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.PropertyChangeListener
s
Before the state of the old axis is transferred they will receive
withPropertyChangeListener.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_REPLACE
event for the removal: So be careful not to react on that first event by removing your listener from the axis as you then will not receive the replace event!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 of
ms.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.usesetToolTipType(IToolTipType)
instead.Chart2D.ToolTipType.DATAVALUES
Set 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 available
constants.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)
.