java.lang.Object
   ↳ java.awt.Component
     ↳ java.awt.Container
       ↳ javax.swing.JComponent
         ↳ javax.swing.JPanel
           ↳ org.jfree.chart.ChartPanel
Known Direct Subclasses

Class Overview

A Swing GUI component for displaying a 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.

Summary

Constants
String COPY_COMMAND Copy action command.
boolean DEFAULT_BUFFER_USED Default setting for buffer usage.
int DEFAULT_HEIGHT The default panel height.
int DEFAULT_MAXIMUM_DRAW_HEIGHT The default limit above which chart scaling kicks in.
int DEFAULT_MAXIMUM_DRAW_WIDTH The default limit above which chart scaling kicks in.
int DEFAULT_MINIMUM_DRAW_HEIGHT The default limit below which chart scaling kicks in.
int DEFAULT_MINIMUM_DRAW_WIDTH The default limit below which chart scaling kicks in.
int DEFAULT_WIDTH The default panel width.
int DEFAULT_ZOOM_TRIGGER_DISTANCE The minimum size required to perform a zoom on a rectangle
String PRINT_COMMAND Print action command.
String PROPERTIES_COMMAND Properties action command.
String SAVE_COMMAND Save action command.
String ZOOM_IN_BOTH_COMMAND Zoom in (both axes) action command.
String ZOOM_IN_DOMAIN_COMMAND Zoom in (domain axis only) action command.
String ZOOM_IN_RANGE_COMMAND Zoom in (range axis only) action command.
String ZOOM_OUT_BOTH_COMMAND Zoom out (both axes) action command.
String ZOOM_OUT_DOMAIN_COMMAND Zoom out (domain axis only) action command.
String ZOOM_OUT_RANGE_COMMAND Zoom out (range axis only) action command.
String ZOOM_RESET_BOTH_COMMAND Zoom reset (both axes) action command.
String ZOOM_RESET_DOMAIN_COMMAND Zoom reset (domain axis only) action command.
String ZOOM_RESET_RANGE_COMMAND Zoom reset (range axis only) action command.
[Expand]
Inherited Constants
From class javax.swing.JComponent
From class java.awt.Component
From interface java.awt.image.ImageObserver
From interface java.awt.print.Printable
Fields
protected static ResourceBundle localizationResources The resourceBundle for the localization.
[Expand]
Inherited Fields
From class javax.swing.JComponent
Public Constructors
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.
Public Methods
void actionPerformed(ActionEvent event)
Handles action events generated by the popup menu.
void addChartMouseListener(ChartMouseListener listener)
Adds a listener to the list of objects listening for chart mouse events.
void addOverlay(Overlay overlay)
Add an overlay to the panel.
void chartChanged(ChartChangeEvent event)
Receives notification of changes to the chart, and redraws the chart.
void chartProgress(ChartProgressEvent event)
Receives notification of a chart progress event.
void createChartPrintJob()
Creates a print job for the chart.
void doCopy()
Copies the current chart to the system clipboard.
void doEditChartProperties()
Displays a dialog that allows the user to edit the properties for the current chart.
void doSaveAs()
Opens a file chooser and gives the user an opportunity to save the chart in PNG format.
Point2D getAnchor()
Returns the anchor point.
JFreeChart getChart()
Returns the chart contained in the panel.
ChartRenderingInfo getChartRenderingInfo()
Returns the chart rendering info from the most recent chart redraw.
File getDefaultDirectoryForSaveAs()
Returns the default directory for the "save as" option.
int getDismissDelay()
Returns the dismissal tooltip delay value used inside this chart panel.
ChartEntity getEntityForPoint(int viewX, int viewY)
Returns the chart entity at a given point.
boolean getFillZoomRectangle()
Returns the flag that controls whether or not the zoom rectangle is filled when drawn.
boolean 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.
int getInitialDelay()
Returns the initial tooltip delay value used inside this chart panel.
EventListener[] getListeners(Class listenerType)
Returns an array of the listeners of the given type registered with the panel.
int getMaximumDrawHeight()
Returns the maximum drawing height for charts.
int getMaximumDrawWidth()
Returns the maximum drawing width for charts.
int getMinimumDrawHeight()
Returns the minimum drawing height for charts.
int getMinimumDrawWidth()
Returns the minimum drawing width for charts.
JPopupMenu getPopupMenu()
Returns the popup menu.
boolean getRefreshBuffer()
Returns the flag that controls whether or not the offscreen buffer needs to be refreshed.
int getReshowDelay()
Returns the reshow tooltip delay value used inside this chart panel.
double getScaleX()
Returns the X scale factor for the chart.
double getScaleY()
Returns the Y scale factory for the chart.
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.
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).
String getToolTipText(MouseEvent e)
Returns a string for the tooltip.
boolean 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.
boolean getZoomAroundAnchor()
Returns the flag that controls whether or not zoom operations are centered around the current anchor point.
Paint getZoomFillPaint()
Returns the zoom rectangle fill paint.
double getZoomInFactor()
Returns the zoom in factor.
double getZoomOutFactor()
Returns the zoom out factor.
Paint getZoomOutlinePaint()
Returns the zoom rectangle outline paint.
int getZoomTriggerDistance()
Returns the zoom trigger distance.
boolean isDomainZoomable()
Returns the flag that determines whether or not zooming is enabled for the domain axis.
boolean isEnforceFileExtensions()
Returns true if file extensions should be enforced, and false otherwise.
boolean isMouseWheelEnabled()
Returns true if the mouse wheel handler is enabled, and false otherwise.
boolean isRangeZoomable()
Returns the flag that determines whether or not zooming is enabled for the range axis.
void mouseClicked(MouseEvent event)
Receives notification of mouse clicks on the panel.
void mouseDragged(MouseEvent e)
Handles a 'mouse dragged' event.
void mouseEntered(MouseEvent e)
Handles a 'mouse entered' event.
void mouseExited(MouseEvent e)
Handles a 'mouse exited' event.
void mouseMoved(MouseEvent e)
Implementation of the MouseMotionListener's method.
void mousePressed(MouseEvent e)
Handles a 'mouse pressed' event.
void mouseReleased(MouseEvent e)
Handles a 'mouse released' event.
void overlayChanged(OverlayChangeEvent event)
Handles a change to an overlay by repainting the panel.
void paintComponent(Graphics g)
Paints the component by drawing the chart to fill the entire component, but allowing for the insets (which will be non-zero if a border has been set for this component).
int print(Graphics g, PageFormat pf, int pageIndex)
Prints the chart on a single page.
void removeChartMouseListener(ChartMouseListener listener)
Removes a listener from the list of objects listening for chart mouse events.
void removeOverlay(Overlay overlay)
Removes an overlay from the panel.
void restoreAutoBounds()
Restores the auto-range calculation on both axes.
void restoreAutoDomainBounds()
Restores the auto-range calculation on the domain axis.
void restoreAutoRangeBounds()
Restores the auto-range calculation on the range axis.
Rectangle2D scale(Rectangle2D rect)
Applies any scaling that is in effect for the chart drawing to the given rectangle.
void setChart(JFreeChart chart)
Sets the chart that is displayed in the panel.
void setDefaultDirectoryForSaveAs(File directory)
Sets the default directory for the "save as" option.
void setDismissDelay(int delay)
Specifies the dismissal delay value for this chart panel.
void setDisplayToolTips(boolean flag)
Switches the display of tooltips for the panel on or off.
void setDomainZoomable(boolean flag)
Sets the flag that controls whether or not zooming is enable for the domain axis.
void setEnforceFileExtensions(boolean enforce)
Sets a flag that controls whether or not file extensions are enforced.
void setFillZoomRectangle(boolean flag)
A flag that controls how the zoom rectangle is drawn.
void setHorizontalAxisTrace(boolean flag)
A flag that controls trace lines on the horizontal axis.
void setInitialDelay(int delay)
Specifies the initial delay value for this chart panel.
void setMaximumDrawHeight(int height)
Sets the maximum drawing height for the chart on this panel.
void setMaximumDrawWidth(int width)
Sets the maximum drawing width for the chart on this panel.
void setMinimumDrawHeight(int height)
Sets the minimum drawing height for the chart on this panel.
void setMinimumDrawWidth(int width)
Sets the minimum drawing width for the chart on this panel.
void setMouseWheelEnabled(boolean flag)
Enables or disables mouse wheel support for the panel.
void setMouseZoomable(boolean flag)
A convenience method that switches on mouse-based zooming.
void setMouseZoomable(boolean flag, boolean fillRectangle)
A convenience method that switches on mouse-based zooming.
void setPopupMenu(JPopupMenu popup)
Sets the popup menu for the panel.
void setRangeZoomable(boolean flag)
A flag that controls mouse-based zooming on the vertical axis.
void setRefreshBuffer(boolean flag)
Sets the refresh buffer flag.
void setReshowDelay(int delay)
Specifies the amount of time before the user has to wait initialDelay milliseconds before a tooltip will be shown.
void setVerticalAxisTrace(boolean flag)
A flag that controls trace lines on the vertical axis.
void setZoomAroundAnchor(boolean zoomAroundAnchor)
Sets the flag that controls whether or not zoom operations are centered around the current anchor point.
void setZoomFillPaint(Paint paint)
Sets the zoom rectangle fill paint.
void setZoomInFactor(double factor)
Sets the zoom in factor.
void setZoomOutFactor(double factor)
Sets the zoom out factor.
void setZoomOutlinePaint(Paint paint)
Sets the zoom rectangle outline paint.
void setZoomTriggerDistance(int distance)
Sets the zoom trigger distance.
Point translateJava2DToScreen(Point2D java2DPoint)
Translates a Java2D point on the chart to a screen location.
Point2D translateScreenToJava2D(Point screenPoint)
Translates a panel (component) location to a Java2D point.
void updateUI()
Updates the UI for a LookAndFeel change.
void zoom(Rectangle2D selection)
Zooms in on a selected region.
void zoomInBoth(double x, double y)
Zooms in on an anchor point (specified in screen coordinate space).
void zoomInDomain(double x, double y)
Decreases the length of the domain axis, centered about the given coordinate on the screen.
void zoomInRange(double x, double y)
Decreases the length of the range axis, centered about the given coordinate on the screen.
void zoomOutBoth(double x, double y)
Zooms out on an anchor point (specified in screen coordinate space).
void zoomOutDomain(double x, double y)
Increases the length of the domain axis, centered about the given coordinate on the screen.
void zoomOutRange(double x, double y)
Increases the length the range axis, centered about the given coordinate on the screen.
Protected Methods
JPopupMenu createPopupMenu(boolean properties, boolean copy, boolean save, boolean print, boolean zoom)
Creates a popup menu for the panel.
JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom)
Creates a popup menu for the panel.
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.
Line2D getHorizontalTraceLine()
Returns the horizontal trace line.
Line2D getVerticalTraceLine()
Returns the vertical trace line.
void setAnchor(Point2D anchor)
Sets the anchor point.
void setHorizontalTraceLine(Line2D line)
Sets the horizontal trace line.
void setVerticalTraceLine(Line2D line)
Sets the vertical trace line.
[Expand]
Inherited Methods
From class javax.swing.JPanel
From class javax.swing.JComponent
From class java.awt.Container
From class java.awt.Component
From class java.lang.Object
From interface java.awt.MenuContainer
From interface java.awt.event.ActionListener
From interface java.awt.event.MouseListener
From interface java.awt.event.MouseMotionListener
From interface java.awt.image.ImageObserver
From interface java.awt.print.Printable
From interface javax.accessibility.Accessible
From interface org.jfree.chart.event.ChartChangeListener
From interface org.jfree.chart.event.ChartProgressListener
From interface org.jfree.chart.event.OverlayChangeListener

Constants

public static final String COPY_COMMAND

Copy action command.

Constant Value: "COPY"

public static final boolean DEFAULT_BUFFER_USED

Default setting for buffer usage. The default has been changed to true from 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).

Constant Value: true

public static final int DEFAULT_HEIGHT

The default panel height.

Constant Value: 420 (0x000001a4)

public static final int DEFAULT_MAXIMUM_DRAW_HEIGHT

The default limit above which chart scaling kicks in.

Constant Value: 768 (0x00000300)

public static final int DEFAULT_MAXIMUM_DRAW_WIDTH

The default limit above which chart scaling kicks in.

Constant Value: 1024 (0x00000400)

public static final int DEFAULT_MINIMUM_DRAW_HEIGHT

The default limit below which chart scaling kicks in.

Constant Value: 200 (0x000000c8)

public static final int DEFAULT_MINIMUM_DRAW_WIDTH

The default limit below which chart scaling kicks in.

Constant Value: 300 (0x0000012c)

public static final int DEFAULT_WIDTH

The default panel width.

Constant Value: 680 (0x000002a8)

public static final int DEFAULT_ZOOM_TRIGGER_DISTANCE

The minimum size required to perform a zoom on a rectangle

Constant Value: 10 (0x0000000a)

public static final String PRINT_COMMAND

