|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opensourcephysics.media.core.VideoAdapter
public class VideoAdapter
This provides basic implementations of all Video methods. Subclasses should provide a raw image for display--see ImageVideo for an example.
Field Summary | |
---|---|
protected DoubleArray |
aspects
|
protected java.awt.image.BufferedImage |
bufferedImage
|
protected java.awt.image.Raster |
clearRaster
|
protected ImageCoordSystem |
coords
|
protected int |
endFrameNumber
|
protected java.awt.image.BufferedImage |
filteredImage
|
protected FilterStack |
filterStack
|
protected int |
frameCount
|
protected int |
frameNumber
|
protected boolean |
isMeasured
|
protected boolean |
isValidFilteredImage
|
protected boolean |
isValidImage
|
protected boolean |
isValidMeasure
|
protected boolean |
looping
|
protected double |
maxX
|
protected double |
maxY
|
protected double |
minX
|
protected double |
minY
|
protected boolean |
mouseEnabled
|
protected boolean |
playing
|
protected java.util.HashMap<java.lang.String,java.lang.Object> |
properties
|
protected double |
rate
|
protected java.awt.Image |
rawImage
|
protected java.awt.Dimension |
size
|
protected int |
startFrameNumber
|
protected java.beans.PropertyChangeSupport |
support
|
protected boolean |
visible
|
protected boolean |
widthDominates
|
Constructor Summary | |
---|---|
protected |
VideoAdapter()
Protected constructor creates an empty VideoAdapter |
Method Summary | |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to this video. |
void |
addPropertyChangeListener(java.lang.String property,
java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to this video. |
void |
back()
Steps the video back one frame. |
void |
dispose()
Disposes of this video. |
void |
draw(DrawingPanel panel,
java.awt.Graphics g)
Draws the video image on the panel. |
protected void |
finalize()
Called by the garbage collector when this video is no longer in use. |
Interactive |
findInteractive(DrawingPanel panel,
int xpix,
int ypix)
Returns this video if enabled. |
protected void |
findMinMaxValues()
Finds the min and max values of x and y. |
protected void |
firePropertyChange(java.lang.String property,
java.lang.Object oldVal,
java.lang.Object newVal)
Sends a PropertyChangeEvent to registered listeners. |
double |
getAngle()
Gets the angle in radians of the curent video frame measured ccw from the world x-axis. |
ImageCoordSystem |
getCoords()
Gets the image coordinate system. |
double |
getDuration()
Gets the duration of the video. |
int |
getEndFrameNumber()
Gets the end frame number. |
double |
getEndTime()
Gets the end time in milliseconds. |
FilterStack |
getFilterStack()
Gets the filter stack. |
int |
getFrameCount()
Gets the total number of video frames. |
double |
getFrameDuration(int n)
Gets the duration of the specified frame in milliseconds. |
int |
getFrameNumber()
Gets the current video frame number. |
double |
getFrameTime(int n)
Gets the start time of the specified frame in milliseconds. |
double |
getHeight()
Gets the current height of the video frame. |
java.awt.image.BufferedImage |
getImage()
Gets the current video image after applying enabled filters. |
java.lang.Object |
getProperty(java.lang.String name)
Gets a user property of the video. |
java.util.Collection<java.lang.String> |
getPropertyNames()
Gets a collection of user property names for the video. |
double |
getRate()
Gets the relative play rate. |
double |
getRelativeAspect()
Gets the relative aspect of the current video frame. |
int |
getStartFrameNumber()
Gets the start frame number. |
double |
getStartTime()
Gets the start time in milliseconds. |
double |
getTime()
Gets the current video time in milliseconds. |
double |
getWidth()
Gets the current width of the video frame. |
double |
getX()
Gets x position of upper left corner of the current video frame in world units. |
double |
getXMax()
Gets the maximum x needed to draw this object. |
double |
getXMin()
Gets the minimum x needed to draw this object. |
double |
getY()
Gets y position of upper left corner of the current video frame in world units. |
double |
getYMax()
Gets the maximum y needed to draw this object. |
double |
getYMin()
Gets the minimum y needed to draw this object. |
void |
goToEnd()
Sets the frame number to the end frame. |
void |
goToStart()
Sets the frame number to the start frame. |
protected void |
initialize()
Initialize this video. |
boolean |
isEnabled()
Gets whether this responds to mouse hits. |
boolean |
isLooping()
Gets the looping state of the video. |
boolean |
isMeasured()
Reports whether information is available to set min/max values. |
boolean |
isPlaying()
Gets the playing state of this video. |
boolean |
isVisible()
Gets the visibility of the video. |
void |
play()
Plays the video at the current rate. |
void |
propertyChange(java.beans.PropertyChangeEvent e)
Responds to property change events. |
protected void |
refreshBufferedImage()
Refreshes the BufferedImage based on current size. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from this video. |
void |
removePropertyChangeListener(java.lang.String property,
java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener for a specified property. |
void |
reset()
Stops the video and resets it to the start time. |
void |
setAngle(double theta)
Sets the angle in radians of all video frames measured ccw from the world x-axis. |
void |
setCoords(ImageCoordSystem coords)
Sets the image coordinate system used to convert from imagespace to worldspace. |
void |
setEnabled(boolean enabled)
Sets whether this responds to mouse hits. |
void |
setEndFrameNumber(int n)
Sets the end frame number. |
void |
setEndTime(double millis)
Sets the end time in milliseconds. |
void |
setFilterStack(FilterStack stack)
Sets the filter stack. |
void |
setFrameAngle(int n,
double theta)
Sets the angle in radians of the specified video frame measured ccw from the world x-axis. |
void |
setFrameHeight(int n,
double height)
Sets the height of the specified video frame in world units. |
void |
setFrameNumber(int n)
Sets the video frame number. |
void |
setFrameRelativeAspect(int n,
double relativeAspect)
Sets the relative aspect of the specified video frame. |
void |
setFrameWidth(int n,
double width)
Sets the width of the specified video frame in world units. |
void |
setFrameX(int n,
double x)
Sets x position of upper left corner of the specified video frame in world units. |
void |
setFrameXY(int n,
double x,
double y)
Sets the x and y position of the UL corner of the specified video frame in world units. |
void |
setFrameY(int n,
double y)
Sets y position of upper left corner of the specified video frame in world units. |
void |
setHeight(double height)
Sets the height of all video frames in world units. |
void |
setLooping(boolean loops)
Sets the looping state of this video. |
void |
setPlaying(boolean playing)
Starts and stops the video. |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Sets a user property of the video. |
void |
setRate(double rate)
Sets the relative play rate. |
void |
setRelativeAspect(double relativeAspect)
Sets the relative aspect of all video frames. |
void |
setStartFrameNumber(int n)
Sets the start frame number. |
void |
setStartTime(double millis)
Sets the start time in milliseconds. |
void |
setTime(double millis)
Sets the video time in milliseconds. |
void |
setVisible(boolean visible)
Shows or hides the video. |
void |
setWidth(double width)
Sets the width of all video frames in world units. |
void |
setX(double x)
Sets x position of upper left corner of all video frames in world units. |
void |
setXY(double x,
double y)
Sets the x and y position of the UL corner of all video frames in world units. |
void |
setY(double y)
Sets y position of upper left corner of all video frames in world units. |
void |
step()
Steps the video forward one frame. |
void |
stop()
Stops the video. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.awt.Image rawImage
protected java.awt.Dimension size
protected java.awt.image.BufferedImage bufferedImage
protected java.awt.image.BufferedImage filteredImage
protected int frameCount
protected int frameNumber
protected int startFrameNumber
protected int endFrameNumber
protected double rate
protected boolean playing
protected boolean looping
protected double minX
protected double maxX
protected double minY
protected double maxY
protected boolean mouseEnabled
protected boolean visible
protected boolean isMeasured
protected boolean isValidMeasure
protected boolean widthDominates
protected boolean isValidImage
protected boolean isValidFilteredImage
protected ImageCoordSystem coords
protected DoubleArray aspects
protected java.beans.PropertyChangeSupport support
protected java.util.HashMap<java.lang.String,java.lang.Object> properties
protected FilterStack filterStack
protected java.awt.image.Raster clearRaster
Constructor Detail |
---|
protected VideoAdapter()
Method Detail |
---|
public void draw(DrawingPanel panel, java.awt.Graphics g)
draw
in interface Drawable
panel
- the drawing panel requesting the drawingg
- the graphics context on which to drawpublic void setVisible(boolean visible)
setVisible
in interface DrawableImage
visible
- true
to show the videopublic boolean isVisible()
isVisible
in interface DrawableImage
true
if the video is visiblepublic double getXMin()
getXMin
in interface Measurable
public double getXMax()
getXMax
in interface Measurable
public double getYMin()
getYMin
in interface Measurable
public double getYMax()
getYMax
in interface Measurable
public boolean isMeasured()
isMeasured
in interface Measurable
true
if min/max values are validpublic java.awt.image.BufferedImage getImage()
getImage
in interface DrawableImage
public Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
findInteractive
in interface Interactive
panel
- the drawing panelxpix
- the x coordinate in pixelsypix
- the y coordinate in pixels
public void setEnabled(boolean enabled)
setEnabled
in interface Interactive
enabled
- true
if this responds to mouse hits.public boolean isEnabled()
isEnabled
in interface Interactive
true
if this responds to mouse hits.public void setFrameX(int n, double x)
setFrameX
in interface Video
n
- the video frame numberx
- the world x positionpublic void setX(double x)
setX
in interface Interactive
x
- the world x positionpublic void setFrameY(int n, double y)
setFrameY
in interface Video
n
- the video frame numbery
- the world y positionpublic void setY(double y)
setY
in interface Interactive
y
- the world y positionpublic double getX()
getX
in interface Interactive
public double getY()
getY
in interface Interactive
public void setFrameXY(int n, double x, double y)
setFrameXY
in interface Video
n
- the video frame numberx
- the world x positiony
- the world y positionpublic void setXY(double x, double y)
setXY
in interface Interactive
x
- the world x positiony
- the world y positionpublic void setFrameRelativeAspect(int n, double relativeAspect)
setFrameRelativeAspect
in interface Video
n
- the video frame numberrelativeAspect
- the desired relative aspectpublic void setRelativeAspect(double relativeAspect)
setRelativeAspect
in interface InteractiveImage
relativeAspect
- the desired relative aspectpublic double getRelativeAspect()
getRelativeAspect
in interface InteractiveImage
InteractiveImage.setRelativeAspect(double)
public void setFrameWidth(int n, double width)
setFrameWidth
in interface Video
n
- the video frame numberwidth
- the width in world unitssetRelativeAspect(double)
public void setWidth(double width)
setWidth
in interface InteractiveImage
width
- the width in world unitssetRelativeAspect(double)
public double getWidth()
getWidth
in interface InteractiveImage
public void setFrameHeight(int n, double height)
setFrameHeight
in interface Video
n
- the video frame numberheight
- the height in world unitssetRelativeAspect(double)
public void setHeight(double height)
setHeight
in interface InteractiveImage
height
- the height in world unitssetRelativeAspect(double)
public double getHeight()
getHeight
in interface InteractiveImage
public void setFrameAngle(int n, double theta)
setFrameAngle
in interface Video
n
- the video frame numbertheta
- the angle in radianspublic void setAngle(double theta)
setAngle
in interface InteractiveImage
theta
- the angle in radianspublic double getAngle()
getAngle
in interface InteractiveImage
public void step()
step
in interface Video
public void back()
back
in interface Video
public int getFrameCount()
getFrameCount
in interface Video
public int getFrameNumber()
getFrameNumber
in interface Video
public void setFrameNumber(int n)
setFrameNumber
in interface Video
n
- the desired frame numberVideo.getStartFrameNumber()
,
Video.getEndFrameNumber()
public int getStartFrameNumber()
getStartFrameNumber
in interface Video
getEndFrameNumber()
public void setStartFrameNumber(int n)
setStartFrameNumber
in interface Video
n
- the desired start frame numbersetEndFrameNumber(int)
public int getEndFrameNumber()
getEndFrameNumber
in interface Video
getStartFrameNumber()
public void setEndFrameNumber(int n)
setEndFrameNumber
in interface Video
n
- the desired end frame number,setStartFrameNumber(int)
public double getFrameTime(int n)
getFrameTime
in interface Video
n
- the frame number
public double getFrameDuration(int n)
getFrameDuration
in interface Video
n
- the frame number
public void play()
play
in interface Playable
public void stop()
stop
in interface Playable
public void reset()
reset
in interface Playable
public double getTime()
getTime
in interface Playable
public void setTime(double millis)
setTime
in interface Playable
millis
- the desired time in millisecondspublic double getStartTime()
getStartTime
in interface Playable
public void setStartTime(double millis)
setStartTime
in interface Playable
millis
- the desired start time in millisecondspublic double getEndTime()
getEndTime
in interface Playable
public void setEndTime(double millis)
setEndTime
in interface Playable
millis
- the desired end time in millisecondspublic double getDuration()
getDuration
in interface Playable
public void goToStart()
goToStart
in interface Playable
public void goToEnd()
goToEnd
in interface Playable
public void setPlaying(boolean playing)
setPlaying
in interface Playable
playing
- true
starts the video, and
false
stops itpublic boolean isPlaying()
isPlaying
in interface Playable
true
if the video is playingpublic void setLooping(boolean loops)
setLooping
in interface Playable
loops
- true
if the video loopspublic boolean isLooping()
isLooping
in interface Playable
true
if the video loopspublic void setRate(double rate)
setRate
in interface Playable
rate
- the relative play rate.public double getRate()
getRate
in interface Playable
public void setCoords(ImageCoordSystem coords)
setCoords
in interface InteractiveImage
coords
- the image coordinate systempublic ImageCoordSystem getCoords()
getCoords
in interface InteractiveImage
public void setFilterStack(FilterStack stack)
setFilterStack
in interface DrawableImage
stack
- the new filter stackpublic FilterStack getFilterStack()
getFilterStack
in interface DrawableImage
public void setProperty(java.lang.String name, java.lang.Object value)
setProperty
in interface DrawableImage
name
- the name of the propertyvalue
- the value of the propertypublic java.lang.Object getProperty(java.lang.String name)
getProperty
in interface DrawableImage
name
- the name of the property
public java.util.Collection<java.lang.String> getPropertyNames()
getPropertyNames
in interface DrawableImage
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in interface Playable
listener
- the object requesting property change notificationpublic void addPropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in interface Playable
property
- the name of the property of interest to the listenerlistener
- the object requesting property change notificationpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in interface Playable
listener
- the listener requesting removalpublic void removePropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in interface Playable
property
- the name of the propertylistener
- the listener to removepublic void dispose()
dispose
in interface Video
public void propertyChange(java.beans.PropertyChangeEvent e)
propertyChange
in interface java.beans.PropertyChangeListener
e
- the property change eventprotected void firePropertyChange(java.lang.String property, java.lang.Object oldVal, java.lang.Object newVal)
property
- the name of the property that has changedoldVal
- the value of the property before the change (may be null)newVal
- the value of the property after the change (may be null)protected void finalize()
finalize
in class java.lang.Object
protected void initialize()
protected void refreshBufferedImage()
protected void findMinMaxValues()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |