org.opensourcephysics.media.core
Class VideoPanel

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.media.core.VideoPanel
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, InteractiveMouseHandler, Renderable

public class VideoPanel
extends InteractivePanel
implements java.beans.PropertyChangeListener

This is an interactive drawing panel with a video player. It can draw videos and other Trackable objects in either imagespace or worldspace. When drawing in imagespace, the image reference frame (ie the image itself) is fixed. When drawing in worldspace, the world reference frame is fixed. The image reference frame defines positions in pixel units relative to the upper left corner of a video image--ie, the UL corner of a 320 x 240 video is at (0.0, 0.0) and the LR corner is at (320.0, 240.0). When drawing in imagespace, non-Trackable objects are not drawn.

Version:
1.0
Author:
Douglas Brown
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
 boolean changed
          set to true when this panel has been changed, false when saved
protected  ImageCoordSystem coords
           
protected  java.io.File dataFile
           
 java.lang.String defaultFileName
          default file name used for initial saveAs
protected static int defaultHeight
           
protected static int defaultWidth
           
protected  boolean drawingInImageSpace
           
protected  java.util.Map<java.lang.String,java.lang.Class<? extends Filter>> filterClasses
           
protected  double imageBorder
           
protected  double imageHeight
           
protected  double imageWidth
           
protected  TextPanel messagePanel
           
protected  TextPanel mousePanel
           
protected  VideoPlayer player
           
protected  boolean playerVisible
           
protected  java.awt.geom.Point2D pt
           
protected  Video video
           
protected  double xOffset
           
protected  double yOffset
           
 
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
VideoPanel()
          Constructs a blank VideoPanel with a player.
VideoPanel(Video video)
          Constructs a VideoPanel with a video and player.
 
Method Summary
 void addDrawable(Drawable drawable)
          Adds a drawable object to the drawable list.
 void addFilter(java.lang.Class<? extends Filter> filterClass)
          Adds a video filter class to the map of available filters.
protected  boolean checkImage()
          Overrides DrawingPanel checkImage method so offscreenImage will not include the videoPlayer.
 void clear()
          Removes all drawable objects except the video.
 ImageCoordSystem getCoords()
          Gets the current image coordinate system used for drawing.
 java.io.File getDataFile()
          Gets the file where data is saved.
 java.util.ArrayList<Drawable> getDrawables()
          Overrides DrawingPanel getDrawables method.
 java.lang.String getFilePath()
          Gets the default path for the saveAs method.
 java.util.Map<java.lang.String,java.lang.Class<? extends Filter>> getFilters()
          Gets the map of available video filters.
 int getFrameNumber()
          Gets the current frame number.
 double getImageBorder()
          Gets the image border.
 double getImageHeight()
          Gets the image height in image units (1.0 unit/pixel).
 double getImageWidth()
          Gets the image width in image units.
static XML.ObjectLoader getLoader()
          Returns an XML.ObjectLoader to save and load data for this object.
 VideoPlayer getPlayer()
          Gets the video player.
 int getStepNumber()
          Gets the current step number.
 Video getVideo()
          Gets the video.
 java.awt.geom.Point2D getWorldMousePoint()
          Gets the world coordinates of the last mouse event
 void hideMouseBox()
          Hides the mouse box
 boolean isDrawingInImageSpace()
          Returns true if this is drawing in image space rather than world space.
 boolean isPlayerVisible()
          Gets the video player visibility.
 boolean isShowCoordinates()
          Returns true if mouse coordinates are displayed
protected  void paintEverything(java.awt.Graphics g)
          Overrides DrawingPanel paintEverything method.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Responds to property change events.
 void removeDrawable(Drawable drawable)
          Removes a drawable object from the drawable list.
 void removeFilter(java.lang.Class<?> filterClass)
          Removes a video filter class from the map of available filters.
<T extends Drawable>
void
removeObjectsOfClass(java.lang.Class<T> c)
          Removes all objects of the specified class.
protected  void scale(java.util.ArrayList<Drawable> drawables)
          Overrides DrawingPanel scale method to handle drawing in imagespace
 void setCoords(ImageCoordSystem newCoords)
          Sets the image coordinate system used to convert between image and world spaces.
 void setDataFile(java.io.File file)
          Sets the file in which data is saved.
 void setDrawingInImageSpace(boolean imagespace)
          Sets the drawing space to imagespace or worldspace.
 void setImageBorder(double borderFraction)
          Sets the image border.
 void setImageHeight(double h)
          Sets the image height in image units (1.0 unit/pixel).
 void setImageWidth(double w)
          Sets the image width in image units.
 void setPlayerVisible(boolean visible)
          Shows or hides the video player.
 void setVideo(Video newVideo)
          Sets the video.
 
