com.jrefinery.chart
Class ChartPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.jrefinery.chart.ChartPanel
All Implemented Interfaces:
ChartPanelConstants, com.jrefinery.chart.event.ChartChangeListener, java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class ChartPanel
extends javax.swing.JPanel
implements ChartPanelConstants, java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.print.Printable, com.jrefinery.chart.event.ChartChangeListener

A Swing GUI component for displaying a JFreeChart.

The panel is registered to receive notification of changes to the chart, so that the chart can be redrawn automatically as required.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.JMenuItem addTaskItem
           
protected  javax.swing.JMenuItem all
           
protected  javax.swing.JMenuItem autoRangeBothMenuItem
          Menu item for resetting the zoom (both axes).
protected  javax.swing.JMenuItem autoRangeHorizontalMenuItem
          Menu item for resetting the zoom (horizontal axis only).
protected  javax.swing.JMenuItem autoRangeVerticalMenuItem
          Menu item for resetting the zoom (vertical axis only).
protected  javax.swing.JMenuItem chamber1
           
protected  javax.swing.JMenuItem chamber2
           
protected  javax.swing.JMenuItem chamber3
           
protected  javax.swing.JMenuItem chamber4
           
protected  JFreeChart chart
          The chart that is displayed in the panel.
protected  java.awt.Image chartBuffer
          A buffer for the rendered chart.
protected  int chartBufferHeight
          The height of the chart buffer.
protected  int chartBufferWidth
          The width of the chart buffer.
protected  java.util.List chartMouseListeners
          Storage for registered (chart) mouse listeners.
protected  java.util.List chartMouseMotionListeners
          Storage for registered (chart) mouse motion listeners.
protected  boolean fillZoomRectangle
          Controls if the zoom rectangle is drawn as an outline or filled.
protected  com.jrefinery.chart.demo.GanttDemo ganttDemo
           
protected  boolean horizontalAxisTrace
           
protected  boolean horizontalZoom
           
protected  ChartRenderingInfo info
          The drawing info collected the last time the chart was drawn.
protected  javax.swing.JMenuItem insertItem
           
protected  javax.swing.JMenuItem loadMissionItem
           
protected  int maximumDrawHeight
          The maximum height for drawing a chart (uses scaling for bigger heights).
protected  int maximumDrawWidth
          The maximum width for drawing a chart (uses scaling for bigger widths).
protected  int minimumDrawHeight
          The minimum height for drawing a chart (uses scaling for smaller heights).
protected  int minimumDrawWidth
          The minimum width for drawing a chart (uses scaling for smaller widths).
protected  javax.swing.JMenuItem pasteItem
           
protected  javax.swing.JMenu pasteTo
           
protected  javax.swing.JMenuItem pasteToChamber1
           
protected  javax.swing.JMenuItem pasteToChamber2
           
protected  javax.swing.JMenuItem pasteToChamber3
           
protected  javax.swing.JMenuItem pasteToChamber4
           
protected  javax.swing.JPopupMenu popup
          The popup menu for the frame.
protected  boolean refreshBuffer
          A flag that indicates that the buffer should be refreshed.
protected  javax.swing.JMenuItem saveMissionItem
           
protected  double scaleX
          The scale factor used to draw the chart.
protected  double scaleY
          The scale factor used to draw the chart.
protected  javax.swing.JMenu select
           
protected  javax.swing.JMenuItem undoCut
           
protected  boolean useBuffer
          A flag that controls whether or not the off-screen buffer is used.
protected  boolean verticalAxisTrace
           
protected  boolean verticalZoom
           
protected  javax.swing.JMenuItem zoomInBothAxesMenuItem
          Menu item for zooming in on a chart (both axes).
protected  javax.swing.JMenuItem zoomInHorizontalMenuItem
          Menu item for zooming in on a chart (horizontal axis).
protected  javax.swing.JMenuItem zoomInVerticalMenuItem
          Menu item for zooming in on a chart (vertical axis).
protected  javax.swing.JMenuItem zoomOutBothMenuItem
          Menu item for zooming out on a chart.
protected  javax.swing.JMenuItem zoomOutHorizontalMenuItem
          Menu item for zooming out on a chart (horizontal axis).
