Class ChartPanel
- All Implemented Interfaces:
ActionListener,MouseListener,MouseMotionListener,ImageObserver,MenuContainer,Printable,Serializable,EventListener,Accessible,ChartChangeListener,ChartProgressListener,OverlayChangeListener
- Direct Known Subclasses:
OfflineRenderingChartPanel,PolarChartPanel
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringCopy action command.static final booleanDefault setting for buffer usage.static final intThe default panel height.static final intThe default limit above which chart scaling kicks in.static final intThe default limit above which chart scaling kicks in.static final intThe default limit below which chart scaling kicks in.static final intThe default limit below which chart scaling kicks in.static final intThe default panel width.static final intThe minimum size required to perform a zoom on a rectangleprotected static ResourceBundleThe resourceBundle for the localization.static final StringPrint action command.static final StringProperties action command.static final StringSave action command.static final StringZoom in (both axes) action command.static final StringZoom in (domain axis only) action command.static final StringZoom in (range axis only) action command.static final StringZoom out (both axes) action command.static final StringZoom out (domain axis only) action command.static final StringZoom out (range axis only) action command.static final StringZoom reset (both axes) action command.static final StringZoom reset (domain axis only) action command.static final StringZoom reset (range axis only) action command.Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS -
Constructor Summary
ConstructorsConstructorDescriptionChartPanel(JFreeChart chart) Constructs a panel that displays the specified chart.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.ChartPanel(JFreeChart chart, int width, int height, int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth, int maximumDrawHeight, boolean useBuffer, boolean properties, boolean copy, boolean save, boolean print, boolean zoom, boolean tooltips) Constructs a JFreeChart panel. -
Method Summary
Modifier and TypeMethodDescriptionvoidactionPerformed(ActionEvent event) Handles action events generated by the popup menu.voidaddChartMouseListener(ChartMouseListener listener) Adds a listener to the list of objects listening for chart mouse events.voidaddOverlay(Overlay overlay) Add an overlay to the panel.voidchartChanged(ChartChangeEvent event) Receives notification of changes to the chart, and redraws the chart.voidchartProgress(ChartProgressEvent event) Receives notification of a chart progress event.voidCreates a print job for the chart.protected JPopupMenucreatePopupMenu(boolean properties, boolean save, boolean print, boolean zoom) Creates a popup menu for the panel.protected JPopupMenucreatePopupMenu(boolean properties, boolean copy, boolean save, boolean print, boolean zoom) Creates a popup menu for the panel.protected voiddisplayPopupMenu(int x, int y) The idea is to modify the zooming options depending on the type of chart being displayed by the panel.voiddoCopy()Copies the current chart to the system clipboard.voidDisplays a dialog that allows the user to edit the properties for the current chart.voiddoSaveAs()Opens a file chooser and gives the user an opportunity to save the chart in PNG format.Returns the anchor point.getChart()Returns the chart contained in the panel.Returns the chart rendering info from the most recent chart redraw.Returns the default directory for the "save as" option.intReturns the dismissal tooltip delay value used inside this chart panel.getEntityForPoint(int viewX, int viewY) Returns the chart entity at a given point.booleanReturns the flag that controls whether or not the zoom rectangle is filled when drawn.booleanReturns the flag that controls whether or not a horizontal axis trace line is drawn over the plot area at the current mouse location.protected Line2DReturns the horizontal trace line.intReturns the initial tooltip delay value used inside this chart panel.getListeners(Class listenerType) Returns an array of the listeners of the given type registered with the panel.intReturns the maximum drawing height for charts.intReturns the maximum drawing width for charts.intReturns the minimum drawing height for charts.intReturns the minimum drawing width for charts.Returns the popup menu.booleanReturns the flag that controls whether or not the offscreen buffer needs to be refreshed.intReturns the reshow tooltip delay value used inside this chart panel.doubleReturns the X scale factor for the chart.doubleReturns the Y scale factory for the chart.Returns the data area for the chart (the area inside the axes) with the current scaling applied (that is, the area as it appears on screen).getScreenDataArea(int x, int y) Returns the data area (the area inside the axes) for the plot or subplot, with the current scaling applied.Returns a string for the tooltip.booleanReturns the flag that controls whether or not a vertical axis trace line is drawn over the plot area at the current mouse location.protected Line2DReturns the vertical trace line.booleanReturns the flag that controls whether or not zoom operations are centered around the current anchor point.Returns the zoom rectangle fill paint.doubleReturns the zoom in factor.doubleReturns the zoom out factor.Returns the zoom rectangle outline paint.intReturns the zoom trigger distance.booleanReturns the flag that determines whether or not zooming is enabled for the domain axis.booleanReturnstrueif file extensions should be enforced, andfalseotherwise.booleanReturnstrueif the mouse wheel handler is enabled, andfalseotherwise.booleanReturns the flag that determines whether or not zooming is enabled for the range axis.voidmouseClicked(MouseEvent event) Receives notification of mouse clicks on the panel.voidHandles a 'mouse dragged' event.voidHandles a 'mouse entered' event.voidHandles a 'mouse exited' event.voidImplementation of the MouseMotionListener's method.voidHandles a 'mouse pressed' event.voidHandles a 'mouse released' event.voidoverlayChanged(OverlayChangeEvent event) Handles a change to an overlay by repainting the panel.protected BufferedImagepaintChartToBuffer(Graphics2D g2, Dimension bufferSize, Dimension chartSize, Point2D anchor, ChartRenderingInfo info) Paints the chart to fill the entire off-screen buffer image.voidPaints 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).intprint(Graphics g, PageFormat pf, int pageIndex) Prints the chart on a single page.voidremoveChartMouseListener(ChartMouseListener listener) Removes a listener from the list of objects listening for chart mouse events.voidremoveOverlay(Overlay overlay) Removes an overlay from the panel.voidRestores the auto-range calculation on both axes.voidRestores the auto-range calculation on the domain axis.voidRestores the auto-range calculation on the range axis.scale(Rectangle2D rect) Applies any scaling that is in effect for the chart drawing to the given rectangle.protected voidSets the anchor point.voidsetChart(JFreeChart chart) Sets the chart that is displayed in the panel.voidsetDefaultDirectoryForSaveAs(File directory) Sets the default directory for the "save as" option.voidsetDismissDelay(int delay) Specifies the dismissal delay value for this chart panel.voidsetDisplayToolTips(boolean flag) Switches the display of tooltips for the panel on or off.voidsetDomainZoomable(boolean flag) Sets the flag that controls whether or not zooming is enabled for the domain axis.voidsetEnforceFileExtensions(boolean enforce) Sets a flag that controls whether or not file extensions are enforced.voidsetFillZoomRectangle(boolean flag) A flag that controls how the zoom rectangle is drawn.voidsetHorizontalAxisTrace(boolean flag) A flag that controls trace lines on the horizontal axis.protected voidsetHorizontalTraceLine(Line2D line) Sets the horizontal trace line.voidsetInitialDelay(int delay) Specifies the initial delay value for this chart panel.voidsetMaximumDrawHeight(int height) Sets the maximum drawing height for the chart on this panel.voidsetMaximumDrawWidth(int width) Sets the maximum drawing width for the chart on this panel.voidsetMinimumDrawHeight(int height) Sets the minimum drawing height for the chart on this panel.voidsetMinimumDrawWidth(int width) Sets the minimum drawing width for the chart on this panel.voidsetMouseWheelEnabled(boolean flag) Enables or disables mouse wheel support for the panel.voidsetMouseZoomable(boolean flag) A convenience method that switches on mouse-based zooming.voidsetMouseZoomable(boolean flag, boolean fillRectangle) A convenience method that switches on mouse-based zooming.voidsetPopupMenu(JPopupMenu popup) Sets the popup menu for the panel.voidsetRangeZoomable(boolean flag) A flag that controls mouse-based zooming on the vertical axis.voidsetRefreshBuffer(boolean flag) Sets the refresh buffer flag.voidsetReshowDelay(int delay) Specifies the amount of time before the user has to wait initialDelay milliseconds before a tooltip will be shown.voidsetVerticalAxisTrace(boolean flag) A flag that controls trace lines on the vertical axis.protected voidsetVerticalTraceLine(Line2D line) Sets the vertical trace line.voidsetZoomAroundAnchor(boolean zoomAroundAnchor) Sets the flag that controls whether or not zoom operations are centered around the current anchor point.voidsetZoomFillPaint(Paint paint) Sets the zoom rectangle fill paint.voidsetZoomInFactor(double factor) Sets the zoom in factor.voidsetZoomOutFactor(double factor) Sets the zoom out factor.voidsetZoomOutlinePaint(Paint paint) Sets the zoom rectangle outline paint.voidsetZoomTriggerDistance(int distance) Sets the zoom trigger distance.translateJava2DToScreen(Point2D java2DPoint) Translates a Java2D point on the chart to a screen location.translateScreenToJava2D(Point screenPoint) Translates a panel (component) location to a Java2D point.voidupdateUI()Updates the UI for a LookAndFeel change.voidzoom(Rectangle2D selection) Zooms in on a selected region.voidzoomInBoth(double x, double y) Zooms in on an anchor point (specified in screen coordinate space).voidzoomInDomain(double x, double y) Decreases the length of the domain axis, centered about the given coordinate on the screen.voidzoomInRange(double x, double y) Decreases the length of the range axis, centered about the given coordinate on the screen.voidzoomOutBoth(double x, double y) Zooms out on an anchor point (specified in screen coordinate space).voidzoomOutDomain(double x, double y) Increases the length of the domain axis, centered about the given coordinate on the screen.voidzoomOutRange(double x, double y) Increases the length the range axis, centered about the given coordinate on the screen.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, 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, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, 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
-
Field Details
-
DEFAULT_BUFFER_USED
Default setting for buffer usage. The default has been changed totruefrom version 1.0.13 onwards, because of a severe performance problem with drawing the zoom rectangle using XOR (which now happens only when the buffer is NOT used).- See Also:
-
DEFAULT_WIDTH
The default panel width.- See Also:
-
DEFAULT_HEIGHT
The default panel height.- See Also:
-
DEFAULT_MINIMUM_DRAW_WIDTH
The default limit below which chart scaling kicks in.- See Also:
-
DEFAULT_MINIMUM_DRAW_HEIGHT
The default limit below which chart scaling kicks in.- See Also:
-
DEFAULT_MAXIMUM_DRAW_WIDTH
The default limit above which chart scaling kicks in.- See Also:
-
DEFAULT_MAXIMUM_DRAW_HEIGHT
The default limit above which chart scaling kicks in.- See Also:
-
DEFAULT_ZOOM_TRIGGER_DISTANCE
The minimum size required to perform a zoom on a rectangle- See Also:
-
PROPERTIES_COMMAND
Properties action command.- See Also:
-
COPY_COMMAND
Copy action command.- See Also:
-
SAVE_COMMAND
Save action command.- See Also:
-
PRINT_COMMAND
Print action command.- See Also:
-
ZOOM_IN_BOTH_COMMAND
Zoom in (both axes) action command.- See Also:
-
ZOOM_IN_DOMAIN_COMMAND
Zoom in (domain axis only) action command.- See Also:
-
ZOOM_IN_RANGE_COMMAND
Zoom in (range axis only) action command.- See Also:
-
ZOOM_OUT_BOTH_COMMAND
Zoom out (both axes) action command.- See Also:
-
ZOOM_OUT_DOMAIN_COMMAND
Zoom out (domain axis only) action command.- See Also:
-
ZOOM_OUT_RANGE_COMMAND
Zoom out (range axis only) action command.- See Also:
-
ZOOM_RESET_BOTH_COMMAND
Zoom reset (both axes) action command.- See Also:
-
ZOOM_RESET_DOMAIN_COMMAND
Zoom reset (domain axis only) action command.- See Also:
-
ZOOM_RESET_RANGE_COMMAND
Zoom reset (range axis only) action command.- See Also:
-
localizationResources
The resourceBundle for the localization.
-
-
Constructor Details
-
ChartPanel
Constructs a panel that displays the specified chart.- Parameters:
chart- the chart.
-
ChartPanel
Constructs a panel containing a chart. TheuseBufferflag controls whether or not an offscreenBufferedImageis maintained for the chart. If the buffer is used, more memory is consumed, but panel repaints will be a lot quicker in cases where the chart itself hasn't changed (for example, when another frame is moved to reveal the panel). WARNING: If you set theuseBufferflag to false, note that the mouse zooming rectangle will (in that case) be drawn using XOR, and there is a SEVERE performance problem with that on JRE6 on Windows.- Parameters:
chart- the chart.useBuffer- a flag controlling whether or not an off-screen buffer is used (read the warning above before setting this tofalse).
-
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.
-
ChartPanel
public ChartPanel(JFreeChart chart, int width, int height, int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth, int maximumDrawHeight, boolean useBuffer, boolean properties, boolean copy, 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.copy- a flag indicating whether or not a copy option 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
-
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 (nullpermitted).
-
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
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
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
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.
-
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.
-
setMinimumDrawHeight
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.
-
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
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
Returns the X scale factor for the chart. This will be 1.0 if no scaling has been used.- Returns:
- The scale factor.
-
getScaleY
Returns the Y scale factory for the chart. This will be 1.0 if no scaling has been used.- Returns:
- The scale factor.
-
getAnchor
Returns the anchor point.- Returns:
- The anchor point (possibly
null).
-
setAnchor
Sets the anchor point. This method is provided for the use of subclasses, not end users.- Parameters:
anchor- the anchor point (nullpermitted).
-
getPopupMenu
Returns the popup menu.- Returns:
- The popup menu.
-
setPopupMenu
Sets the popup menu for the panel.- Parameters:
popup- the popup menu (nullpermitted).
-
getChartRenderingInfo
Returns the chart rendering info from the most recent chart redraw.- Returns:
- The chart rendering info.
-
setMouseZoomable
A convenience method that switches on mouse-based zooming.- Parameters:
flag-trueenables zooming and rectangle fill on zoom.
-
setMouseZoomable
A convenience method that switches on mouse-based zooming.- Parameters:
flag-trueif zooming enabledfillRectangle-trueif zoom rectangle is filled, false if rectangle is shown as outline only.
-
isDomainZoomable
Returns the flag that determines whether or not zooming is enabled for the domain axis.- Returns:
- A boolean.
-
setDomainZoomable
Sets the flag that controls whether or not zooming is enabled for the domain axis. A check is made to ensure that the current plot supports zooming for the domain values.- Parameters:
flag-trueenables zooming if possible.
-
isRangeZoomable
Returns the flag that determines whether or not zooming is enabled for the range axis.- Returns:
- A boolean.
-
setRangeZoomable
A flag that controls mouse-based zooming on the vertical axis.- Parameters:
flag-trueenables zooming.
-
getFillZoomRectangle
Returns the flag that controls whether or not the zoom rectangle is filled when drawn.- Returns:
- A boolean.
-
setFillZoomRectangle
A flag that controls how the zoom rectangle is drawn.- Parameters:
flag-trueinstructs to fill the rectangle on zoom, otherwise it will be outlined.
-
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
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).
-
getHorizontalAxisTrace
Returns the flag that controls whether or not a horizontal axis trace line is drawn over the plot area at the current mouse location.- Returns:
- A boolean.
-
setHorizontalAxisTrace
A flag that controls trace lines on the horizontal axis.- Parameters:
flag-trueenables trace lines for the mouse pointer on the horizontal axis.
-
getHorizontalTraceLine
Returns the horizontal trace line.- Returns:
- The horizontal trace line (possibly
null).
-
setHorizontalTraceLine
Sets the horizontal trace line.- Parameters:
line- the line (nullpermitted).
-
getVerticalAxisTrace
Returns the flag that controls whether or not a vertical axis trace line is drawn over the plot area at the current mouse location.- Returns:
- A boolean.
-
setVerticalAxisTrace
A flag that controls trace lines on the vertical axis.- Parameters:
flag-trueenables trace lines for the mouse pointer on the vertical axis.
-
getVerticalTraceLine
Returns the vertical trace line.- Returns:
- The vertical trace line (possibly
null).
-
setVerticalTraceLine
Sets the vertical trace line.- Parameters:
line- the line (nullpermitted).
-
getDefaultDirectoryForSaveAs
Returns the default directory for the "save as" option.- Returns:
- The default directory (possibly
null).
-
setDefaultDirectoryForSaveAs
Sets the default directory for the "save as" option. If you set this tonull, the user's default directory will be used.- Parameters:
directory- the directory (nullpermitted).
-
isEnforceFileExtensions
Returnstrueif file extensions should be enforced, andfalseotherwise.- Returns:
- The flag.
- See Also:
-
setEnforceFileExtensions
Sets a flag that controls whether or not file extensions are enforced.- Parameters:
enforce- the new flag value.- See Also:
-
getZoomAroundAnchor
Returns the flag that controls whether or not zoom operations are centered around the current anchor point.- Returns:
- A boolean.
- See Also:
-
setZoomAroundAnchor
Sets the flag that controls whether or not zoom operations are centered around the current anchor point.- Parameters:
zoomAroundAnchor- the new flag value.- See Also:
-
getZoomFillPaint
Returns the zoom rectangle fill paint.- Returns:
- The zoom rectangle fill paint (never
null). - See Also:
-
setZoomFillPaint
Sets the zoom rectangle fill paint.- Parameters:
paint- the paint (nullnot permitted).- See Also:
-
getZoomOutlinePaint
Returns the zoom rectangle outline paint.- Returns:
- The zoom rectangle outline paint (never
null). - See Also:
-
setZoomOutlinePaint
Sets the zoom rectangle outline paint.- Parameters:
paint- the paint (nullnot permitted).- See Also:
-
isMouseWheelEnabled
Returnstrueif the mouse wheel handler is enabled, andfalseotherwise.- Returns:
- A boolean.
-
setMouseWheelEnabled
Enables or disables mouse wheel support for the panel.- Parameters:
flag- a boolean.
-
addOverlay
Add an overlay to the panel.- Parameters:
overlay- the overlay (nullnot permitted).
-
removeOverlay
Removes an overlay from the panel.- Parameters:
overlay- the overlay to remove (nullnot permitted).
-
overlayChanged
Handles a change to an overlay by repainting the panel.- Specified by:
overlayChangedin interfaceOverlayChangeListener- Parameters:
event- the event.
-
setDisplayToolTips
Switches the display of tooltips for the panel on or off. Note that tooltips can only be displayed if the chart has been configured to generate tooltip items.- Parameters:
flag-trueto enable tooltips,falseto disable tooltips.
-
getToolTipText
Returns a string for the tooltip.- Overrides:
getToolTipTextin classJComponent- Parameters:
e- the mouse event.- Returns:
- A tool tip or
nullif 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 panel (component) location to a Java2D point.- Parameters:
screenPoint- the screen location (nullnot permitted).- Returns:
- The Java2D coordinates.
-
scale
Applies any scaling that is in effect for the chart drawing to the given rectangle.- Parameters:
rect- the rectangle (nullnot permitted).- Returns:
- A new scaled rectangle.
-
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).
-
getRefreshBuffer
Returns the flag that controls whether or not the offscreen buffer needs to be refreshed.- Returns:
- A boolean.
-
setRefreshBuffer
Sets the refresh buffer flag. This flag is used to avoid unnecessary redrawing of the chart when the offscreen image buffer is used.- Parameters:
flag-trueindicates 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.- Overrides:
paintComponentin classJComponent- Parameters:
g- the graphics device for drawing on.
-
paintChartToBuffer
protected BufferedImage paintChartToBuffer(Graphics2D g2, Dimension bufferSize, Dimension chartSize, Point2D anchor, ChartRenderingInfo info) Paints the chart to fill the entire off-screen buffer image.- Parameters:
g2- the graphics context to create an off-screen buffer image.bufferSize- the required off-screen buffer image size.chartSize- the size with which the chart should be drawn (apply scaling if not equal tobufferSize).anchor- the anchor point (in Java2D space) for the chart (nullpermitted).info- records info about the drawing (nullmeans collect no info).- Returns:
- the off-screen buffer image to draw onto the panel.
-
chartChanged
Receives notification of changes to the chart, and redraws the chart.- Specified by:
chartChangedin interfaceChartChangeListener- Parameters:
event- details of the chart change event.
-
chartProgress
Receives notification of a chart progress event.- Specified by:
chartProgressin interfaceChartProgressListener- Parameters:
event- the event.
-
actionPerformed
Handles action events generated by the popup menu.- Specified by:
actionPerformedin 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:
mouseEnteredin 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:
mouseExitedin 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:
mousePressedin interfaceMouseListener- Parameters:
e- The mouse event.
-
mouseDragged
Handles a 'mouse dragged' event.- Specified by:
mouseDraggedin interfaceMouseMotionListener- 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:
mouseReleasedin interfaceMouseListener- Parameters:
e- information about the event.
-
mouseClicked
Receives notification of mouse clicks on the panel. These are translated and passed on to any registeredChartMouseListeners.- Specified by:
mouseClickedin interfaceMouseListener- Parameters:
event- Information about the mouse event.
-
mouseMoved
Implementation of the MouseMotionListener's method.- Specified by:
mouseMovedin interfaceMouseMotionListener- Parameters:
e- the event.
-
zoomInBoth
Zooms in on an anchor point (specified in screen coordinate space).- Parameters:
x- the x value (in screen coordinates).y- the y value (in screen coordinates).
-
zoomInDomain
Decreases the length of the domain axis, centered about the given coordinate on the screen. The length of the domain axis is reduced by the value ofgetZoomInFactor().- Parameters:
x- the x coordinate (in screen coordinates).y- the y-coordinate (in screen coordinates).
-
zoomInRange
Decreases the length of the range axis, centered about the given coordinate on the screen. The length of the range axis is reduced by the value ofgetZoomInFactor().- Parameters:
x- the x-coordinate (in screen coordinates).y- the y coordinate (in screen coordinates).
-
zoomOutBoth
Zooms out on an anchor point (specified in screen coordinate space).- Parameters:
x- the x value (in screen coordinates).y- the y value (in screen coordinates).
-
zoomOutDomain
Increases the length of the domain axis, centered about the given coordinate on the screen. The length of the domain axis is increased by the value ofgetZoomOutFactor().- Parameters:
x- the x coordinate (in screen coordinates).y- the y-coordinate (in screen coordinates).
-
zoomOutRange
Increases the length the range axis, centered about the given coordinate on the screen. The length of the range axis is increased by the value ofgetZoomOutFactor().- Parameters:
x- the x coordinate (in screen coordinates).y- the y-coordinate (in screen coordinates).
-
zoom
Zooms in on a selected region.- Parameters:
selection- the selected region.
-
restoreAutoBounds
Restores the auto-range calculation on both axes. -
restoreAutoDomainBounds
Restores the auto-range calculation on the domain axis. -
restoreAutoRangeBounds
Restores the auto-range calculation on the range axis. -
getScreenDataArea
Returns the data area for the chart (the area inside the axes) with the current scaling applied (that is, the area as it appears on screen).- Returns:
- The scaled data area.
-
getScreenDataArea
Returns the data area (the area inside the axes) for the plot or subplot, with the current scaling applied.- Parameters:
x- the x-coordinate (for subplot selection).y- the y-coordinate (for subplot selection).- Returns:
- The scaled data area.
-
getInitialDelay
Returns the initial tooltip delay value used inside this chart panel.- Returns:
- An integer representing the initial delay value, in milliseconds.
- See Also:
-
getReshowDelay
Returns the reshow tooltip delay value used inside this chart panel.- Returns:
- An integer representing the reshow delay value, in milliseconds.
- See Also:
-
getDismissDelay
Returns the dismissal tooltip delay value used inside this chart panel.- Returns:
- An integer representing the dismissal delay value, in milliseconds.
- See Also:
-
setInitialDelay
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:
-
setReshowDelay
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:
-
setDismissDelay
Specifies the dismissal delay value for this chart panel.- Parameters:
delay- the number of milliseconds to delay before taking away the tooltip- See Also:
-
getZoomInFactor
Returns the zoom in factor.- Returns:
- The zoom in factor.
- See Also:
-
setZoomInFactor
Sets the zoom in factor.- Parameters:
factor- the factor.- See Also:
-
getZoomOutFactor
Returns the zoom out factor.- Returns:
- The zoom out factor.
- See Also:
-
setZoomOutFactor
Sets the zoom out factor.- Parameters:
factor- the factor.- See Also:
-
doEditChartProperties
Displays a dialog that allows the user to edit the properties for the current chart. -
doCopy
Copies the current chart to the system clipboard. -
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
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 (nullnot permitted).
-
removeChartMouseListener
Removes a listener from the list of objects listening for chart mouse events.- Parameters:
listener- the listener.
-
getListeners
Returns an array of the listeners of the given type registered with the panel.- Overrides:
getListenersin classJComponent- Parameters:
listenerType- the listener type.- Returns:
- An array of listeners.
-
createPopupMenu
Creates a popup menu for the panel.- Parameters:
properties- include a menu item for the chart property editor.save- include a menu item for saving the chart.print- include a menu item for printing the chart.zoom- include menu items for zooming.- Returns:
- The popup menu.
-
createPopupMenu
protected JPopupMenu createPopupMenu(boolean properties, boolean copy, boolean save, boolean print, boolean zoom) Creates a popup menu for the panel.- Parameters:
properties- include a menu item for the chart property editor.copy- include a menu item for copying to the clipboard.save- include a menu item for saving the chart.print- include a menu item for printing the chart.zoom- include menu items for zooming.- Returns:
- The popup menu.
-
displayPopupMenu
The idea is to modify the zooming options depending on the type of chart being displayed by the panel.- Parameters:
x- horizontal position of the popup.y- vertical position of the popup.
-
updateUI
Updates the UI for a LookAndFeel change.
-