org.jfree.chart

Class ChartPanel

public class ChartPanel extends JPanel implements ChartChangeListener, ChartProgressListener, ActionListener, MouseListener, MouseMotionListener, Printable, Serializable

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.

Field Summary
static booleanDEFAULT_BUFFER_USED
Default setting for buffer usage.
static intDEFAULT_HEIGHT
The default panel height.
static intDEFAULT_MAXIMUM_DRAW_HEIGHT
The default limit below which chart scaling kicks in.
static intDEFAULT_MAXIMUM_DRAW_WIDTH
The default limit below which chart scaling kicks in.
static intDEFAULT_MINIMUM_DRAW_HEIGHT
The default limit below which chart scaling kicks in.
static intDEFAULT_MINIMUM_DRAW_WIDTH
The default limit below which chart scaling kicks in.
static intDEFAULT_WIDTH
The default panel width.
static intDEFAULT_ZOOM_TRIGGER_DISTANCE
The minimum size required to perform a zoom on a rectangle
protected static ResourceBundlelocalizationResources
The resourceBundle for the localization.
static StringPRINT_COMMAND
Print action command.
static StringPROPERTIES_COMMAND
Properties action command.
static StringSAVE_COMMAND
Save action command.
static StringZOOM_IN_BOTH_COMMAND
Zoom in (both axes) action command.
static StringZOOM_IN_DOMAIN_COMMAND
Zoom in (domain axis only) action command.
static StringZOOM_IN_RANGE_COMMAND
Zoom in (range axis only) action command.
static StringZOOM_OUT_BOTH_COMMAND
Zoom out (both axes) action command.
static StringZOOM_OUT_DOMAIN_COMMAND
Zoom out (domain axis only) action command.
static StringZOOM_OUT_RANGE_COMMAND
Zoom out (range axis only) action command.
static StringZOOM_RESET_BOTH_COMMAND
Zoom reset (both axes) action command.
static StringZOOM_RESET_DOMAIN_COMMAND
Zoom reset (domain axis only) action command.
static StringZOOM_RESET_RANGE_COMMAND
Zoom reset (range axis only) action command.
Constructor Summary
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.
Method Summary
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.
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 save, boolean print, boolean zoom)
Creates a popup menu for the panel.
protected voiddisplayPopupMenu(int x, int y)
The idea is to modify the zooming options depending on the type of chart being displayed by the panel.
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.
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.
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.
booleangetHorizontalAxisTrace()
Returns the flag that controls whether or not a horizontal axis trace line is drawn over the plot area at the current mouse location.
protected Line2DgetHorizontalTraceLine()
Returns the horizontal trace line.
intgetInitialDelay()
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.
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.
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.
StringgetToolTipText(MouseEvent e)
Returns a string for the tooltip.
booleangetVerticalAxisTrace()
Returns the flag that controls whether or not a vertical axis trace line is drawn over the plot area at the current mouse location.
protected Line2DgetVerticalTraceLine()
Returns the vertical trace line.
doublegetZoomInFactor()
Returns the zoom in factor.
doublegetZoomOutFactor()
Returns the zoom out factor.
intgetZoomTriggerDistance()
Returns the zoom trigger distance.
booleanisDomainZoomable()
Returns the flag that determines whether or not zooming is enabled for the domain axis.
booleanisEnforceFileExtensions()
Returns true if file extensions should be enforced, and false otherwise.
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.
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.
voidremoveChartMouseListener(ChartMouseListener listener)
Removes a listener from the list of objects listening for chart mouse events.
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.
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.
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 enable for the domain axis.
voidsetEnforceFileExtensions(boolean enforce)
Sets a flag that controls whether or not file extensions are enforced.
voidsetFillZoomRectangle(boolean flag)
A flag that controls how the zoom rectangle is drawn.
voidsetHorizontalAxisTrace(boolean flag)
A flag that controls trace lines on the horizontal axis.
protected voidsetHorizontalTraceLine(Line2D line)
Sets the horizontal trace line.
voidsetInitialDelay(int delay)
Specifies the initial delay value for this chart panel.
voidsetMaximumDrawHeight(int height)
Sets the maximum drawing height for the chart on this panel.
voidsetMaximumDrawWidth(int width)
Sets the maximum drawing width for the chart on this panel.
voidsetMinimumDrawHeight(int height)
Sets the minimum drawing height for the chart on this panel.
voidsetMinimumDrawWidth(int width)
Sets the minimum drawing width for the chart on this panel.
voidsetMouseZoomable(boolean flag)
A convenience method that switches on mouse-based zooming.
voidsetMouseZoomable(boolean flag, boolean fillRectangle)
A convenience method that switches on mouse-based zooming.
voidsetPopupMenu(JPopupMenu popup)
Sets the popup menu for the panel.
voidsetRangeZoomable(boolean flag)
A flag that controls mouse-based zooming on the vertical axis.
voidsetRefreshBuffer(boolean flag)
Sets the refresh buffer flag.
voidsetReshowDelay(int delay)
Specifies the amount of time before the user has to wait initialDelay milliseconds before a tooltip will be shown.
voidsetVerticalAxisTrace(boolean flag)
A flag that controls trace lines on the vertical axis.
protected voidsetVerticalTraceLine(Line2D line)
Sets the vertical trace line.
voidsetZoomInFactor(double factor)
Sets the zoom in factor.
voidsetZoomOutFactor(double factor)
Sets the zoom out factor.
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 screen location to a Java2D point.
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.