protected  javax.swing.JMenuItem zoomOutVerticalMenuItem
          Menu item for zooming out on a chart (vertical axis).
protected  java.awt.geom.Point2D zoomPoint
          The zoom rectangle starting point (selected by the user with a mouse click)
protected  java.awt.geom.Rectangle2D zoomRectangle
          The zoom rectangle (selected by the user with the mouse).
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface com.jrefinery.chart.ChartPanelConstants
ADDTASK_ACTION_COMMAND, AUTO_RANGE_BOTH_ACTION_COMMAND, AUTO_RANGE_HORIZONTAL_ACTION_COMMAND, AUTO_RANGE_VERTICAL_ACTION_COMMAND, COPY_ACTION_COMMAND, CUT_ACTION_COMMAND, DEFAULT_BUFFER_USED, DEFAULT_HEIGHT, DEFAULT_MAXIMUM_DRAW_HEIGHT, DEFAULT_MAXIMUM_DRAW_WIDTH, DEFAULT_MINIMUM_DRAW_HEIGHT, DEFAULT_MINIMUM_DRAW_WIDTH, DEFAULT_WIDTH, INJECT_TASK_PROPERTIES, INSERT_ACTION_COMMAND, LOAD_MISSION_COMMAND, MINIMUM_DRAG_ZOOM_SIZE, PASTE_ACTION_COMMAND, PASTE_CHAMBER_1_COMMAND, PASTE_CHAMBER_2_COMMAND, PASTE_CHAMBER_3_COMMAND, PASTE_CHAMBER_4_COMMAND, PRINT_ACTION_COMMAND, PROPERTIES_ACTION_COMMAND, SAMPLE_TASK_PROPERTIES, SAVE_ACTION_COMMAND, SAVE_MISSION_COMMAND, SELECT_ALL_COMMAND, SELECT_CHAMBER_1_COMMAND, SELECT_CHAMBER_2_COMMAND, SELECT_CHAMBER_3_COMMAND, SELECT_CHAMBER_4_COMMAND, STIRRER_TASK_PROPERTIES, TASK_PROPERTIES_ACTION_COMMAND, UNDO_CUT_COMMAND, ZOOM_IN_BOTH_ACTION_COMMAND, ZOOM_IN_HORIZONTAL_ACTION_COMMAND, ZOOM_IN_VERTICAL_ACTION_COMMAND, ZOOM_OUT_BOTH_ACTION_COMMAND, ZOOM_OUT_HORIZONTAL_ACTION_COMMAND, ZOOM_OUT_VERTICAL_ACTION_COMMAND
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ChartPanel(JFreeChart chart)
          Constructs a JFreeChart panel.
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
 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 addChartMouseMotionListener(ChartMouseMotionListener listener)
          Adds a mouse motion listener to the list of objects listening for chart mouse motion events.
 void autoRangeBoth()
          Restores the auto-range calculation on both axes.
 void autoRangeHorizontal()
          Restores the auto-range calculation on the horizontal axis.
 void autoRangeVertical()
          Restores the auto-range calculation on the vertical axis.
 void chartChanged(com.jrefinery.chart.event.ChartChangeEvent event)
          Receives notification of changes to the chart, and redraws the chart.
 void createChartPrintJob()
          Creates a print job for the chart.
 void createMenuItems()
           
