Class MorphTransition.MorphElement

java.lang.Object
com.codename1.ui.animations.MorphTransition.MorphElement
Enclosing class:
MorphTransition

public static final class MorphTransition.MorphElement extends Object

Describes an arbitrary rendered element that the morph tweens between two states: position, size, opacity, rotation and scale. Build one with #create(Image) (e.g. a rendered SVG, an icon, an EncodedImage) or #create(Component) (the component is snapshotted to an image when the transition initializes), then hand it to MorphTransition#morph(MorphElement).

All builder setters return this for chaining; every state has an identity default (opacity 1, rotation 0, scale 1, and the element's own bounds for position / size) so only the properties you actually want to tween need to be set.

  • Method Details

    • create

      public static MorphTransition.MorphElement create(Image image)
      Creates an element backed by a pre-rendered Image (a rasterized SVG, an icon, a snapshot, ...).
    • create

      public static MorphTransition.MorphElement create(Component cmp)
      Creates an element backed by a Component; the component is snapshotted to an image when the transition initializes. The component's laid-out bounds seed the source rectangle unless #from(int, int, int, int) is given.
    • from

      public MorphTransition.MorphElement from(int x, int y, int w, int h)
      Sets the source rectangle (state at t = 0).
    • to

      public MorphTransition.MorphElement to(int x, int y, int w, int h)
      Sets the destination rectangle (state at t = 1).
    • opacity

      public MorphTransition.MorphElement opacity(float from, float to)
      Tweens the element opacity from from to to (both [0, 1]).
    • rotation

      public MorphTransition.MorphElement rotation(float fromDegrees, float toDegrees)
      Tweens the element rotation in degrees about its center.
    • scale

      public MorphTransition.MorphElement scale(float from, float to)
      Tweens an extra scale multiplier about the element center (on top of the interpolated size).
    • getCurrentX

      public float getCurrentX()
      The interpolated x of the element at the current progress.
    • getCurrentY

      public float getCurrentY()
      The interpolated y of the element at the current progress.
    • getCurrentWidth

      public float getCurrentWidth()
      The interpolated width of the element at the current progress.
    • getCurrentHeight

      public float getCurrentHeight()
      The interpolated height of the element at the current progress.
    • getCurrentOpacity

      public float getCurrentOpacity()
      The interpolated opacity (0..1) at the current progress.
    • getCurrentRotation

      public float getCurrentRotation()
      The interpolated rotation (degrees) at the current progress.
    • getCurrentScale

      public float getCurrentScale()
      The interpolated scale multiplier at the current progress.