Print action command.

Constant Value: "PRINT"

public static final String PROPERTIES_COMMAND

Properties action command.

Constant Value: "PROPERTIES"

public static final String SAVE_COMMAND

Save action command.

Constant Value: "SAVE"

public static final String ZOOM_IN_BOTH_COMMAND

Zoom in (both axes) action command.

Constant Value: "ZOOM_IN_BOTH"

public static final String ZOOM_IN_DOMAIN_COMMAND

Zoom in (domain axis only) action command.

Constant Value: "ZOOM_IN_DOMAIN"

public static final String ZOOM_IN_RANGE_COMMAND

Zoom in (range axis only) action command.

Constant Value: "ZOOM_IN_RANGE"

public static final String ZOOM_OUT_BOTH_COMMAND

Zoom out (both axes) action command.

Constant Value: "ZOOM_OUT_BOTH"

public static final String ZOOM_OUT_DOMAIN_COMMAND

Zoom out (domain axis only) action command.

Constant Value: "ZOOM_DOMAIN_BOTH"

public static final String ZOOM_OUT_RANGE_COMMAND

Zoom out (range axis only) action command.

Constant Value: "ZOOM_RANGE_BOTH"

public static final String ZOOM_RESET_BOTH_COMMAND

Zoom reset (both axes) action command.

