org.opensourcephysics.display
Class PlottingPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.opensourcephysics.display.DrawingPanel
                      extended byorg.opensourcephysics.display.InteractivePanel
                          extended byorg.opensourcephysics.display.PlottingPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, InteractiveMouseHandler, java.awt.MenuContainer, java.awt.print.Printable, Renderable, java.io.Serializable

public class PlottingPanel
extends InteractivePanel

A Drawing Panel that has an X axis, a Y axis, and a title.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.opensourcephysics.display.InteractivePanel
InteractivePanel.IADMouseController
 
Nested classes inherited from class org.opensourcephysics.display.DrawingPanel
DrawingPanel.ZoomBox
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class org.opensourcephysics.display.InteractivePanel
containsInteractive, interactive, MOUSE_CLICKED, MOUSE_DRAGGED, MOUSE_ENTERED, MOUSE_EXITED, MOUSE_MOVED, MOUSE_PRESSED, MOUSE_RELEASED, mouseAction, mouseEvent
 
Fields inherited from class org.opensourcephysics.display.DrawingPanel
antialiasShapeOn, antialiasTextOn, autoscaleMargin, autoscaleX, autoscaleY, bgColor, blMessageBox, BOTTOM_LEFT, BOTTOM_RIGHT, bottomGutter, brMessageBox, clipAtGutter, coordinateStrBuilder, customInspector, decimalFormat, dimensionSetter, drawableList, enableZoom, fixedPixelPerUnit, glassPanel, glassPanelLayout, height, leftGutter, mouseController, offscreenImage, optionController, pixelMatrix, pixelTransform, popupmenu, propertiesItem, rightGutter, scientificFormat, showCoordinates, squareAspect, tlMessageBox, TOP_LEFT, TOP_RIGHT, topGutter, trMessageBox, validImage, viewRect, width, workingImage, xceil, xfloor, xmax, xmaxPreferred, xmin, xminPreferred, xPixPerUnit, yceil, yfloor, ymax, ymaxPreferred, ymin, yminPreferred, yPixPerUnit, zoomBox, zoomMode
 
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 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
PlottingPanel(int _xAxisType, int _yAxisType)
          Constructs a new PlottingPanel that uses the given X axis type and Y axis type.
PlottingPanel(java.lang.String xlabel, java.lang.String ylabel, java.lang.String plotTitle)
          Constructs a new PlottingPanel that uses the given X axis label, Y axis label, and plot title.
PlottingPanel(java.lang.String xlabel, java.lang.String ylabel, java.lang.String plotTitle, int xAxisType, int yAxisType)
          Constructs a new PlottingPanel with cartesian axes that use the given X axis label, Y axis label, and plot title.
 
Method Summary
protected  void computeGutters()
          Computes the size of the gutters using a Dimensioned object.
static PlottingPanel createPolarType1(java.lang.String plotTitle, double deltaR)
          Constructs a new PlottingPanel with polar type 1 axes using the given title.
static PlottingPanel createPolarType2(java.lang.String plotTitle, double deltaR)
          Constructs a new PlottingPanel with polar type 2 axes using the given title.
static PlottingPanel createType1(java.lang.String xlabel, java.lang.String ylabel, java.lang.String plotTitle)
          Constructs a new PlottingPanel with cartesian type 1 axes using the given X axis label, Y axis label, and plot title.
static PlottingPanel createType2(java.lang.String xlabel, java.lang.String ylabel, java.lang.String plotTitle)
          Constructs a new PlottingPanel with cartesian type 2 axes using the given X axis label, Y axis label, and plot title.
static PlottingPanel createType3(java.lang.String xlabel, java.lang.String ylabel, java.lang.String plotTitle)
          Constructs a new PlottingPanel with cartesian type 3 axes using the given X axis label, Y axis label, and plot title.
 org.opensourcephysics.display.axes.DrawableAxes getAxes()
          Gets the axes.
 Interactive getInteractive()
          Gets the interactive drawable that was accessed by the last mouse event.