Methods inherited from class org.opensourcephysics.display.InteractivePanel
getCurrentDraggable, getInteractive, 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, computeGutters, enableInspector, findViewRect, getAspectRatio, getBottomGutter, getCoordinateStringBuilder, getDimensionSetter, getDrawables, getGlassPanel, getGutters, getHeight, getImageRatio, getLeftGutter, getMaxPixPerUnit, getMeasure, getObjectOfClass, getPixelMatrix, getPixelTransform, getPopupMenu, getPreferredXMax, getPreferredXMin, getPreferredYMax, getPreferredYMin, getRightGutter, getScale, 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, isSquareAspect, isValidImage, isZoom, limitAutoscaleX, limitAutoscaleY, measure, paint, paintComponent, paintDrawableList, paintFirst, paintLast, pixToX, pixToY, project, recomputeTransform, refreshGUI, removeDrawables, removeOptionController, render, render, replaceDrawable, resetGutters, scale, scaleX, scaleY, setAdjustableGutter, setAntialiasShapeOn, setAntialiasTextOn, setAutoscaleMargin, setAutoscaleX, setAutoscaleY, setBounds, setBounds, setBuffered, setClipAtGutter, setCoordinateStringBuilder, setCustomInspector, setFixedScale, setFontLevel, setGutters, setGutters, setIgnoreRepaint, setMessage, setMessage, setMouseCursor, setPixelScale, setPixelsPerUnit, setPopupMenu, setPreferredGutters, setPreferredMinMax, setPreferredMinMax, setPreferredMinMaxX, setPreferredMinMaxY, setSquareAspect, setVideoTool, setVisible, setXLeftMarginPercentage, setXMarginPercentage, setXMarginPercentage, setXRightMarginPercentage, setYBottomMarginPercentage, setYMarginPercentage, setYMarginPercentage, setYTopMarginPercentage, setZoom, showInspector, snapshot, xToGraphics, xToPix, yToGraphics, yToPix, 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
 

Field Detail

defaultWidth

protected static int defaultWidth

defaultHeight

protected static int defaultHeight

changed

public boolean changed
set to true when this panel has been changed, false when saved


defaultFileName

public java.lang.String defaultFileName
default file name used for initial saveAs


player

protected VideoPlayer player

mousePanel

protected TextPanel mousePanel

messagePanel

protected TextPanel messagePanel

video

protected Video video

playerVisible

protected boolean playerVisible

drawingInImageSpace

protected boolean drawingInImageSpace

imageWidth

protected double imageWidth

imageHeight

protected double imageHeight

xOffset

protected double xOffset

yOffset

protected double yOffset

imageBorder

protected double imageBorder

coords

protected ImageCoordSystem coords

pt

protected java.awt.geom.Point2D pt

dataFile

protected java.io.File dataFile

filterClasses

protected java.util.Map<java.lang.String,java.lang.Class<? extends Filter>> filterClasses
Constructor Detail

VideoPanel

public VideoPanel()
Constructs a blank VideoPanel with a player.


VideoPanel

public VideoPanel(Video video)
Constructs a VideoPanel with a video and player.

Parameters:
video - the video to be drawn
Method Detail

setVideo

public void setVideo(Video newVideo)
Sets the video.

Parameters:
newVideo - the video

getVideo

public Video getVideo()
Gets the video.

Returns:
the video

getImageWidth

public double getImageWidth()
Gets the image width in image units.

Returns:
the width

setImageWidth

public void setImageWidth(double w)
Sets the image width in image units.

Parameters:
w - the width

getImageHeight

public double getImageHeight()
Gets the image height in image units (1.0 unit/pixel).

Returns:
the height

setImageHeight

public void setImageHeight(double h)
Sets the image height in image units (1.0 unit/pixel).

Parameters:
h - the height

getImageBorder

public double getImageBorder()
Gets the image border.

Returns:
the border fraction

setImageBorder

public void setImageBorder(double borderFraction)
Sets the image border.

Parameters:
borderFraction - the border fraction

setCoords

