|
MATES 3.0-rc2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mates.sim.Experiment
org.mates.plugins.TopologyMoviePlugin
A plugin experiment for recording a movie of the topology, by
taking one screenshot per simulator iteration. Note that for an
actual movie file to be created (as opposed to a directory full of
individual frames), MPlayer's mencoder
utility is
required to be installed on the system. This utility is usually
installed automatically with mplayer
.
By default, this TopologyMoviePlugin renders the topology
using a DefaultTopologyVisualizer
. However,
this may be overridden with a custom TopologyVisualizer
by calling setTopologyVisualizer(TopologyVisualizer)
.
Also by default, all frames created by this plugin are
temporary and will be deleted when the JVM exits. To make
frames permanent, use setAllFramesTemporary(boolean)
.
Finally, note that the TopologyMoviePlugin does not
automatically capture frames by default. To start capturing
frames, call startCapture()
.
Nested Class Summary | |
class |
TopologyMoviePlugin.ScreenshotProvider
Class used as a callback for Screenshot.saveScreenshot(java.lang.Object, int,
int, java.io.File) to prevent the topology visualizer from
double buffering. |
Field Summary |
Fields inherited from class org.mates.sim.Experiment |
parent, simulator |
Constructor Summary | |
TopologyMoviePlugin(Experiment parent,
java.io.File directory,
java.lang.String filePrefix)
Creates a new TopologyMoviePlugin. |
Method Summary | |
void |
captureFrame()
Manually causes the plugin to record a new frame from the TopologyVisualizer . |
void |
cleanup()
Forcefully deletes all frames since either the last cleanup or experiment reset. |
java.io.File |
getDirectory()
Returns the directory to which the individual frames are being stored. |
long |
getFrameCounter()
Returns the current value of the frame counter. |
java.util.LinkedList |
getFrames()
Returns a LinkedList of File
objects pointing to the individual frames of the movie. |
java.awt.Component |
getGUI()
Returns the GUI component associated with this experiment. |
protected void |
handleInitialize()
Callback function for initializing the experiment. |
protected void |
handleIterate()
Callback function for iterating the experiment. |
protected void |
handleReset()
Callback function for resetting the experiment. |
boolean |
isCapturing()
Returns true if the plugin is currently
automatically capturing frames. |
void |
saveToMovie(java.io.File pathForMovie,
int fps,
java.lang.String videoCodec)
Saves the current set of frames to a movie. |
boolean |
saveTopologyScreenshot(java.io.File saveFile)
Saves a screenshot of the current topology to saveFile . |
void |
setAllFramesTemporary(boolean framesAreTemporary)
Sets whether or not individual frames will be deleted once the JVM exits. |
void |
setFrameCounter(long numFrames)
Sets the index of the current frame. |
void |
setTopologyVisualizer(TopologyVisualizer visualizer)
Sets the topology visualizer that will be used to render the individual frames of the movie. |
void |
startCapture()
Causes the plugin to start automatically capturing frames, one per iteration. |
void |
stopCapture()
Causes the plugin to stop automatically capturing frames. |
Methods inherited from class org.mates.sim.Experiment |
complete, getMenuItems, getParentExperiment, getSimulator, getSubExperiments, handleMenuAction, initialize, iterate, reset |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TopologyMoviePlugin(Experiment parent, java.io.File directory, java.lang.String filePrefix)
parent
- the parent experiment in the experiment tree.directory
- the directory to which to save the individual
frames before they are combined into a movie. If this is
null
, a new temporary directory will be created in
the system's default temporary directory.filePrefix
- a prefix to the frame number of an image. If
null
, no prefix will be used. For example, if
filePrefix
equals "image"
, the frames
will be named, "image0001.png," "image0002.png," et
cetera.Method Detail |
public java.util.LinkedList getFrames()
LinkedList
of File
objects pointing to the individual frames of the movie.
public void setTopologyVisualizer(TopologyVisualizer visualizer)
public boolean saveTopologyScreenshot(java.io.File saveFile) throws java.lang.ClassNotFoundException, java.io.IOException
saveFile
.
true
on success.
java.lang.ClassNotFoundException
- when writing to an EPS file and
org.jibble.epsgraphics.EpsGraphics2D
cannot be found.
java.io.IOException
- on error writing to saveFile
.protected void handleIterate()
Experiment
super.handleIterate()
need not be called from
re-implementations of this function.
handleIterate
in class Experiment
protected void handleInitialize()
Experiment
super.handleInitialize()
need not be called from
re-implementations of this function.
handleInitialize
in class Experiment
protected void handleReset()
Experiment
super.handleReset()
need not be called from
re-implementations of this function.
handleReset
in class Experiment
public void setAllFramesTemporary(boolean framesAreTemporary)
true
to this function.
public void cleanup()
cleanup
or experiment reset. This will also reset
the frame counter to zero.
public void setFrameCounter(long numFrames)
public long getFrameCounter()
public java.io.File getDirectory()
directory
argument to the constructor was passed as null
).
public void saveToMovie(java.io.File pathForMovie, int fps, java.lang.String videoCodec) throws java.lang.Exception
cleanup()
or the last experiment
reset.
Note that this function requires that mencoder
be installed and runnable on the system.
pathForMovie
- file to which to save the movie.fps
- the number of frames per second at which the movie
will play back.videoCodec
- string representing the video codec to be
used. This will be passed verbatim to the
mencoder
"-ovc
" option. Examples
include "copy" and "lavc". Different mencoder
installations may have different codecs available; run
`mencoder -ovc help
` to get a list of the
available codecs. If videoCodec
is
null
, the codec will be set to "copy".
java.lang.Exception
- if either mencoder
was not
found, or mencoder
returned an error.public void captureFrame() throws java.lang.IllegalArgumentException, java.lang.ClassNotFoundException, java.io.IOException
TopologyVisualizer
.
java.lang.IllegalArgumentException
java.lang.ClassNotFoundException
java.io.IOException
public boolean isCapturing()
true
if the plugin is currently
automatically capturing frames.
startCapture()
public void startCapture()
public void stopCapture()
public java.awt.Component getGUI()
Experiment
GraphicalUserInterface
is used.
This function defaults to return null
.
getGUI()
is intended for child classes that extend
Experiment
to re-implement this function and
return a GUI object.
getGUI
in class Experiment
|
MATES 3.0-rc2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |