Class Keyframe

java.lang.Object
sc.fiji.snt.viewer.Keyframe

public class Keyframe extends Object
A snapshot of a Bvv or Bdv viewer state at a particular moment, used as a keyframe for movie recording. Captures the viewer transform, camera/slab parameters (dCam, nearClip, farClip), the current timepoint, and which "actors" (volume channels, paths, annotations) are visible.

Keyframes are serialized/deserialized via toString() and fromString(String) so they can be dumped to the console with the K hotkey and pasted into scripts. Camera/slab parameters are only meaningful in BVV: BDV ignores them on playback.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    Display settings of a single source.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    int
    Easing type for the transition into this keyframe (0-5).
    final double
    Camera depth parameter (perspective).
    Per-source display settings (levels and LUT color), keyed by 0-based source index.
    final double
    Far clipping distance (slab back).
    int
    Number of frames for the transition from the previous keyframe into this one.
    int
    Viewer (canvas) size in pixels at capture, or -1 if unspecified.
    final double
    Near clipping distance (slab front).
    int
    Timepoint (1-based) displayed at this keyframe.
    final net.imglib2.realtransform.AffineTransform3D
    Viewer transform (camera position + zoom + rotation).
    final Set<String>
    Names of visible actors (e.g.
    int
    Viewer (canvas) size in pixels at capture, or -1 if unspecified.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Keyframe(String serialized)
    Convenience constructor that deserializes a keyframe from a string.
    Keyframe(net.imglib2.realtransform.AffineTransform3D transform, double dCam, double nearClip, double farClip, Set<String> visibleActors, int accelType)
     
    Keyframe(net.imglib2.realtransform.AffineTransform3D transform, double dCam, double nearClip, double farClip, Set<String> visibleActors, int accelType, int frames)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    accel(double t, int type)
    Easing function for keyframe transitions, adapted from BDV movie recorder.
    accel(String name)
    Sets the easing type by name (chainable, for scripts).
    frames(int frames)
    Sets the transition length (chainable, for scripts).
    static Keyframe
    Deserializes a keyframe from the string produced by toString().
    Returns the current easing type as a human-readable name.
    void
    Sets the easing type by name.
    Serializes this keyframe to a single-line string: transform=d0,d1,...,d11|cam=dCam,near,far|visible=a;b;c|accel=name|frames=N|t=N|size=WxH|display=i:min,max,#RRGGBB;... (the timepoint, size and display entries are omitted if unspecified).
    toString(boolean includeTiming)
    Serializes this keyframe, optionally leaving out the timing entries (accel and frames), e.g., when they are set separately through frames(int) and accel(String).
    net.imglib2.realtransform.AffineTransform3D
    transformFor(int canvasWidth, int canvasHeight)
    Returns a copy of the viewer transform adjusted to a canvas of the given size.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • transform

      public final net.imglib2.realtransform.AffineTransform3D transform
      Viewer transform (camera position + zoom + rotation).
    • dCam

      public final double dCam
      Camera depth parameter (perspective).
    • nearClip

      public final double nearClip
      Near clipping distance (slab front).
    • farClip

      public final double farClip
      Far clipping distance (slab back).
    • visibleActors

      public final Set<String> visibleActors
      Names of visible actors (e.g. "vol:Sample#1", "paths", "annotations").
    • timepoint

      public int timepoint
      Timepoint (1-based) displayed at this keyframe. Interpolated linearly (and rounded) between keyframes. A value <= 0 means "unspecified": the viewer's timepoint is left untouched.
    • width

      public int width
      Viewer (canvas) size in pixels at capture, or -1 if unspecified. The viewer transform is in screen pixels, so it depends on the canvas size: see transformFor(int, int).
    • height

      public int height
      Viewer (canvas) size in pixels at capture, or -1 if unspecified. The viewer transform is in screen pixels, so it depends on the canvas size: see transformFor(int, int).
    • display

      public final Map<Integer,Keyframe.SourceDisplay> display
      Per-source display settings (levels and LUT color), keyed by 0-based source index. Interpolated between keyframes for sources present in both; sources absent from the map are left untouched.
    • accelType

      public int accelType
      Easing type for the transition into this keyframe (0-5). Can be set by name via setAccel(String).
      See Also:
    • ACCEL_SYMMETRIC

      public static final int ACCEL_SYMMETRIC
      See Also:
    • ACCEL_SLOW_START

      public static final int ACCEL_SLOW_START
      See Also:
    • ACCEL_SLOW_END

      public static final int ACCEL_SLOW_END
      See Also:
    • ACCEL_SOFT_SYMMETRIC

      public static final int ACCEL_SOFT_SYMMETRIC
      See Also:
    • ACCEL_SOFT_SLOW_START

      public static final int ACCEL_SOFT_SLOW_START
      See Also:
    • ACCEL_SOFT_SLOW_END

      public static final int ACCEL_SOFT_SLOW_END
      See Also:
    • frames

      public int frames
      Number of frames for the transition from the previous keyframe into this one. Ignored for the first keyframe in a sequence. Defaults to 60 (~2 s at 30 fps).
  • Constructor Details

    • Keyframe

      public Keyframe(String serialized)
      Convenience constructor that deserializes a keyframe from a string. Equivalent to fromString(String) but usable as new Keyframe("transform=...|cam=...|...") in scripts.
      Parameters:
      serialized - the string produced by toString()
      Throws:
      IllegalArgumentException - if parsing fails
    • Keyframe

      public Keyframe(net.imglib2.realtransform.AffineTransform3D transform, double dCam, double nearClip, double farClip, Set<String> visibleActors, int accelType)
    • Keyframe

      public Keyframe(net.imglib2.realtransform.AffineTransform3D transform, double dCam, double nearClip, double farClip, Set<String> visibleActors, int accelType, int frames)
  • Method Details

    • setAccel

      public void setAccel(String name)
      Sets the easing type by name. Accepted values (case-insensitive, spaces or underscores): "symmetric", "slow_start" / "slow start", "slow_end", "soft_symmetric", "soft_slow_start", "soft_slow_end".
      Parameters:
      name - the easing name
      Throws:
      IllegalArgumentException - if the name is not recognized
    • getAccelName

      public String getAccelName()
      Returns the current easing type as a human-readable name.
      Returns:
      the easing name, e.g. "slow start"
    • transformFor

      public net.imglib2.realtransform.AffineTransform3D transformFor(int canvasWidth, int canvasHeight)
      Returns a copy of the viewer transform adjusted to a canvas of the given size. Mirrors what the viewer does when resized (the scene center stays at the canvas center): the translation is shifted by half the size difference. The transform is returned unchanged if this keyframe has no recorded size.
      Parameters:
      canvasWidth - the current canvas width in pixels
      canvasHeight - the current canvas height in pixels
      Returns:
      a new transform
    • frames

      public Keyframe frames(int frames)
      Sets the transition length (chainable, for scripts).
      Parameters:
      frames - number of frames of the transition into this keyframe
      Returns:
      this keyframe
    • accel

      public Keyframe accel(String name)
      Sets the easing type by name (chainable, for scripts).
      Parameters:
      name - the easing name, see setAccel(String)
      Returns:
      this keyframe
    • toString

      public String toString()
      Serializes this keyframe to a single-line string: transform=d0,d1,...,d11|cam=dCam,near,far|visible=a;b;c|accel=name|frames=N|t=N|size=WxH|display=i:min,max,#RRGGBB;... (the timepoint, size and display entries are omitted if unspecified).
      Overrides:
      toString in class Object
    • toString

      public String toString(boolean includeTiming)
      Serializes this keyframe, optionally leaving out the timing entries (accel and frames), e.g., when they are set separately through frames(int) and accel(String).
      Parameters:
      includeTiming - whether to include the accel and frames entries
      Returns:
      the serialized keyframe
    • fromString

      public static Keyframe fromString(String s)
      Deserializes a keyframe from the string produced by toString().
      Parameters:
      s - the serialised keyframe string
      Returns:
      a new Keyframe, or null if parsing fails
    • accel

      public static double accel(double t, int type)
      Easing function for keyframe transitions, adapted from BDV movie recorder.
      Parameters:
      t - progress value in [0, 1]
      type - easing type: 0 = symmetric, 1 = slow start, 2 = slow end, 3 = soft symmetric, 4 = soft slow start, 5 = soft slow end
      Returns:
      eased progress value in [0, 1]
      See Also: