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 SummaryNested classes/interfaces inherited from class org.opensourcephysics.display.InteractivePanelInteractivePanel.IADMouseControllerNested classes/interfaces inherited from class org.opensourcephysics.display.DrawingPanelDrawingPanel.PopupmenuListener, DrawingPanel.ZoomBoxNested classes/interfaces inherited from class javax.swing.JPanelJPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponentJComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.ContainerContainer.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.ComponentComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected DrawableAxesintprotected static final doubleprotected static final LogBase10FunctionFields inherited from class org.opensourcephysics.display.InteractivePanelcontainsInteractive, interactive, MOUSE_CLICKED, MOUSE_DRAGGED, MOUSE_ENTERED, MOUSE_EXITED, MOUSE_MOVED, MOUSE_PRESSED, MOUSE_RELEASED, mouseAction, mouseEventFields inherited from class org.opensourcephysics.display.DrawingPaneladjustableGutter, 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, zoomTimerFields inherited from class javax.swing.JComponentlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.ComponentaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserverABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface org.opensourcephysics.display.OSPRuntime.Disposableallocated
- 
Constructor SummaryConstructorsConstructorDescriptionPlottingPanel(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 SummaryModifier and TypeMethodDescriptionprotected voidComputes the size of the gutters using a Dimensioned object.getAxes()Gets the axes.intGets the bottom gutter of this DrawingPanel.Gets the interactive drawable that was accessed by the last mouse event.static XML.ObjectLoaderReturns an XML.ObjectLoader to save and load object data.intGets the bottom gutter of this DrawingPanel.protected voidinitAxes()Override to specify a different kind of axes.protected voidPaints before the panel iterates through its list of Drawables.doublepixToX(int pix) Converts pixel to x world units.doublepixToY(int pix) Converts pixel to x world units.voidsetAxes(DrawableAxes _axes) Sets the axes.voidsetAxesVisible(boolean isVisible) Sets the visibility of the axes.voidsetCartesian(String xLabel, String yLabel, String plotTitle) Converts this panel to cartesian coordinates.voidsetLogScale(boolean _logScaleX, boolean _logScaleY) Sets Cartesian axes to log scale.voidsetLogScaleX(boolean _logScaleX) Sets Cartesian x-axes to log scale.voidsetLogScaleY(boolean _logScaleY) Sets Cartesian axes to log scale.voidCalculates min and max values and the affine transformation based on the current size of the panel and the squareAspect boolean.voidConverts this panel to polar coordinatesvoidSets the title.voidSets the title and font.voidSets the label for the X (horizontal) axis.voidSets the label and font for the X (horizontal) axis.voidSets the label for the Y (vertical) axis.voidSets the label and font for the Y (vertical) axis.floatxToGraphics(double x) Converts x from world to graphics device units.intxToPix(double x) Converts x from world to pixel units.floatyToGraphics(double y) Converts y from world to graphics device units.intyToPix(double y) Converts y from world to pixel units.Methods inherited from class org.opensourcephysics.display.InteractivePaneladdDrawable, clear, dispose, getCurrentDraggable, getMouseAction, getMouseButton, getMouseClickCount, getMouseIntX, getMouseIntY, getMouseX, getMouseY, handleMouseAction, saveMouseEvent, scaleX, scaleY, setInteractiveMouseHandler, setMouseListeners, setShowCoordinatesMethods inherited from class org.opensourcephysics.display.DrawingPanelactionPerformed, 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, zoomOutMethods inherited from class javax.swing.JPanelgetAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponentaddAncestorListener, 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, updateMethods inherited from class java.awt.Containeradd, 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, validateTreeMethods inherited from class java.awt.Componentaction, 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
- 
log10protected static final double log10
- 
logBase10Function
- 
idpublic int id
 
- 
- 
Constructor Details- 
PlottingPanelConstructs 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.
 
- 
PlottingPanelpublic 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.
 
- 
PlottingPanelConstructs 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 Details- 
getInteractiveGets 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:
- getInteractivein class- InteractivePanel
- Returns:
- the interactive object
 
- 
getAxesGets the axes.- Returns:
- the axes
 
- 
initAxesprotected void initAxes()Override to specify a different kind of axes.
- 
setAxesSets the axes.- Parameters:
- _axes- the new axes
 
- 
setPolarConverts this panel to polar coordinates- Parameters:
- plotTitle- String
- deltaR- double
 
- 
setCartesianConverts this panel to cartesian coordinates.- Parameters:
- xLabel- String
- yLabel- String
- plotTitle- String
 
- 
setXLabelSets the label for the X (horizontal) axis.- Parameters:
- label- the label
 
- 
setYLabelSets the label for the Y (vertical) axis.- Parameters:
- label- the label
 
- 
setTitleSets the title.- Parameters:
- title- the title
 
- 
setXLabelSets 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
 
- 
setYLabelSets 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
 
- 
setTitleSets the title and font. If the font name is null, the font is unchanged.- Parameters:
- title-
- font_name- the optional new font
 
- 
setAxesVisiblepublic void setAxesVisible(boolean isVisible) Sets the visibility of the axes. Axes that are not visible will not be drawn.- Parameters:
- isVisible-
 
- 
setLogScalepublic void setLogScale(boolean _logScaleX, boolean _logScaleY) Sets Cartesian axes to log scale.- Parameters:
- _logScaleX- The new logScale value
- _logScaleY- The new logScale value
 
- 
setLogScaleXpublic void setLogScaleX(boolean _logScaleX) Sets Cartesian x-axes to log scale.- Parameters:
- _logScaleX- The new logScale value
 
- 
setLogScaleYpublic void setLogScaleY(boolean _logScaleY) Sets Cartesian axes to log scale.- Parameters:
- _logScaleY- The new logScale value
 
- 
computeGuttersprotected 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:
- computeGuttersin class- DrawingPanel
 
- 
paintFirstPaints before the panel iterates through its list of Drawables.- Overrides:
- paintFirstin class- DrawingPanel
- Parameters:
- g- Graphics
 
- 
pixToXpublic double pixToX(int pix) Converts pixel to x world units.- Overrides:
- pixToXin class- DrawingPanel
- Parameters:
- pix-
- Returns:
- x panel units
 
- 
xToPixpublic int xToPix(double x) Converts x from world to pixel units.- Overrides:
- xToPixin class- DrawingPanel
- Parameters:
- x-
- Returns:
- the pixel value of the x coordinate
 
- 
xToGraphicspublic float xToGraphics(double x) Converts x from world to graphics device units.- Overrides:
- xToGraphicsin class- DrawingPanel
- Parameters:
- x-
- Returns:
- the graphics device value of the x coordinate
 
- 
pixToYpublic double pixToY(int pix) Converts pixel to x world units.- Overrides:
- pixToYin class- DrawingPanel
- Parameters:
- pix-
- Returns:
- x panel units
 
- 
yToPixpublic int yToPix(double y) Converts y from world to pixel units.- Overrides:
- yToPixin class- DrawingPanel
- Parameters:
- y-
- Returns:
- the pixel value of the y coordinate
 
- 
yToGraphicspublic float yToGraphics(double y) Converts y from world to graphics device units.- Overrides:
- yToGraphicsin class- DrawingPanel
- Parameters:
- y-
- Returns:
- the graphics device value of the x coordinate
 
- 
getBottomGutterpublic int getBottomGutter()Gets the bottom gutter of this DrawingPanel.- Overrides:
- getBottomGutterin class- DrawingPanel
- Returns:
- bottom gutter
 
- 
getTopGutterpublic int getTopGutter()Gets the bottom gutter of this DrawingPanel.- Overrides:
- getTopGutterin class- DrawingPanel
- Returns:
- right gutter
 
- 
setPixelScalepublic void setPixelScale()Calculates min and max values and the affine transformation based on the current size of the panel and the squareAspect boolean.- Overrides:
- setPixelScalein class- DrawingPanel
 
- 
getLoaderReturns an XML.ObjectLoader to save and load object data.- Returns:
- the XML.ObjectLoader
 
 
-