org.opensourcephysics.display
Class PlottingPanel

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 org.opensourcephysics.display.DrawingPanel
                      extended by org.opensourcephysics.display.InteractivePanel
                          extended by org.opensourcephysics.display.PlottingPanel
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, InteractiveMouseHandler, Renderable

public class PlottingPanel
extends InteractivePanel

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

Author:
Wolfgang Christian
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.opensourcephysics.display.InteractivePanel
InteractivePanel.IADMouseController
 
Nested classes/interfaces inherited from class org.opensourcephysics.display.DrawingPanel
DrawingPanel.ZoomBox
 
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
 
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
adjustableGutter, antialiasShapeOn, antialiasTextOn, autoscaleItem, autoscaleMargin, autoscaleX, autoscaleXMax, autoscaleXMin, autoscaleY, autoscaleYMax, autoscaleYMin, bgColor, blMessageBox, BOTTOM_LEFT, BOTTOM_RIGHT, bottomGutter, bottomGutterPreferred, brMessageBox, clipAtGutter, coordinateStrBuilder, customInspector, decimalFormat, dimensionSetter, drawableList, enableZoom, fixedPixelPerUnit, fixedScale, glassPanel, glassPanelLayout, height, leftGutter, leftGutterPreferred, mouseController, offscreenImage, optionController, pixelMatrix, pixelTransform, popupmenu, propertiesItem, rightGutter, rightGutterPreferred, scaleItem, scientificFormat, showCoordinates, snapshotItem, squareAspect, tlMessageBox, TOP_LEFT, TOP_RIGHT, topGutter, topGutterPreferred, trMessageBox, viewRect, width, workingImage, xceil, xfloor, xLeftMarginPercentage, xmax, xmaxPreferred, xmin, xminPreferred, xPixPerUnit, xRightMarginPercentage, yBottomMarginPercentage, yceil, yfloor, ymax, ymaxPreferred, ymin, yminPreferred, yPixPerUnit, yTopMarginPercentage, zoomBox, zoomInItem, zoomOutItem
 
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.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.
 DrawableAxes getAxes()
          Gets the axes.
 int getBottomGutter()
          Gets the bottom gutter of this DrawingPanel.
 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.
 int getTopGutter()
          Gets the bottom gutter of this DrawingPanel.
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 recomputeTransform()
          Recomputes the pixel transformation based on the current minimum and maximum values and the gutters.
 void setAxes(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.
 float xToGraphics(double x)
          Converts x from world to graphics device units.
 int xToPix(double x)
          Converts x from world to pixel units.
 float yToGraphics(double y)
          Converts y from world to graphics device units.
 int yToPix(double y)
          Converts y from world to pixel units.
 
Methods inherited from class org.opensourcephysics.display.InteractivePanel
addDrawable, clear, getCurrentDraggable, getMouseAction, getMouseButton, getMouseClickCount, getMouseIntX, getMouseIntY, getMouseX, getMouseY, handleMouseAction, saveMouseEvent, scaleX, scaleY, setInteractiveMouseHandler, setShowCoordinates
 
Methods inherited from class org.opensourcephysics.display.DrawingPanel
actionPerformed, addDrawableAtIndex, addDrawables, buildPopupmenu, checkWorkingImage, enableInspector, findViewRect, getAspectRatio, getCoordinateStringBuilder, getDimensionSetter, getDrawables, getDrawables, getGlassPanel, getGutters, getHeight, getImageRatio, getLeftGutter, getMaxPixPerUnit, getMeasure, getObjectOfClass, getPixelMatrix, getPopupMenu, getPreferredXMax, getPreferredXMin, getPreferredYMax, getPreferredYMin, getRightGutter, getScale, getVideoTool, getViewRect, getWidth, getXMax, getXMin, getXPixPerUnit, getYMax, getYMin, getYPixPerUnit, getZoomBox, hasInspector, hideInspector, invalidateImage, isAdjustableGutter, isAntialiasShapeOn, isAntialiasTextOn, isAutoscaleX, isAutoscaleXMax, isAutoscaleXMin, isAutoscaleY, isAutoscaleYMax, isAutoscaleYMin, isBuffered, isClipAtGutter, isFixedScale, isIconified, isLogScaleX, isLogScaleY, isPointInside, isSquareAspect, isValidImage, isZoom, limitAutoscaleX, limitAutoscaleY, measure, paint, paintComponent, paintDrawableList, paintEverything, paintLast, project, refreshGUI, removeDrawable, removeDrawables, removeObjectsOfClass, removeOptionController, render, render, replaceDrawable, resetGutters, scale, scale, scaleX, scaleY, setAdjustableGutter, setAntialiasShapeOn, setAntialiasTextOn, setAutoscaleMargin, setAutoscaleX, setAutoscaleY, setBounds, setBounds, setBuffered, setClipAtGutter, setCoordinateStringBuilder, setCustomInspector, setFixedScale, setFontLevel, setGutters, setGutters, setIgnoreRepaint, setMessage, setMessage, setMouseCursor, setPixelsPerUnit, setPopupMenu, setPreferredGutters, setPreferredMinMax, setPreferredMinMax, setPreferredMinMaxX, setPreferredMinMaxY, setSquareAspect, setVideoTool, setVisible, setXLeftMarginPercentage, setXMarginPercentage, setXMarginPercentage, setXRightMarginPercentage, setYBottomMarginPercentage, setYMarginPercentage, setYMarginPercentage, setYTopMarginPercentage, 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, 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, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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, 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, 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

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 DrawableAxes getAxes()
Gets the axes.

Returns:
the axes

setAxes

public void setAxes(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

setLogScaleY

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

Parameters:
_logScaleY - The new logScale value

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

xToGraphics

public float xToGraphics(double x)
Converts x from world to graphics device units.

Overrides:
xToGraphics in class DrawingPanel
Parameters:
x -
Returns:
the graphics device 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

yToGraphics

public float yToGraphics(double y)
Converts y from world to graphics device units.

Overrides:
yToGraphics in class DrawingPanel
Parameters:
y -
Returns:
the graphics device value of the x coordinate

getBottomGutter

public int getBottomGutter()
Gets the bottom gutter of this DrawingPanel.

Overrides:
getBottomGutter in class DrawingPanel
Returns:
bottom gutter

getTopGutter

public int getTopGutter()
Gets the bottom gutter of this DrawingPanel.

Overrides:
getTopGutter in class DrawingPanel
Returns:
right gutter

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

recomputeTransform

public void recomputeTransform()
Recomputes the pixel transformation based on the current minimum and maximum values and the gutters.

Overrides:
recomputeTransform 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