- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.jfree.chart.swing.ChartPanel
-
- All Implemented Interfaces:
ActionListener,MouseListener,MouseMotionListener,ImageObserver,MenuContainer,Printable,Serializable,EventListener,Accessible,ChartChangeListener,ChartProgressListener,OverlayChangeListener
- Direct Known Subclasses:
PolarChartPanel
public class ChartPanel extends JPanel implements ChartChangeListener, ChartProgressListener, ActionListener, MouseListener, MouseMotionListener, OverlayChangeListener, Printable, Serializable
A Swing GUI component for displaying aJFreeChartobject.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.JPanel
JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description protected Point2DanchorThe chart anchor point.protected JFreeChartchartThe chart that is displayed in the panel.protected ImagechartBufferA buffer for the rendered chart.protected intchartBufferHeightThe height of the chart buffer.protected intchartBufferWidthThe width of the chart buffer.protected EventListenerListchartMouseListenersStorage for registered (chart) mouse listeners.static StringCOPY_COMMANDCopy action command.static booleanDEFAULT_BUFFER_USEDDefault setting for buffer usage.static intDEFAULT_HEIGHTThe default panel height.static intDEFAULT_MAXIMUM_DRAW_HEIGHTThe default limit above which chart scaling kicks in.static intDEFAULT_MAXIMUM_DRAW_WIDTHThe default limit above which chart scaling kicks in.static intDEFAULT_MINIMUM_DRAW_HEIGHTThe default limit below which chart scaling kicks in.static intDEFAULT_MINIMUM_DRAW_WIDTHThe default limit below which chart scaling kicks in.static intDEFAULT_WIDTHThe default panel width.protected FiledefaultDirectoryForSaveAsThe default directory for saving charts to file.protected booleandomainZoomableA flag that controls whether or not domain zooming is enabled.protected booleanenforceFileExtensionsA flag that controls whether or not file extensions are enforced.protected ChartRenderingInfoinfoThe drawing info collected the last time the chart was drawn.protected static ResourceBundlelocalizationResourcesThe resourceBundle for the localization.protected intmaximumDrawHeightThe maximum height for drawing a chart (uses scaling for bigger heights).protected intmaximumDrawWidthThe maximum width for drawing a chart (uses scaling for bigger widths).protected intminimumDrawHeightThe minimum height for drawing a chart (uses scaling for smaller heights).protected intminimumDrawWidthThe minimum width for drawing a chart (uses scaling for smaller widths).protected MouseWheelHandlermouseWheelHandlerThe mouse wheel handler.protected PlotOrientationorientationThe plot orientation.protected intoriginalToolTipDismissDelayOriginal dismiss tooltip delay of ToolTipManager.sharedInstance().protected intoriginalToolTipInitialDelayOriginal initial tooltip delay of ToolTipManager.sharedInstance().protected intoriginalToolTipReshowDelayOriginal reshow tooltip delay of ToolTipManager.sharedInstance().protected List<Overlay>overlaysA list of overlays for the panel.protected booleanownToolTipDelaysActiveA flag that indicates if original tooltip delays are changed.protected intownToolTipDismissDelayOwn dismiss tooltip delay to be used in this chart panel.protected intownToolTipInitialDelayOwn initial tooltip delay to be used in this chart panel.protected intownToolTipReshowDelayOwn reshow tooltip delay to be used in this chart panel.protected Map<Integer,Integer>panButtonMasksThe masks for mouse events to trigger panning, per mouse button.protected doublepanHTemporary storage for the width and height of the chart drawing area during panning.protected PointpanLastThe last mouse position during panning.protected intpanMaskThe default mask for mouse events to trigger panning.protected doublepanWTemporary storage for the width and height of the chart drawing area during panning.protected JPopupMenupopupThe popup menu for the frame.static StringPRINT_COMMANDPrint action command.static StringPROPERTIES_COMMANDProperties action command.protected booleanrangeZoomableA flag that controls whether or not range zooming is enabled.protected booleanrefreshBufferA flag that indicates that the buffer should be refreshed.protected static StringSAVE_AS_PDF_COMMANDAction command to save as PDF.protected static StringSAVE_AS_PNG_COMMANDAction command to save as PNG.protected static StringSAVE_AS_PNG_SIZE_COMMANDAction command to save as PNG - use screen sizeprotected static StringSAVE_AS_SVG_COMMANDAction command to save as SVG.static StringSAVE_COMMANDSave action command.protected doublescaleXThe scale factor used to draw the chart.protected doublescaleYThe scale factor used to draw the chart.protected static longserialVersionUIDFor serialization.protected booleanuseBufferA flag that controls whether or not the off-screen buffer is used.static StringZOOM_IN_BOTH_COMMANDZoom in (both axes) action command.static StringZOOM_IN_DOMAIN_COMMANDZoom in (domain axis only) action command.static StringZOOM_IN_RANGE_COMMANDZoom in (range axis only) action command.static StringZOOM_OUT_BOTH_COMMANDZoom out (both axes) action command.static StringZOOM_OUT_DOMAIN_COMMANDZoom out (domain axis only) action command.static StringZOOM_OUT_RANGE_COMMANDZoom out (range axis only) action command.static StringZOOM_RESET_BOTH_COMMANDZoom reset (both axes) action command.static StringZOOM_RESET_DOMAIN_COMMANDZoom reset (domain axis only) action command.static StringZOOM_RESET_RANGE_COMMANDZoom reset (range axis only) action command.protected booleanzoomAroundAnchorA flag that controls whether zoom operations are centred on the current anchor point, or the centre point of the relevant axis.protected Map<Integer,Integer>zoomButtonMasksThe masks for mouse events to trigger zooming, per mouse button.protected JMenuItemzoomInBothMenuItemMenu item for zooming in on a chart (both axes).protected JMenuItemzoomInDomainMenuItemMenu item for zooming in on a chart (domain axis).protected doublezoomInFactorThe factor used to zoom in on an axis range.protected JMenuItemzoomInRangeMenuItemMenu item for zooming in on a chart (range axis).protected intzoomMaskThe default mask for mouse events to trigger zooming.protected JMenuItemzoomOutBothMenuItemMenu item for zooming out on a chart.protected JMenuItemzoomOutDomainMenuItemMenu item for zooming out on a chart (domain axis).protected doublezoomOutFactorThe factor used to zoom out on an axis range.protected JMenuItemzoomOutRangeMenuItemMenu item for zooming out on a chart (range axis).protected JMenuItemzoomResetBothMenuItemMenu item for resetting the zoom (both axes).protected JMenuItemzoomResetDomainMenuItemMenu item for resetting the zoom (domain axis only).protected JMenuItemzoomResetRangeMenuItemMenu item for resetting the zoom (range axis only).-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
-
-
Constructor Summary
Constructors Constructor Description ChartPanel(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(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.voidcreateChartPrintJob()Creates a print job for the chart.protected JPopupMenucreatePopupMenu(boolean properties, boolean copy, boolean save, boolean print, boolean zoom)Creates a popup menu for the panel.protected Graphics2DcreateSVGGraphics2D(int w, int h)Creates anSVGGraphics2Dinstance (from JFreeSVG) using reflection.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.voiddoEditChartProperties()Displays 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.voiddoSaveAs(int w, int h)Opens a file chooser and gives the user an opportunity to save the chart in PNG format.protected StringgenerateSVG(int width, int height)Generates a string containing a rendering of the chart in SVG format.Point2DgetAnchor()Returns the anchor point.JFreeChartgetChart()Returns the chart contained in the panel.ChartRenderingInfogetChartRenderingInfo()Returns the chart rendering info from the most recent chart redraw.FilegetDefaultDirectoryForSaveAs()Returns the default directory for the "save as" option.static intgetDefaultDragModifiersEx()The standard mouse button modifiers for alternative drag operations.intgetDismissDelay()Returns the dismissal tooltip delay value used inside this chart panel.ChartEntitygetEntityForPoint(int viewX, int viewY)Returns the chart entity at a given point.booleangetFillZoomRectangle()Returns the flag that controls whether or not the zoom rectangle is filled when drawn.intgetInitialDelay()Returns the initial tooltip delay value used inside this chart panel.<T extends EventListener>
T[]getListeners(Class<T> listenerType)Returns an array of the listeners of the given type registered with the panel.intgetMaximumDrawHeight()Returns the maximum drawing height for charts.intgetMaximumDrawWidth()Returns the maximum drawing width for charts.intgetMinimumDrawHeight()Returns the minimum drawing height for charts.intgetMinimumDrawWidth()Returns the minimum drawing width for charts.protected Point2DgetPointInRectangle(int x, int y, Rectangle2D area)Returns a point based on (x, y) but constrained to be within the bounds of the given rectangle.JPopupMenugetPopupMenu()Returns the popup menu.booleangetRefreshBuffer()Returns the flag that controls whether or not the offscreen buffer needs to be refreshed.intgetReshowDelay()Returns the reshow tooltip delay value used inside this chart panel.doublegetScaleX()Returns the X scale factor for the chart.doublegetScaleY()Returns the Y scale factory for the chart.Rectangle2DgetScreenDataArea()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).Rectangle2DgetScreenDataArea(int x, int y)Returns the data area (the area inside the axes) for the plot or subplot, with the current scaling applied.SelectionZoomStrategygetSelectionZoomStrategy()Returns a strategy used to control and draw zoom rectangle.StringgetToolTipText(MouseEvent e)Returns a string for the tooltip.booleangetZoomAroundAnchor()Returns the flag that controls whether or not zoom operations are centered around the current anchor point.PaintgetZoomFillPaint()Returns the zoom rectangle fill paint.doublegetZoomInFactor()Returns the zoom in factor.doublegetZoomOutFactor()Returns the zoom out factor.PaintgetZoomOutlinePaint()Returns the zoom rectangle outline paint.intgetZoomTriggerDistance()Returns the zoom trigger distance.booleanisDomainZoomable()Returns the flag that determines whether or not zooming is enabled for the domain axis.booleanisEnforceFileExtensions()Returnstrueif file extensions should be enforced, andfalseotherwise.booleanisMouseWheelEnabled()Returnstrueif the mouse wheel handler is enabled, andfalseotherwise.booleanisRangeZoomable()Returns 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.voidmouseDragged(MouseEvent e)Handles a 'mouse dragged' event.voidmouseEntered(MouseEvent e)Handles a 'mouse entered' event.voidmouseExited(MouseEvent e)Handles a 'mouse exited' event.voidmouseMoved(MouseEvent e)Implementation of the MouseMotionListener's method.voidmousePressed(MouseEvent e)Handles a 'mouse pressed' event.voidmouseReleased(MouseEvent e)Handles a 'mouse released' event.voidoverlayChanged(OverlayChangeEvent event)Handles a change to an overlay by repainting the panel.voidpaintComponent(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).intprint(Graphics g, PageFormat pf, int pageIndex)Prints the chart on a single page.protected voidreadObject(ObjectInputStream stream)Provides serialization support.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.voidrestoreAutoBounds()Restores the auto-range calculation on both axes.voidrestoreAutoDomainBounds()Restores the auto-range calculation on the domain axis.voidrestoreAutoRangeBounds()Restores the auto-range calculation on the range axis.protected voidsaveAsPDF(File f)Saves the chart in PDF format (a filechooser will be displayed so that the user can specify the filename).protected voidsaveAsSVG(File f)Saves the chart in SVG format (a filechooser will be displayed so that the user can specify the filename).Rectangle2Dscale(Rectangle2D rect)Applies any scaling that is in effect for the chart drawing to the given rectangle.protected voidsetAnchor(Point2D anchor)Sets 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.voidsetDefaultPanModifiersEx(int modifiersEx)Sets default modifier keys for pan operations for all mouse buttons.voidsetDefaultZoomModifiersEx(int modifiersEx)Sets default modifier keys for zoom operations for all mouse buttons.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.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.voidsetPanModifiersEx(int mouseButton, int modifiersEx)Sets modifier keys for panning with a specific mouse button.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.voidsetSelectionZoomStrategy(SelectionZoomStrategy selectionZoomStrategy)A strategy used to control and draw zoom rectangle.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.voidsetZoomModifiersEx(int mouseButton, int modifiersEx)Sets modifier keys for zooming with a specific mouse button.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.PointtranslateJava2DToScreen(Point2D java2DPoint)Translates a Java2D point on the chart to a screen location.Point2DtranslateScreenToJava2D(Point screenPoint)Translates a panel (component) location to a Java2D point.voidupdateUI()Updates the UI for a LookAndFeel change.protected voidwriteObject(ObjectOutputStream stream)Provides serialization support.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, setUI
-
Methods 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, 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, 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 Detail
-
serialVersionUID
protected static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
DEFAULT_BUFFER_USED
public static final boolean 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:
- Constant Field Values
-
DEFAULT_WIDTH
public static final int DEFAULT_WIDTH
The default panel width.- See Also:
- Constant Field Values
-
DEFAULT_HEIGHT
public static final int DEFAULT_HEIGHT
The default panel height.- See Also:
- Constant Field Values
-
DEFAULT_MINIMUM_DRAW_WIDTH
public static final int DEFAULT_MINIMUM_DRAW_WIDTH
The default limit below which chart scaling kicks in.- See Also:
- Constant Field Values
-
DEFAULT_MINIMUM_DRAW_HEIGHT
public static final int DEFAULT_MINIMUM_DRAW_HEIGHT
The default limit below which chart scaling kicks in.- See Also:
- Constant Field Values
-
DEFAULT_MAXIMUM_DRAW_WIDTH
public static final int DEFAULT_MAXIMUM_DRAW_WIDTH
The default limit above which chart scaling kicks in.- See Also:
- Constant Field Values
-
DEFAULT_MAXIMUM_DRAW_HEIGHT
public static final int DEFAULT_MAXIMUM_DRAW_HEIGHT
The default limit above which chart scaling kicks in.- See Also:
- Constant Field Values
-
PROPERTIES_COMMAND
public static final String PROPERTIES_COMMAND
Properties action command.- See Also:
- Constant Field Values
-
COPY_COMMAND
public static final String COPY_COMMAND
Copy action command.- See Also:
- Constant Field Values
-
SAVE_COMMAND
public static final String SAVE_COMMAND
Save action command.- See Also:
- Constant Field Values
-
SAVE_AS_PNG_COMMAND
protected static final String SAVE_AS_PNG_COMMAND
Action command to save as PNG.- See Also:
- Constant Field Values
-
SAVE_AS_PNG_SIZE_COMMAND
protected static final String SAVE_AS_PNG_SIZE_COMMAND
Action command to save as PNG - use screen size- See Also:
- Constant Field Values
-
SAVE_AS_SVG_COMMAND
protected static final String SAVE_AS_SVG_COMMAND
Action command to save as SVG.- See Also:
- Constant Field Values
-
SAVE_AS_PDF_COMMAND
protected static final String SAVE_AS_PDF_COMMAND
Action command to save as PDF.- See Also:
- Constant Field Values
-
PRINT_COMMAND
public static final String PRINT_COMMAND
Print action command.- See Also:
- Constant Field Values
-
ZOOM_IN_BOTH_COMMAND
public static final String ZOOM_IN_BOTH_COMMAND
Zoom in (both axes) action command.- See Also:
- Constant Field Values
-
ZOOM_IN_DOMAIN_COMMAND
public static final String ZOOM_IN_DOMAIN_COMMAND
Zoom in (domain axis only) action command.- See Also:
- Constant Field Values
-
ZOOM_IN_RANGE_COMMAND
public static final String ZOOM_IN_RANGE_COMMAND
Zoom in (range axis only) action command.- See Also:
- Constant Field Values
-
ZOOM_OUT_BOTH_COMMAND
public static final String ZOOM_OUT_BOTH_COMMAND
Zoom out (both axes) action command.- See Also:
- Constant Field Values
-
ZOOM_OUT_DOMAIN_COMMAND
public static final String ZOOM_OUT_DOMAIN_COMMAND
Zoom out (domain axis only) action command.- See Also:
- Constant Field Values
-
ZOOM_OUT_RANGE_COMMAND
public static final String ZOOM_OUT_RANGE_COMMAND
Zoom out (range axis only) action command.- See Also:
- Constant Field Values
-
ZOOM_RESET_BOTH_COMMAND
public static final String ZOOM_RESET_BOTH_COMMAND
Zoom reset (both axes) action command.- See Also:
- Constant Field Values
-
ZOOM_RESET_DOMAIN_COMMAND
public static final String ZOOM_RESET_DOMAIN_COMMAND
Zoom reset (domain axis only) action command.- See Also:
- Constant Field Values
-
ZOOM_RESET_RANGE_COMMAND
public static final String ZOOM_RESET_RANGE_COMMAND
Zoom reset (range axis only) action command.- See Also:
- Constant Field Values
-
chart
protected JFreeChart chart
The chart that is displayed in the panel.
-
chartMouseListeners
protected transient EventListenerList chartMouseListeners
Storage for registered (chart) mouse listeners.
-
useBuffer
protected boolean useBuffer
A flag that controls whether or not the off-screen buffer is used.
-
refreshBuffer
protected boolean refreshBuffer
A flag that indicates that the buffer should be refreshed.
-
chartBuffer
protected transient Image chartBuffer
A buffer for the rendered chart.
-
chartBufferHeight
protected int chartBufferHeight
The height of the chart buffer.
-
chartBufferWidth
protected int chartBufferWidth
The width of the chart buffer.
-
minimumDrawWidth
protected int minimumDrawWidth
The minimum width for drawing a chart (uses scaling for smaller widths).
-
minimumDrawHeight
protected int minimumDrawHeight
The minimum height for drawing a chart (uses scaling for smaller heights).
-
maximumDrawWidth
protected int maximumDrawWidth
The maximum width for drawing a chart (uses scaling for bigger widths).
-
maximumDrawHeight
protected int maximumDrawHeight
The maximum height for drawing a chart (uses scaling for bigger heights).
-
popup
protected JPopupMenu popup
The popup menu for the frame.
-
info
protected ChartRenderingInfo info
The drawing info collected the last time the chart was drawn.
-
scaleX
protected double scaleX
The scale factor used to draw the chart.
-
scaleY
protected double scaleY
The scale factor used to draw the chart.
-
orientation
protected PlotOrientation orientation
The plot orientation.
-
domainZoomable
protected boolean domainZoomable
A flag that controls whether or not domain zooming is enabled.
-
rangeZoomable
protected boolean rangeZoomable
A flag that controls whether or not range zooming is enabled.
-
zoomInBothMenuItem
protected JMenuItem zoomInBothMenuItem
Menu item for zooming in on a chart (both axes).
-
zoomInDomainMenuItem
protected JMenuItem zoomInDomainMenuItem
Menu item for zooming in on a chart (domain axis).
-
zoomInRangeMenuItem
protected JMenuItem zoomInRangeMenuItem
Menu item for zooming in on a chart (range axis).
-
zoomOutBothMenuItem
protected JMenuItem zoomOutBothMenuItem
Menu item for zooming out on a chart.
-
zoomOutDomainMenuItem
protected JMenuItem zoomOutDomainMenuItem
Menu item for zooming out on a chart (domain axis).
-
zoomOutRangeMenuItem
protected JMenuItem zoomOutRangeMenuItem
Menu item for zooming out on a chart (range axis).
-
zoomResetBothMenuItem
protected JMenuItem zoomResetBothMenuItem
Menu item for resetting the zoom (both axes).
-
zoomResetDomainMenuItem
protected JMenuItem zoomResetDomainMenuItem
Menu item for resetting the zoom (domain axis only).
-
zoomResetRangeMenuItem
protected JMenuItem zoomResetRangeMenuItem
Menu item for resetting the zoom (range axis only).
-
defaultDirectoryForSaveAs
protected File defaultDirectoryForSaveAs
The default directory for saving charts to file.
-
enforceFileExtensions
protected boolean enforceFileExtensions
A flag that controls whether or not file extensions are enforced.
-
ownToolTipDelaysActive
protected boolean ownToolTipDelaysActive
A flag that indicates if original tooltip delays are changed.
-
originalToolTipInitialDelay
protected int originalToolTipInitialDelay
Original initial tooltip delay of ToolTipManager.sharedInstance().
-
originalToolTipReshowDelay
protected int originalToolTipReshowDelay
Original reshow tooltip delay of ToolTipManager.sharedInstance().
-
originalToolTipDismissDelay
protected int originalToolTipDismissDelay
Original dismiss tooltip delay of ToolTipManager.sharedInstance().
-
ownToolTipInitialDelay
protected int ownToolTipInitialDelay
Own initial tooltip delay to be used in this chart panel.
-
ownToolTipReshowDelay
protected int ownToolTipReshowDelay
Own reshow tooltip delay to be used in this chart panel.
-
ownToolTipDismissDelay
protected int ownToolTipDismissDelay
Own dismiss tooltip delay to be used in this chart panel.
-
zoomInFactor
protected double zoomInFactor
The factor used to zoom in on an axis range.
-
zoomOutFactor
protected double zoomOutFactor
The factor used to zoom out on an axis range.
-
zoomAroundAnchor
protected boolean zoomAroundAnchor
A flag that controls whether zoom operations are centred on the current anchor point, or the centre point of the relevant axis.
-
localizationResources
protected static ResourceBundle localizationResources
The resourceBundle for the localization.
-
panW
protected double panW
Temporary storage for the width and height of the chart drawing area during panning.
-
panH
protected double panH
Temporary storage for the width and height of the chart drawing area during panning.
-
panMask
protected int panMask
The default mask for mouse events to trigger panning. Since 2.0.0, this mask uses extended modifiers, as returned byInputEvent.getModifiersEx(). Only used if no button-specific modifiers were set inpanButtonMasks.
-
zoomMask
protected int zoomMask
The default mask for mouse events to trigger zooming.- Since:
- 2.0.0
-
panButtonMasks
protected final Map<Integer,Integer> panButtonMasks
The masks for mouse events to trigger panning, per mouse button.- Since:
- 2.0.0
-
zoomButtonMasks
protected final Map<Integer,Integer> zoomButtonMasks
The masks for mouse events to trigger zooming, per mouse button.- Since:
- 2.0.0
-
mouseWheelHandler
protected MouseWheelHandler mouseWheelHandler
The mouse wheel handler.
-
-
Constructor Detail
-
ChartPanel
public ChartPanel(JFreeChart chart)
Constructs a panel that displays the specified chart.- Parameters:
chart- the chart.
-
ChartPanel
public ChartPanel(JFreeChart chart, boolean useBuffer)
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 Detail
-
getDefaultDragModifiersEx
public static int getDefaultDragModifiersEx()
The standard mouse button modifiers for alternative drag operations. There are two kinds of mouse drag operations: pan and zoom. To distinguish between them, one needs to require modifier keys to be held down during the dragging. However, some modifiers may not be usable on all platforms. For example, on Mac OS X it is impossible to perform Ctrl-drags or right-drags, see http://developer.apple.com/qa/qa2004/qa1362.html. This function returns a non-zero modifier usable for any platform: Alt for Mac OS X, Ctrl for other platforms. It is recommended to use these modifiers for one operation, and zero modifiers for the other.- Returns:
- modifiers mask, as in
InputEvent.getModifiersEx() - See Also:
setPanModifiersEx(int, int),setZoomModifiersEx(int, int),setDefaultPanModifiersEx(int),setDefaultZoomModifiersEx(int)
-
getChart
public JFreeChart getChart()
Returns the chart contained in the panel.- Returns:
- The chart (possibly
null).
-
setChart
public void setChart(JFreeChart chart)
Sets the chart that is displayed in the panel.- Parameters:
chart- the chart (nullpermitted).
-
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.
-
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.
-
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.
-
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.
-
getAnchor
public Point2D getAnchor()
Returns the anchor point.- Returns:
- The anchor point (possibly
null).
-
setAnchor
protected void setAnchor(Point2D anchor)
Sets the anchor point. This method is provided for the use of subclasses, not end users.- Parameters:
anchor- the anchor point (nullpermitted).
-
getPopupMenu
public JPopupMenu getPopupMenu()
Returns the popup menu.- Returns:
- The popup menu.
-
setPopupMenu
public void setPopupMenu(JPopupMenu popup)
Sets the popup menu for the panel.- Parameters:
popup- the popup menu (nullpermitted).
-
getChartRenderingInfo
public ChartRenderingInfo getChartRenderingInfo()
Returns the chart rendering info from the most recent chart redraw.- Returns:
- The chart rendering info.
-
setMouseZoomable
public void setMouseZoomable(boolean flag)
A convenience method that switches on mouse-based zooming.- Parameters:
flag-trueenables zooming and rectangle fill on zoom.
-
setMouseZoomable
public void setMouseZoomable(boolean flag, boolean fillRectangle)
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.
-
setDefaultPanModifiersEx
public void setDefaultPanModifiersEx(int modifiersEx)
Sets default modifier keys for pan operations for all mouse buttons. Modifiers for a specific button can be set withsetPanModifiersEx(int, int). If there are none set for a certain button, it will use the modifiers passed to this function, defaulting togetDefaultDragModifiersEx()if this function was never called.Only
InputEvent.SHIFT_DOWN_MASK,InputEvent.CTRL_DOWN_MASK,InputEvent.META_DOWN_MASKandInputEvent.ALT_DOWN_MASKare checked. To avoid platform-specific problems, it is recommended to usegetDefaultDragModifiersEx()for one operation, and zero modifiers for the other.If the same modifiers are set for both zooming and panning, panning will be performed.
- Parameters:
modifiersEx- modifier keys, as returned byInputEvent.getModifiersEx()
-
setDefaultZoomModifiersEx
public void setDefaultZoomModifiersEx(int modifiersEx)
Sets default modifier keys for zoom operations for all mouse buttons. Modifiers for a specific button can be set withsetZoomModifiersEx(int, int). If there are none set for a certain button, it will use the modifiers passed to this function, defaulting to zero (no modifiers) if this function was never called.Only
InputEvent.SHIFT_DOWN_MASK,InputEvent.CTRL_DOWN_MASK,InputEvent.META_DOWN_MASKandInputEvent.ALT_DOWN_MASKare checked. To avoid platform-specific problems, it is recommended to usegetDefaultDragModifiersEx()for one operation, and zero modifiers for the other.If the same modifiers are set for both zooming and panning, panning will be performed.
- Parameters:
modifiersEx- modifier keys, as returned byInputEvent.getModifiersEx()
-
setPanModifiersEx
public void setPanModifiersEx(int mouseButton, int modifiersEx)
Sets modifier keys for panning with a specific mouse button. If there are none set for a certain button with this function, default modifiers set withsetDefaultPanModifiersEx(int)will be used, defaulting togetDefaultDragModifiersEx()if none were set either.Only
InputEvent.SHIFT_DOWN_MASK,InputEvent.CTRL_DOWN_MASK,InputEvent.META_DOWN_MASKandInputEvent.ALT_DOWN_MASKare checked. To avoid platform-specific problems, it is recommended to usegetDefaultDragModifiersEx()for one operation, and zero modifiers for the other.If the same modifiers are set for both zooming and panning, panning will be performed.
- Parameters:
mouseButton- the mouse buttonmodifiersEx- modifier keys, as returned byInputEvent.getModifiersEx()
-
setZoomModifiersEx
public void setZoomModifiersEx(int mouseButton, int modifiersEx)
Sets modifier keys for zooming with a specific mouse button. If there are none set for a certain button with this function, default modifiers set withsetDefaultZoomModifiersEx(int)will be used, defaulting to zero (no modifiers) if none were set either.Only
InputEvent.SHIFT_DOWN_MASK,InputEvent.CTRL_DOWN_MASK,InputEvent.META_DOWN_MASKandInputEvent.ALT_DOWN_MASKare checked. To avoid platform-specific problems, it is recommended to usegetDefaultDragModifiersEx()for one operation, and zero modifiers for the other.If the same modifiers are set for both zooming and panning, panning will be performed.
- Parameters:
mouseButton- the mouse button.modifiersEx- modifier keys, as returned byInputEvent.getModifiersEx()
-
isDomainZoomable
public boolean isDomainZoomable()
Returns the flag that determines whether or not zooming is enabled for the domain axis.- Returns:
- A boolean.
-
setDomainZoomable
public void setDomainZoomable(boolean flag)
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
public boolean isRangeZoomable()
Returns the flag that determines whether or not zooming is enabled for the range axis.- Returns:
- A boolean.
-
setRangeZoomable
public void setRangeZoomable(boolean flag)
A flag that controls mouse-based zooming on the vertical axis.- Parameters:
flag-trueenables zooming.
-
getSelectionZoomStrategy
public SelectionZoomStrategy getSelectionZoomStrategy()
Returns a strategy used to control and draw zoom rectangle.- Returns:
- A zoom rectangle strategy.
-
setSelectionZoomStrategy
public void setSelectionZoomStrategy(SelectionZoomStrategy selectionZoomStrategy)
A strategy used to control and draw zoom rectangle.- Parameters:
selectionZoomStrategy- A zoom rectangle strategy.
-
getFillZoomRectangle
public boolean getFillZoomRectangle()
Returns the flag that controls whether or not the zoom rectangle is filled when drawn.- Returns:
- A boolean.
-
setFillZoomRectangle
public void setFillZoomRectangle(boolean flag)
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
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).
-
getDefaultDirectoryForSaveAs
public File getDefaultDirectoryForSaveAs()
Returns the default directory for the "save as" option.- Returns:
- The default directory (possibly
null).
-
setDefaultDirectoryForSaveAs
public void setDefaultDirectoryForSaveAs(File directory)
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
public boolean isEnforceFileExtensions()
Returnstrueif file extensions should be enforced, andfalseotherwise.- Returns:
- The flag.
- See Also:
setEnforceFileExtensions(boolean)
-
setEnforceFileExtensions
public void setEnforceFileExtensions(boolean enforce)
Sets a flag that controls whether or not file extensions are enforced.- Parameters:
enforce- the new flag value.- See Also:
isEnforceFileExtensions()
-
getZoomAroundAnchor
public boolean getZoomAroundAnchor()
Returns the flag that controls whether or not zoom operations are centered around the current anchor point.- Returns:
- A boolean.
- See Also:
setZoomAroundAnchor(boolean)
-
setZoomAroundAnchor
public void setZoomAroundAnchor(boolean zoomAroundAnchor)
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:
getZoomAroundAnchor()
-
getZoomFillPaint
public Paint getZoomFillPaint()
Returns the zoom rectangle fill paint.- Returns:
- The zoom rectangle fill paint (never
null). - See Also:
setZoomFillPaint(java.awt.Paint),setFillZoomRectangle(boolean)
-
setZoomFillPaint
public void setZoomFillPaint(Paint paint)
Sets the zoom rectangle fill paint.- Parameters:
paint- the paint (nullnot permitted).- See Also:
getZoomFillPaint(),getFillZoomRectangle()
-
getZoomOutlinePaint
public Paint getZoomOutlinePaint()
Returns the zoom rectangle outline paint.- Returns:
- The zoom rectangle outline paint (never
null). - See Also:
setZoomOutlinePaint(java.awt.Paint),setFillZoomRectangle(boolean)
-
setZoomOutlinePaint
public void setZoomOutlinePaint(Paint paint)
Sets the zoom rectangle outline paint.- Parameters:
paint- the paint (nullnot permitted).- See Also:
getZoomOutlinePaint(),getFillZoomRectangle()
-
isMouseWheelEnabled
public boolean isMouseWheelEnabled()
Returnstrueif the mouse wheel handler is enabled, andfalseotherwise.- Returns:
- A boolean.
-
setMouseWheelEnabled
public void setMouseWheelEnabled(boolean flag)
Enables or disables mouse wheel support for the panel.- Parameters:
flag- a boolean.
-
addOverlay
public void addOverlay(Overlay overlay)
Add an overlay to the panel.- Parameters:
overlay- the overlay (nullnot permitted).
-
removeOverlay
public void removeOverlay(Overlay overlay)
Removes an overlay from the panel.- Parameters:
overlay- the overlay to remove (nullnot permitted).
-
overlayChanged
public void overlayChanged(OverlayChangeEvent event)
Handles a change to an overlay by repainting the panel.- Specified by:
overlayChangedin interfaceOverlayChangeListener- Parameters:
event- the event.
-
setDisplayToolTips
public void setDisplayToolTips(boolean flag)
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
public String getToolTipText(MouseEvent e)
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
public Point translateJava2DToScreen(Point2D java2DPoint)
Translates a Java2D point on the chart to a screen location.- Parameters:
java2DPoint- the Java2D point.- Returns:
- The screen location.
-
translateScreenToJava2D
public Point2D translateScreenToJava2D(Point screenPoint)
Translates a panel (component) location to a Java2D point.- Parameters:
screenPoint- the screen location (nullnot permitted).- Returns:
- The Java2D coordinates.
-
scale
public Rectangle2D scale(Rectangle2D rect)
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
public ChartEntity getEntityForPoint(int viewX, int viewY)
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
public boolean getRefreshBuffer()
Returns the flag that controls whether or not the offscreen buffer needs to be refreshed.- Returns:
- A boolean.
-
setRefreshBuffer
public void setRefreshBuffer(boolean flag)
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
public 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). 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.
-
chartChanged
public void chartChanged(ChartChangeEvent event)
Receives notification of changes to the chart, and redraws the chart.- Specified by:
chartChangedin interfaceChartChangeListener- Parameters:
event- details of the chart change event.
-
chartProgress
public void chartProgress(ChartProgressEvent event)
Receives notification of a chart progress event.- Specified by:
chartProgressin interfaceChartProgressListener- Parameters:
event- the event.
-
actionPerformed
public void actionPerformed(ActionEvent event)
Handles action events generated by the popup menu.- Specified by:
actionPerformedin interfaceActionListener- Parameters:
event- the event.
-
mouseEntered
public void mouseEntered(MouseEvent e)
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
public void mouseExited(MouseEvent e)
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
public void mousePressed(MouseEvent e)
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.
-
getPointInRectangle
protected Point2D getPointInRectangle(int x, int y, Rectangle2D area)
Returns a point based on (x, y) but constrained to be within the bounds of the given rectangle. This method could be moved to JCommon.- Parameters:
x- the x-coordinate.y- the y-coordinate.area- the rectangle (nullnot permitted).- Returns:
- A point within the rectangle.
-
mouseDragged
public void mouseDragged(MouseEvent e)
Handles a 'mouse dragged' event.- Specified by:
mouseDraggedin interfaceMouseMotionListener- Parameters:
e- the mouse event.
-
mouseReleased
public void mouseReleased(MouseEvent e)
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
public void mouseClicked(MouseEvent event)
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
public void mouseMoved(MouseEvent e)
Implementation of the MouseMotionListener's method.- Specified by:
mouseMovedin interfaceMouseMotionListener- Parameters:
e- the event.
-
zoomInBoth
public void zoomInBoth(double x, double y)
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
public void zoomInDomain(double x, double y)
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
public void zoomInRange(double x, double y)
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
public void zoomOutBoth(double x, double y)
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
public void zoomOutDomain(double x, double y)
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
public void zoomOutRange(double x, double y)
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
public void zoom(Rectangle2D selection)
Zooms in on a selected region.- Parameters:
selection- the selected region.
-
restoreAutoBounds
public void restoreAutoBounds()
Restores the auto-range calculation on both axes.
-
restoreAutoDomainBounds
public void restoreAutoDomainBounds()
Restores the auto-range calculation on the domain axis.
-
restoreAutoRangeBounds
public void restoreAutoRangeBounds()
Restores the auto-range calculation on the range axis.
-
getScreenDataArea
public Rectangle2D 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
public Rectangle2D getScreenDataArea(int x, int y)
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
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.
- See Also:
setZoomInFactor(double)
-
setZoomInFactor
public void setZoomInFactor(double factor)
Sets the zoom in factor.- Parameters:
factor- the factor.- See Also:
getZoomInFactor()
-
getZoomOutFactor
public double getZoomOutFactor()
Returns the zoom out factor.- Returns:
- The zoom out factor.
- See Also:
setZoomOutFactor(double)
-
setZoomOutFactor
public void setZoomOutFactor(double factor)
Sets the zoom out factor.- Parameters:
factor- the factor.- See Also:
getZoomOutFactor()
-
doEditChartProperties
public void doEditChartProperties()
Displays a dialog that allows the user to edit the properties for the current chart.
-
doCopy
public void doCopy()
Copies the current chart to the system clipboard.
-
doSaveAs
public void doSaveAs() throws IOException
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.
-
doSaveAs
public void doSaveAs(int w, int h) throws IOException
Opens a file chooser and gives the user an opportunity to save the chart in PNG format.- Parameters:
w- the width for the saved image (if less than or equal to zero, the panel width will be used);h- the height for the PNG image (if less than or equal to zero, the panel height will be used);- Throws:
IOException- if there is an I/O error.
-
saveAsSVG
protected void saveAsSVG(File f) throws IOException
Saves the chart in SVG format (a filechooser will be displayed so that the user can specify the filename). Note that this method only works if the JFreeSVG library is on the classpath...if this library is not present, the method will fail.- Parameters:
f- the file.- Throws:
IOException- if there is an exception.
-
generateSVG
protected String generateSVG(int width, int height)
Generates a string containing a rendering of the chart in SVG format. This feature is only supported if the JFreeSVG library is included on the classpath.- Parameters:
width- the width.height- the height.- Returns:
- A string containing an SVG element for the current chart, or
nullif there is a problem with the method invocation by reflection.
-
createSVGGraphics2D
protected Graphics2D createSVGGraphics2D(int w, int h)
Creates anSVGGraphics2Dinstance (from JFreeSVG) using reflection. If JFreeSVG is not on the classpath, this method returnsnull.- Parameters:
w- the width.h- the height.- Returns:
- An
SVGGraphics2Dinstance ornull.
-
saveAsPDF
protected void saveAsPDF(File f)
Saves the chart in PDF format (a filechooser will be displayed so that the user can specify the filename). Note that this method only works if the OrsonPDF library is on the classpath...if this library is not present, the method will fail.- Parameters:
f- the file.
-
createChartPrintJob
public void createChartPrintJob()
Creates a print job for the chart.
-
print
public int print(Graphics g, PageFormat pf, int pageIndex)
Prints the chart on a single page.
-
addChartMouseListener
public void addChartMouseListener(ChartMouseListener listener)
Adds a listener to the list of objects listening for chart mouse events.- Parameters:
listener- the listener (nullnot permitted).
-
removeChartMouseListener
public void removeChartMouseListener(ChartMouseListener listener)
Removes a listener from the list of objects listening for chart mouse events.- Parameters:
listener- the listener.
-
getListeners
public <T extends EventListener> T[] getListeners(Class<T> listenerType)
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
protected JPopupMenu createPopupMenu(boolean properties, boolean copy, boolean save, boolean print, boolean zoom)
Creates a popup menu for the panel. This method includes code that auto-detects JFreeSVG and OrsonPDF (via reflection) and, if they are present (and thesaveargument istrue, adds a menu item for each.- Parameters:
properties- include a menu item for the chart property editor.copy- include a menu item for copying to the clipboard.save- include one or more menu items for saving the chart to supported image formats.print- include a menu item for printing the chart.zoom- include menu items for zooming.- Returns:
- The popup menu.
-
displayPopupMenu
protected void displayPopupMenu(int x, int y)
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
public void updateUI()
Updates the UI for a LookAndFeel change.
-
writeObject
protected void writeObject(ObjectOutputStream stream) throws IOException
Provides serialization support.- Parameters:
stream- the output stream.- Throws:
IOException- if there is an I/O error.
-
readObject
protected void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException
Provides serialization support.- Parameters:
stream- the input stream.- Throws:
IOException- if there is an I/O error.ClassNotFoundException- if there is a classpath problem.
-
-