Package org.apache.flex.forks.batik.anim.values

Examples of org.apache.flex.forks.batik.anim.values.AnimatableValue


    /**
     * Called when the element is sampled at the given unit time.  This updates
     * the {@link #value} of the animation if active.
     */
    protected void sampledAtUnitTime(float unitTime, int repeatIteration) {
        AnimatableValue value, accumulation;
        float interpolation = 0;
        if (unitTime != 1) {
            int keyTimeIndex = 0;
            while (keyTimeIndex < keyTimes.length - 1
                    && unitTime >= keyTimes[keyTimeIndex + 1]) {
                keyTimeIndex++;
            }
            if (keyTimeIndex == keyTimes.length - 1 && calcMode == CALC_MODE_DISCRETE) {
                keyTimeIndex = keyTimes.length - 2;
                interpolation = 1;
            } else {
                if (calcMode == CALC_MODE_LINEAR || calcMode == CALC_MODE_PACED
                        || calcMode == CALC_MODE_SPLINE) {
                    if (unitTime == 0) {
                        interpolation = 0;
                    } else {
                        interpolation = (unitTime - keyTimes[keyTimeIndex])
                            / (keyTimes[keyTimeIndex + 1] - keyTimes[keyTimeIndex]);
                    }
                    if (calcMode == CALC_MODE_SPLINE && unitTime != 0) {
                        // XXX This could be done better, e.g. with
                        //     Newton-Raphson.
                        Cubic c = keySplineCubics[keyTimeIndex];
                        float tolerance = 0.001f;
                        float min = 0;
                        float max = 1;
                        Point2D.Double p;
                        for (;;) {
                            float t = (min + max) / 2;
                            p = c.eval(t);
                            double x = p.getX();
                            if (Math.abs(x - interpolation) < tolerance) {
                                break;
                            }
                            if (x < interpolation) {
                                min = t;
                            } else {
                                max = t;
                            }
                        }
                        interpolation = (float) p.getY();
                    }
                }
            }
            float point = keyPoints[keyTimeIndex];
            if (interpolation != 0) {
                point += interpolation *
                    (keyPoints[keyTimeIndex + 1] - keyPoints[keyTimeIndex]);
            }
            point *= pathLength.lengthOfPath();
            Point2D p = pathLength.pointAtLength(point);
            float ang;
            if (rotateAuto) {
                ang = pathLength.angleAtLength(point);
                if (rotateAutoReverse) {
                    ang += Math.PI;
                }
            } else {
                ang = rotateAngle;
            }
            value = new AnimatableMotionPointValue(null, (float) p.getX(),
                                                   (float) p.getY(), ang);
        } else {
            Point2D p = pathLength.pointAtLength(pathLength.lengthOfPath());
            float ang;
            if (rotateAuto) {
                ang = pathLength.angleAtLength(pathLength.lengthOfPath());
                if (rotateAutoReverse) {
                    ang += Math.PI;
                }
            } else {
                ang = rotateAngle;
            }
            value = new AnimatableMotionPointValue(null, (float) p.getX(),
                                                   (float) p.getY(), ang);
        }
        if (cumulative) {
            Point2D p = pathLength.pointAtLength(pathLength.lengthOfPath());
            float ang;
            if (rotateAuto) {
                ang = pathLength.angleAtLength(pathLength.lengthOfPath());
                if (rotateAutoReverse) {
                    ang += Math.PI;
                }
            } else {
                ang = rotateAngle;
            }
            accumulation = new AnimatableMotionPointValue(null, (float) p.getX(),
                                                          (float) p.getY(), ang);
        } else {
            accumulation = null;
        }

        this.value = value.interpolate(this.value, null, interpolation,
                                       accumulation, repeatIteration);
        if (this.value.hasChanged()) {
            markDirty();
        }
    }
