Search in sources :

Example 1 with AnimationCallback

use of com.ait.lienzo.client.core.animation.AnimationCallback in project kie-wb-common by kiegroup.

the class ShapeStateAttributeAnimationHandler method animate.

private IAnimationHandle animate(final com.ait.lienzo.client.core.shape.Shape<?> shape, final ShapeStateAttributes attributes, final long duration) {
    final AnimationProperties properties = new AnimationProperties();
    attributes.consume((attr, value) -> {
        switch(attr) {
            case FILL_COLOR:
                properties.push(FILL_COLOR((String) value));
                break;
            case FILL_ALPHA:
                properties.push(FILL_ALPHA((double) value));
                break;
            case STROKE_COLOR:
                properties.push(STROKE_COLOR((String) value));
                break;
            case STROKE_ALPHA:
                properties.push(STROKE_ALPHA((double) value));
                break;
            case STROKE_WIDTH:
                properties.push(STROKE_WIDTH((double) value));
                break;
        }
    });
    return shape.animate(AnimationTweener.LINEAR, properties, duration, new AnimationCallback() {

        @Override
        public void onClose(final IAnimation animation, final IAnimationHandle handle) {
            super.onClose(animation, handle);
            if (null != animationHandle && !animationHandle.isRunning()) {
                setAnimationHandle(null);
                completeCallback.execute();
            }
        }
    });
}
Also used : IAnimationHandle(com.ait.lienzo.client.core.animation.IAnimationHandle) AnimationProperties(com.ait.lienzo.client.core.animation.AnimationProperties) IAnimation(com.ait.lienzo.client.core.animation.IAnimation) AnimationCallback(com.ait.lienzo.client.core.animation.AnimationCallback)

Example 2 with AnimationCallback

use of com.ait.lienzo.client.core.animation.AnimationCallback in project kie-wb-common by kiegroup.

the class ShapeStateAttributeAnimationHandlerTest method testApplyStateAnimationWithResetBeforeAnimationCompletes.

@Test
public void testApplyStateAnimationWithResetBeforeAnimationCompletes() {
    final ArgumentCaptor<AnimationCallback> animationCallbackCaptor = ArgumentCaptor.forClass(AnimationCallback.class);
    tested.applyState(ShapeState.SELECTED);
    verify(shape, times(1)).animate(any(AnimationTweener.class), any(AnimationProperties.class), anyDouble(), animationCallbackCaptor.capture());
    tested.reset();
    final AnimationCallback animationCallback = animationCallbackCaptor.getValue();
    animationCallback.onClose(mock(IAnimation.class), mock(IAnimationHandle.class));
}
Also used : IAnimationHandle(com.ait.lienzo.client.core.animation.IAnimationHandle) AnimationProperties(com.ait.lienzo.client.core.animation.AnimationProperties) IAnimation(com.ait.lienzo.client.core.animation.IAnimation) AnimationCallback(com.ait.lienzo.client.core.animation.AnimationCallback) AnimationTweener(com.ait.lienzo.client.core.animation.AnimationTweener) Test(org.junit.Test)

Aggregations

AnimationCallback (com.ait.lienzo.client.core.animation.AnimationCallback)2 AnimationProperties (com.ait.lienzo.client.core.animation.AnimationProperties)2 IAnimation (com.ait.lienzo.client.core.animation.IAnimation)2 IAnimationHandle (com.ait.lienzo.client.core.animation.IAnimationHandle)2 AnimationTweener (com.ait.lienzo.client.core.animation.AnimationTweener)1 Test (org.junit.Test)1