Package org.opensourcephysics.media.core
Class ImageVideo
java.lang.Object
org.opensourcephysics.display.OSPRuntime.Supported
org.opensourcephysics.media.core.VideoAdapter
org.opensourcephysics.media.core.ImageVideo
- All Implemented Interfaces:
PropertyChangeListener
,EventListener
,Drawable
,Interactive
,Measurable
,DrawableImage
,InteractiveImage
,Trackable
,Video
This is a Video assembled from one or more still images.
- Version:
- 1.0
- Author:
- Douglas Brown
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected double
protected Image[]
protected Component
protected String[]
protected boolean
protected BufferedImage
protected Dimension
Fields inherited from class org.opensourcephysics.media.core.VideoAdapter
aspects, baseDir, bufferedImage, clearRaster, coords, displayedSize, endFrameNumber, filteredImage, filterStack, frameCount, frameNumber, isMeasured, isValidFilteredImage, isValidImage, isValidMeasure, looping, maxX, maxY, minX, minY, mouseEnabled, playing, properties, rate, rawImage, size, startFrameNumber, startTimesMS, visible, widthDominates
Fields inherited from interface org.opensourcephysics.media.core.Trackable
PROPERTY_ADJUSTING
Fields inherited from interface org.opensourcephysics.media.core.Video
PROPERTY_VIDEO_COORDS, PROPERTY_VIDEO_ENDFRAME, PROPERTY_VIDEO_FILTERCHANGED, PROPERTY_VIDEO_FRAMENUMBER, PROPERTY_VIDEO_IMAGE, PROPERTY_VIDEO_LOOPING, PROPERTY_VIDEO_NEXTFRAME, PROPERTY_VIDEO_PLAYING, PROPERTY_VIDEO_RATE, PROPERTY_VIDEO_SIZE, PROPERTY_VIDEO_VIDEOVISIBLE
-
Constructor Summary
ConstructorsConstructorDescriptionImageVideo
(Image clipBoardImage) Creates an editable ImageVideo from an image pasted from the clipboard.ImageVideo
(String imageName) Creates a read-only ImageVideo and loads a named image or image sequence, asking the user if they want just the first image or all, if numbers are found.ImageVideo
(String imageName, String basePath, boolean sequence) Creates a read-only ImageVideo and loads a named image or image sequence.ImageVideo
(ImageVideo video) Creates an editable ImageVideo from another ImageVideo Replaces ImageVideo(BufferedImage[]) BH: Code moved here from VideoIO Called by VideoIO.clone (which is not referenced?), untested. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Appends the named image or image sequence to the end of this video.void
Appends the named image or image sequence to the end of this video.double
Gets the end time in milliseconds.double
Gets the duration of the video.double
getFrameTime
(int n) Gets the start time of the specified frame in milliseconds.getImage()
Gets the current video image after applying enabled filters.Image[]
Gets the image array.static XML.ObjectLoader
Returns an XML.ObjectLoader to save and load ImageVideo data.static String
getNextImagePathInSequence
(String imagePath) Gets the RGB size of this image video.getStackPaths
(String imagePath) Returns a list of all numbered images that follow the original name pattern.Returns the VideoType name of this video.String[]
Returns the valid paths (i.e., those that are not "").protected String[]
Returns the valid paths (i.e., those that are not "") relative to a base path.protected void
Inserts images starting at the specified index.void
Inserts an image at the specified index.void
Inserts the named image or image sequence at the specified index.void
Inserts the named image or image sequence at the specified index.boolean
Returns true if all images are loaded into memory.boolean
Returns true if all of the images are associated with files.void
play()
Plays the video at the current rate.remove
(int index) Removes the image at the specified index.boolean
Allows user to save invalid images, if any.void
setEditable
(boolean edit) Sets the editable property.void
setEndTime
(double millis) Sets the end time in milliseconds.void
setFrameDuration
(double millis) Sets the frame duration in milliseconds.void
setFrameNumber
(int n) Sets the video frame number.protected void
void
stop()
Stops the video.toString()
protected void
Methods inherited from class org.opensourcephysics.media.core.VideoAdapter
back, dispose, draw, finalize, findInteractive, findMinMaxValues, getAbsolutePath, getAngle, getCoords, getEndFrameNumber, getFilterStack, getFrameCount, getFrameDuration, getFrameNumber, getHeight, getImageSize, getProperty, getPropertyNames, getRate, getRawBufferedImage, getRelativeAspect, getStartFrameNumber, getStartTime, getWidth, getX, getXMax, getXMin, getY, getYMax, getYMin, goToEnd, goToStart, initialize, invalidateVideoAndFilter, isEnabled, isLooping, isMeasured, isPlaying, isVisible, notifyFrame, notifySize, propertyChange, refreshBufferedImage, reset, setAngle, setCoords, setEnabled, setEndFrameNumber, setFilterStack, setFrameAngle, setFrameCount, setFrameHeight, setFrameRelativeAspect, setFrameWidth, setFrameX, setFrameXY, setFrameY, setHeight, setLooping, setNotify, setPlaying, setProperty, setRate, setRelativeAspect, setStartFrameNumber, setStartTime, setVisible, setWidth, setX, setXY, setY, step
Methods inherited from class org.opensourcephysics.display.OSPRuntime.Supported
addListeners, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListenerSafely, dispose, firePropertyChange, firePropertyChange, removeListeners, removePropertyChangeListener, removePropertyChangeListener
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opensourcephysics.display.Interactive
isInteractive
Methods inherited from interface org.opensourcephysics.media.core.Video
addListener, addPropertyChangeListener, addPropertyChangeListener, getAverageFrameDuration, getAverageFrameRate, getOutliers, isValid, removeListener, removePropertyChangeListener, removePropertyChangeListener
-
Field Details
-
observer
-
images
-
rgbImage
-
paths
-
readOnly
protected boolean readOnly -
deltaT
protected double deltaT -
rgbSize
-
-
Constructor Details
-
ImageVideo
Creates a read-only ImageVideo and loads a named image or image sequence. The standard constructor.- Parameters:
imageName
- the name of the image filesequence
- true to automatically load image sequence, if any- Throws:
IOException
-
ImageVideo
Creates a read-only ImageVideo and loads a named image or image sequence, asking the user if they want just the first image or all, if numbers are found. No reference to this constructor in osp, ejs, or tracker- Parameters:
imageName
- the name of the image file- Throws:
IOException
-
ImageVideo
Creates an editable ImageVideo from an image pasted from the clipboard. No questions are asked.- Parameters:
clipBoardImage
- the image
-
ImageVideo
Creates an editable ImageVideo from another ImageVideo Replaces ImageVideo(BufferedImage[]) BH: Code moved here from VideoIO Called by VideoIO.clone (which is not referenced?), untested.- Parameters:
images
- the image array
-
-
Method Details
-
play
public void play()Plays the video at the current rate. -
stop
public void stop()Stops the video. -
setFrameNumber
public void setFrameNumber(int n) Description copied from class:VideoAdapter
Sets the video frame number.- Specified by:
setFrameNumber
in interfaceVideo
- Overrides:
setFrameNumber
in classVideoAdapter
- Parameters:
n
- the desired frame number- See Also:
-
setFrameDuration
public void setFrameDuration(double millis) Sets the frame duration in milliseconds.- Parameters:
millis
- the desired frame duration in milliseconds
-
getEndTime
public double getEndTime()Gets the end time in milliseconds.- Specified by:
getEndTime
in interfaceVideo
- Overrides:
getEndTime
in classVideoAdapter
- Returns:
- the end time in milliseconds, or -1 if not known
-
setEndTime
public void setEndTime(double millis) Sets the end time in milliseconds. NOTE: the actual end time is set to the end of a frame.- Specified by:
setEndTime
in interfaceVideo
- Overrides:
setEndTime
in classVideoAdapter
- Parameters:
millis
- the desired end time in milliseconds
-
getFrameCountDurationMS
public double getFrameCountDurationMS()Gets the duration of the video.- Returns:
- the duration of the video in milliseconds, or -1 if not known
-
getFrameTime
public double getFrameTime(int n) Gets the start time of the specified frame in milliseconds.- Specified by:
getFrameTime
in interfaceVideo
- Overrides:
getFrameTime
in classVideoAdapter
- Parameters:
n
- the frame number- Returns:
- the start time of the frame in milliseconds, or -1 if not known
-
getImages
Gets the image array.- Returns:
- the image array
-
append
Appends the named image or image sequence to the end of this video. This method will ask user whether to load sequences, if any.- Parameters:
imageName
- the image name- Throws:
IOException
-
append
Appends the named image or image sequence to the end of this video.- Parameters:
imageName
- the image namesequence
- true to automatically load image sequence, if any- Throws:
IOException
-
insert
Inserts the named image or image sequence at the specified index. This method will ask user whether to load sequences, if any.- Parameters:
imageName
- the image nameindex
- the index- Throws:
IOException
-
insert
Inserts the named image or image sequence at the specified index.- Parameters:
imageName
- the image nameindex
- the indexsequence
- true to automatically load image sequence, if any- Throws:
IOException
-
insert
Inserts an image at the specified index.- Parameters:
image
- the imageindex
- the index
-
remove
Removes the image at the specified index.- Parameters:
index
- the index- Returns:
- the path of the image, or null if none removed
-
getRGBSize
Gets the RGB size of this image video.- Returns:
- the RGB size of the current image
-
isFileBased
public boolean isFileBased()Returns true if all of the images are associated with files.- Returns:
- true if all images are file-based
-
isEditable
public boolean isEditable()Returns true if all images are loaded into memory.- Returns:
- true if editable
-
setEditable
Sets the editable property.- Parameters:
edit
- true to edit- Throws:
IOException
-
saveInvalidImages
public boolean saveInvalidImages()Allows user to save invalid images, if any.- Returns:
- true if saved
-
getValidPaths
Returns the valid paths (i.e., those that are not ""). Invalid paths are associated with pasted images rather than files.- Returns:
- the valid paths
-
getValidPathsRelativeTo
Returns the valid paths (i.e., those that are not "") relative to a base path. Invalid paths are associated with pasted images rather than files.- Parameters:
base
- a base path- Returns:
- the valid relative paths
-
insert
Inserts images starting at the specified index.- Parameters:
newImages
- an array of images. May be null if readOnlyindex
- the insertion indeximagePaths
- array of image file paths.
-
updateBufferedImage
protected void updateBufferedImage()- Overrides:
updateBufferedImage
in classVideoAdapter
-
getImage
Gets the current video image after applying enabled filters.- Specified by:
getImage
in interfaceDrawableImage
- Overrides:
getImage
in classVideoAdapter
- Returns:
- the current video image with filters applied
-
getNextImagePathInSequence
-
getStackPaths
Returns a list of all numbered images that follow the original name pattern. Note this does NOT check to see if the path resources exist.- Returns:
- the list
-
getLoader
Returns an XML.ObjectLoader to save and load ImageVideo data.- Returns:
- the object loader
-
getTypeName
Description copied from interface:Video
Returns the VideoType name of this video. -
toString
-
setStartTimes
protected void setStartTimes()- Specified by:
setStartTimes
in classVideoAdapter
-