public class ChartPanel extends javax.swing.JPanel implements ChartChangeListener, ChartProgressListener, java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, OverlayChangeListener, java.awt.print.Printable, java.io.Serializable
JFreeChart
object.
The panel registers with the chart to receive notification of changes to any component of the chart. The chart is redrawn automatically whenever this notification is received.
javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPY_COMMAND
Copy action command.
|
static boolean |
DEFAULT_BUFFER_USED
Default setting for buffer usage.
|
static int |
DEFAULT_HEIGHT
The default panel height.
|
static int |
DEFAULT_MAXIMUM_DRAW_HEIGHT
The default limit above which chart scaling kicks in.
|
static int |
DEFAULT_MAXIMUM_DRAW_WIDTH
The default limit above which chart scaling kicks in.
|
static int |
DEFAULT_MINIMUM_DRAW_HEIGHT
The default limit below which chart scaling kicks in.
|
static int |
DEFAULT_MINIMUM_DRAW_WIDTH
The default limit below which chart scaling kicks in.
|
static int |
DEFAULT_WIDTH
The default panel width.
|
static int |
DEFAULT_ZOOM_TRIGGER_DISTANCE
The minimum size required to perform a zoom on a rectangle
|
protected static java.util.ResourceBundle |
localizationResources
The resourceBundle for the localization.
|
static java.lang.String |
PRINT_COMMAND
Print action command.
|
static java.lang.String |
PROPERTIES_COMMAND
Properties action command.
|
static java.lang.String |
SAVE_COMMAND
Save action command.
|
static java.lang.String |
ZOOM_IN_BOTH_COMMAND
Zoom in (both axes) action command.
|
static java.lang.String |
ZOOM_IN_DOMAIN_COMMAND
Zoom in (domain axis only) action command.
|
static java.lang.String |
ZOOM_IN_RANGE_COMMAND
Zoom in (range axis only) action command.
|
static java.lang.String |
ZOOM_OUT_BOTH_COMMAND
Zoom out (both axes) action command.
|
static java.lang.String |
ZOOM_OUT_DOMAIN_COMMAND
Zoom out (domain axis only) action command.
|
static java.lang.String |
ZOOM_OUT_RANGE_COMMAND
Zoom out (range axis only) action command.
|
static java.lang.String |
ZOOM_RESET_BOTH_COMMAND
Zoom reset (both axes) action command.
|
static java.lang.String |
ZOOM_RESET_DOMAIN_COMMAND
Zoom reset (domain axis only) action command.
|
static java.lang.String |
ZOOM_RESET_RANGE_COMMAND
Zoom reset (range axis only) action command.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.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.
|
protected javax.swing.JPopupMenu |
createPopupMenu(boolean properties,
boolean save,
boolean print,
boolean zoom)
Creates a popup menu for the panel.
|
protected javax.swing.JPopupMenu |
createPopupMenu(boolean properties,
boolean copy,
boolean save,
boolean print,
boolean zoom)
Creates a popup menu for the panel.
|
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.
|
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.
|
java.awt.geom.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.
|
java.io.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.
|
protected java.awt.geom.Line2D |
getHorizontalTraceLine()
Returns the horizontal trace line.
|
int |
getInitialDelay()
Returns the initial tooltip delay value used inside this chart panel.
|
java.util.EventListener[] |
getListeners(java.lang.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.
|
javax.swing.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.
|
java.awt.geom.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).
|
java.awt.geom.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.
|
java.lang.String |
getToolTipText(java.awt.event.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.
|
protected java.awt.geom.Line2D |
getVerticalTraceLine()
Returns the vertical trace line.
|
boolean |
getZoomAroundAnchor()
Returns the flag that controls whether or not zoom operations are
centered around the current anchor point.
|
java.awt.Paint |
getZoomFillPaint()
Returns the zoom rectangle fill paint.
|
double |
getZoomInFactor()
Returns the zoom in factor.
|
double |
getZoomOutFactor()
Returns the zoom out factor.
|
java.awt.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(java.awt.event.MouseEvent event)
Receives notification of mouse clicks on the panel.
|
void |
mouseDragged(java.awt.event.MouseEvent e)
Handles a 'mouse dragged' event.
|
void |
mouseEntered(java.awt.event.MouseEvent e)
Handles a 'mouse entered' event.
|
void |
mouseExited(java.awt.event.MouseEvent e)
Handles a 'mouse exited' event.
|
void |
mouseMoved(java.awt.event.MouseEvent e)
Implementation of the MouseMotionListener's method.
|
void |
mousePressed(java.awt.event.MouseEvent e)
Handles a 'mouse pressed' event.
|
void |
mouseReleased(java.awt.event.MouseEvent e)
Handles a 'mouse released' event.
|
void |
overlayChanged(OverlayChangeEvent event)
Handles a change to an overlay by repainting the panel.
|
void |
paintComponent(java.awt.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(java.awt.Graphics g,
java.awt.print.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.
|
java.awt.geom.Rectangle2D |
scale(java.awt.geom.Rectangle2D rect)
Applies any scaling that is in effect for the chart drawing to the
given rectangle.
|
protected void |
setAnchor(java.awt.geom.Point2D anchor)
Sets the anchor point.
|
void |
setChart(JFreeChart chart)
Sets the chart that is displayed in the panel.
|
void |
setDefaultDirectoryForSaveAs(java.io.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 enabled 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.
|
protected void |
setHorizontalTraceLine(java.awt.geom.Line2D line)
Sets the horizontal trace line.
|
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(javax.swing.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.
|
protected void |
setVerticalTraceLine(java.awt.geom.Line2D line)
Sets the vertical trace line.
|
void |
setZoomAroundAnchor(boolean zoomAroundAnchor)
Sets the flag that controls whether or not zoom operations are
centered around the current anchor point.
|
void |
setZoomFillPaint(java.awt.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(java.awt.Paint paint)
Sets the zoom rectangle outline paint.
|
void |
setZoomTriggerDistance(int distance)
Sets the zoom trigger distance.
|
java.awt.Point |
translateJava2DToScreen(java.awt.geom.Point2D java2DPoint)
Translates a Java2D point on the chart to a screen location.
|
java.awt.geom.Point2D |
translateScreenToJava2D(java.awt.Point screenPoint)
Translates a panel (component) location to a Java2D point.
|
void |
updateUI()
Updates the UI for a LookAndFeel change.
|
void |
zoom(java.awt.geom.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.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI
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
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
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, getPeer, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final boolean DEFAULT_BUFFER_USED
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).public static final int DEFAULT_WIDTH
public static final int DEFAULT_HEIGHT
public static final int DEFAULT_MINIMUM_DRAW_WIDTH
public static final int DEFAULT_MINIMUM_DRAW_HEIGHT
public static final int DEFAULT_MAXIMUM_DRAW_WIDTH
public static final int DEFAULT_MAXIMUM_DRAW_HEIGHT
public static final int DEFAULT_ZOOM_TRIGGER_DISTANCE
public static final java.lang.String PROPERTIES_COMMAND
public static final java.lang.String COPY_COMMAND
public static final java.lang.String SAVE_COMMAND
public static final java.lang.String PRINT_COMMAND
public static final java.lang.String ZOOM_IN_BOTH_COMMAND
public static final java.lang.String ZOOM_IN_DOMAIN_COMMAND
public static final java.lang.String ZOOM_IN_RANGE_COMMAND
public static final java.lang.String ZOOM_OUT_BOTH_COMMAND
public static final java.lang.String ZOOM_OUT_DOMAIN_COMMAND
public static final java.lang.String ZOOM_OUT_RANGE_COMMAND
public static final java.lang.String ZOOM_RESET_BOTH_COMMAND
public static final java.lang.String ZOOM_RESET_DOMAIN_COMMAND
public static final java.lang.String ZOOM_RESET_RANGE_COMMAND
protected static java.util.ResourceBundle localizationResources
public ChartPanel(JFreeChart chart)
chart
- the chart.public ChartPanel(JFreeChart chart, boolean useBuffer)
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.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)
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)
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)
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 JFreeChart getChart()
null
).public void setChart(JFreeChart chart)
chart
- the chart (null
permitted).public int getMinimumDrawWidth()
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.
public void setMinimumDrawWidth(int width)
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.
width
- The width.public int getMaximumDrawWidth()
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.
public void setMaximumDrawWidth(int width)
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.
width
- The width.public int getMinimumDrawHeight()
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.
public void setMinimumDrawHeight(int height)
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.
height
- The height.public int getMaximumDrawHeight()
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.
public void setMaximumDrawHeight(int height)
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.
height
- The height.public double getScaleX()
public double getScaleY()
public java.awt.geom.Point2D getAnchor()
null
).protected void setAnchor(java.awt.geom.Point2D anchor)
anchor
- the anchor point (null
permitted).public javax.swing.JPopupMenu getPopupMenu()
public void setPopupMenu(javax.swing.JPopupMenu popup)
popup
- the popup menu (null
permitted).public ChartRenderingInfo getChartRenderingInfo()
public void setMouseZoomable(boolean flag)
flag
- true
enables zooming and rectangle fill on
zoom.public void setMouseZoomable(boolean flag, boolean fillRectangle)
flag
- true
if zooming enabledfillRectangle
- true
if zoom rectangle is filled,
false if rectangle is shown as outline only.public boolean isDomainZoomable()
public void setDomainZoomable(boolean flag)
flag
- true
enables zooming if possible.public boolean isRangeZoomable()
public void setRangeZoomable(boolean flag)
flag
- true
enables zooming.public boolean getFillZoomRectangle()
public void setFillZoomRectangle(boolean flag)
flag
- true
instructs to fill the rectangle on
zoom, otherwise it will be outlined.public int getZoomTriggerDistance()
public void setZoomTriggerDistance(int distance)
distance
- the distance (in Java2D units).public boolean getHorizontalAxisTrace()
public void setHorizontalAxisTrace(boolean flag)
flag
- true
enables trace lines for the mouse
pointer on the horizontal axis.protected java.awt.geom.Line2D getHorizontalTraceLine()
null
).protected void setHorizontalTraceLine(java.awt.geom.Line2D line)
line
- the line (null
permitted).public boolean getVerticalAxisTrace()
public void setVerticalAxisTrace(boolean flag)
flag
- true
enables trace lines for the mouse
pointer on the vertical axis.protected java.awt.geom.Line2D getVerticalTraceLine()
null
).protected void setVerticalTraceLine(java.awt.geom.Line2D line)
line
- the line (null
permitted).public java.io.File getDefaultDirectoryForSaveAs()
null
).public void setDefaultDirectoryForSaveAs(java.io.File directory)
null
, the user's default directory will be used.directory
- the directory (null
permitted).public boolean isEnforceFileExtensions()
true
if file extensions should be enforced, and
false
otherwise.setEnforceFileExtensions(boolean)
public void setEnforceFileExtensions(boolean enforce)
enforce
- the new flag value.isEnforceFileExtensions()
public boolean getZoomAroundAnchor()
setZoomAroundAnchor(boolean)
public void setZoomAroundAnchor(boolean zoomAroundAnchor)
zoomAroundAnchor
- the new flag value.getZoomAroundAnchor()
public java.awt.Paint getZoomFillPaint()
null
).setZoomFillPaint(java.awt.Paint)
,
setFillZoomRectangle(boolean)
public void setZoomFillPaint(java.awt.Paint paint)
paint
- the paint (null
not permitted).getZoomFillPaint()
,
getFillZoomRectangle()
public java.awt.Paint getZoomOutlinePaint()
null
).setZoomOutlinePaint(java.awt.Paint)
,
setFillZoomRectangle(boolean)
public void setZoomOutlinePaint(java.awt.Paint paint)
paint
- the paint (null
not permitted).getZoomOutlinePaint()
,
getFillZoomRectangle()
public boolean isMouseWheelEnabled()
true
if the mouse wheel handler is enabled, and
false
otherwise.public void setMouseWheelEnabled(boolean flag)
flag
- a boolean.public void addOverlay(Overlay overlay)
overlay
- the overlay (null
not permitted).public void removeOverlay(Overlay overlay)
overlay
- the overlay to remove (null
not permitted).public void overlayChanged(OverlayChangeEvent event)
overlayChanged
in interface OverlayChangeListener
event
- the event.public void setDisplayToolTips(boolean flag)
flag
- true
to enable tooltips, false
to
disable tooltips.public java.lang.String getToolTipText(java.awt.event.MouseEvent e)
getToolTipText
in class javax.swing.JComponent
e
- the mouse event.null
if no tooltip is available.public java.awt.Point translateJava2DToScreen(java.awt.geom.Point2D java2DPoint)
java2DPoint
- the Java2D point.public java.awt.geom.Point2D translateScreenToJava2D(java.awt.Point screenPoint)
screenPoint
- the screen location (null
not
permitted).public java.awt.geom.Rectangle2D scale(java.awt.geom.Rectangle2D rect)
rect
- the rectangle (null
not permitted).public ChartEntity getEntityForPoint(int viewX, int viewY)
This method will return null if there is (a) no entity at the given point, or (b) no entity collection has been generated.
viewX
- the x-coordinate.viewY
- the y-coordinate.null
).public boolean getRefreshBuffer()
public void setRefreshBuffer(boolean flag)
flag
- true
indicates that the buffer should be
refreshed.public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
g
- the graphics device for drawing on.public void chartChanged(ChartChangeEvent event)
chartChanged
in interface ChartChangeListener
event
- details of the chart change event.public void chartProgress(ChartProgressEvent event)
chartProgress
in interface ChartProgressListener
event
- the event.public void actionPerformed(java.awt.event.ActionEvent event)
actionPerformed
in interface java.awt.event.ActionListener
event
- the event.public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
e
- the mouse event.public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
e
- the mouse event.public void mousePressed(java.awt.event.MouseEvent e)
This event is the popup trigger on Unix/Linux. For Windows, the popup trigger is the 'mouse released' event.
mousePressed
in interface java.awt.event.MouseListener
e
- The mouse event.public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
e
- the mouse event.public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
e
- information about the event.public void mouseClicked(java.awt.event.MouseEvent event)
ChartMouseListener
s.mouseClicked
in interface java.awt.event.MouseListener
event
- Information about the mouse event.public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
e
- the event.public void zoomInBoth(double x, double y)
x
- the x value (in screen coordinates).y
- the y value (in screen coordinates).public void zoomInDomain(double x, double y)
getZoomInFactor()
.x
- the x coordinate (in screen coordinates).y
- the y-coordinate (in screen coordinates).public void zoomInRange(double x, double y)
getZoomInFactor()
.x
- the x-coordinate (in screen coordinates).y
- the y coordinate (in screen coordinates).public void zoomOutBoth(double x, double y)
x
- the x value (in screen coordinates).y
- the y value (in screen coordinates).public void zoomOutDomain(double x, double y)
getZoomOutFactor()
.x
- the x coordinate (in screen coordinates).y
- the y-coordinate (in screen coordinates).public void zoomOutRange(double x, double y)
getZoomOutFactor()
.x
- the x coordinate (in screen coordinates).y
- the y-coordinate (in screen coordinates).public void zoom(java.awt.geom.Rectangle2D selection)
selection
- the selected region.public void restoreAutoBounds()
public void restoreAutoDomainBounds()
public void restoreAutoRangeBounds()
public java.awt.geom.Rectangle2D getScreenDataArea()
public java.awt.geom.Rectangle2D getScreenDataArea(int x, int y)
x
- the x-coordinate (for subplot selection).y
- the y-coordinate (for subplot selection).public int getInitialDelay()
ToolTipManager.getInitialDelay()
public int getReshowDelay()
ToolTipManager.getReshowDelay()
public int getDismissDelay()
ToolTipManager.getDismissDelay()
public void setInitialDelay(int delay)
delay
- the number of milliseconds to delay (after the cursor has
paused) before displaying.ToolTipManager.setInitialDelay(int)
public void setReshowDelay(int delay)
delay
- time in millisecondsToolTipManager.setReshowDelay(int)
public void setDismissDelay(int delay)
delay
- the number of milliseconds to delay before taking away the
tooltipToolTipManager.setDismissDelay(int)
public double getZoomInFactor()
setZoomInFactor(double)
public void setZoomInFactor(double factor)
factor
- the factor.getZoomInFactor()
public double getZoomOutFactor()
setZoomOutFactor(double)
public void setZoomOutFactor(double factor)
factor
- the factor.getZoomOutFactor()
public void doEditChartProperties()
public void doCopy()
public void doSaveAs() throws java.io.IOException
java.io.IOException
- if there is an I/O error.public void createChartPrintJob()
public int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int pageIndex)
print
in interface java.awt.print.Printable
g
- the graphics context.pf
- the page format to use.pageIndex
- the index of the page. If not 0
, nothing
gets print.public void addChartMouseListener(ChartMouseListener listener)
listener
- the listener (null
not permitted).public void removeChartMouseListener(ChartMouseListener listener)
listener
- the listener.public java.util.EventListener[] getListeners(java.lang.Class listenerType)
getListeners
in class javax.swing.JComponent
listenerType
- the listener type.protected javax.swing.JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom)
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.protected javax.swing.JPopupMenu createPopupMenu(boolean properties, boolean copy, boolean save, boolean print, boolean zoom)
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.protected void displayPopupMenu(int x, int y)
x
- horizontal position of the popup.y
- vertical position of the popup.public void updateUI()
updateUI
in class javax.swing.JPanel