Constant Value: "ZOOM_RESET_BOTH"

public static final String ZOOM_RESET_DOMAIN_COMMAND

Zoom reset (domain axis only) action command.

Constant Value: "ZOOM_RESET_DOMAIN"

public static final String ZOOM_RESET_RANGE_COMMAND

Zoom reset (range axis only) action command.

Constant Value: "ZOOM_RESET_RANGE"

Fields

protected static ResourceBundle localizationResources

The resourceBundle for the localization.

Public Constructors

public ChartPanel (JFreeChart chart)

Constructs a panel that displays the specified chart.

Parameters
chart the chart.

public ChartPanel (JFreeChart chart, boolean useBuffer)

Constructs a panel containing a chart. The useBuffer flag controls whether or not an offscreen BufferedImage is 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 the useBuffer flag 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 to false).

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.

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.

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.

Public Methods

public void actionPerformed (ActionEvent event)

Handles action events generated by the popup menu.

Parameters
event the event.

public void addChartMouseListener (ChartMouseListener listener)

Adds a listener to the list of objects listening for chart mouse events.

Parameters
listener the listener (null not permitted).

public void addOverlay (Overlay overlay)

Add an overlay to the panel.

Parameters
overlay the overlay (null not permitted).

public void chartChanged (ChartChangeEvent event)

Receives notification of changes to the chart, and redraws the chart.

Parameters
event details of the chart change event.

public void chartProgress (ChartProgressEvent event)

Receives notification of a chart progress event.

Parameters
event the event.

public void createChartPrintJob ()

Creates a print job for the chart.

public void doCopy ()

Copies the current chart to the system clipboard.

public void doEditChartProperties ()

Displays a dialog that allows the user to edit the properties for the current chart.

public void 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.

public Point2D getAnchor ()

Returns the anchor point.

Returns
  • The anchor point (possibly null).

public JFreeChart getChart ()

Returns the chart contained in the panel.

Returns
  • The chart (possibly null).

public ChartRenderingInfo getChartRenderingInfo ()

Returns the chart rendering info from the most recent chart redraw.

Returns
  • The chart rendering info.

public File getDefaultDirectoryForSaveAs ()

Returns the default directory for the "save as" option.

Returns
  • The default directory (possibly null).

public int getDismissDelay ()

Returns the dismissal tooltip delay value used inside this chart panel.