Field Detail

DEFAULT_BUFFER_USED

public static final boolean DEFAULT_BUFFER_USED
Default setting for buffer usage.

DEFAULT_HEIGHT

public static final int DEFAULT_HEIGHT
The default panel height.

DEFAULT_MAXIMUM_DRAW_HEIGHT

public static final int DEFAULT_MAXIMUM_DRAW_HEIGHT
The default limit below which chart scaling kicks in.

DEFAULT_MAXIMUM_DRAW_WIDTH

public static final int DEFAULT_MAXIMUM_DRAW_WIDTH
The default limit below which chart scaling kicks in.

DEFAULT_MINIMUM_DRAW_HEIGHT

public static final int DEFAULT_MINIMUM_DRAW_HEIGHT
The default limit below which chart scaling kicks in.

DEFAULT_MINIMUM_DRAW_WIDTH

public static final int DEFAULT_MINIMUM_DRAW_WIDTH
The default limit below which chart scaling kicks in.

DEFAULT_WIDTH

public static final int DEFAULT_WIDTH
The default panel width.

DEFAULT_ZOOM_TRIGGER_DISTANCE

public static final int DEFAULT_ZOOM_TRIGGER_DISTANCE
The minimum size required to perform a zoom on a rectangle

localizationResources

protected static ResourceBundle localizationResources
The resourceBundle for the localization.

PRINT_COMMAND

public static final String PRINT_COMMAND
Print action command.

PROPERTIES_COMMAND

public static final String PROPERTIES_COMMAND
Properties action command.

SAVE_COMMAND

public static final String SAVE_COMMAND
Save action command.

ZOOM_IN_BOTH_COMMAND

public static final String ZOOM_IN_BOTH_COMMAND
Zoom in (both axes) action command.

ZOOM_IN_DOMAIN_COMMAND

public static final String ZOOM_IN_DOMAIN_COMMAND
Zoom in (domain axis only) action command.

ZOOM_IN_RANGE_COMMAND

public static final String ZOOM_IN_RANGE_COMMAND
Zoom in (range axis only) action command.

ZOOM_OUT_BOTH_COMMAND

public static final String ZOOM_OUT_BOTH_COMMAND
Zoom out (both axes) action command.

ZOOM_OUT_DOMAIN_COMMAND

public static final String ZOOM_OUT_DOMAIN_COMMAND
Zoom out (domain axis only) action command.

ZOOM_OUT_RANGE_COMMAND

public static final String ZOOM_OUT_RANGE_COMMAND
Zoom out (range axis only) action command.

ZOOM_RESET_BOTH_COMMAND

public static final String ZOOM_RESET_BOTH_COMMAND
Zoom reset (both axes) action command.

ZOOM_RESET_DOMAIN_COMMAND

public static final String ZOOM_RESET_DOMAIN_COMMAND
Zoom reset (domain axis only) action command.

ZOOM_RESET_RANGE_COMMAND

public static final String ZOOM_RESET_RANGE_COMMAND
Zoom reset (range axis only) action command.

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.

Parameters: chart the chart. useBuffer a flag controlling whether or not an off-screen buffer is used.

ChartPanel

public ChartPanel(JFreeChart chart, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips)
Constructs a JFreeChart panel.

Parameters: chart the chart. properties a flag indicating whether or not the chart property editor should be available via the popup menu. save a flag indicating whether or not save options should be available via the popup menu. print a flag indicating whether or not the print option should be available via the popup menu. zoom a flag indicating whether or not zoom options should be added to the popup menu. tooltips a flag indicating whether or not tooltips should be enabled for the chart.

ChartPanel

public ChartPanel(JFreeChart chart, int width, int height, int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth, int maximumDrawHeight, boolean useBuffer, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips)
Constructs a JFreeChart panel.

Parameters: chart the chart. width the preferred width of the panel. height the preferred height of the panel. minimumDrawWidth the minimum drawing width. minimumDrawHeight the minimum drawing height. maximumDrawWidth the maximum drawing width. maximumDrawHeight the maximum drawing height. useBuffer a flag that indicates whether to use the off-screen buffer to improve performance (at the expense of memory). properties a flag indicating whether or not the chart property editor should be available via the popup menu. save a flag indicating whether or not save options should be available via the popup menu. print a flag indicating whether or not the print option should be available via the popup menu. zoom a flag indicating whether or not zoom options should be added to the popup menu. tooltips a flag indicating whether or not tooltips should be enabled for the chart.

Method Detail

actionPerformed

public void actionPerformed(ActionEvent event)
Handles action events generated by the popup menu.

Parameters: event the event.

addChartMouseListener

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

chartChanged

public void chartChanged(ChartChangeEvent event)
Receives notification of changes to the chart, and redraws the chart.

Parameters: event details of the chart change event.

chartProgress

public void chartProgress(ChartProgressEvent event)
Receives notification of a chart progress event.

Parameters: event the event.

createChartPrintJob

public void createChartPrintJob()
Creates a print job for the chart.

createPopupMenu

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.

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.

doEditChartProperties

public void doEditChartProperties()
Displays a dialog that allows the user to edit the properties for the current chart.

Since: 1.0.3

doSaveAs

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.

getAnchor

public Point2D getAnchor()
Returns the anchor point.

Returns: The anchor point (possibly null).

getChart

public JFreeChart getChart()
Returns the chart contained in the panel.

Returns: The chart (possibly null).

getChartRenderingInfo

public ChartRenderingInfo getChartRenderingInfo()
Returns the chart rendering info from the most recent chart redraw.

Returns: The chart rendering info.

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: javax.swing.ToolTipManager#getDismissDelay()

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

getFillZoomRectangle

public boolean getFillZoomRectangle()
Returns the flag that controls whether or not the zoom rectangle is filled when drawn.

Returns: A boolean.

getHorizontalAxisTrace

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.

getHorizontalTraceLine

protected Line2D getHorizontalTraceLine()
Returns the horizontal trace line.

Returns: The horizontal trace line (possibly null).

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: javax.swing.ToolTipManager#getInitialDelay()

getListeners

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.

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.

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.

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.

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.

getPopupMenu

public JPopupMenu getPopupMenu()
Returns the popup menu.

Returns: The popup menu.

getRefreshBuffer

public boolean getRefreshBuffer()
Returns the flag that controls whether or not the offscreen buffer needs to be refreshed.

Returns: A boolean.

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: javax.swing.ToolTipManager#getReshowDelay()

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.

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.

getToolTipText

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.

getVerticalAxisTrace

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.

getVerticalTraceLine

protected Line2D getVerticalTraceLine()
Returns the vertical trace line.

Returns: The vertical trace line (possibly null).

getZoomInFactor

public double getZoomInFactor()
Returns the zoom in factor.

Returns: The zoom in factor.

See Also: ChartPanel

getZoomOutFactor

public double getZoomOutFactor()
Returns the zoom out factor.

Returns: The zoom out factor.

See Also: ChartPanel

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

isDomainZoomable

public boolean isDomainZoomable()
Returns the flag that determines whether or not zooming is enabled for the domain axis.

