Class BubbleTransition

java.lang.Object
com.codename1.ui.animations.Transition
com.codename1.ui.animations.BubbleTransition
All Implemented Interfaces:
Animation

public class BubbleTransition extends Transition

A Transitions that animates the destination component as a growing window until the destination is displayed in place. The Bubble window can be round on supported platforms

Form hi = new Form("Bubble");
Button showBubble = new Button("+");
showBubble.setName("BubbleButton");
Style buttonStyle = showBubble.getAllStyles();
buttonStyle.setBorder(Border.createEmpty());
buttonStyle.setFgColor(0xffffff);
buttonStyle.setBgPainter((g, rect) -> {
    g.setColor(0xff);
    int actualWidth = rect.getWidth();
    int actualHeight = rect.getHeight();
    int xPos, yPos;
    int size;
    if(actualWidth > actualHeight) {
        yPos = rect.getY();
        xPos = rect.getX() + (actualWidth - actualHeight) / 2;
        size = actualHeight;
    } else {
        yPos = rect.getY() + (actualHeight - actualWidth) / 2;
        xPos = rect.getX();
        size = actualWidth;
    }
    g.setAntiAliased(true);
    g.fillArc(xPos, yPos, size, size, 0, 360);
});
hi.add(showBubble);
hi.setTintColor(0);
showBubble.addActionListener((e) -> {
    Dialog dlg = new Dialog("Bubbled");
    dlg.setLayout(new BorderLayout());
    SpanLabel sl = new SpanLabel("This dialog should appear with a bubble transition from the button", "DialogBody");
    sl.getTextUnselectedStyle().setFgColor(0xffffff);
    dlg.add(BorderLayout.CENTER, sl);
    dlg.setTransitionInAnimator(new BubbleTransition(500, "BubbleButton"));
    dlg.setTransitionOutAnimator(new BubbleTransition(500, "BubbleButton"));
    dlg.setDisposeWhenPointerOutOfBounds(true);
    dlg.getTitleStyle().setFgColor(0xffffff);

    Style dlgStyle = dlg.getDialogStyle();
    dlgStyle.setBorder(Border.createEmpty());
    dlgStyle.setBgColor(0xff);
    dlgStyle.setBgTransparency(0xff);
    dlg.showPacked(BorderLayout.NORTH, true);
});

hi.show();
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a Bubble Transition
    BubbleTransition(int duration)
    Creates a Bubble Transition
    BubbleTransition(int duration, String componentName)
    Creates a Bubble Transition
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Allows the animation to reduce "repaint" calls when it returns false.
    void
    Optional operation to cleanup the garbage left over by a running transition
    copy(boolean reverse)
    Create a copy of the transition, usually the transition used is a copy.
    int
    The duration for the transition
    void
    Callback thats invoked before a transition begins, the source form may be null for the first form in the application.
    void
    Draws the animation, within a component the standard paint method would be invoked since it bares the exact same signature.
    void
    setComponentName(String componentName)
    the name of the component from the source Form that this transition should start from.
    void
    setDuration(int duration)
    The duration for the transition
    void
    setRoundBubble(boolean roundBubble)
    Determines if the Bubble is a round circle or a rectangle.

    Methods inherited from class Transition

    cleanSource, getDestination, getSource, hideInterformContainers, init, paintInterformContainers, showInterformContainers
    Modifier and Type
    Method
    Description
    protected final void
    Allows setting the source form to null to save memory if the transition doesn't need it in memory.
    final Component
    Returns the destination form that should be set once animation is completed
    final Component
    Returns the source form which is the form from which the animation is starting.
    protected void
    Sets visibility on all shared InterFormContainers between the source and destination to be hidden.
    final void
    init(Component source, Component destination)
    Invoked by com.codename1.ui.Display to set the source and destination forms.
    protected void
    Paints all shared InterFormContainers between the source and destination.
    protected void
    Sets visibility on all shared InterFormContainers between the source and destination to be visible.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
     
    boolean
    Indicates whether some other object is "equal to" this one.
    final Class
    Returns the runtime class of an object.
    int
    Returns a hash code value for the object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    Returns a string representation of the object.
    final void
    Causes current thread to wait until another thread invokes the method or the method for this object.
    final void
    wait(long timeout)
    Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
    final void
    wait(long timeout, int nanos)
    Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
  • Constructor Details

    • BubbleTransition

      public BubbleTransition()
      Creates a Bubble Transition
    • BubbleTransition

      public BubbleTransition(int duration)

      Creates a Bubble Transition

      Parameters
      • duration: the duration of the transition
    • BubbleTransition

      public BubbleTransition(int duration, String componentName)

      Creates a Bubble Transition

      Parameters
      • duration: the duration of the transition

      • componentName: @param componentName the name of the component from the source Form that this transition should start from.

  • Method Details

    • setComponentName

      public void setComponentName(String componentName)

      the name of the component from the source Form that this transition should start from.

      Parameters
      • componentName: name of the component to start the transition from
    • initTransition

      public void initTransition()
      Description copied from class: Transition
      Callback thats invoked before a transition begins, the source form may be null for the first form in the application.
      Overrides:
      initTransition in class Transition
    • animate

      public boolean animate()
      Description copied from class: Transition

      Allows the animation to reduce "repaint" calls when it returns false. It is called once for every frame. Frames are defined by the com.codename1.ui.Display class.

      Returns

      true if a repaint is desired or false if no repaint is necessary

      Specified by:
      animate in interface Animation
      Specified by:
      animate in class Transition
    • paint

      public void paint(Graphics g)
      Description copied from class: Transition

      Draws the animation, within a component the standard paint method would be invoked since it bares the exact same signature.

      Parameters
      • g: graphics context
      Specified by:
      paint in interface Animation
      Specified by:
      paint in class Transition
    • setRoundBubble

      public void setRoundBubble(boolean roundBubble)

      Determines if the Bubble is a round circle or a rectangle. Round bubble apply to platforms who supports shaped clipping. See Graphics.isShapeClipSupported().

      Parameters
      • roundBubble: true if the bubble should be round
    • cleanup

      public void cleanup()
      Description copied from class: Transition
      Optional operation to cleanup the garbage left over by a running transition
      Overrides:
      cleanup in class Transition
    • getDuration

      public int getDuration()

      The duration for the transition

      Returns

      the duration

    • setDuration

      public void setDuration(int duration)

      The duration for the transition

      Parameters
      • duration: the duration to set
    • copy

      public Transition copy(boolean reverse)

      Create a copy of the transition, usually the transition used is a copy.

      Parameters
      • reverse: @param reverse creates a new transition instance with "reverse" behavior useful for signifying "back" operations
      Returns

      new transition instance

      Parameters
      • reverse:

      Create a copy of the transition, usually the transition used is a copy.

      Parameters
      • reverse: @param reverse creates a new transition instance with "reverse" behavior useful for signifying "back" operations
      Returns

      new transition instance

      Returns

      Create a copy of the transition, usually the transition used is a copy.

      Parameters
      • reverse: @param reverse creates a new transition instance with "reverse" behavior useful for signifying "back" operations
      Returns

      new transition instance

      Overrides:
      copy in class Transition