Package org.opensourcephysics.display
Class DrawingFrame
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
org.opensourcephysics.display.OSPFrame
org.opensourcephysics.display.DrawingFrame
- All Implemented Interfaces:
ClipboardOwner
,ImageObserver
,MenuContainer
,Serializable
,Accessible
,RootPaneContainer
,WindowConstants
,AppFrame
,Hidable
- Direct Known Subclasses:
Complex2DFrame
,ComplexPlotFrame
,DisplayFrame
,FFT2DFrame
,FFTFrame
,HistogramFrame
,LatticeFrame
,ParticleFrame
,PlotFrame
,RasterFrame
,Scalar2DFrame
,Vector2DFrame
,VideoFrame
Drawing Frame: a frame that contains a drawing panel.
- Version:
- 1.1
- Author:
- Wolfgang Christian
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.Type
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 JMenuItem
protected Window
protected DrawingPanel
protected JMenu
protected JMenu
protected static final int
protected JMenuItem
protected JMenuItem
protected Tool
Fields inherited from class org.opensourcephysics.display.OSPFrame
action, animated, autoclear, buttonPanel, childFrames, constructorThreadGroup, customButtons, keepHidden, myFontLevel, strategy
Fields inherited from class javax.swing.JFrame
accessibleContext, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
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
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
-
Constructor Summary
ConstructorsConstructorDescriptionDrawingFrame constructor that creates a default DrawingPanel.DrawingFrame
(String title, DrawingPanel _drawingPanel) DrawingFrame constructor specifying the title and the DrawingPanel that will be placed in the center of the content pane.DrawingFrame
(DrawingPanel drawingPanel) DrawingFrame constructor specifying the DrawingPanel that will be placed in the center of the content pane. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDrawable
(Drawable drawable) Adds a drawable object to the frame's drawing panel.protected void
Adds Views menu items on the menu bar.void
Clears data and repaints the drawing panel within this frame.void
Clears Drawable objects added by the user from this frame.protected void
copyAction
(XMLControlElement control) Copies objects found in the specified xml control.getAxes()
Gets Drawable previously objects added by the user.getDrawables
(Class<T> c) Gets Drawable objects added by the user of an assignable type.getDrawablesExcept
(Class<T> c, Drawable except) Gets the drawing panel.static XML.ObjectLoader
Returns an XML.ObjectLoader to save and load data for this program.getObjectOfClass
(Class<T> c) Gets objects of a specific class from the drawing panel.void
Inspects the drawing frame by using an xml document tree.void
Invalidates image buffers if a drawing panel buffered.boolean
Determines if the panel's x axis autoscale property is true.boolean
Determines if the y axis autoscale property is true.void
limitAutoscaleX
(double floor, double ceil) Limits the xmin and xmax values during autoscaling so that the mininimum value will be no greater than the floor and the maximum value will be no smaller than the ceil.void
limitAutoscaleY
(double floor, double ceil) Limits ymin and ymax values during autoscaling so that the mininimum value will be no greater than the floor and the maximum value will be no smaller than the ceil.protected JMenu
Adds a Display menu to the menu bar.protected JMenu
Adds a Tools menu to the menu bar.void
lostOwnership
(Clipboard clipboard, Transferable contents) Implementation of ClipboardOwner interface.void
This is a hack to fix a bug when the reload button is pressed in browsers running JDK 1.4.protected void
pasteAction
(XMLControlElement control) Pastes drawables found in the specified xml control.protected void
Refreshes the user interface in response to display changes such as Language.void
removeDrawable
(Drawable drawable) Removes a drawable object to the frame's drawing panel.<T extends Drawable>
voidremoveObjectsOfClass
(Class<T> c) Removes all objects of the given class from the drawable list.void
render()
Renders the drawing panel if the frame is showing and not iconified.void
replaceAction
(XMLControlElement control) Replaces the drawables with the drawables found in the specified XML control.void
replaceDrawable
(Drawable oldDrawable, Drawable newDrawable) Replaces a Drawable object with another Drawable.void
saveXML()
void
setAutoscaleX
(boolean autoscale) Autoscale the drawing panel's x axis using min and max values.void
setAutoscaleY
(boolean autoscale) Autoscale the y axis using min and max values.void
setCartesian
(String xLabel, String yLabel, String plotTitle) Converts to cartesian coordinates.void
Sets a custom properties inspector window.void
setDrawingPanel
(DrawingPanel _drawingPanel) Adds the drawing panel to the the frame.void
setEnabledCopy
(boolean enable) Enables the copy edit menu item.void
setEnabledPaste
(boolean enable) Enables the paste edit menu item.void
setEnabledReplace
(boolean enable) Enables the replace edit menu item.void
Sets the interactive mouse handler if the drawing panel is an interactive panel.void
setInteriorBackground
(Color color) Sets the interior background color for the current drawing panel.void
setLogScale
(boolean logX, boolean logY) Sets Cartesian axes to log scale.void
setMessage
(String msg) Shows a message in a yellow text box in the lower right hand corner.void
setMessage
(String msg, int location) Shows a message in a yellow text box at the given location.void
setPixelsPerUnit
(boolean enable, double xPixPerUnit, double yPixPerUnit) Sets the scale using pixels per unit.void
Converts to polar coordinates.void
setPreferredMinMax
(double xmin, double xmax, double ymin, double ymax) Sets the drawing panel's preferred scale.void
setPreferredMinMaxX
(double xmin, double xmax) Sets the drawing panel's preferred scale in the horizontal direction.void
setPreferredMinMaxY
(double ymin, double ymax) Sets the drawing panel's preferred scale in the vertical direction.void
setSquareAspect
(boolean isSquare) Sets the aspect ratio for horizontal to vertical to unity whentrue<\code>.
void
Sets the label for the X (horizontal) axis.void
Sets the label for the Y (vertical) axis.Methods inherited from class org.opensourcephysics.display.OSPFrame
addButton, addChildFrame, bufferStrategyShow, clearChildFrames, clearData, createBufferStrategy, dispose, getChildFrames, getChooser, getConstructorThreadGroup, getMenu, isAnimated, isAutoclear, isIconified, isKeepHidden, parseXMLMenu, parseXMLMenu, removeMenu, removeMenuItem, setAnimated, setAutoclear, setDefaultCloseOperation, setFontLevel, setKeepHidden, setResizeAction, setSize, setTitle, setVisible, show, wishesToExit
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setType, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opensourcephysics.display.AppFrame
getDefaultCloseOperation
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
-
Field Details
-
fileMenu
-
editMenu
-
copyItem
-
pasteItem
-
replaceItem
-
drawingPanel
-
MENU_SHORTCUT_KEY_MASK
protected static final int MENU_SHORTCUT_KEY_MASK -
customInspector
-
reply
-
-
Constructor Details
-
DrawingFrame
public DrawingFrame()DrawingFrame constructor that creates a default DrawingPanel. The default DrawingPanel is an InteractivePanel. -
DrawingFrame
DrawingFrame constructor specifying the DrawingPanel that will be placed in the center of the content pane.- Parameters:
drawingPanel
-
-
DrawingFrame
DrawingFrame constructor specifying the title and the DrawingPanel that will be placed in the center of the content pane.- Parameters:
title
-_drawingPanel
-
-
-
Method Details
-
render
public void render()Renders the drawing panel if the frame is showing and not iconified. -
invalidateImage
public void invalidateImage()Invalidates image buffers if a drawing panel buffered.- Overrides:
invalidateImage
in classOSPFrame
-
getDrawingPanel
Gets the drawing panel.- Returns:
- the drawingPanel
-
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
-
setPolar
Converts to polar coordinates.- Parameters:
plotTitle
- StringdeltaR
- double
-
setCartesian
Converts to cartesian coordinates.- Parameters:
xLabel
- StringyLabel
- StringplotTitle
- String
-
limitAutoscaleX
public void limitAutoscaleX(double floor, double ceil) Limits the xmin and xmax values during autoscaling so that the mininimum value will be no greater than the floor and the maximum value will be no smaller than the ceil. Setting a floor or ceil value toDouble.NaN<\code> will disable that limit.
- Parameters:
floor
- the xfloor valueceil
- the xceil value
-
limitAutoscaleY
public void limitAutoscaleY(double floor, double ceil) Limits ymin and ymax values during autoscaling so that the mininimum value will be no greater than the floor and the maximum value will be no smaller than the ceil. Setting a floor or ceil value toDouble.NaN<\code> will disable that limit.
- Parameters:
floor
- the yfloor valueceil
- the yceil value
-
setAutoscaleX
public void setAutoscaleX(boolean autoscale) Autoscale the drawing panel's x axis using min and max values. from measurable objects.- Parameters:
autoscale
-
-
isAutoscaleX
public boolean isAutoscaleX()Determines if the panel's x axis autoscale property is true.- Returns:
true<\code> if autoscaled.
-
setAutoscaleY
public void setAutoscaleY(boolean autoscale) Autoscale the y axis using min and max values. from measurable objects.- Parameters:
autoscale
-
-
isAutoscaleY
public boolean isAutoscaleY()Determines if the y axis autoscale property is true.- Returns:
true<\code> if autoscaled.
-
setSquareAspect
public void setSquareAspect(boolean isSquare) Sets the aspect ratio for horizontal to vertical to unity whentrue<\code>.
- Parameters:
isSquare
- boolean
-
setLogScale
public void setLogScale(boolean logX, boolean logY) Sets Cartesian axes to log scale.- Parameters:
logX
-logY
-
-
setPixelsPerUnit
public void setPixelsPerUnit(boolean enable, double xPixPerUnit, double yPixPerUnit) Sets the scale using pixels per unit.- Parameters:
enable
- boolean enable fixed pixels per unitxPixPerUnit
- doubleyPixPerUnit
- double
-
setPreferredMinMax
public void setPreferredMinMax(double xmin, double xmax, double ymin, double ymax) Sets the drawing panel's preferred scale.- Parameters:
xmin
-xmax
-ymin
-ymax
-
-
setPreferredMinMaxY
public void setPreferredMinMaxY(double ymin, double ymax) Sets the drawing panel's preferred scale in the vertical direction.- Parameters:
ymin
-ymax
-
-
setPreferredMinMaxX
public void setPreferredMinMaxX(double xmin, double xmax) Sets the drawing panel's preferred scale in the horizontal direction.- Parameters:
xmin
- the minimum valuexmax
- the maximum value
-
clearDataAndRepaint
public void clearDataAndRepaint()Clears data and repaints the drawing panel within this frame.- Overrides:
clearDataAndRepaint
in classOSPFrame
-
clearDrawables
public void clearDrawables()Clears Drawable objects added by the user from this frame. -
addDrawable
Adds a drawable object to the frame's drawing panel.- Parameters:
drawable
-
-
replaceDrawable
Replaces a Drawable object with another Drawable.- Parameters:
oldDrawable
- DrawablenewDrawable
- Drawable
-
removeDrawable
Removes a drawable object to the frame's drawing panel.- Parameters:
drawable
-
-
setMessage
Shows a message in a yellow text box in the lower right hand corner.- Parameters:
msg
-
-
setMessage
Shows a message in a yellow text box at the given location. location 0=bottom left location 1=bottom right location 2=top right location 3=top left- Parameters:
msg
-location
-
-
getObjectOfClass
Gets objects of a specific class from the drawing panel. Assignable subclasses are NOT returned. Interfaces CANNOT be specified. The same objects will be in the drawable list and the cloned list.- Parameters:
c
- the class of the object- Returns:
- the list
-
getDrawables
Gets Drawable previously objects added by the user.- Returns:
- the list
-
getDrawablesNoClone
-
getAxes
-
getDrawables
Gets Drawable objects added by the user of an assignable type. The list contains objects that are assignable from the class or interface.- Parameters:
c
- the type of Drawable object- Returns:
- the cloned list
- See Also:
-
getDrawablesExcept
-
removeObjectsOfClass
Removes all objects of the given class from the drawable list. Assignable subclasses are NOT removed. Interfaces CANNOT be specified.- Parameters:
c
- the class
-
setInteractiveMouseHandler
Sets the interactive mouse handler if the drawing panel is an interactive panel. Throws an invalid cast exception if the panel is not of the correct type.- Parameters:
handler
- the mouse handler
-
setDrawingPanel
Adds the drawing panel to the the frame. The panel is added to the center of the frame's content pane.- Parameters:
_drawingPanel
-
-
setInteriorBackground
Sets the interior background color for the current drawing panel. The interior of a PlottingaPanel is the area inside the axes where is displayed. The interior of a DrawingPanel is the entire panel. -
paint
This is a hack to fix a bug when the reload button is pressed in browsers running JDK 1.4. -
setEnabledPaste
public void setEnabledPaste(boolean enable) Enables the paste edit menu item.- Parameters:
enable
- boolean
-
pasteAction
Pastes drawables found in the specified xml control.- Parameters:
control
- the xml control
-
setEnabledReplace
public void setEnabledReplace(boolean enable) Enables the replace edit menu item.- Parameters:
enable
- boolean
-
replaceAction
Replaces the drawables with the drawables found in the specified XML control.- Parameters:
control
- XMLControlElement
-
copyAction
Copies objects found in the specified xml control.- Parameters:
control
- the xml control
-
lostOwnership
Implementation of ClipboardOwner interface. Override this method to receive notification that data copied to the clipboard has changed.- Specified by:
lostOwnership
in interfaceClipboardOwner
- Parameters:
clipboard
- Clipboardcontents
- Transferable
-
setEnabledCopy
public void setEnabledCopy(boolean enable) Enables the copy edit menu item.- Parameters:
enable
- boolean
-
refreshGUI
protected void refreshGUI()Description copied from class:OSPFrame
Refreshes the user interface in response to display changes such as Language.- Overrides:
refreshGUI
in classOSPFrame
-
addMenuItems
protected void addMenuItems()Adds Views menu items on the menu bar. Override this method to add custom menu items. -
loadDisplayMenu
Adds a Display menu to the menu bar.- Overrides:
loadDisplayMenu
in classOSPFrame
-
loadToolsMenu
Adds a Tools menu to the menu bar.- Overrides:
loadToolsMenu
in classOSPFrame
-
setCustomInspector
Sets a custom properties inspector window.- Parameters:
w
- the new inspector window
-
inspectXML
public void inspectXML()Inspects the drawing frame by using an xml document tree. -
saveXML
public void saveXML() -
getLoader
Returns an XML.ObjectLoader to save and load data for this program.- Returns:
- the object loader
-