Returns
  • An integer representing the dismissal delay value, in milliseconds.

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).

public boolean getFillZoomRectangle ()

Returns the flag that controls whether or not the zoom rectangle is filled when drawn.

Returns
  • A boolean.

public boolean 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.

public int getInitialDelay ()

Returns the initial tooltip delay value used inside this chart panel.

Returns
  • An integer representing the initial delay value, in milliseconds.

public EventListener[] getListeners (Class listenerType)

Returns an array of the listeners of the given type registered with the panel.

Parameters
listenerType the listener type.
Returns
  • An array of listeners.

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.

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.

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.

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.

public JPopupMenu getPopupMenu ()

Returns the popup menu.

Returns
  • The popup menu.

public boolean getRefreshBuffer ()

Returns the flag that controls whether or not the offscreen buffer needs to be refreshed.

Returns
  • A boolean.

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

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.

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.

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.

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.

public String getToolTipText (MouseEvent e)

Returns a string for the tooltip.

Parameters
e the mouse event.
Returns
  • A tool tip or null if no tooltip is available.

public boolean 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.

public boolean getZoomAroundAnchor ()

Returns the flag that controls whether or not zoom operations are centered around the current anchor point.

Returns
  • A boolean.

public Paint getZoomFillPaint ()

Returns the zoom rectangle fill paint.

Returns
  • The zoom rectangle fill paint (never null).

public double getZoomInFactor ()

Returns the zoom in factor.

Returns
  • The zoom in factor.

public double getZoomOutFactor ()

Returns the zoom out factor.

Returns
  • The zoom out factor.

public Paint getZoomOutlinePaint ()

Returns the zoom rectangle outline paint.

Returns
  • The zoom rectangle outline paint (never null).

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).

public boolean isDomainZoomable ()

Returns the flag that determines whether or not zooming is enabled for the domain axis.

Returns
  • A boolean.

public boolean isEnforceFileExtensions ()

Returns true if file extensions should be enforced, and false otherwise.

Returns
  • The flag.

public boolean isMouseWheelEnabled ()

Returns true if the mouse wheel handler is enabled, and false otherwise.

Returns
  • A boolean.

public boolean isRangeZoomable ()

Returns the flag that determines whether or not zooming is enabled for the range axis.

Returns
  • A boolean.

public void mouseClicked (MouseEvent event)

Receives notification of mouse clicks on the panel. These are translated and passed on to any registered ChartMouseListeners.

Parameters
event Information about the mouse event.

public void mouseDragged (MouseEvent e)

Handles a 'mouse dragged' event.

Parameters
e the mouse event.

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.

Parameters
e the mouse event.

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()

Parameters
e the mouse event.

public void mouseMoved (MouseEvent e)

Implementation of the MouseMotionListener's method.

Parameters
e the event.

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.

Parameters
e The mouse event.

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.

Parameters
e information about the event.

public void overlayChanged (OverlayChangeEvent event)

Handles a change to an overlay by repainting the panel.

Parameters
event the event.

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.

Parameters
g the graphics device for drawing on.

public int print (Graphics g, PageFormat pf, int pageIndex)

Prints the chart on a single page.

Parameters
g the graphics context.
pf the page format to use.
pageIndex the index of the page. If not 0, nothing gets print.
Returns
  • The result of printing.

public void removeChartMouseListener (ChartMouseListener listener)

Removes a listener from the list of objects listening for chart mouse events.

Parameters
listener the listener.

public void removeOverlay (Overlay overlay)

Removes an overlay from the panel.

Parameters
overlay the overlay to remove (null not permitted).

public void restoreAutoBounds ()

Restores the auto-range calculation on both axes.

public void restoreAutoDomainBounds ()

Restores the auto-range calculation on the domain axis.

public void restoreAutoRangeBounds ()

Restores the auto-range calculation on the range axis.

public Rectangle2D scale (Rectangle2D rect)

Applies any scaling that is in effect for the chart drawing to the given rectangle.

Parameters
rect the rectangle (null not permitted).
Returns
  • A new scaled rectangle.

public void setChart (JFreeChart chart)

Sets the chart that is displayed in the panel.

Parameters
chart the chart (null permitted).

public void setDefaultDirectoryForSaveAs (File directory)