View Full Code Here


            return null;
        }
        if (isDirty) {
            // Trace.print("willReplace() == " + willReplace());
            // Trace.print("value == " + value);
            AnimatableValue lowerValue = null;
            if (!willReplace()) {
                // Trace.print("lowerAnimation == " + lowerAnimation);
                if (lowerAnimation == null) {
                    lowerValue = animatableElement.getUnderlyingValue();
                    usesUnderlyingValue = true;
View Full Code Here

                String localName = (String) e2.getKey2();
                Sandwich sandwich = (Sandwich) e2.getValue();
                if (sandwich.shouldUpdate ||
                        sandwich.animation != null
                            && sandwich.animation.isDirty) {
                    AnimatableValue av = null;
                    boolean usesUnderlying = false;
                    AbstractAnimation anim = sandwich.animation;
                    if (anim != null) {
                        av = anim.getComposedValue();
                        usesUnderlying =
                            sandwich.lowestAnimation.usesUnderlyingValue();
                        anim.isDirty = false;
                    }
                    if (usesUnderlying && !sandwich.listenerRegistered) {
                        target.addTargetListener(namespaceURI, localName, false,
                                                 targetListener);
                        sandwich.listenerRegistered = true;
                    } else if (!usesUnderlying && sandwich.listenerRegistered) {
                        target.removeTargetListener(namespaceURI, localName,
                                                    false, targetListener);
                        sandwich.listenerRegistered = false;
                    }
                    target.updateAttributeValue(namespaceURI, localName, av);
                    sandwich.shouldUpdate = false;
                }
            }

            // Update the CSS animations.
            j = info.cssAnimations.entrySet().iterator();
            while (j.hasNext()) {
                Map.Entry e2 = (Map.Entry) j.next();
                String propertyName = (String) e2.getKey();
                Sandwich sandwich = (Sandwich) e2.getValue();
                if (sandwich.shouldUpdate ||
                        sandwich.animation != null
                            && sandwich.animation.isDirty) {
                    AnimatableValue av = null;
                    boolean usesUnderlying = false;
                    AbstractAnimation anim = sandwich.animation;
                    if (anim != null) {
                        av = anim.getComposedValue();
                        usesUnderlying =
                            sandwich.lowestAnimation.usesUnderlyingValue();
                        anim.isDirty = false;
                    }
                    if (usesUnderlying && !sandwich.listenerRegistered) {
                        target.addTargetListener(null, propertyName, true,
                                                 targetListener);
                        sandwich.listenerRegistered = true;
                    } else if (!usesUnderlying && sandwich.listenerRegistered) {
                        target.removeTargetListener(null, propertyName, true,
                                                    targetListener);
                        sandwich.listenerRegistered = false;
                    }
                    if (usesUnderlying) {
                        target.updatePropertyValue(propertyName, null);
                    }
                    if (!(usesUnderlying && av == null)) {
                        target.updatePropertyValue(propertyName, av);
                    }
                    sandwich.shouldUpdate = false;
                }
            }

            // Update the other animations.
            j = info.otherAnimations.entrySet().iterator();
            while (j.hasNext()) {
                Map.Entry e2 = (Map.Entry) j.next();
                String type = (String) e2.getKey();
                Sandwich sandwich = (Sandwich) e2.getValue();
                if (sandwich.shouldUpdate || sandwich.animation.isDirty) {
                    AnimatableValue av = null;
                    AbstractAnimation anim = sandwich.animation;
                    if (anim != null) {
                        av = sandwich.animation.getComposedValue();
                        anim.isDirty = false;
                    }
View Full Code Here

    /**
     * Called when the element is sampled at the given unit time.  This updates
     * the {@link #value} of the animation if active.
     */
    protected void sampledAtUnitTime(float unitTime, int repeatIteration) {
        AnimatableValue value, accumulation, nextValue;
        float interpolation = 0;
        if (unitTime != 1) {
            int keyTimeIndex = 0;
            while (keyTimeIndex < keyTimes.length - 1
                    && unitTime >= keyTimes[keyTimeIndex + 1]) {
                keyTimeIndex++;
            }
            value = values[keyTimeIndex];
            if (calcMode == CALC_MODE_LINEAR
                    || calcMode == CALC_MODE_PACED
                    || calcMode == CALC_MODE_SPLINE) {
                nextValue = values[keyTimeIndex + 1];
                interpolation = (unitTime - keyTimes[keyTimeIndex])
                    / (keyTimes[keyTimeIndex + 1] - keyTimes[keyTimeIndex]);
                if (calcMode == CALC_MODE_SPLINE && unitTime != 0) {
                    // XXX This could be done better, e.g. with
                    //     Newton-Raphson.
                    Cubic c = keySplineCubics[keyTimeIndex];
                    float tolerance = 0.001f;
                    float min = 0;
                    float max = 1;
                    Point2D.Double p;
                    for (;;) {
                        float t = (min + max) / 2;
                        p = c.eval(t);
                        double x = p.getX();
                        if (Math.abs(x - interpolation) < tolerance) {
                            break;
                        }
                        if (x < interpolation) {
                            min = t;
                        } else {
                            max = t;
                        }
                    }
                    interpolation = (float) p.getY();
                }
            } else {
                nextValue = null;
            }
        } else {
            value = values[values.length - 1];
            nextValue = null;
        }
        if (cumulative) {
            accumulation = values[values.length - 1];
        } else {
            accumulation = null;
        }

        this.value = value.interpolate(this.value, nextValue, interpolation,
                                       accumulation, repeatIteration);
        if (this.value.hasChanged()) {
            markDirty();
        }
    }
View Full Code Here

    /**
     * Creates the animation object for the animation element.
     */
    protected AbstractAnimation createAnimation(AnimationTarget target) {
        AnimatableValue from = parseAnimatableValue(SVG_FROM_ATTRIBUTE);
        AnimatableValue to = parseAnimatableValue(SVG_TO_ATTRIBUTE);
        AnimatableValue by = parseAnimatableValue(SVG_BY_ATTRIBUTE);
        return new ColorAnimation(timedElement,
                                  this,
                                  parseCalcMode(),
                                  parseKeyTimes(),
                                  parseKeySplines(),
View Full Code Here

     */
    protected AbstractAnimation createAnimation(AnimationTarget target) {
        animationType = AnimationEngine.ANIM_TYPE_OTHER;
        attributeLocalName = "motion";

        AnimatableValue from = parseLengthPair(SVG_FROM_ATTRIBUTE);
        AnimatableValue to = parseLengthPair(SVG_TO_ATTRIBUTE);
        AnimatableValue by = parseLengthPair(SVG_BY_ATTRIBUTE);

        boolean rotateAuto = false, rotateAutoReverse = false;
        float rotateAngle = 0;
        short rotateAngleUnit = SVGAngle.SVG_ANGLETYPE_UNKNOWN;
        String rotateString = element.getAttributeNS(null,
View Full Code Here

    /**
     * Creates the animation object for the animation element.
     */
    protected AbstractAnimation createAnimation(AnimationTarget target) {
        AnimatableValue from = parseAnimatableValue(SVG_FROM_ATTRIBUTE);
        AnimatableValue to = parseAnimatableValue(SVG_TO_ATTRIBUTE);
        AnimatableValue by = parseAnimatableValue(SVG_BY_ATTRIBUTE);
        return new SimpleAnimation(timedElement,
                                   this,
                                   parseCalcMode(),
                                   parseKeyTimes(),
                                   parseKeySplines(),
View Full Code Here

                    }
                    c = valuesString.charAt(i);
                }
            }
            end = i++;
            AnimatableValue val = eng.parseAnimatableValue
                (element, animationTarget, attributeNamespaceURI,
                 attributeLocalName, isCSS, valuesString.substring(start, end));
            if (!checkValueType(val)) {
                throw new BridgeException
                    (ctx, element, ErrorConstants.ERR_ATTRIBUTE_VALUE_MALFORMED,
View Full Code Here

    protected AnimatableValue parseAnimatableValue(String an) {
        if (!element.hasAttributeNS(null, an)) {
            return null;
        }
        String s = element.getAttributeNS(null, an);
        AnimatableValue val = eng.parseAnimatableValue
            (element, animationTarget, attributeNamespaceURI,
             attributeLocalName, animationType == AnimationEngine.ANIM_TYPE_CSS,
             s);
        if (!checkValueType(val)) {
            throw new BridgeException
View Full Code Here

    /**
     * Creates the animation object for the animation element.
     */
    protected AbstractAnimation createAnimation(AnimationTarget target) {
        short type = parseType();
        AnimatableValue from = null, to = null, by = null;
        if (element.hasAttributeNS(null, SVG_FROM_ATTRIBUTE)) {
            from = parseValue(element.getAttributeNS(null, SVG_FROM_ATTRIBUTE),
                              type, target);
        }
        if (element.hasAttributeNS(null, SVG_TO_ATTRIBUTE)) {
View Full Code Here

TOP

Related Classes of org.apache.flex.forks.batik.anim.values.AnimatableValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.