static XML.ObjectLoader getLoader()
          Returns an XML.ObjectLoader to save and load object data.
 java.awt.geom.AffineTransform getPixelTransform()
          Gets the affine transformation that converts from world to pixel coordinates.
 boolean isLogScaleX()
          Gets the logScaleX value.
 boolean isLogScaleY()
          Gets the logScaleY value.
protected  void paintFirst(java.awt.Graphics g)
          Paints before the panel iterates through its list of Drawables.
 double pixToX(int pix)
          Converts pixel to x world units.
 double pixToY(int pix)
          Converts pixel to x world units.
 void setAxes(org.opensourcephysics.display.axes.DrawableAxes _axes)
          Sets the axes.
 void setAxesVisible(boolean isVisible)
          Sets the visibility of the axes.
 void setCartesian(java.lang.String xLabel, java.lang.String yLabel, java.lang.String plotTitle)
          Converts this panel to cartesian coordinates.
 void setLogScale(boolean _logScaleX, boolean _logScaleY)
          Sets Cartesian axes to log scale.
 void setLogScaleX(boolean _logScaleX)
          Sets Cartesian x-axes to log scale.
 void setLogScaleY(boolean _logScaleY)
          Sets Cartesian axes to log scale.
 void setPixelScale()
          Calculates min and max values and the affine transformation based on the current size of the panel and the squareAspect boolean.
 void setPolar(java.lang.String plotTitle, double deltaR)
          Converts this panel to polar coordinates
 void setTitle(java.lang.String title)
          Sets the title.
 void setTitle(java.lang.String title, java.lang.String font_name)
          Sets the title and font.
 void setXLabel(java.lang.String label)
          Sets the label for the X (horizontal) axis.
 void setXLabel(java.lang.String label, java.lang.String font_name)
          Sets the label and font for the X (horizontal) axis.
 void setYLabel(java.lang.String label)
          Sets the label for the Y (vertical) axis.
 void setYLabel(java.lang.String label, java.lang.String font_name)
          Sets the label and font for the Y (vertical) axis.
 int xToPix(double x)
          Converts x from world to pixel units.
 int yToPix(double y)
          Converts y from world to pixel units.
 
Methods inherited from class org.opensourcephysics.display.InteractivePanel
addDrawable, clear, getMouseAction, getMouseButton, getMouseClickCount, getMouseIntX, getMouseIntY, getMouseX, getMouseY, handleMouseAction, saveMouseEvent, setInteractiveMouseHandler, setShowCoordinates
 
Methods inherited from class org.opensourcephysics.display.DrawingPanel
actionPerformed, addDrawables, buildPopupmenu, checkWorkingImage, enableInspector, findViewRect, getAspectRatio, getBottomGutter, getCoordinateStringBuilder, getDimensionSetter, getDrawables, getDrawables, getGlassPanel, getGutters, getLeftGutter, getMaxPixPerUnit, getMeasure, getObjectOfClass, getPixelMatrix, getPopupMenu, getPreferredXMax, getPreferredXMin, getPreferredYMax, getPreferredYMin, getRightGutter, getScale, getTopGutter, getVideoCaptureTool, getViewRect, getXMax, getXMin, getXPixPerUnit, getYMax, getYMin, getYPixPerUnit, hasInspector, hideInspector, invalidateImage, isAntialiasShapeOn, isAntialiasTextOn, isAutoscaleX, isAutoscaleY, isBuffered, isClipAtGutter, isIconified, isPointInside, isSquareAspect, isZoom, limitAutoscaleX, limitAutoscaleY, measure, paintComponent, paintDrawableList, paintEverything, paintLast, print, project, removeDrawable, removeDrawables, removeObjectsOfClass, removeOptionController, render, render, replaceDrawable, scale, scale, scaleX, scaleY, setAntialiasShapeOn, setAntialiasTextOn, setAutoscaleMargin, setAutoscaleX, setAutoscaleY, setBounds, setBounds, setBuffered, setClipAtGutter, setCoordinateStringBuilder, setCustomInspector, setFontLevel, setGutters, setGutters, setIgnoreRepaint, setMessage, setMessage, setMouseCursor, setPixelsPerUnit, setPopupMenu, setPreferredMinMax, setPreferredMinMaxX, setPreferredMinMaxY, setSquareAspect, setVideoCaptureTool, setVisible, setZoom, showInspector, snapshot, zoomIn, zoomOut
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, 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
 

Constructor Detail

PlottingPanel

public PlottingPanel(java.lang.String xlabel,
                     java.lang.String ylabel,
                     java.lang.String plotTitle)
Constructs a new PlottingPanel that uses the given X axis label, Y axis label, and plot title.

Parameters:
xlabel - The X axis label.
ylabel - The Y axis label.
plotTitle - The plot title.

PlottingPanel

public PlottingPanel(int _xAxisType,
                     int _yAxisType)
Constructs a new PlottingPanel that uses the given X axis type and Y axis type.

Parameters:
_xAxisType - The X axis type.
_yAxisType - The Y axis type.

PlottingPanel

public PlottingPanel(java.lang.String xlabel,
                     java.lang.String ylabel,
                     java.lang.String plotTitle,
                     int xAxisType,
                     int yAxisType)
Constructs a new PlottingPanel with cartesian axes that use the given X axis label, Y axis label, and plot title.

Parameters:
xlabel - The X axis label.
ylabel - The Y axis label.
plotTitle - The plot title.
xAxisType - Description of Parameter
yAxisType - Description of Parameter
Method Detail

createType1

public static PlottingPanel createType1(java.lang.String xlabel,
                                        java.lang.String ylabel,
                                        java.lang.String plotTitle)
Constructs a new PlottingPanel with cartesian type 1 axes using the given X axis label, Y axis label, and plot title.

Parameters:
xlabel - The X axis label.
ylabel - The Y axis label.
plotTitle - The plot title.

createType2

public static PlottingPanel createType2(java.lang.String xlabel,
                                        java.lang.String ylabel,
                                        java.lang.String plotTitle)
Constructs a new PlottingPanel with cartesian type 2 axes using the given X axis label, Y axis label, and plot title.

Parameters:
xlabel - The X axis label.
ylabel - The Y axis label.
plotTitle - The plot title.

createPolarType1

public static PlottingPanel createPolarType1(java.lang.String plotTitle,
                                             double deltaR)
Constructs a new PlottingPanel with polar type 1 axes using the given title.

Parameters:
plotTitle - the plot title.

createPolarType2

public static PlottingPanel createPolarType2(java.lang.String plotTitle,
                                             double deltaR)
Constructs a new PlottingPanel with polar type 2 axes using the given title.

Parameters:
plotTitle - the plot title.

createType3

public static PlottingPanel createType3(java.lang.String xlabel,
                                        java.lang.String ylabel,
                                        java.lang.String plotTitle)
Constructs a new PlottingPanel with cartesian type 3 axes using the given X axis label, Y axis label, and plot title.

Parameters:
xlabel - The X axis label.
ylabel - The Y axis label.
plotTitle - The plot title.

getInteractive

public Interactive getInteractive()
Gets the interactive drawable that was accessed by the last mouse event. This methods overrides the default implemenation in order to check for draggable axes.

Overrides:
getInteractive in class InteractivePanel
Returns:
the interactive object

getAxes

public org.opensourcephysics.display.axes.DrawableAxes getAxes()
Gets the axes.

Returns:
the axes

setAxes

public void setAxes(org.opensourcephysics.display.axes.DrawableAxes _axes)
Sets the axes.

Parameters:
_axes - the new axes

setPolar

public void setPolar(java.lang.String plotTitle,
                     double deltaR)
Converts this panel to polar coordinates

Parameters:
plotTitle - String
deltaR - double

setCartesian

