public class BubbleTransition

  1. Object
  2. Transition
  3. BubbleTransition

ImplementsAnimation

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();

Constructors

public BubbleTransition()Creates a Bubble Transition
public BubbleTransition(int duration)Creates a Bubble Transition
public BubbleTransition(int duration, String componentName)Creates a Bubble Transition

Methods

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

Inherited methods

Constructor details

BubbleTransition

public BubbleTransition()
Creates a Bubble Transition

BubbleTransition

public BubbleTransition(int duration)
Creates a Bubble Transition

Parameters

duration int
the duration of the transition

BubbleTransition

public BubbleTransition(int duration, String componentName)
Creates a Bubble Transition

Parameters

duration int
the duration of the transition
componentName String
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 String
name of the component to start the transition from

initTransition

public void initTransition()
Callback thats invoked before a transition begins, the source form may be null for the first form in the application.

animate

public boolean animate()
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

paint

public void paint(Graphics g)
Draws the animation, within a component the standard paint method would be invoked since it bares the exact same signature.

Parameters

g Graphics
graphics context

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 boolean
true if the bubble should be round

cleanup

public void cleanup()
Optional operation to cleanup the garbage left over by a running 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 int
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 boolean
creates a new transition instance with “reverse” behavior useful for signifying “back” operations

Returns

new transition instance