Returns: A boolean.

isEnforceFileExtensions

public boolean isEnforceFileExtensions()
Returns true if file extensions should be enforced, and false otherwise.

Returns: The flag.

isRangeZoomable

public boolean isRangeZoomable()
Returns the flag that determines whether or not zooming is enabled for the range axis.

Returns: A boolean.

mouseClicked

public void mouseClicked(MouseEvent event)
Receives notification of mouse clicks on the panel. These are translated and passed on to any registered chart mouse click listeners.

Parameters: event Information about the mouse event.

mouseDragged

public void mouseDragged(MouseEvent e)
Handles a 'mouse dragged' event.

Parameters: e the mouse 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.

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

Parameters: e the mouse event.

mouseMoved

public void mouseMoved(MouseEvent e)
Implementation of the MouseMotionListener's method.

Parameters: e the 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.

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.

Parameters: e information about the event.

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.

Parameters: g the graphics device for drawing on.

print

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.

removeChartMouseListener

public void removeChartMouseListener(ChartMouseListener listener)
Removes a listener from the list of objects listening for chart mouse events.

Parameters: listener the listener.

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.

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.

Returns: A new scaled rectangle.

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

setChart

public void setChart(JFreeChart chart)
Sets the chart that is displayed in the panel.

Parameters: chart the chart (null permitted).

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: javax.swing.ToolTipManager#setDismissDelay(int)

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

setDomainZoomable

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.

setEnforceFileExtensions

public void setEnforceFileExtensions(boolean enforce)
Sets a flag that controls whether or not file extensions are enforced.

Parameters: enforce the new flag value.

setFillZoomRectangle

public void setFillZoomRectangle(boolean flag)
A flag that controls how the zoom rectangle is drawn.

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

setHorizontalAxisTrace

public void setHorizontalAxisTrace(boolean flag)
A flag that controls trace lines on the horizontal axis.

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

setHorizontalTraceLine

protected void setHorizontalTraceLine(Line2D line)
Sets the horizontal trace line.

Parameters: line the line (null permitted).

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: javax.swing.ToolTipManager#setInitialDelay(int)

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.

setMaximumDrawWidth

public void setMaximumDrawWidth(int width)
Sets the maximum drawing width for the chart on this panel.

At the time the chart is drawn on the panel, if the available width is greater than this amount, the chart will be drawn using the maximum width then scaled up to fit the available space.

Parameters: width The width.

setMinimumDrawHeight

public void setMinimumDrawHeight(int height)
Sets the minimum drawing height for the chart on this panel.

At the time the chart is drawn on the panel, if the available height is less than this amount, the chart will be drawn using the minimum height then scaled down to fit the available space.

Parameters: height The height.

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.

setMouseZoomable

public void setMouseZoomable(boolean flag)
A convenience method that switches on mouse-based zooming.

Parameters: flag true enables 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 true if zooming enabled fillRectangle true if zoom rectangle is filled, false if rectangle is shown as outline only.

setPopupMenu

public void setPopupMenu(JPopupMenu popup)
Sets the popup menu for the panel.

Parameters: popup the popup menu (null permitted).

setRangeZoomable

public void setRangeZoomable(boolean flag)
A flag that controls mouse-based zooming on the vertical axis.

Parameters: flag true enables zooming.

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

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: javax.swing.ToolTipManager#setReshowDelay(int)

setVerticalAxisTrace

public void setVerticalAxisTrace(boolean flag)
A flag that controls trace lines on the vertical axis.

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

setVerticalTraceLine

protected void setVerticalTraceLine(Line2D line)
Sets the vertical trace line.

Parameters: line the line (null permitted).

setZoomInFactor

public void setZoomInFactor(double factor)
Sets the zoom in factor.

Parameters: factor the factor.

See Also: getZoomInFactor

setZoomOutFactor

public void setZoomOutFactor(double factor)
Sets the zoom out factor.

Parameters: factor the factor.

See Also: getZoomOutFactor

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

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 screen location to a Java2D point.

Parameters: screenPoint the screen location.

Returns: The Java2D coordinates.

zoom

public void zoom(Rectangle2D selection)
Zooms in on a selected region.

Parameters: selection the selected region.

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

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

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

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

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