protected  javax.swing.JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom)
          Creates a popup menu for the panel.
 void doSaveAs()
          Opens a file chooser and gives the user an opportunity to save the chart in PNG format.
 void enable()
           
 JFreeChart getChart()
          Returns the chart contained in the panel.
 ChartRenderingInfo getRenderingInfo()
          returns the rendering info object associated with the panel
 java.awt.geom.Rectangle2D getScaledDataArea()
          Returns the data area for the chart (the area inside the axes) with the current scaling applied.
 double getScaleX()
           
 double getScaleY()
           
 java.lang.String getToolTipText(java.awt.event.MouseEvent e)
          Returns a string for the tooltip.
 void mouseClicked(java.awt.event.MouseEvent event)
          Receives notification of mouse clicks on the panel...these are translated and passed on to any registered chart mouse click listeners.
 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 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 registerGanttDemo(com.jrefinery.chart.demo.GanttDemo ganttDemo)
           
 void removeChartMouseListener(ChartMouseListener listener)
          Removes a listener from the list of objects listening for chart mouse events.
 void removeMouseMotionListener(ChartMouseMotionListener listener)
          Removes a mouse motion listener from the list of objects listening for chart mouse motion events.
 void setChart(JFreeChart chart)
          Sets the chart that is displayed in the panel.
 void setClipboard(boolean clipboard)
           
 void setFillZoomRectangle(boolean flag)
          A flag that controls how the zoom rectangle is drawn.
 void setGenerateToolTips(boolean flag)
          Switches chart tooltip generation on or off.
 void setHorizontalAxisTrace(boolean flag)
          A flag that controls trace lines on the horizontal axis.
 void setHorizontalZoom(boolean flag)
          A flag that controls mouse-based zooming on the horizontal axis.
 void setMouseZoomable(boolean flag)
          A flag that controls mouse-based zooming.
 void setMouseZoomable(boolean flag, boolean fillRectangle)
          Controls mouse zooming and how the zoom rectangle is displayed
 void setRefreshBuffer(boolean flag)
          Sets the refresh buffer flag.
 void setVerticalAxisTrace(boolean flag)
          A flag that controls trace lines on the vertical axis.
 void setVerticalZoom(boolean flag)
          A flag that controls mouse-based zooming on the vertical axis.
 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 (measured in Java2D coordinates).
 void zoomInHorizontal(double x)
          Decreases the range on the horizontal axis, centered about a Java2D x coordinate.
 void zoomInVertical(double y)
          Decreases the range on the vertical axis, centered about a Java2D y coordinate.
 void zoomOutBoth(double x, double y)
          Zooms out on an anchor point (measured in Java2D coordinates).
 void zoomOutHorizontal(double x)
          Increases the range on the horizontal axis, centered about a Java2D x coordinate.
 void zoomOutVertical(double y)
          Increases the range on the vertical axis, centered about a Java2D y coordinate.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, 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, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

chart

protected JFreeChart chart
The chart that is displayed in the panel.


chartMouseListeners

protected java.util.List chartMouseListeners
Storage for registered (chart) mouse listeners.


chartMouseMotionListeners

protected java.util.List chartMouseMotionListeners
Storage for registered (chart) mouse motion listeners.


useBuffer

protected boolean useBuffer
A flag that controls whether or not the off-screen buffer is used.


refreshBuffer

protected boolean refreshBuffer
A flag that indicates that the buffer should be refreshed.


chartBuffer

protected java.awt.Image chartBuffer
A buffer for the rendered chart.


chartBufferHeight

protected int chartBufferHeight
The height of the chart buffer.


chartBufferWidth

protected int chartBufferWidth
The width of the chart buffer.


minimumDrawWidth

protected int minimumDrawWidth
The minimum width for drawing a chart (uses scaling for smaller widths).


minimumDrawHeight

protected int minimumDrawHeight
The minimum height for drawing a chart (uses scaling for smaller heights).


maximumDrawWidth

protected int maximumDrawWidth
The maximum width for drawing a chart (uses scaling for bigger widths).


maximumDrawHeight

protected int maximumDrawHeight
The maximum height for drawing a chart (uses scaling for bigger heights).


popup

protected javax.swing.JPopupMenu popup
The popup menu for the frame.


info

protected ChartRenderingInfo info
The drawing info collected the last time the chart was drawn.


scaleX

protected double scaleX
The scale factor used to draw the chart.


scaleY

protected double scaleY
The scale factor used to draw the chart.


zoomRectangle

protected java.awt.geom.Rectangle2D zoomRectangle
The zoom rectangle (selected by the user with the mouse).


zoomPoint

protected java.awt.geom.Point2D zoomPoint
The zoom rectangle starting point (selected by the user with a mouse click)


fillZoomRectangle

protected boolean fillZoomRectangle
Controls if the zoom rectangle is drawn as an outline or filled.


horizontalZoom

protected boolean horizontalZoom

verticalZoom

protected boolean verticalZoom

horizontalAxisTrace

