Class PlotRecorder

java.lang.Object
com.eco.bio7.spatial.PlotRecorder

public class PlotRecorder extends Object
Records a plot of the plot API (see Plot3D) frame by frame, e.g., a plot which is updated in each step of a simulation (see Plot3D.update), and exports the recording to an HTML page with WebGL: the plot with the axes, the title and the legends of each frame, Play/Pause, a timeline, the speed and a loop (the view can be rotated and zoomed while the recording plays) or for Blender as an animation (see exportBlender).
PlotRecorder recorder = new PlotRecorder().speed(10);
for (int t = 0; t < 100; t++) {
        step(); // the model
        plot.clearLayers().add(Plot3D.scatter(x, y, z)).update();
        recorder.frame(plot);
}
recorder.export("/path/recording.html");
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    autoplay(boolean autoplay)
    Plays the recording when the page is opened (default false).
    blender(boolean keep)
    Keeps the geometry of the frames for the Blender export (default true, false needs less memory for a long recording which is only exported to HTML).
    Removes the recorded frames.
    export(String file)
    Writes the HTML page of the recording.
    Exports the recording for Blender as an animation: a glTF file (*.glb) with the objects of all frames (an object which doesn't change is exported once) and a Python script with the same name (*.py) which imports the file and animates the visibility of the objects and the texts (the frames 1 ...
    frame(Plot3D plot)
    Records the current state of a plot as a frame (the plot is computed if it was not displayed or updated).
    int
    Returns the number of the recorded frames.
    loop(boolean loop)
    Plays the recording again from the start (default true, a check box of the page).
    maxFrames(int maxFrames)
    The maximum number of the frames (default 10000, further frames are ignored).
    speed(double framesPerSecond)
    The speed of the playback in frames per second (default 10).
    Returns the HTML page of the recording.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PlotRecorder

      public PlotRecorder()
  • Method Details

    • frame

      public PlotRecorder frame(Plot3D plot)
      Records the current state of a plot as a frame (the plot is computed if it was not displayed or updated).
      Parameters:
      plot - the plot
      Returns:
      the recorder
    • speed

      public PlotRecorder speed(double framesPerSecond)
      The speed of the playback in frames per second (default 10).
    • loop

      public PlotRecorder loop(boolean loop)
      Plays the recording again from the start (default true, a check box of the page).
    • autoplay

      public PlotRecorder autoplay(boolean autoplay)
      Plays the recording when the page is opened (default false).
    • maxFrames

      public PlotRecorder maxFrames(int maxFrames)
      The maximum number of the frames (default 10000, further frames are ignored).
    • blender

      public PlotRecorder blender(boolean keep)
      Keeps the geometry of the frames for the Blender export (default true, false needs less memory for a long recording which is only exported to HTML).
    • exportBlender

      public String exportBlender(String file) throws IOException
      Exports the recording for Blender as an animation: a glTF file (*.glb) with the objects of all frames (an object which doesn't change is exported once) and a Python script with the same name (*.py) which imports the file and animates the visibility of the objects and the texts (the frames 1 ... n of the timeline of Blender with the speed of the recording), e.g., to render a film. In Blender: Scripting - Open - Run Script.
      Parameters:
      file - the glTF file (*.glb), the script is written next to it
      Returns:
      the path of the Python script
      Throws:
      IOException - if a file cannot be written
    • frames

      public int frames()
      Returns the number of the recorded frames.
    • clear

      public PlotRecorder clear()
      Removes the recorded frames.
    • toHtml

      public String toHtml()
      Returns the HTML page of the recording.
    • export

      public PlotRecorder export(String file) throws IOException
      Writes the HTML page of the recording.
      Parameters:
      file - the HTML file
      Returns:
      the recorder
      Throws:
      IOException - if the file cannot be written