public void setCoords(ImageCoordSystem newCoords)
Sets the image coordinate system used to convert between image and world spaces.

Parameters:
newCoords - the image coordinate system

getCoords

public ImageCoordSystem getCoords()
Gets the current image coordinate system used for drawing.

Returns:
the current image coordinate system

setDataFile

public void setDataFile(java.io.File file)
Sets the file in which data is saved.

Parameters:
file - the data file

getDataFile

public java.io.File getDataFile()
Gets the file where data is saved.

Returns:
the data file

getFilePath

public java.lang.String getFilePath()
Gets the default path for the saveAs method.

Returns:
the relative path to the file

setDrawingInImageSpace

public void setDrawingInImageSpace(boolean imagespace)
Sets the drawing space to imagespace or worldspace.

Parameters:
imagespace - true to draw in imagespace

isDrawingInImageSpace

public boolean isDrawingInImageSpace()
Returns true if this is drawing in image space rather than world space.

Returns:
true if drawing in image space

getPlayer

public VideoPlayer getPlayer()
Gets the video player.

Returns:
the video player

setPlayerVisible

public void setPlayerVisible(boolean visible)
Shows or hides the video player.

Parameters:
visible - true to show the player

isPlayerVisible

public boolean isPlayerVisible()
Gets the video player visibility.

Returns:
true if the player is visible

getStepNumber

public int getStepNumber()
Gets the current step number.

Returns:
the current step number

getFrameNumber

public int getFrameNumber()
Gets the current frame number.

Returns:
the frame number

getDrawables

public java.util.ArrayList<Drawable> getDrawables()
Overrides DrawingPanel getDrawables method.

Overrides:
getDrawables in class DrawingPanel
Returns:
a list of Drawable objects

addDrawable

public void addDrawable(Drawable drawable)
Adds a drawable object to the drawable list.

Overrides:
addDrawable in class InteractivePanel
Parameters:
drawable - the drawable object

removeDrawable

public void removeDrawable(Drawable drawable)
Removes a drawable object from the drawable list.

Overrides:
removeDrawable in class DrawingPanel
Parameters:
drawable - the drawable object

removeObjectsOfClass

public <T extends Drawable> void removeObjectsOfClass(java.lang.Class<T> c)
Removes all objects of the specified class.

Overrides:
removeObjectsOfClass in class DrawingPanel
Parameters:
c - the class to remove
See Also:
DrawingPanel.removeDrawables(Class c)

clear

public void clear()
Removes all drawable objects except the video. To remove the video, use setVideo(null);

Overrides:
clear in class InteractivePanel

addFilter

public void addFilter(java.lang.Class<? extends Filter> filterClass)
Adds a video filter class to the map of available filters.

Parameters:
filterClass - the filter class to add

removeFilter

public void removeFilter(java.lang.Class<?> filterClass)
Removes a video filter class from the map of available filters.

Parameters:
filterClass - the filter class to remove

getFilters

public java.util.Map<java.lang.String,java.lang.Class<? extends Filter>> getFilters()
Gets the map of available video filters.

Returns:
the map of available video filters

isShowCoordinates

public boolean isShowCoordinates()
Returns true if mouse coordinates are displayed

Returns:
true if mouse coordinates are displayed

hideMouseBox

public void hideMouseBox()
Hides the mouse box


propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Responds to property change events. VideoPanel listens for the following events: "videoclip" and "stepnumber" from VideoPlayer, "coords" and "image" from Video.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
e - the property change event

paintEverything

protected void paintEverything(java.awt.Graphics g)
Overrides DrawingPanel paintEverything method.

Overrides:
paintEverything in class DrawingPanel
Parameters:
g - the graphics context to draw on

scale

protected void scale(java.util.ArrayList<Drawable> drawables)
Overrides DrawingPanel scale method to handle drawing in imagespace

Overrides:
scale in class DrawingPanel
Parameters:
drawables - the list of drawable objects

checkImage

protected boolean checkImage()
Overrides DrawingPanel checkImage method so offscreenImage will not include the videoPlayer.

Returns:
true if the image is correctly sized

getWorldMousePoint

public java.awt.geom.Point2D getWorldMousePoint()
Gets the world coordinates of the last mouse event

Returns:
world coordinates of last mouse event

getLoader

public static XML.ObjectLoader getLoader()
Returns an XML.ObjectLoader to save and load data for this object.

Returns:
the object loader