Class ChartPanel
- All Implemented Interfaces:
ActionListener
,MouseListener
,MouseMotionListener
,ImageObserver
,MenuContainer
,Printable
,Serializable
,EventListener
,Accessible
,ChartPanelConstants
,ChartChangeListener
,ChartProgressListener
- Direct Known Subclasses:
PolarChartPanel
public class ChartPanel extends JPanel implements ChartPanelConstants, ChartChangeListener, ChartProgressListener, ActionListener, MouseListener, MouseMotionListener, Printable, Serializable
JFreeChart
object.
The panel registers with the chart to receive notification of changes to any component of the chart. The chart is redrawn automatically whenever this notification is received.
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
-
Field Summary
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface org.jfree.chart.ChartPanelConstants
AUTO_RANGE_BOTH_ACTION_COMMAND, AUTO_RANGE_HORIZONTAL_ACTION_COMMAND, AUTO_RANGE_VERTICAL_ACTION_COMMAND, DEFAULT_BUFFER_USED, DEFAULT_HEIGHT, DEFAULT_MAXIMUM_DRAW_HEIGHT, DEFAULT_MAXIMUM_DRAW_WIDTH, DEFAULT_MINIMUM_DRAW_HEIGHT, DEFAULT_MINIMUM_DRAW_WIDTH, DEFAULT_WIDTH, DEFAULT_ZOOM_TRIGGER_DISTANCE, PRINT_ACTION_COMMAND, PROPERTIES_ACTION_COMMAND, SAVE_ACTION_COMMAND, ZOOM_IN_BOTH_ACTION_COMMAND, ZOOM_IN_HORIZONTAL_ACTION_COMMAND, ZOOM_IN_VERTICAL_ACTION_COMMAND, ZOOM_OUT_BOTH_ACTION_COMMAND, ZOOM_OUT_HORIZONTAL_ACTION_COMMAND, ZOOM_OUT_VERTICAL_ACTION_COMMAND
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 Constructor Description ChartPanel(JFreeChart chart)
Constructs a JFreeChart panel.ChartPanel(JFreeChart chart, boolean useBuffer)
Constructs a panel containing a chart.ChartPanel(JFreeChart chart, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips)
Constructs a JFreeChart panel.ChartPanel(JFreeChart chart, int width, int height, int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth, int maximumDrawHeight, boolean useBuffer, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips)
Constructs a JFreeChart panel. -
Method Summary
Modifier and Type Method Description void
actionPerformed(ActionEvent event)
Handles action events generated by the popup menu.void
addChartMouseListener(ChartMouseListener listener)
Adds a listener to the list of objects listening for chart mouse events.void
autoRangeBoth()
Restores the auto-range calculation on both axes.void
autoRangeHorizontal()
Restores the auto-range calculation on the horizontal axis.void
autoRangeVertical()
Restores the auto-range calculation on the vertical axis.void
chartChanged(ChartChangeEvent event)
Receives notification of changes to the chart, and redraws the chart.void
chartProgress(ChartProgressEvent event)
Receives notification of a chart progress event.void
createChartPrintJob()
Creates a print job for the chart.void
doSaveAs()
Opens a file chooser and gives the user an opportunity to save the chart in PNG format.void
enableMouseClickProcessing()
JFreeChart
getChart()
Returns the chart contained in the panel.ChartRenderingInfo
getChartRenderingInfo()
Returns the chart rendering info from the most recent chart redraw.int
getDismissDelay()
Returns the dismissal tooltip delay value used inside this chart panel.ChartEntity
getEntityForPoint(int viewX, int viewY)
Returns the chart entity at a given point.int
getInitialDelay()
Returns the initial tooltip delay value used inside this chart panel.int
getMaximumDrawHeight()
Returns the maximum drawing height for charts.int
getMaximumDrawWidth()
Returns the maximum drawing width for charts.int
getMinimumDrawHeight()
Returns the minimum drawing height for charts.int
getMinimumDrawWidth()
Returns the minimum drawing width for charts.JPopupMenu
getPopupMenu()
Returns the popup menu.int
getReshowDelay()
Returns the reshow tooltip delay value used inside this chart panel.Rectangle2D
getScaledDataArea()
Returns the data area for the chart (the area inside the axes) with the current scaling applied.double
getScaleX()
Returns the X scale factor for the chart.double
getScaleY()
Returns the Y scale factory for the chart.String
getToolTipText(MouseEvent e)
Returns a string for the tooltip.double
getZoomInFactor()
Returns the zoom in factor.double
getZoomOutFactor()
Returns the zoom out factor.int
getZoomTriggerDistance()
Returns the zoom trigger distance.boolean
isEnforceFileExtensions()
Returnstrue
if file extensions should be enforced, andfalse
otherwise.void
mouseClicked(MouseEvent event)
Receives notification of mouse clicks on the panel.void
mouseDragged(MouseEvent e)
Handles a 'mouse dragged' event.void
mouseEntered(MouseEvent e)
Handles a 'mouse entered' event.void
mouseExited(MouseEvent e)
Handles a 'mouse exited' event.void
mouseMoved(MouseEvent e)
Implementation of the MouseMotionListener's methodvoid
mousePressed(MouseEvent e)
Handles a 'mouse pressed' event.void
mouseReleased(MouseEvent e)
Handles a 'mouse released' event.void
paintComponent(Graphics g)
Paints the component by drawing the chart to fill the entire component, but allowing for the insets (which will be non-zero if a border has been set for this component).int
print(Graphics g, PageFormat pf, int pageIndex)
Prints the chart on a single page.void
removeChartMouseListener(ChartMouseListener listener)
Removes a listener from the list of objects listening for chart mouse events.void
setChart(JFreeChart chart)
Sets the chart that is displayed in the panel.void
setDismissDelay(int delay)
Specifies the dismissal delay value for this chart panel.void
setDisplayToolTips(boolean flag)
Switches chart tooltip generation on or off.void
setEnforceFileExtensions(boolean enforce)
Sets a flag that controls whether or not file extensions are enforced.void
setFillZoomRectangle(boolean flag)
A flag that controls how the zoom rectangle is drawn.void
setHorizontalAxisTrace(boolean flag)
A flag that controls trace lines on the horizontal axis.void
setHorizontalZoom(boolean flag)
A flag that controls mouse-based zooming on the horizontal axis.void
setInitialDelay(int delay)
Specifies the initial delay value for this chart panel.void
setMaximumDrawHeight(int height)
Sets the maximum drawing height for the chart on this panel.void
setMaximumDrawWidth(int width)
Sets the maximum drawing width for the chart on this panel.void
setMinimumDrawHeight(int height)
Sets the minimum drawing height for the chart on this panel.void
setMinimumDrawWidth(int width)
Sets the minimum drawing width for the chart on this panel.void
setMouseZoomable(boolean flag)
A flag that controls mouse-based zooming.void
setMouseZoomable(boolean flag, boolean fillRectangle)
Controls mouse zooming and how the zoom rectangle is displayedvoid
setPopupMenu(JPopupMenu popup)
Sets the popup menu for the panel.void
setRefreshBuffer(boolean flag)
Sets the refresh buffer flag.void
setReshowDelay(int delay)
Specifies the amount of time before the user has to wait initialDelay milliseconds before a tooltip will be shown.void
setVerticalAxisTrace(boolean flag)
A flag that controls trace lines on the vertical axis.void
setVerticalZoom(boolean flag)
A flag that controls mouse-based zooming on the vertical axis.void
setZoomInFactor(double factor)
Sets the zoom in factor.void
setZoomOutFactor(double factor)
Sets the zoom out factor.void
setZoomTriggerDistance(int distance)
Sets the zoom trigger distance.Point
translateJava2DToScreen(Point2D java2DPoint)
Translates a Java2D point on the chart to a screen location.Point2D
translateScreenToJava2D(Point screenPoint)
Translates a screen location to a Java2D point.void
zoom(Rectangle2D selection)
Zooms in on a selected region.void
zoomInBoth(double x, double y)
Zooms in on an anchor point (measured in Java2D coordinates).void
zoomInHorizontal(double x)
Decreases the range on the horizontal axis, centered about a Java2D x coordinate.void
zoomInVertical(double y)
Decreases the range on the vertical axis, centered about a Java2D y coordinate.void
zoomOutBoth(double x, double y)
Zooms out on an anchor point (measured in Java2D coordinates).void
zoomOutHorizontal(double x)
Increases the range on the horizontal axis, centered about a Java2D x coordinate.void
zoomOutVertical(double y)
Increases the range on the vertical axis, centered about a Java2D y coordinate.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, getSize, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
ChartPanel
Constructs a JFreeChart panel.- Parameters:
chart
- the chart.
-
ChartPanel
Constructs a panel containing a chart.- Parameters:
chart
- the chart.useBuffer
- a flag controlling whether or not an off-screen buffer is used.
-
ChartPanel
public ChartPanel(JFreeChart chart, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips)Constructs a JFreeChart panel.- Parameters:
chart
- the chart.properties
- a flag indicating whether or not the chart property editor should be available via the popup menu.save
- a flag indicating whether or not save options should be available via the popup menu.print
- a flag indicating whether or not the print option should be available via the popup menu.zoom
- a flag indicating whether or not zoom options should be added to the popup menu.tooltips
- a flag indicating whether or not tooltips should be enabled for the chart.
-
ChartPanel
public ChartPanel(JFreeChart chart, int width, int height, int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth, int maximumDrawHeight, boolean useBuffer, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips)Constructs a JFreeChart panel.- Parameters:
chart
- the chart.width
- the preferred width of the panel.height
- the preferred height of the panel.minimumDrawWidth
- the minimum drawing width.minimumDrawHeight
- the minimum drawing height.maximumDrawWidth
- the maximum drawing width.maximumDrawHeight
- the maximum drawing height.useBuffer
- a flag that indicates whether to use the off-screen buffer to improve performance (at the expense of memory).properties
- a flag indicating whether or not the chart property editor should be available via the popup menu.save
- a flag indicating whether or not save options should be available via the popup menu.print
- a flag indicating whether or not the print option should be available via the popup menu.zoom
- a flag indicating whether or not zoom options should be added to the popup menu.tooltips
- a flag indicating whether or not tooltips should be enabled for the chart.
-
-
Method Details
-
enableMouseClickProcessing
public void enableMouseClickProcessing() -
getChart
Returns the chart contained in the panel.- Returns:
- the chart (possibly
null
).
-
setChart
Sets the chart that is displayed in the panel.- Parameters:
chart
- the chart (null
permitted).
-
getMinimumDrawWidth
public int getMinimumDrawWidth()Returns the minimum drawing width for charts.If the width available on the panel is less than this, then the chart is drawn at the minimum width then scaled down to fit.
- Returns:
- The minimum drawing width.
-
setMinimumDrawWidth
public void setMinimumDrawWidth(int width)Sets the minimum drawing width for the chart on this panel.At the time the chart is drawn on the panel, if the available width is less than this amount, the chart will be drawn using the minimum width then scaled down to fit the available space.
- Parameters:
width
- The width.
-
getMaximumDrawWidth
public int getMaximumDrawWidth()Returns the maximum drawing width for charts.If the width available on the panel is greater than this, then the chart is drawn at the maximum width then scaled up to fit.
- Returns:
- The maximum drawing width.
-
setMaximumDrawWidth
public void setMaximumDrawWidth(int width)Sets the maximum drawing width for the chart on this panel.At the time the chart is drawn on the panel, if the available width is greater than this amount, the chart will be drawn using the maximum width then scaled up to fit the available space.
- Parameters:
width
- The width.
-
setMinimumDrawHeight
public void setMinimumDrawHeight(int height)Sets the minimum drawing height for the chart on this panel.At the time the chart is drawn on the panel, if the available height is less than this amount, the chart will be drawn using the minimum height then scaled down to fit the available space.
- Parameters:
height
- The height.
-
getMinimumDrawHeight
public int getMinimumDrawHeight()Returns the minimum drawing height for charts.If the height available on the panel is less than this, then the chart is drawn at the minimum height then scaled down to fit.
- Returns:
- The minimum drawing height.
-
getMaximumDrawHeight
public int getMaximumDrawHeight()Returns the maximum drawing height for charts.If the height available on the panel is greater than this, then the chart is drawn at the maximum height then scaled up to fit.
- Returns:
- The maximum drawing height.
-
setMaximumDrawHeight
public void setMaximumDrawHeight(int height)Sets the maximum drawing height for the chart on this panel.At the time the chart is drawn on the panel, if the available height is greater than this amount, the chart will be drawn using the maximum height then scaled up to fit the available space.
- Parameters:
height
- The height.
-
getScaleX
public double getScaleX()Returns the X scale factor for the chart. This will be 1.0 if no scaling has been used.- Returns:
- The scale factor.
-
getScaleY
public double getScaleY()Returns the Y scale factory for the chart. This will be 1.0 if no scaling has been used.- Returns:
- The scale factor.
-
getPopupMenu
Returns the popup menu.- Returns:
- the popup menu.
-
setPopupMenu
Sets the popup menu for the panel.- Parameters:
popup
- the new popup menu.
-
getChartRenderingInfo
Returns the chart rendering info from the most recent chart redraw.- Returns:
- the chart rendering info.
-
setMouseZoomable
public void setMouseZoomable(boolean flag)A flag that controls mouse-based zooming.- Parameters:
flag
-true
enables zooming and rectangle fill on zoom.
-
setMouseZoomable
public void setMouseZoomable(boolean flag, boolean fillRectangle)Controls mouse zooming and how the zoom rectangle is displayed- Parameters:
flag
-true
if zooming enabledfillRectangle
-true
if zoom rectangle is filled, false if rectangle is shown as outline only.
-
setHorizontalZoom
public void setHorizontalZoom(boolean flag)A flag that controls mouse-based zooming on the horizontal axis.- Parameters:
flag
-true
enables zooming on HorizontalValuePlots.
-
setFillZoomRectangle
public void setFillZoomRectangle(boolean flag)A flag that controls how the zoom rectangle is drawn.- Parameters:
flag
-true
instructs to fill the rectangle on zoom, otherwise it will be outlined.
-
setVerticalZoom
public void setVerticalZoom(boolean flag)A flag that controls mouse-based zooming on the vertical axis.- Parameters:
flag
-true
enables zooming on VerticalValuePlots.
-
getZoomTriggerDistance
public int getZoomTriggerDistance()Returns the zoom trigger distance. This controls how far the mouse must move before a zoom action is triggered.- Returns:
- The distance (in Java2D units).
-
setZoomTriggerDistance
public void setZoomTriggerDistance(int distance)Sets the zoom trigger distance. This controls how far the mouse must move before a zoom action is triggered.- Parameters:
distance
- the distance (in Java2D units).
-
setHorizontalAxisTrace
public void setHorizontalAxisTrace(boolean flag)A flag that controls trace lines on the horizontal axis.- Parameters:
flag
-true
enables trace lines for the mouse pointer on the horizontal axis.
-
setVerticalAxisTrace
public void setVerticalAxisTrace(boolean flag)A flag that controls trace lines on the vertical axis.- Parameters:
flag
-true
enables trace lines for the mouse pointer on the vertical axis.
-
isEnforceFileExtensions
public boolean isEnforceFileExtensions()Returnstrue
if file extensions should be enforced, andfalse
otherwise.- Returns:
- The flag.
-
setEnforceFileExtensions
public void setEnforceFileExtensions(boolean enforce)Sets a flag that controls whether or not file extensions are enforced.- Parameters:
enforce
- the new flag value.
-
setDisplayToolTips
public void setDisplayToolTips(boolean flag)Switches chart tooltip generation on or off.- Parameters:
flag
- the flag.
-
getToolTipText
Returns a string for the tooltip.- Overrides:
getToolTipText
in classJComponent
- Parameters:
e
- the mouse event.- Returns:
- a tool tip or
null
if no tooltip is available.
-
translateJava2DToScreen
Translates a Java2D point on the chart to a screen location.- Parameters:
java2DPoint
- the Java2D point.- Returns:
- the screen location.
-
translateScreenToJava2D
Translates a screen location to a Java2D point.- Parameters:
screenPoint
- the screen location.- Returns:
- the Java2D coordinates.
-
getEntityForPoint
Returns the chart entity at a given point.This method will return null if there is (a) no entity at the given point, or (b) no entity collection has been generated.
- Parameters:
viewX
- the x-coordinate.viewY
- the y-coordinate.- Returns:
- the chart entity (possibly null).
-
setRefreshBuffer
public void setRefreshBuffer(boolean flag)Sets the refresh buffer flag.- Parameters:
flag
-true
indicate, that the buffer should be refreshed.
-
paintComponent
Paints the component by drawing the chart to fill the entire component, but allowing for the insets (which will be non-zero if a border has been set for this component). To increase performance (at the expense of memory), an off-screen buffer image can be used.- Parameters:
g
- the graphics device for drawing on.
-
chartChanged
Receives notification of changes to the chart, and redraws the chart.- Specified by:
chartChanged
in interfaceChartChangeListener
- Parameters:
event
- details of the chart change event.
-
chartProgress
Receives notification of a chart progress event.- Specified by:
chartProgress
in interfaceChartProgressListener
- Parameters:
event
- the event.
-
actionPerformed
Handles action events generated by the popup menu.- Specified by:
actionPerformed
in interfaceActionListener
- Parameters:
event
- the event.
-
mouseEntered
Handles a 'mouse entered' event. This method changes the tooltip delays of ToolTipManager.sharedInstance() to the possibly different values set for this chart panel.- Specified by:
mouseEntered
in interfaceMouseListener
- Parameters:
e
- the mouse event.
-
mouseExited
Handles a 'mouse exited' event. This method resets the tooltip delays of ToolTipManager.sharedInstance() to their original values in effect before mouseEntered()- Specified by:
mouseExited
in interfaceMouseListener
- Parameters:
e
- the mouse event.
-
mousePressed
Handles a 'mouse pressed' event.This event is the popup trigger on Unix/Linux. For Windows, the popup trigger is the 'mouse released' event.
- Specified by:
mousePressed
in interfaceMouseListener
- Parameters:
e
- The mouse event.
-
mouseReleased
Handles a 'mouse released' event.On Windows, we need to check if this is a popup trigger, but only if we haven't already been tracking a zoom rectangle.
- Specified by:
mouseReleased
in interfaceMouseListener
- Parameters:
e
- Information about the event.
-
mouseClicked
Receives notification of mouse clicks on the panel. These are translated and passed on to any registered chart mouse click listeners.- Specified by:
mouseClicked
in interfaceMouseListener
- Parameters:
event
- Information about the mouse event.
-
mouseMoved
Implementation of the MouseMotionListener's method- Specified by:
mouseMoved
in interfaceMouseMotionListener
- Parameters:
e
- the event.
-
mouseDragged
Handles a 'mouse dragged' event.- Specified by:
mouseDragged
in interfaceMouseMotionListener
- Parameters:
e
- the mouse event.
-
zoomInBoth
public void zoomInBoth(double x, double y)Zooms in on an anchor point (measured in Java2D coordinates).- Parameters:
x
- The x value.y
- The y value.
-
zoomInHorizontal
public void zoomInHorizontal(double x)Decreases the range on the horizontal axis, centered about a Java2D x coordinate.The range on the x axis is halved.
- Parameters:
x
- The x coordinate in Java2D space.
-
zoomInVertical
public void zoomInVertical(double y)Decreases the range on the vertical axis, centered about a Java2D y coordinate.The range on the y axis is halved.
- Parameters:
y
- The y coordinate in Java2D space.
-
zoomOutBoth
public void zoomOutBoth(double x, double y)Zooms out on an anchor point (measured in Java2D coordinates).- Parameters:
x
- The x value.y
- The y value.
-
zoomOutHorizontal
public void zoomOutHorizontal(double x)Increases the range on the horizontal axis, centered about a Java2D x coordinate.The range on the x axis is doubled.
- Parameters:
x
- The x coordinate in Java2D space.
-
zoomOutVertical
public void zoomOutVertical(double y)Increases the range on the vertical axis, centered about a Java2D y coordinate.The range on the y axis is doubled.
- Parameters:
y
- the y coordinate in Java2D space.
-
zoom
Zooms in on a selected region.- Parameters:
selection
- the selected region.
-
autoRangeBoth
public void autoRangeBoth()Restores the auto-range calculation on both axes. -
autoRangeHorizontal
public void autoRangeHorizontal()Restores the auto-range calculation on the horizontal axis. -
autoRangeVertical
public void autoRangeVertical()Restores the auto-range calculation on the vertical axis. -
getScaledDataArea
Returns the data area for the chart (the area inside the axes) with the current scaling applied.- Returns:
- The scaled data area.
-
getInitialDelay
public int getInitialDelay()Returns the initial tooltip delay value used inside this chart panel.- Returns:
- an integer representing the initial delay value, in milliseconds.
- See Also:
ToolTipManager.getInitialDelay()
-
getReshowDelay
public int getReshowDelay()Returns the reshow tooltip delay value used inside this chart panel.- Returns:
- an integer representing the reshow delay value, in milliseconds.
- See Also:
ToolTipManager.getReshowDelay()
-
getDismissDelay
public int getDismissDelay()Returns the dismissal tooltip delay value used inside this chart panel.- Returns:
- an integer representing the dismissal delay value, in milliseconds.
- See Also:
ToolTipManager.getDismissDelay()
-
setInitialDelay
public void setInitialDelay(int delay)Specifies the initial delay value for this chart panel.- Parameters:
delay
- the number of milliseconds to delay (after the cursor has paused) before displaying.- See Also:
ToolTipManager.setInitialDelay(int)
-
setReshowDelay
public void setReshowDelay(int delay)Specifies the amount of time before the user has to wait initialDelay milliseconds before a tooltip will be shown.- Parameters:
delay
- time in milliseconds- See Also:
ToolTipManager.setReshowDelay(int)
-
setDismissDelay
public void setDismissDelay(int delay)Specifies the dismissal delay value for this chart panel.- Parameters:
delay
- the number of milliseconds to delay before taking away the tooltip- See Also:
ToolTipManager.setDismissDelay(int)
-
getZoomInFactor
public double getZoomInFactor()Returns the zoom in factor.- Returns:
- The zoom in factor.
-
setZoomInFactor
public void setZoomInFactor(double factor)Sets the zoom in factor.- Parameters:
factor
- the factor.
-
getZoomOutFactor
public double getZoomOutFactor()Returns the zoom out factor.- Returns:
- The zoom out factor.
-
setZoomOutFactor
public void setZoomOutFactor(double factor)Sets the zoom out factor.- Parameters:
factor
- the factor.
-
doSaveAs
Opens a file chooser and gives the user an opportunity to save the chart in PNG format.- Throws:
IOException
- if there is an I/O error.
-
createChartPrintJob
public void createChartPrintJob()Creates a print job for the chart. -
print
Prints the chart on a single page. -
addChartMouseListener
Adds a listener to the list of objects listening for chart mouse events.- Parameters:
listener
- the listener.
-
removeChartMouseListener
Removes a listener from the list of objects listening for chart mouse events.- Parameters:
listener
- the listener.
-