Search in sources :

Example 1 with TransitionListener

use of org.apache.pivot.wtk.effects.TransitionListener in project pivot by apache.

the class Transitions method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    button1 = (PushButton) namespace.get("button1");
    button2 = (PushButton) namespace.get("button2");
    button3 = (PushButton) namespace.get("button3");
    button4 = (PushButton) namespace.get("button4");
    ButtonPressListener buttonPressListener = new ButtonPressListener() {

        @Override
        public void buttonPressed(final Button button) {
            if (collapseTransition == null) {
                collapseTransition = new CollapseTransition(button, TRANSITION_DURATION, TRANSITION_RATE);
                TransitionListener transitionListener = new TransitionListener() {

                    @Override
                    public void transitionCompleted(Transition transition) {
                        CollapseTransition collapseTransitionLocal = (CollapseTransition) transition;
                        if (!transition.isReversed()) {
                            Component component = collapseTransitionLocal.getComponent();
                            component.getParent().remove(component);
                        }
                        Transitions.this.collapseTransition = null;
                    }
                };
                collapseTransition.start(transitionListener);
            } else {
                collapseTransition.reverse();
                if (collapseTransition.getComponent() != button) {
                    collapseTransition.end();
                }
            }
        }
    };
    button1.getButtonPressListeners().add(buttonPressListener);
    button2.getButtonPressListeners().add(buttonPressListener);
    button3.getButtonPressListeners().add(buttonPressListener);
    button4.getButtonPressListeners().add(buttonPressListener);
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) Transition(org.apache.pivot.wtk.effects.Transition) TransitionListener(org.apache.pivot.wtk.effects.TransitionListener) Component(org.apache.pivot.wtk.Component)

Example 2 with TransitionListener

use of org.apache.pivot.wtk.effects.TransitionListener in project pivot by apache.

the class TerraTooltipSkin method previewWindowClose.

@Override
public Vote previewWindowClose(final Window window) {
    Vote vote = Vote.APPROVE;
    if (fade) {
        if (closeTransition == null) {
            closeTransition = new FadeWindowTransition(window, closeTransitionDuration, closeTransitionRate, dropShadowDecorator);
            closeTransition.start(new TransitionListener() {

                @Override
                public void transitionCompleted(Transition transition) {
                    window.close();
                }
            });
            vote = Vote.DEFER;
        } else {
            vote = (closeTransition.isRunning()) ? Vote.DEFER : Vote.APPROVE;
        }
    }
    return vote;
}
Also used : Vote(org.apache.pivot.util.Vote) Transition(org.apache.pivot.wtk.effects.Transition) TransitionListener(org.apache.pivot.wtk.effects.TransitionListener)

Example 3 with TransitionListener

use of org.apache.pivot.wtk.effects.TransitionListener in project pivot by apache.

the class TerraExpanderSkin method previewExpandedChange.

/**
 * {@inheritDoc}
 */
@Override
public Vote previewExpandedChange(final Expander expander) {
    Vote vote;
    if (expander.isShowing() && expandTransition == null && expander.getContent() != null) {
        final boolean expanded = expander.isExpanded();
        shadeButton.setButtonData(expanded ? collapseImage : expandImage);
        expandTransition = new ExpandTransition(expanded);
        expandTransition.start(new TransitionListener() {

            @Override
            public void transitionCompleted(Transition transition) {
                expander.setExpanded(!expanded);
                expandTransition = null;
            }
        });
    }
    if (expandTransition == null || !expandTransition.isRunning()) {
        vote = Vote.APPROVE;
    } else {
        vote = Vote.DEFER;
    }
    return vote;
}
Also used : Vote(org.apache.pivot.util.Vote) Transition(org.apache.pivot.wtk.effects.Transition) TransitionListener(org.apache.pivot.wtk.effects.TransitionListener)

Example 4 with TransitionListener

use of org.apache.pivot.wtk.effects.TransitionListener in project pivot by apache.

the class TerraSheetSkin method windowOpened.

@Override
public void windowOpened(Window window) {
    super.windowOpened(window);
    Display display = window.getDisplay();
    display.getContainerMouseListeners().add(displayMouseListener);
    display.reenterMouse();
    if (dropShadowDecorator != null) {
        dropShadowDecorator.setShadowOpacity(DropShadowDecorator.DEFAULT_SHADOW_OPACITY);
    }
    alignToOwner();
    Window owner = window.getOwner();
    owner.getComponentListeners().add(ownerListener);
    openTransition = new OpenTransition(false);
    openTransition.start(new TransitionListener() {

        @Override
        public void transitionCompleted(Transition transition) {
            openTransition = null;
        }
    });
    if (!window.requestFocus()) {
        Component.clearFocus();
    }
}
Also used : Window(org.apache.pivot.wtk.Window) Transition(org.apache.pivot.wtk.effects.Transition) TransitionListener(org.apache.pivot.wtk.effects.TransitionListener) Display(org.apache.pivot.wtk.Display)

Example 5 with TransitionListener

use of org.apache.pivot.wtk.effects.TransitionListener in project pivot by apache.

the class TerraRollupSkin method previewExpandedChange.

// Rollup state events
@Override
public Vote previewExpandedChange(final Rollup rollup) {
    Vote vote;
    if (rollup.isShowing() && expandTransition == null && rollup.getContent() != null) {
        final boolean expanded = rollup.isExpanded();
        expandTransition = new ExpandTransition(expanded);
        expandTransition.start(new TransitionListener() {

            @Override
            public void transitionCompleted(Transition transition) {
                rollup.setExpanded(!expanded);
                expandTransition = null;
            }
        });
    }
    if (expandTransition == null || !expandTransition.isRunning()) {
        vote = Vote.APPROVE;
    } else {
        vote = Vote.DEFER;
    }
    return vote;
}
Also used : Vote(org.apache.pivot.util.Vote) Transition(org.apache.pivot.wtk.effects.Transition) TransitionListener(org.apache.pivot.wtk.effects.TransitionListener)

Aggregations

Transition (org.apache.pivot.wtk.effects.Transition)8 TransitionListener (org.apache.pivot.wtk.effects.TransitionListener)8 Vote (org.apache.pivot.util.Vote)4 Component (org.apache.pivot.wtk.Component)2 GradientPaint (java.awt.GradientPaint)1 Button (org.apache.pivot.wtk.Button)1 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)1 Display (org.apache.pivot.wtk.Display)1 PushButton (org.apache.pivot.wtk.PushButton)1 Window (org.apache.pivot.wtk.Window)1