Sets the default directory for the "save as" option. If you set this to null, the user's default directory will be used.

Parameters
directory the directory (null permitted).

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

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 true to enable tooltips, false to disable tooltips.

public void setDomainZoomable (boolean flag)

Sets the flag that controls whether or not zooming is enable for the domain axis. A check is made to ensure that the current plot supports zooming for the domain values.

Parameters
flag true enables zooming if possible.

public void setEnforceFileExtensions (boolean enforce)

Sets a flag that controls whether or not file extensions are enforced.

Parameters
enforce the new flag value.

public void setFillZoomRectangle (boolean flag)

A flag that controls how the zoom rectangle is drawn.

Parameters
flag true instructs to fill the rectangle on zoom, otherwise it will be outlined.

public void setHorizontalAxisTrace (boolean flag)

A flag that controls trace lines on the horizontal axis.

Parameters
flag true enables trace lines for the mouse pointer on the horizontal axis.

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.

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.

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.

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.

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.

public void setMouseWheelEnabled (boolean flag)

Enables or disables mouse wheel support for the panel. Note that this method does nothing when running JFreeChart on JRE 1.3.1, because that older version of the Java runtime does not support mouse wheel events.

Parameters
flag a boolean.

public void setMouseZoomable (boolean flag)

A convenience method that switches on mouse-based zooming.

Parameters
flag true enables zooming and rectangle fill on zoom.

public void setMouseZoomable (boolean flag, boolean fillRectangle)

A convenience method that switches on mouse-based zooming.

Parameters
flag true if zooming enabled
fillRectangle true if zoom rectangle is filled, false if rectangle is shown as outline only.

public void setPopupMenu (JPopupMenu popup)

Sets the popup menu for the panel.

Parameters
popup the popup menu (null permitted).

public void setRangeZoomable (boolean flag)

A flag that controls mouse-based zooming on the vertical axis.

Parameters
flag true enables zooming.

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 true indicates that the buffer should be refreshed.

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

public void setVerticalAxisTrace (boolean flag)

A flag that controls trace lines on the vertical axis.

Parameters
flag true enables trace lines for the mouse pointer on the vertical axis.

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.

public void setZoomFillPaint (Paint paint)

Sets the zoom rectangle fill paint.

Parameters
paint the paint (null not permitted).

public void setZoomInFactor (double factor)

Sets the zoom in factor.

Parameters
factor the factor.

public void setZoomOutFactor (double factor)

Sets the zoom out factor.

Parameters
factor the factor.

public void setZoomOutlinePaint (Paint paint)

Sets the zoom rectangle outline paint.

Parameters
paint the paint (null not permitted).

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).

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.

public Point2D translateScreenToJava2D (Point screenPoint)

Translates a panel (component) location to a Java2D point.

Parameters
screenPoint the screen location (null not permitted).
Returns
  • The Java2D coordinates.

public void updateUI ()

Updates the UI for a LookAndFeel change.

public void zoom (Rectangle2D selection)

Zooms in on a selected region.

Parameters
selection the selected region.

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).

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 of getZoomInFactor().

Parameters
x the x coordinate (in screen coordinates).
y the y-coordinate (in screen coordinates).

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 of getZoomInFactor().

Parameters
x the x-coordinate (in screen coordinates).
y the y coordinate (in screen coordinates).

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).

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 of getZoomOutFactor().

Parameters
x the x coordinate (in screen coordinates).
y the y-coordinate (in screen coordinates).

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 of getZoomOutFactor().

Parameters
x the x coordinate (in screen coordinates).
y the y-coordinate (in screen coordinates).

Protected Methods

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.

protected JPopupMenu createPopupMenu (boolean properties, boolean save, boolean print, boolean zoom)

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.

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.

protected Line2D getHorizontalTraceLine ()

Returns the horizontal trace line.

Returns
  • The horizontal trace line (possibly null).

protected Line2D getVerticalTraceLine ()

Returns the vertical trace line.

Returns
  • The vertical trace line (possibly null).

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 (null permitted).

protected void setHorizontalTraceLine (Line2D line)

Sets the horizontal trace line.

Parameters
line the line (null permitted).

protected void setVerticalTraceLine (Line2D line)

Sets the vertical trace line.

Parameters
line the line (null permitted).