Package org.opensourcephysics.display
Class InteractivePanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.opensourcephysics.display.DrawingPanel
org.opensourcephysics.display.InteractivePanel
- All Implemented Interfaces:
 ActionListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible,InteractiveMouseHandler,OSPRuntime.Disposable,Renderable
- Direct Known Subclasses:
 PlottingPanel,VideoPanel
InteractivePanel is a drawing panel that invokes the handleMouseAction method in
 Interactive objects.
- Version:
 - 1.0
 - Author:
 - Wolfgang Christian, Francisco Esquembre
 - See Also:
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classThe inner class that will handle all mouse related events.Nested classes/interfaces inherited from class org.opensourcephysics.display.DrawingPanel
DrawingPanel.PopupmenuListener, DrawingPanel.ZoomBoxNested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy - 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected InteractiveMouseHandlerstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intprotected intprotected MouseEventFields 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, zoomTimerFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface org.opensourcephysics.display.OSPRuntime.Disposable
allocated - 
Constructor Summary
ConstructorsConstructorDescriptionConstructs an InteractivePanel with an internal handler.Constructs an InteractivePanel with the given handler. - 
Method Summary
Modifier and TypeMethodDescriptionvoidaddDrawable(Drawable drawable) Adds a drawable object to the drawable list.voidclear()Removes all drawable objects from the drawable list.voiddispose()Get the Interactive object that is currently being dragged.Gets the interactive object that was accessed by the last mouse event.intGets the last mouse action.intGets the mouse button of the last mouse event.intGets the click count of the last mouse event.intGets the x pixel coordinate of the last mouse event.intGets the y pixel coordinate of the last mouse event.doubleGets the x world coordinate of the last mouse event.doubleGets the y world coordinate of the last moust eventvoidhandleMouseAction(InteractivePanel panel, MouseEvent evt) Handles mouse actions by dragging the current interactive drawable object.voidsaveMouseEvent(int type, MouseEvent evt) Saves the last mouse event.protected voidSets the x axis scale based on the max and min values of all measurable objects.protected voidSets the y axis scale based on the max and min values of all measurable objects.voidSets the interactive mouse handler.protected voidvoidsetShowCoordinates(boolean show) Shows the coordinates in the text box in the lower left hand corner.Methods inherited from class org.opensourcephysics.display.DrawingPanel
actionPerformed, addDrawableAtIndex, addDrawables, addMessageLabel, addOptionController, buildPopupMenu, checkWorkingImage, computeGutters, displayCoordinates, dref, enableInspector, findViewRect, firePropertyChange, getAspectRatio, getBottomGutter, getCoordinateStringBuilder, getDimensionSetter, getDrawables, getDrawables, getDrawables, getDrawablesExcept, getDrawablesExcept, getDrawablesNoClone, getFirstDrawable, getGlassPane, getGutters, getHeight, getImageRatio, getLeftGutter, getLoader, getMaxPixPerUnit, getMeasure, getObjectOfClass, getPixelMatrix, getPixelTransform, getPixelTransform, getPopupMenu, getPreferredXMax, getPreferredXMin, getPreferredYMax, getPreferredYMin, getRightGutter, getScale, getSnapshotItem, getTopGutter, 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, paintFirst, paintLast, pixToX, pixToY, 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, setPixelScale, setPixelsPerUnit, setPopupMenu, setPreferredGutters, setPreferredMinMax, setPreferredMinMax, setPreferredMinMaxX, setPreferredMinMaxY, setSquareAspect, setVideoTool, setVisible, setXLeftMarginPercentage, setXMarginPercentage, setXMarginPercentage, setXRightMarginPercentage, setYBottomMarginPercentage, setYMarginPercentage, setYMarginPercentage, setYTopMarginPercentage, setZoom, showInspector, snapshot, transformPath, transformShape, validateImage, xToGraphics, xToPix, yToGraphics, yToPix, zoomIn, zoomOutMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods 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, updateMethods 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, validateTreeMethods 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
- 
MOUSE_PRESSED
public static final int MOUSE_PRESSED- See Also:
 
 - 
MOUSE_RELEASED
public static final int MOUSE_RELEASED- See Also:
 
 - 
MOUSE_DRAGGED
public static final int MOUSE_DRAGGED- See Also:
 
 - 
MOUSE_CLICKED
public static final int MOUSE_CLICKED- See Also:
 
 - 
MOUSE_ENTERED
public static final int MOUSE_ENTERED- See Also:
 
 - 
MOUSE_EXITED
public static final int MOUSE_EXITED- See Also:
 
 - 
MOUSE_MOVED
public static final int MOUSE_MOVED- See Also:
 
 - 
containsInteractive
protected boolean containsInteractive - 
mouseAction
protected int mouseAction - 
mouseEvent
 - 
interactive
 
 - 
 - 
Constructor Details
- 
InteractivePanel
Constructs an InteractivePanel with the given handler.- Parameters:
 in- InteractiveMouseHandler
 - 
InteractivePanel
public InteractivePanel()Constructs an InteractivePanel with an internal handler. 
 - 
 - 
Method Details
- 
setMouseListeners
protected void setMouseListeners()- Overrides:
 setMouseListenersin classDrawingPanel
 - 
addDrawable
Adds a drawable object to the drawable list.- Overrides:
 addDrawablein classDrawingPanel- Parameters:
 drawable-
 - 
clear
public void clear()Removes all drawable objects from the drawable list.- Overrides:
 clearin classDrawingPanel
 - 
scaleX
Sets the x axis scale based on the max and min values of all measurable objects. Autoscale flag is not respected.- Overrides:
 scaleXin classDrawingPanel
 - 
scaleY
Sets the y axis scale based on the max and min values of all measurable objects. Autoscale flag is not respected.- Overrides:
 scaleYin classDrawingPanel
 - 
setInteractiveMouseHandler
Sets the interactive mouse handler. The interactive mouse handler is notified whenever a mouse action occurs.- Parameters:
 handler- the mouse handler
 - 
handleMouseAction
Handles mouse actions by dragging the current interactive drawable object.- Specified by:
 handleMouseActionin interfaceInteractiveMouseHandler- Parameters:
 panel-evt-
 - 
getCurrentDraggable
Get the Interactive object that is currently being dragged.- Returns:
 - Interactive
 
 - 
getInteractive
Gets the interactive object that was accessed by the last mouse event.- Returns:
 - Interactive
 
 - 
setShowCoordinates
public void setShowCoordinates(boolean show) Shows the coordinates in the text box in the lower left hand corner.- Overrides:
 setShowCoordinatesin classDrawingPanel- Parameters:
 show-
 - 
getMouseButton
public int getMouseButton()Gets the mouse button of the last mouse event.- Returns:
 - int
 
 - 
getMouseClickCount
public int getMouseClickCount()Gets the click count of the last mouse event.- Returns:
 - int
 
 - 
getMouseAction
public int getMouseAction()Gets the last mouse action.- Returns:
 - int
 
 - 
getMouseIntX
public int getMouseIntX()Gets the x pixel coordinate of the last mouse event.- Returns:
 - pixel
 
 - 
getMouseIntY
public int getMouseIntY()Gets the y pixel coordinate of the last mouse event.- Returns:
 - pixel
 
 - 
getMouseX
public double getMouseX()Gets the x world coordinate of the last mouse event.- Returns:
 - coordiante
 
 - 
getMouseY
public double getMouseY()Gets the y world coordinate of the last moust event- Returns:
 - coordinate
 
 - 
saveMouseEvent
Saves the last mouse event.- Parameters:
 type-evt-
 - 
dispose
public void dispose()- Specified by:
 disposein interfaceOSPRuntime.Disposable- Overrides:
 disposein classDrawingPanel
 
 -