public void setCartesian(java.lang.String xLabel,
                         java.lang.String yLabel,
                         java.lang.String plotTitle)
Converts this panel to cartesian coordinates.

Parameters:
xLabel - String
yLabel - String
plotTitle - String

setXLabel

public void setXLabel(java.lang.String label)
Sets the label for the X (horizontal) axis.

Parameters:
label - the label

setYLabel

public void setYLabel(java.lang.String label)
Sets the label for the Y (vertical) axis.

Parameters:
label - the label

setTitle

public void setTitle(java.lang.String title)
Sets the title.

Parameters:
title - the title

setXLabel

public void setXLabel(java.lang.String label,
                      java.lang.String font_name)
Sets the label and font for the X (horizontal) axis. If the font name is null, the font is unchanged.

Parameters:
label - the label
font_name - the optional new font

setYLabel

public void setYLabel(java.lang.String label,
                      java.lang.String font_name)
Sets the label and font for the Y (vertical) axis. If the font name is null, the font is unchanged.

Parameters:
label - the label
font_name - the optional new font

setTitle

public void setTitle(java.lang.String title,
                     java.lang.String font_name)
Sets the title and font. If the font name is null, the font is unchanged.

Parameters:
title -
font_name - the optional new font

setAxesVisible

public void setAxesVisible(boolean isVisible)
Sets the visibility of the axes. Axes that are not visible will not be drawn.

Parameters:
isVisible -

setLogScale

public void setLogScale(boolean _logScaleX,
                        boolean _logScaleY)
Sets Cartesian axes to log scale.

Parameters:
_logScaleX - The new logScale value
_logScaleY - The new logScale value

setLogScaleX

public void setLogScaleX(boolean _logScaleX)
Sets Cartesian x-axes to log scale.

Parameters:
_logScaleX - The new logScale value

isLogScaleX

public boolean isLogScaleX()
Gets the logScaleX value.

Returns:
boolean

setLogScaleY

public void setLogScaleY(boolean _logScaleY)
Sets Cartesian axes to log scale.

Parameters:
_logScaleY - The new logScale value

isLogScaleY

public boolean isLogScaleY()
Gets the logScaleY value.

Returns:
boolean

computeGutters

protected void computeGutters()
Computes the size of the gutters using a Dimensioned object. Gutters are usually set by the axes to insure that there is enough space for axes labels. Other objects can, however, perform this function by implementing the Dimensioned interface.

Overrides:
computeGutters in class DrawingPanel

paintFirst

protected void paintFirst(java.awt.Graphics g)
Paints before the panel iterates through its list of Drawables.

Overrides:
paintFirst in class DrawingPanel
Parameters:
g - Graphics

pixToX

public double pixToX(int pix)
Converts pixel to x world units.

Overrides:
pixToX in class DrawingPanel
Parameters:
pix -
Returns:
x panel units

xToPix

public int xToPix(double x)
Converts x from world to pixel units.

Overrides:
xToPix in class DrawingPanel
Parameters:
x -
Returns:
the pixel value of the x coordinate

pixToY

public double pixToY(int pix)
Converts pixel to x world units.

Overrides:
pixToY in class DrawingPanel
Parameters:
pix -
Returns:
x panel units

yToPix

public int yToPix(double y)
Converts y from world to pixel units.

Overrides:
yToPix in class DrawingPanel
Parameters:
y -
Returns:
the pixel value of the y coordinate

setPixelScale

public void setPixelScale()
Calculates min and max values and the affine transformation based on the current size of the panel and the squareAspect boolean.

Overrides:
setPixelScale in class DrawingPanel

getPixelTransform

public java.awt.geom.AffineTransform getPixelTransform()
Gets the affine transformation that converts from world to pixel coordinates.

Overrides:
getPixelTransform in class DrawingPanel
Returns:
the affine transformation

getLoader

public static XML.ObjectLoader getLoader()
Returns an XML.ObjectLoader to save and load object data.

Returns:
the XML.ObjectLoader