Package org.opensourcephysics.display
Class PlottingPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.opensourcephysics.display.DrawingPanel
org.opensourcephysics.display.InteractivePanel
org.opensourcephysics.display.PlottingPanel
- All Implemented Interfaces:
ActionListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,InteractiveMouseHandler
,OSPRuntime.Disposable
,Renderable
- Direct Known Subclasses:
DataToolTab.DataToolPlotter
,TrackPlottingPanel
A Drawing Panel that has an X axis, a Y axis, and a title.
- Author:
- Wolfgang Christian
- See Also:
-
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.PopupmenuListener, DrawingPanel.ZoomBox
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DrawableAxes
int
protected static final double
protected static final LogBase10Function
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, BOTTOM_LEFT, BOTTOM_RIGHT, bottomGutter, bottomGutterPreferred, clipAtGutter, coordinateStrBuilder, currentTime, customInspector, decimalFormat, dimensionSetter, displayCoordsOnMouseMoved, drawableList, dxmax, dxmin, dymax, dymin, enableZoom, fixedPixelPerUnit, fixedScale, guiChangeListener, imageRatio, isDisposed, isInteractive, lastHeight, lastWidth, leftGutter, leftGutterPreferred, logScaleX, logScaleY, messages, messagesAsJLabels, mouseController, offscreenImage, optionController, paintDrawables, pixelMatrix, pixelTransform, popupmenu, propertiesItem, RECORD_PAINT_TIMES, refreshDelay, refreshTimer, rightGutter, rightGutterPreferred, scaleItem, scientificFormat, showCoordinates, snapshotItem, squareAspect, TOP_LEFT, TOP_RIGHT, topGutter, topGutterPreferred, vidCap, viewRect, workingImage, xceil, xfloor, xLeftMarginPercentage, xmax, xmaxPreferred, xmin, xminPreferred, xPixPerUnit, xRightMarginPercentage, yBottomMarginPercentage, yceil, yfloor, ymax, ymaxPreferred, ymin, yminPreferred, yPixPerUnit, yTopMarginPercentage, zoomBox, zoomCount, zoomDelay, zoomInItem, zoomOutItem, zoomTimer
Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
Fields inherited from interface org.opensourcephysics.display.OSPRuntime.Disposable
allocated
-
Constructor Summary
ConstructorsConstructorDescriptionPlottingPanel
(int _xAxisType, int _yAxisType) Constructs a new PlottingPanel that uses the given X axis type and Y axis type.PlottingPanel
(String xlabel, String ylabel, String plotTitle) Constructs a new PlottingPanel that uses the given X axis label, Y axis label, and plot title.PlottingPanel
(String xlabel, String ylabel, 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
Modifier and TypeMethodDescriptionprotected void
Computes the size of the gutters using a Dimensioned object.getAxes()
Gets the axes.int
Gets the bottom gutter of this DrawingPanel.Gets the interactive drawable that was accessed by the last mouse event.static XML.ObjectLoader
Returns an XML.ObjectLoader to save and load object data.int
Gets the bottom gutter of this DrawingPanel.protected void
initAxes()
Override to specify a different kind of axes.protected void
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
(DrawableAxes _axes) Sets the axes.void
setAxesVisible
(boolean isVisible) Sets the visibility of the axes.void
setCartesian
(String xLabel, String yLabel, 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
Calculates min and max values and the affine transformation based on the current size of the panel and the squareAspect boolean.void
Converts this panel to polar coordinatesvoid
Sets the title.void
Sets the title and font.void
Sets the label for the X (horizontal) axis.void
Sets the label and font for the X (horizontal) axis.void
Sets the label for the Y (vertical) axis.void
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, dispose, getCurrentDraggable, getMouseAction, getMouseButton, getMouseClickCount, getMouseIntX, getMouseIntY, getMouseX, getMouseY, handleMouseAction, saveMouseEvent, scaleX, scaleY, setInteractiveMouseHandler, setMouseListeners, setShowCoordinates
Methods inherited from class org.opensourcephysics.display.DrawingPanel
actionPerformed, addDrawableAtIndex, addDrawables, addMessageLabel, addOptionController, buildPopupMenu, checkWorkingImage, displayCoordinates, dref, enableInspector, findViewRect, firePropertyChange, getAspectRatio, getCoordinateStringBuilder, getDimensionSetter, getDrawables, getDrawables, getDrawables, getDrawablesExcept, getDrawablesExcept, getDrawablesNoClone, getFirstDrawable, getGlassPane, getGutters, getHeight, getImageRatio, getLeftGutter, getMaxPixPerUnit, getMeasure, getObjectOfClass, getPixelMatrix, getPixelTransform, getPixelTransform, getPopupMenu, getPreferredXMax, getPreferredXMin, getPreferredYMax, getPreferredYMin, getRightGutter, getScale, getSnapshotItem, 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, isShowCoordinates, isSquareAspect, isValidImage, isZoom, isZoomEvent, limitAutoscaleX, limitAutoscaleY, measure, paint, paintComponent, paintDrawableList, paintEverything, paintLast, project, receiveToolReply, recomputeTransform, refreshDecimalSeparators, refreshGUI, removeDrawable, removeDrawables, removeObjectsOfClass, removeOptionController, render, render, repaint, repaint, repaintForZoom, repaintIfNecessary, replaceDrawable, resetGutters, scale, scale, scaleX, scaleY, setAdjustableGutter, setAntialiasShapeOn, setAntialiasTextOn, setAutoscaleMargin, setAutoscaleX, setAutoscaleY, setBounds, setBounds, setBuffered, setClipAtGutter, setCoordinateStringBuilder, setCustomInspector, setFixedScale, setFontFactor, setFontLevel, setGutters, setGutters, setMessage, setMessage, setMouseCursor, setPaintDrawables, setPixelsPerUnit, setPopupMenu, setPreferredGutters, setPreferredMinMax, setPreferredMinMax, setPreferredMinMaxX, setPreferredMinMaxY, setSquareAspect, setVideoTool, setVisible, setXLeftMarginPercentage, setXMarginPercentage, setXMarginPercentage, setXRightMarginPercentage, setYBottomMarginPercentage, setYMarginPercentage, setYMarginPercentage, setYTopMarginPercentage, setZoom, showInspector, snapshot, transformPath, transformShape, validateImage, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, 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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
axes
-
log10
protected static final double log10 -
logBase10Function
-
id
public int id
-
-
Constructor Details
-
PlottingPanel
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
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 ParameteryAxisType
- Description of Parameter
-
-
Method Details
-
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 classInteractivePanel
- Returns:
- the interactive object
-
getAxes
Gets the axes.- Returns:
- the axes
-
initAxes
protected void initAxes()Override to specify a different kind of axes. -
setAxes
Sets the axes.- Parameters:
_axes
- the new axes
-
setPolar
Converts this panel to polar coordinates- Parameters:
plotTitle
- StringdeltaR
- double
-
setCartesian
Converts this panel to cartesian coordinates.- Parameters:
xLabel
- StringyLabel
- StringplotTitle
- String
-
setXLabel
Sets the label for the X (horizontal) axis.- Parameters:
label
- the label
-
setYLabel
Sets the label for the Y (vertical) axis.- Parameters:
label
- the label
-
setTitle
Sets the title.- Parameters:
title
- the title
-
setXLabel
Sets the label and font for the X (horizontal) axis. If the font name is null, the font is unchanged.- Parameters:
label
- the labelfont_name
- the optional new font
-
setYLabel
Sets the label and font for the Y (vertical) axis. If the font name is null, the font is unchanged.- Parameters:
label
- the labelfont_name
- the optional new font
-
setTitle
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 classDrawingPanel
-
paintFirst
Paints before the panel iterates through its list of Drawables.- Overrides:
paintFirst
in classDrawingPanel
- Parameters:
g
- Graphics
-
pixToX
public double pixToX(int pix) Converts pixel to x world units.- Overrides:
pixToX
in classDrawingPanel
- Parameters:
pix
-- Returns:
- x panel units
-
xToPix
public int xToPix(double x) Converts x from world to pixel units.- Overrides:
xToPix
in classDrawingPanel
- 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 classDrawingPanel
- 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 classDrawingPanel
- Parameters:
pix
-- Returns:
- x panel units
-
yToPix
public int yToPix(double y) Converts y from world to pixel units.- Overrides:
yToPix
in classDrawingPanel
- 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 classDrawingPanel
- 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 classDrawingPanel
- Returns:
- bottom gutter
-
getTopGutter
public int getTopGutter()Gets the bottom gutter of this DrawingPanel.- Overrides:
getTopGutter
in classDrawingPanel
- 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 classDrawingPanel
-
getLoader
Returns an XML.ObjectLoader to save and load object data.- Returns:
- the XML.ObjectLoader
-