protected boolean horizontalAxisTrace

verticalAxisTrace

protected boolean verticalAxisTrace

zoomInBothAxesMenuItem

protected javax.swing.JMenuItem zoomInBothAxesMenuItem
Menu item for zooming in on a chart (both axes).


zoomInHorizontalMenuItem

protected javax.swing.JMenuItem zoomInHorizontalMenuItem
Menu item for zooming in on a chart (horizontal axis).


zoomInVerticalMenuItem

protected javax.swing.JMenuItem zoomInVerticalMenuItem
Menu item for zooming in on a chart (vertical axis).


zoomOutBothMenuItem

protected javax.swing.JMenuItem zoomOutBothMenuItem
Menu item for zooming out on a chart.


zoomOutHorizontalMenuItem

protected javax.swing.JMenuItem zoomOutHorizontalMenuItem
Menu item for zooming out on a chart (horizontal axis).


zoomOutVerticalMenuItem

protected javax.swing.JMenuItem zoomOutVerticalMenuItem
Menu item for zooming out on a chart (vertical axis).


autoRangeBothMenuItem

protected javax.swing.JMenuItem autoRangeBothMenuItem
Menu item for resetting the zoom (both axes).


autoRangeHorizontalMenuItem

protected javax.swing.JMenuItem autoRangeHorizontalMenuItem
Menu item for resetting the zoom (horizontal axis only).


autoRangeVerticalMenuItem

protected javax.swing.JMenuItem autoRangeVerticalMenuItem
Menu item for resetting the zoom (vertical axis only).


ganttDemo

protected com.jrefinery.chart.demo.GanttDemo ganttDemo

pasteItem

protected javax.swing.JMenuItem pasteItem

insertItem

protected javax.swing.JMenuItem insertItem

addTaskItem

protected javax.swing.JMenuItem addTaskItem

saveMissionItem

protected javax.swing.JMenuItem saveMissionItem

loadMissionItem

protected javax.swing.JMenuItem loadMissionItem

select

protected javax.swing.JMenu select

all

protected javax.swing.JMenuItem all

chamber1

protected javax.swing.JMenuItem chamber1

chamber2

protected javax.swing.JMenuItem chamber2

chamber3

protected javax.swing.JMenuItem chamber3

chamber4

protected javax.swing.JMenuItem chamber4

pasteTo

protected javax.swing.JMenu pasteTo

pasteToChamber1

protected javax.swing.JMenuItem pasteToChamber1

pasteToChamber2

protected javax.swing.JMenuItem pasteToChamber2

pasteToChamber3

protected javax.swing.JMenuItem pasteToChamber3

pasteToChamber4

protected javax.swing.JMenuItem pasteToChamber4

undoCut

protected javax.swing.JMenuItem undoCut
Constructor Detail

ChartPanel

public ChartPanel(JFreeChart chart)
Constructs a JFreeChart panel.

Parameters:
chart - The chart.

ChartPanel

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

Parameters:
chart - 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.
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

registerGanttDemo

public void registerGanttDemo(com.jrefinery.chart.demo.GanttDemo ganttDemo)

getChart

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

Returns:
The chart.

setChart

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

Parameters:
chart - The chart.

setMouseZoomable

public void setMouseZoomable(boolean flag)
A flag that controls mouse-based zooming.


setMouseZoomable

public void setMouseZoomable(boolean flag,
                             boolean fillRectangle)
Controls mouse zooming and how the zoom rectangle is displayed

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

setHorizontalZoom

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


setFillZoomRectangle

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


setVerticalZoom

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


setHorizontalAxisTrace

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


setVerticalAxisTrace

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


setGenerateToolTips

public void setGenerateToolTips(boolean flag)
Switches chart tooltip generation on or off.

Parameters:
flag - The flag.

getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent e)
Returns a string for the tooltip.

Overrides:
getToolTipText in class javax.swing.JComponent

setRefreshBuffer

public void setRefreshBuffer(boolean flag)
Sets the refresh buffer flag.


paintComponent

public 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). To increase performance (at the expense of memory), an off-screen buffer image can be used.

Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - The graphics device for drawing on.

chartChanged

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

Specified by:
chartChanged in interface com.jrefinery.chart.event.ChartChangeListener
Parameters:
event - Details of the chart change event.

actionPerformed

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

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - The event.

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Handles a 'mouse entered' event. This method does nothing, but is required for implementation of the MouseListener interface.

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
e - The mouse event.

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Handles a 'mouse exited' event. This method does nothing, but is required for implementation of the MouseListener interface.

Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
e - The mouse event.

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Handles a 'mouse pressed' event.

This event is the popup trigger on Unix/Linux. For Windows, the popup trigger is the 'mouse released' event.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - The mouse event.

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Handles a 'mouse released' event.

On Windows, we need to check if this is a popup trigger, but only if we haven't already been tracking a zoom rectangle.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - Information about the event.

mouseClicked

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

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
event - Information about the mouse event.

mouseMoved

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

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
ev -

mouseDragged

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

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
e -

zoomInBoth

public void zoomInBoth(double x,
                       double y)
Zooms in on an anchor point (measured in Java2D coordinates).

Parameters:
x - The x value.
y - The y value.

zoomInHorizontal

public void zoomInHorizontal(double x)
Decreases the range on the horizontal axis, centered about a Java2D x coordinate.

The range on the x axis is halved.

Parameters:
The - x coordinate in Java2D space.

zoomInVertical

public void zoomInVertical(double y)
Decreases the range on the vertical axis, centered about a Java2D y coordinate.

The range on the y axis is halved.

Parameters:
The - y coordinate in Java2D space.

zoomOutBoth

public void zoomOutBoth(double x,
                        double y)
Zooms out on an anchor point (measured in Java2D coordinates).

Parameters:
x - The x value.
y - The y value.

zoomOutHorizontal

public void zoomOutHorizontal(double x)
Increases the range on the horizontal axis, centered about a Java2D x coordinate.

The range on the x axis is doubled.

Parameters:
The - x coordinate in Java2D space.

zoomOutVertical

public void zoomOutVertical(double y)
Increases the range on the vertical axis, centered about a Java2D y coordinate.

The range on the y axis is doubled.

Parameters:
The - y coordinate in Java2D space.

zoom

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

Parameters:
selection - The selected region.

autoRangeBoth

public void autoRangeBoth()
Restores the auto-range calculation on both axes.


autoRangeHorizontal

public void autoRangeHorizontal()
Restores the auto-range calculation on the horizontal axis.


autoRangeVertical

public void autoRangeVertical()
Restores the auto-range calculation on the vertical axis.


getScaledDataArea

public java.awt.geom.Rectangle2D getScaledDataArea()
Returns the data area for the chart (the area inside the axes) with the current scaling applied.

Returns:
The scaled data area.

doSaveAs

public void doSaveAs()
              throws java.io.IOException
Opens a file chooser and gives the user an opportunity to save the chart in PNG format.

Throws:
java.io.IOException

createChartPrintJob

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


print

public int print(java.awt.Graphics g,
                 java.awt.print.PageFormat pf,
                 int pageIndex)
Prints the chart on a single page.

Specified by:
print in interface java.awt.print.Printable

addChartMouseListener

public void addChartMouseListener(ChartMouseListener listener)
Adds a listener to the list of objects listening for chart mouse events.

Parameters:
listener - The listener.

removeChartMouseListener

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

Parameters:
listener - The listener.

addChartMouseMotionListener

public void addChartMouseMotionListener(ChartMouseMotionListener listener)
Adds a mouse motion listener to the list of objects listening for chart mouse motion events.

Parameters:
listener - The listener.

removeMouseMotionListener

public void removeMouseMotionListener(ChartMouseMotionListener listener)
Removes a mouse motion listener from the list of objects listening for chart mouse motion events.

Parameters:
listener - The listener.

createPopupMenu

protected javax.swing.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.

getRenderingInfo

public ChartRenderingInfo getRenderingInfo()
returns the rendering info object associated with the panel


setClipboard

public void setClipboard(boolean clipboard)

createMenuItems

public void createMenuItems()

getScaleX

public double getScaleX()

getScaleY

public double getScaleY()

enable

public void enable()
Overrides:
enable in class javax.swing.JComponent


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.