Class Chart2D
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- info.monitorenter.gui.chart.Chart2D
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.awt.print.Printable
,java.beans.PropertyChangeListener
,java.io.Serializable
,java.lang.Iterable<ITrace2D>
,java.util.EventListener
,javax.accessibility.Accessible
- Direct Known Subclasses:
ZoomableChart
public class Chart2D extends javax.swing.JPanel implements java.beans.PropertyChangeListener, java.lang.Iterable<ITrace2D>, java.awt.print.Printable
Chart2D
is a component for displaying the data contained in aITrace2D
. It inherits many features fromjavax.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 viaContainer.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
. They inherit the properties to listen fromContainer.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
. Additionally morePropertyChangeEvents
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 theChart2D
instance as well as theITrace2D
(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)
, @linkaddAxisXTop(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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Chart2D.PointFinder
Types of tool tip.static class
Chart2D.ToolTipType
Types of tool tip.-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]
AXIX_CONSTANT_NAMES
Speaking names for axis constants - used for debugging only.static int
CHART_POSITION_BOTTOM
Constant describing the bottom side of the chart.static int
CHART_POSITION_LEFT
Constant describing the left side of the chart.static int
CHART_POSITION_RIGHT
Constant describing the right side of the chart.static int
CHART_POSITION_TOP
Constant describing the top side of the chart.static boolean
DEBUG_HIGHLIGHTING
A package wide switch for debugging problems with highlighting.static boolean
DEBUG_SCALING
A package wide switch for debugging problems with scaling.static boolean
DEBUG_THREADING
A package wide switch for debugging problems with multithreading.protected int
m_minPaintLatency
Chart - wide setting for the ms to give a repaint operation time for collecting several repaint requests into one (performance versus update speed).static java.lang.String
PROPERTY_ADD_REMOVE_TRACE
The bean propertyconstant
identifying a change of traces.static java.lang.String
PROPERTY_ANTIALIASING_ENABLED
The bean propertyconstant
identifying a change of the antialiasing enabled state.static java.lang.String
PROPERTY_AXIS_X
The bean propertyconstant
identifying a change of the internal
instance for the x dimension.IAxis
static java.lang.String
PROPERTY_AXIS_X_BOTTOM_REPLACE
The bean propertyconstant
identifying a replacement of an internal
instance for the bottom x dimension.IAxis
static java.lang.String
PROPERTY_AXIS_X_TOP_REPLACE
The bean propertyconstant
identifying a replacement of an internal
instance for the top x dimension.IAxis
static java.lang.String
PROPERTY_AXIS_Y
The bean propertyconstant
identifying a change of the internal
instance for the y dimension.IAxis
static java.lang.String
PROPERTY_AXIS_Y_LEFT_REPLACE
The bean propertyconstant
identifying a replacement of an internal
instance for the left y dimension.IAxis
static java.lang.String
PROPERTY_AXIS_Y_RIGHT_REPLACE
The bean propertyconstant
identifying a replacement of an internal
instance for the right y dimension.IAxis
static java.lang.String
PROPERTY_BACKGROUND_COLOR
The bean propertyconstant
identifying a change of the background color.static java.lang.String
PROPERTY_FONT
The bean propertyconstant
identifying a change of the font.static java.lang.String
PROPERTY_FOREGROUND_COLOR
The bean propertyconstant
identifying a change of the foreground color.static java.lang.String
PROPERTY_GRID_COLOR
The bean propertyconstant
identifying a change of the grid color.static java.lang.String
PROPERTY_PAINTLABELS
The bean propertyconstant
identifying a change of the paint labels flag.static java.lang.String
PROPERTY_POINT_HIGHLIGHTING_ENABLED
The bean propertyconstant
identifying a change of the point highlighting enabled state.static java.lang.String
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
static java.lang.String
PROPERTY_TOOLTIP_TYPE
The bean propertyconstant
identifying a change of the tool tip type ({Chart2D
).setToolTipType(IToolTipType)
static int
X
Constant describing the x axis (needed for scaling).static int
X_Y
Constant describing the x and y axis (needed for scaling).static int
Y
Constant describing the y axis (needed for scaling).-
Fields inherited from class javax.swing.JComponent
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
-
-
Constructor Summary
Constructors Constructor Description Chart2D()
Creates a new chart.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
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.void
addTrace(ITrace2D points)
Convenience method that adds the trace to this chart with relation to the first bottom x axis and the first left y axis.void
addTrace(ITrace2D points, IAxis<?> xAxis, IAxis<?> yAxis)
Adds the trace to this chart with relation to the given x axis and y axis.javax.swing.JToolTip
createToolTip()
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.java.util.List<IAxis<?>>
getAxes()
Returns the
with all axes of the chart.List
<IAxis
>java.util.List<IAxis<?>>
getAxesXBottom()
Returns the
with instances that are painted in x dimension on the bottom of the chart.List
<IAxis
>java.util.List<IAxis<?>>
getAxesXTop()
Returns the
with instances that are painted in x dimension on top of the chart.List
<IAxis
>java.util.List<IAxis<?>>
getAxesYLeft()
Returns the
with instances that are painted in y dimension on the left side of the chart.List
<IAxis
>java.util.List<IAxis<?>>
getAxesYRight()
Returns the
with instances that are painted in y dimension on the right side of the chart.List
<IAxis
>IAxisTickPainter
getAxisTickPainter()
Returns the painter for the ticks of the axis.IAxis<?>
getAxisX()
Returns the first bottom axis for the x dimension.IAxis<?>
getAxisX(ITrace2D trace)
Returns the x axis that the given trace belongs to or null if this trace does not belong to any x axis of this chart.IAxis<?>
getAxisY()
Returns the first left axis for the y dimension.IAxis<?>
getAxisY(ITrace2D trace)
Returns the y axis that the given trace belongs to or null if this trace does not belong to any y axis of this chart.java.awt.Color
getGridColor()
Returns the color of the grid.int
getHeight()
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.ITracePoint2D
getNearestPointEuclid(int mouseEventX, int mouseEventY)
Returns the nearest
to the given mouse event's screen coordinates in Euclid distance.ITracePoint2D
ITracePoint2D
getNearestPointEuclid(java.awt.event.MouseEvent me)
Returns the nearest
to the given mouse event's screen coordinates in Euclid distance.MouseEvent
ITracePoint2D
getNearestPointManhattan(int mouseEventX, int mouseEventY)
Returns the nearest
to the given mouse event's screen coordinates in Manhattan distance.ITracePoint2D
ITracePoint2D
getNearestPointManhattan(java.awt.event.MouseEvent me)
Returns the nearest
to the given mouse event's screen coordinates in Manhattan distance.MouseEvent
IPointFinder
getPointFinder()
Returns the point finder used to find the nearest point corresponding to a mouse event.java.awt.Dimension
getPreferredSize()
java.awt.Dimension
getSize()
Overridden to allow full - page printing.Chart2D
getSynchronizedXStartChart()
Returns the chart that will be synchronized for finding the start coordinate of this chart to draw in x dimension (getXChartStart()
java.lang.String
getToolTipText(java.awt.event.MouseEvent event)
IToolTipType
getToolTipType()
Returns the type of tool tip shown.ITracePointProvider
getTracePointProvider()
Returns the trace point creator of this chart.java.util.SortedSet<ITrace2D>
getTraces()
Returns the set of traces that are currently rendered by this instance.int
getWidth()
int
getXAxisWidth()
Returns the width of the X axis in px.int
getXChartEnd()
Returns the x coordinate of the chart's right edge in px.int
getXChartStart()
Returns the x coordinate of the chart's left edge in px.int
getYChartEnd()
Returns the y coordinate of the upper edge of the chart's display area in px.int
getYChartStart()
Returns the y coordinate of the chart's lower edge in px.boolean
isEnabledPointHighlighting()
Returns true if highlighting of the nearest point to the cursor is enabled.boolean
isPaintLabels()
Returns true if labels for each chart are painted below it, false else.protected boolean
isRequestedRepaint()
Returns the requestedRepaint.boolean
isToolTipCoords()
Returns true if chart coordinates are drawn as tool tips.boolean
isUseAntialiasing()
Returns whether antialiasing is used.boolean
isVisible(ITracePoint2D point)
Returns true if the given point is in the visible drawing area of the Chart2D.java.util.Iterator<ITrace2D>
iterator()
Returns anIterator
over the containedITrace2D
instances.void
paint(java.awt.Graphics g)
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
paintComponent(java.awt.Graphics g)
A basic rule of a JComponent is:
Never invoke this method directly.int
print(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
void
propertyChange(java.beans.PropertyChangeEvent evt)
Receives all
from all instances the chart registers itself as aPropertyChangeEvent
.PropertyChangeListener
java.util.Set<ITrace2D>
removeAllTraces()
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.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
repaint(java.awt.Rectangle r)
Deprecated.void
resetPrintMode()
Only intended for
.Chart2DActionPrintSingleton
void
setAxisTickPainter(IAxisTickPainter tickPainter)
Sets the axis tick painter.java.util.List<IAxis<?>>
setAxisX(AAxis<?> axisX)
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.java.util.List<IAxis<?>>
setAxisY(AAxis<?> axisY)
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.void
setGridColor(java.awt.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.void
setRequestedRepaint(boolean requestedRepaint)
Sets the requestedRepaint.void
setSynchronizedXStartChart(Chart2D synchronizedXStartChart)
Sets the chart that will be synchronized for finding the start coordinate of this chart to draw in x dimension (
).getXChartStart()
void
setToolTipCoords(boolean toolTipCoords)
Deprecated.usesetToolTipType(IToolTipType)
instead.Chart2D.ToolTipType.DATAVALUES
void
setToolTipType(IToolTipType toolTipType)
Sets the type of tool tip to use.void
setTracePointProvider(ITracePointProvider tracePointProvider)
Sets the trace point creator of this chart.void
setUseAntialiasing(boolean useAntialiasing)
Sets whether antialiasing is used.java.awt.image.BufferedImage
snapShot()
Returns a BufferedImage with the current width and height of the chart filled with the Chart2D's graphics that may be written to a file or OutputStream by using:ImageIO.write(java.awt.image.RenderedImage, java.lang.String, java.io.File)
.java.awt.image.BufferedImage
snapShot(int width, int height)
Returns a BufferedImage with the given width and height that is filled with tChart2D's graphics that may be written to a file or OutputStream by using:ImageIO.write(java.awt.image.RenderedImage, java.lang.String, java.io.File)
.java.lang.String
toString()
ITracePoint2D
translateMousePosition(java.awt.event.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
-
-
-
-
Field Detail
-
AXIX_CONSTANT_NAMES
public static final java.lang.String[] AXIX_CONSTANT_NAMES
Speaking names for axis constants - used for debugging only.
-
CHART_POSITION_BOTTOM
public static final int CHART_POSITION_BOTTOM
Constant describing the bottom side of the chart.- See Also:
IAxis.getAxisPosition()
, Constant Field Values
-
CHART_POSITION_LEFT
public static final int CHART_POSITION_LEFT
Constant describing the left side of the chart.- See Also:
IAxis.getAxisPosition()
, Constant Field Values
-
CHART_POSITION_RIGHT
public static final int CHART_POSITION_RIGHT
Constant describing the right side of the chart.- See Also:
IAxis.getAxisPosition()
, Constant Field Values
-
CHART_POSITION_TOP
public static final int CHART_POSITION_TOP
Constant describing the top side of the chart.- See Also:
IAxis.getAxisPosition()
, Constant Field Values
-
DEBUG_SCALING
public static final boolean DEBUG_SCALING
A package wide switch for debugging problems with scaling. Set to false the compiler will remove the debugging statements.- See Also:
- Constant Field Values
-
DEBUG_HIGHLIGHTING
public static final boolean DEBUG_HIGHLIGHTING
A package wide switch for debugging problems with highlighting. Set to false the compiler will remove the debugging statements.- See Also:
- Constant Field Values
-
DEBUG_THREADING
public static final boolean DEBUG_THREADING
A package wide switch for debugging problems with multithreading. Set to false the compiler will remove the debugging statements.- See Also:
- Constant Field Values
-
PROPERTY_ANTIALIASING_ENABLED
public static final java.lang.String 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:
- Constant Field Values
-
PROPERTY_AXIS_X
public static final java.lang.String 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:
- Constant Field Values
-
PROPERTY_AXIS_X_BOTTOM_REPLACE
public static final java.lang.String 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:
- Constant Field Values
-
PROPERTY_AXIS_X_TOP_REPLACE
public static final java.lang.String 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:
- Constant Field Values
-
PROPERTY_AXIS_Y
public static final java.lang.String 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:
- Constant Field Values
-
PROPERTY_AXIS_Y_LEFT_REPLACE
public static final java.lang.String 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:
- Constant Field Values
-
PROPERTY_AXIS_Y_RIGHT_REPLACE
public static final java.lang.String 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:
- Constant Field Values
-
PROPERTY_BACKGROUND_COLOR
public static final java.lang.String 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:
- Constant Field Values
-
PROPERTY_FONT
public static final java.lang.String 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:
- Constant Field Values
-
PROPERTY_FOREGROUND_COLOR
public static final java.lang.String 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:
- Constant Field Values
-
PROPERTY_GRID_COLOR
public static final java.lang.String PROPERTY_GRID_COLOR
The bean propertyconstant
identifying a change of the grid color.Use this constant to register a
PropertyChangeListener
with theChart2D
.- See Also:
- Constant Field Values
-
PROPERTY_ADD_REMOVE_TRACE
public static final java.lang.String PROPERTY_ADD_REMOVE_TRACE
The bean propertyconstant
identifying a change of traces.Use this constant to register a
PropertyChangeListener
with theChart2D
.- See Also:
- Constant Field Values
-
PROPERTY_PAINTLABELS
public static final java.lang.String PROPERTY_PAINTLABELS
The bean propertyconstant
identifying a change of the paint labels flag.Use this constant to register a
PropertyChangeListener
with theChart2D
.- See Also:
- Constant Field Values
-
PROPERTY_POINT_HIGHLIGHTING_ENABLED
public static final java.lang.String 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:
- Constant Field Values
-
PROPERTY_POINTFINDER
public static final java.lang.String 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:
- Constant Field Values
-
PROPERTY_TOOLTIP_TYPE
public static final java.lang.String 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:
- Constant Field Values
-
X
public static final int X
Constant describing the x axis (needed for scaling).- See Also:
- Constant Field Values
-
X_Y
public static final int X_Y
Constant describing the x and y axis (needed for scaling).- See Also:
- Constant Field Values
-
Y
public static final int Y
Constant describing the y axis (needed for scaling).- See Also:
- Constant Field Values
-
m_minPaintLatency
protected int m_minPaintLatency
Chart - wide setting for the ms to give a repaint operation time for collecting several repaint requests into one (performance versus update speed).
-
-
Method Detail
-
addAxisXBottom
public void addAxisXBottom(AAxis<?> axisX)
Adds the given x axis to the list of internal bottom x axes.The given axis must not be contained before (e.g. as right y axis or bottom x axis...).
- Parameters:
axisX
- the additional bottom x axis.
-
addAxisXTop
public void addAxisXTop(AAxis<?> axisX)
Adds the given x axis to the list of internal top x axes.The given axis must not be contained before (e.g. as right y axis or bottom x axis...).
- Parameters:
axisX
- the additional top x axis.
-
addAxisYLeft
public void addAxisYLeft(AAxis<?> axisY)
Adds the given y axis to the list of internal left y axes.The given axis must not be contained before (e.g. as right y axis or bottom x axis...).
- Parameters:
axisY
- the additional left y axis.
-
addAxisYRight
public void addAxisYRight(AAxis<?> axisY)
Adds the given y axis to the list of internal right y axes.The given axis must not be contained before (e.g. as right y axis or bottom x axis...).
- Parameters:
axisY
- the additional right y axis.
-
addTrace
public final void addTrace(ITrace2D points)
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:
IAxis.PROPERTY_ADD_REMOVE_TRACE
,addTrace(ITrace2D, IAxis, IAxis)
-
addTrace
public final void addTrace(ITrace2D points, IAxis<?> xAxis, IAxis<?> yAxis)
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:
IAxis.PROPERTY_ADD_REMOVE_TRACE
-
createToolTip
public javax.swing.JToolTip createToolTip()
- Overrides:
createToolTip
in classjavax.swing.JComponent
- See Also:
JComponent.createToolTip()
-
destroy
public void destroy()
Destroys the chart.This method is only of interest if you have an application that dynamically adds and removes charts. So if you use the same Chart2D object(s) during the applications lifetime there is no need to use this method.
-
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:
ITrace2D.addPointHighlighter(IPointPainter)
,isEnabledPointHighlighting()
-
finalize
protected void finalize() throws java.lang.Throwable
Cleanup when this instance is dropped.- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
- if a finalizer of a superclass fails.- See Also:
Object.finalize()
-
findAxesOfTrace
public IAxis<?>[] findAxesOfTrace(ITrace2D trace)
Returns an array with the x (position 0) and the y axis (position 1) of the given trace if it is correctly set up. If the given trace is not set up correctly with this chart a missing axis in one dimension will be reflected 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
public final java.util.List<IAxis<?>> getAxes()
Returns the
with all axes of the chart.List
<IAxis
>- Returns:
- the
with all axes of the chartList
<IAxis
>
-
getAxesXBottom
public final java.util.List<IAxis<?>> getAxesXBottom()
Returns the
with instances that are painted in x dimension on the bottom of the chart.List
<IAxis
>Caution! The original list is returned so modifications of it will cause unpredictable side effects.
- Returns:
- the
with instances that are painted in x dimension on the bottom of the chart.List
<IAxis
>
-
getAxesXTop
public final java.util.List<IAxis<?>> getAxesXTop()
Returns the
with instances that are painted in x dimension on top of the chart.List
<IAxis
>Caution! The original list is returned so modifications of it will cause unpredictable side effects.
- Returns:
- the
with instances that are painted in x dimension on top of the chart.List
<IAxis
>
-
getAxesYLeft
public final java.util.List<IAxis<?>> getAxesYLeft()
Returns the
with instances that are painted in y dimension on the left side of the chart.List
<IAxis
>Caution! The original list is returned so modifications of it will cause unpredictable side effects.
- Returns:
- the
with instances that are painted in y dimension on the left side of the chart.List
<IAxis
>
-
getAxesYRight
public final java.util.List<IAxis<?>> getAxesYRight()
Returns the
with instances that are painted in y dimension on the right side of the chart.List
<IAxis
>Caution! The original list is returned so modifications of it will cause unpredictable side effects.
- Returns:
- the
with instances that are painted in y dimension on the right side of the chart.List
<IAxis
>
-
getAxisTickPainter
public IAxisTickPainter getAxisTickPainter()
Returns the painter for the ticks of the axis.- Returns:
- Returns the painter for the ticks of the axis.
-
getAxisX
public final IAxis<?> getAxisX()
Returns the first bottom axis for the x dimension.- Returns:
- the first bottom axis for the x dimension.
-
getAxisX
public IAxis<?> getAxisX(ITrace2D trace)
Returns the x axis that the given trace belongs to or null if this trace does not belong to any x axis of this chart.- Parameters:
trace
- the trace to find the corresponding x axis of this chart for.- Returns:
- the x axis that the given trace belongs to or null if this trace does not belong to any x axis of this chart.
-
getAxisY
public final IAxis<?> getAxisY()
Returns the first left axis for the y dimension.- Returns:
- the first left axis for the y dimension.
-
getAxisY
public IAxis<?> getAxisY(ITrace2D trace)
Returns the y axis that the given trace belongs to or null if this trace does not belong to any y axis of this chart.- Parameters:
trace
- the trace to find the corresponding y axis of this chart for.- Returns:
- the y axis that the given trace belongs to or null if this trace does not belong to any y axis of this chart.
-
getGridColor
public final java.awt.Color getGridColor()
Returns the color of the grid.- Returns:
- the color of the grid.
-
getHeight
public int getHeight()
- Overrides:
getHeight
in classjavax.swing.JComponent
- See Also:
JComponent.getHeight()
-
getMinPaintLatency
public int getMinPaintLatency()
Returns the chart - wide setting for the ms to give a repaint operation time for collecting several repaint requests into one (performance vs. update speed).- Returns:
- the setting for the ms to give a repaint operation time for collecting several repaint requests into one (performance vs. update speed).
-
getNearestPointEuclid
public ITracePoint2D getNearestPointEuclid(int mouseEventX, int mouseEventY)
Returns the nearest
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
public ITracePoint2D getNearestPointEuclid(java.awt.event.MouseEvent me)
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
public ITracePoint2D getNearestPointManhattan(int mouseEventX, int mouseEventY)
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
public ITracePoint2D getNearestPointManhattan(java.awt.event.MouseEvent me)
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
public IPointFinder getPointFinder()
Returns the point finder used to find the nearest point corresponding to a mouse event.- Returns:
- the point finder used to find the nearest point corresponding to a mouse event.
-
getPreferredSize
public java.awt.Dimension getPreferredSize()
- Overrides:
getPreferredSize
in classjavax.swing.JComponent
- See Also:
JComponent.getPreferredSize()
-
getSize
public java.awt.Dimension getSize()
Overridden to allow full - page printing.- Overrides:
getSize
in classjava.awt.Component
- See Also:
Component.getSize()
-
getSynchronizedXStartChart
public final Chart2D getSynchronizedXStartChart()
Returns the chart that will be synchronized for finding the start coordinate of this chart to draw in x dimension (getXChartStart()
This feature is used to allow two separate charts to be painted stacked in y dimension (one below the other) that have different x start coordinates (because of different y labels that shift that value) with an equal starting x value (thus be comparable visually if their x values match).
- Returns:
- the chart that will be synchronized for finding the start
coordinate of this chart to draw in x dimension (
getXChartStart()
-
getToolTipText
public final java.lang.String getToolTipText(java.awt.event.MouseEvent event)
- Overrides:
getToolTipText
in classjavax.swing.JComponent
- See Also:
JComponent.getToolTipText(java.awt.event.MouseEvent)
-
getToolTipType
public IToolTipType getToolTipType()
Returns the type of tool tip shown.- Returns:
- the type of tool tip shown.
- See Also:
Chart2D.ToolTipType.DATAVALUES
,Chart2D.ToolTipType.NONE
,Chart2D.ToolTipType.PIXEL
,Chart2D.ToolTipType.VALUE_SNAP_TO_TRACEPOINTS
-
getTracePointProvider
public ITracePointProvider getTracePointProvider()
Returns the trace point creator of this chart.- Returns:
- the trace point creator of this chart.
-
getTraces
public final java.util.SortedSet<ITrace2D> getTraces()
Returns the set of traces that are currently rendered by this instance.The instances are collected from all underlying axes. The resulting
Set
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 classjavax.swing.JComponent
- See Also:
JComponent.getWidth()
-
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
public boolean isVisible(ITracePoint2D point)
Returns true if the given point is in the visible drawing area of the Chart2D.If the point is null false will be returned.
This only works if the point argument has been scaled already.
- Parameters:
point
- the point to test.- Returns:
- true if the given point is in the visible drawing area of the Chart2D.
-
iterator
public final java.util.Iterator<ITrace2D> iterator()
Returns anIterator
over the containedITrace2D
instances.
-
paint
public void paint(java.awt.Graphics g)
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 classjavax.swing.JComponent
- See Also:
JComponent.paint(java.awt.Graphics)
-
paintComponent
protected void paintComponent(java.awt.Graphics g)
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 classjavax.swing.JComponent
- Parameters:
g
- the graphics context to use.
-
print
public int print(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex) throws java.awt.print.PrinterException
- Specified by:
print
in interfacejava.awt.print.Printable
- Throws:
java.awt.print.PrinterException
- See Also:
Printable.print(java.awt.Graphics, java.awt.print.PageFormat, int)
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
Receives all
from all instances the chart registers itself as aPropertyChangeEvent
.PropertyChangeListener
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
- Parameters:
evt
- the property change event that was fired.- See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)
-
removeAllTraces
public java.util.Set<ITrace2D> 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
public boolean removeAxisXBottom(IAxis<?> axisX)
Removes the given x axis from the list of internal bottom x axes.The given axis should be contained before or false will be returned.
- Parameters:
axisX
- the bottom x axis to remove.- Returns:
- true if the given axis was successfully removed or false if it was not configured as a bottom x axis before or could not be removed for another reason.
-
removeAxisXTop
public boolean removeAxisXTop(IAxis<?> axisX)
Removes the given x axis from the list of internal top x axes.The given axis should be contained before or false will be returned.
- Parameters:
axisX
- the top x axis to remove.- Returns:
- true if the given axis was successfully removed or false if it was not configured as a top x axis before or could not be removed for another reason.
-
removeAxisYLeft
public boolean removeAxisYLeft(IAxis<?> axisY)
Removes the given y axis from the list of internal left y axes.The given axis should be contained before or false will be returned.
- Parameters:
axisY
- the left y axis to remove.- Returns:
- true if the given axis was successfully removed or false if it was not configured as a left y axis before or could not be removed for another reason.
-
removeAxisYRight
public boolean removeAxisYRight(IAxis<?> axisY)
Removes the given y axis from the list of internal right y axes.The given axis should be contained before or false will be returned.
- Parameters:
axisY
- the right y axis to remove.- Returns:
- true if the given axis was successfully removed or false if it was not configured as a right y axis before or could not be removed for another reason.
-
removeTrace
public final boolean removeTrace(ITrace2D points)
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:
IAxis.PROPERTY_ADD_REMOVE_TRACE
-
repaint
@Deprecated public void repaint()
Deprecated.- Overrides:
repaint
in classjava.awt.Component
- See Also:
Component.repaint()
-
repaint
@Deprecated public void repaint(int x, int y, int width, int height)
Deprecated.- Overrides:
repaint
in classjava.awt.Component
- See Also:
Component.repaint(int, int, int, int)
-
repaint
@Deprecated public void repaint(long tm)
Deprecated.- Overrides:
repaint
in classjava.awt.Component
- See Also:
Component.repaint(long)
-
repaint
@Deprecated public void repaint(long tm, int x, int y, int width, int height)
Deprecated.- Overrides:
repaint
in classjavax.swing.JComponent
- See Also:
JComponent.repaint(long, int, int, int, int)
-
repaint
@Deprecated public void repaint(java.awt.Rectangle r)
Deprecated.- Overrides:
repaint
in classjavax.swing.JComponent
- See Also:
JComponent.repaint(java.awt.Rectangle)
-
resetPrintMode
public void resetPrintMode()
Only intended for
.Chart2DActionPrintSingleton
-
setAxisTickPainter
public void setAxisTickPainter(IAxisTickPainter tickPainter)
Sets the axis tick painter.- Parameters:
tickPainter
- The axis tick painter to set.
-
setAxisX
@Deprecated public java.util.List<IAxis<?>> setAxisX(AAxis<?> axisX)
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(AAxis, int)
-
setAxisXBottom
public IAxis<?> setAxisXBottom(AAxis<?> axisX, int position)
Sets the bottom x axis on the given position to use and replaces the old one on that place.This method delegates to
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
public IAxis<?> setAxisXTop(AAxis<?> axisX, int position)
Sets the top x axis on the given position to use and replaces the old one on that place.This method delegates to
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 public java.util.List<IAxis<?>> setAxisY(AAxis<?> axisY)
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(AAxis, int)
-
setAxisYLeft
public IAxis<?> setAxisYLeft(AAxis<?> axisY, int position)
Sets the left y axis on the given position to use and replaces the old one on that place.This method delegates to
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
public IAxis<?> setAxisYRight(AAxis<?> axisY, int position)
Sets the right y axis on the given position to use and replaces the old one on that place.This method delegates to
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
public final void setGridColor(java.awt.Color gridclr)
Set the grid color to use.- Parameters:
gridclr
- the grid color to use.
-
setMinPaintLatency
public void setMinPaintLatency(int minPaintLatency)
Sets the ms to give a repaint operation time for collecting several repaint requests into one (performance vs. update speed).- Parameters:
minPaintLatency
- the setting for the ms to give a repaint operation time for collecting several repaint requests into one (performance vs. update speed).
-
setPaintLabels
public void setPaintLabels(boolean paintLabels)
Decide whether labels for each chart are painted below it. If set to true this will be done, else labels will be omitted.- Parameters:
paintLabels
- the value for paintLabels to set.
-
setPointFinder
public void setPointFinder(IPointFinder pointFinder)
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:
Chart2D.PointFinder.MANHATTAN
,Chart2D.PointFinder.EUCLID
-
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
public void setSynchronizedXStartChart(Chart2D synchronizedXStartChart)
Sets the chart that will be synchronized for finding the start coordinate of this chart to draw in x dimension (
).getXChartStart()
This feature is used to allow two separate charts to be painted stacked in y dimension (one below the other) that have different x start coordinates (because of different y labels that shift that value) with an equal starting x value (thus be comparable visually if their x values match).
- Parameters:
synchronizedXStartChart
- the chart that will be synchronized for finding the start coordinate of this chart to draw in x dimension (getXChartStart()
-
setToolTipCoords
@Deprecated public final void setToolTipCoords(boolean toolTipCoords)
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
public final void setToolTipType(IToolTipType toolTipType)
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:
Chart2D.ToolTipType.DATAVALUES
,Chart2D.ToolTipType.NONE
,Chart2D.ToolTipType.PIXEL
,Chart2D.ToolTipType.VALUE_SNAP_TO_TRACEPOINTS
-
setTracePointProvider
public void setTracePointProvider(ITracePointProvider tracePointProvider)
Sets the trace point creator of this chart.Null assignment attempts will raise an
.AssertionError
- Parameters:
tracePointProvider
- the trace point creator of this chart to set.
-
setUseAntialiasing
public final void setUseAntialiasing(boolean useAntialiasing)
Sets whether antialiasing is used.- Parameters:
useAntialiasing
- true if antialiasing should be used.
-
snapShot
public java.awt.image.BufferedImage snapShot()
Returns a BufferedImage with the current width and height of the chart filled with the Chart2D's graphics that may be written to a file or OutputStream by using:ImageIO.write(java.awt.image.RenderedImage, java.lang.String, java.io.File)
.If the width and height of this chart is zero (this happens when the chart has not been
JComponent.setVisible(boolean)
, the chart was not integrated into layout correctly or the chart's dimenision was set to this value, a default of width 600 and height 400 will temporarily be set (syncrhonized), the image will be rendered, the old dimension will be reset and the image will be returned.
If you want to paint offscreen images (without displayed chart) prefer 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
public java.awt.image.BufferedImage snapShot(int width, int height)
Returns a BufferedImage with the given width and height that is filled with tChart2D's graphics that may be written to a file or OutputStream by using:ImageIO.write(java.awt.image.RenderedImage, java.lang.String, java.io.File)
.- Parameters:
width
- the width of the image to create.height
- the height of the image to create.- Returns:
- a BufferedImage of the Chart2D's graphics that may be written to a file or OutputStream.
- Since:
- 1.03 - please download versions equal or greater than jchart2d-1.03.jar.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.awt.Component
- See Also:
Object.toString()
-
translateMousePosition
@Deprecated public ITracePoint2D translateMousePosition(java.awt.event.MouseEvent mouseEvent) throws java.lang.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:
java.lang.IllegalArgumentException
- if the given mouse event does not belong to this component.
-
-