You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2006/03/15 08:20:47 UTC
svn commit: r385986 [2/2] - in
/xmlgraphics/batik/branches/anim/sources/org/apache/batik: anim/
anim/timing/ anim/values/ bridge/ css/engine/value/ css/engine/value/svg/
dom/ dom/events/ dom/svg/ parser/ transcoder/wmf/tosvg/ util/
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimatableGenericSVGBridge.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimatableGenericSVGBridge.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimatableGenericSVGBridge.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimatableGenericSVGBridge.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,114 @@
+package org.apache.batik.bridge;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+import org.apache.batik.dom.svg.SVGContext;
+import org.apache.batik.dom.svg.SVGOMElement;
+
+import org.w3c.dom.Element;
+
+/**
+ * Abstract bridge class for animatable elements that do not produce
+ * a GraphicsNode.
+ */
+public abstract class AnimatableGenericSVGBridge extends AnimatableSVGBridge
+ implements GenericBridge, SVGContext {
+
+ /**
+ * Invoked to handle an <tt>Element</tt> for a given <tt>BridgeContext</tt>.
+ * For example, see the <tt>SVGTitleElementBridge</tt>.
+ *
+ * @param ctx the bridge context to use
+ * @param e the element being handled
+ */
+ public void handleElement(BridgeContext ctx, Element e) {
+ if (ctx.isDynamic()) {
+ this.e = e;
+ this.ctx = ctx;
+ ((SVGOMElement) e).setSVGContext(this);
+ }
+ }
+
+ // SVGContext ////////////////////////////////////////////////////////////
+
+ /**
+ * Returns the size of a px CSS unit in millimeters.
+ */
+ public float getPixelUnitToMillimeter() {
+ return ctx.getUserAgent().getPixelUnitToMillimeter();
+ }
+
+ /**
+ * Returns the size of a px CSS unit in millimeters.
+ * This will be removed after next release.
+ * @see #getPixelUnitToMillimeter()
+ */
+ public float getPixelToMM() {
+ return getPixelUnitToMillimeter();
+ }
+
+ /**
+ * Returns the tight bounding box in current user space (i.e.,
+ * after application of the transform attribute, if any) on the
+ * geometry of all contained graphics elements, exclusive of
+ * stroke-width and filter effects).
+ */
+ public Rectangle2D getBBox() {
+ return null;
+ }
+
+ /**
+ * Returns the transform from the global transform space to pixels.
+ */
+ public AffineTransform getScreenTransform() {
+ return ctx.getUserAgent().getTransform();
+ }
+
+ /**
+ * Sets the transform to be used from the global transform space to pixels.
+ */
+ public void setScreenTransform(AffineTransform at) {
+ ctx.getUserAgent().setTransform(at);
+ }
+
+ /**
+ * Returns the transformation matrix from current user units
+ * (i.e., after application of the transform attribute, if any) to
+ * the viewport coordinate system for the nearestViewportElement.
+ */
+ public AffineTransform getCTM() {
+ return null;
+ }
+
+ /**
+ * Returns the global transformation matrix from the current
+ * element to the root.
+ */
+ public AffineTransform getGlobalTransform() {
+ return null;
+ }
+
+ /**
+ * Returns the width of the viewport which directly contains the
+ * associated element.
+ */
+ public float getViewportWidth() {
+ return 0f;
+ }
+
+ /**
+ * Returns the height of the viewport which directly contains the
+ * associated element.
+ */
+ public float getViewportHeight() {
+ return 0f;
+ }
+
+ /**
+ * Returns the font-size on the associated element.
+ */
+ public float getFontSize() {
+ return 0f;
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimatableGenericSVGBridge.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimatableSVGBridge.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimatableSVGBridge.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimatableSVGBridge.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimatableSVGBridge.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,102 @@
+package org.apache.batik.bridge;
+
+import org.apache.batik.anim.AnimationTarget;
+import org.apache.batik.anim.AnimationTargetListener;
+import org.apache.batik.anim.values.AnimatableValue;
+import org.apache.batik.dom.AbstractStylableDocument;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.css.CSSStyleDeclaration;
+
+/**
+ * Abstract bridge class for those elements that can be animated.
+ */
+public abstract class AnimatableSVGBridge extends AbstractSVGBridge
+ implements AnimationTarget {
+
+ /**
+ * The element that has been handled by this bridge.
+ */
+ protected Element e;
+
+ /**
+ * The bridge context to use for dynamic updates.
+ */
+ protected BridgeContext ctx;
+
+ // AnimationTarget ///////////////////////////////////////////////////////
+
+ /**
+ * Returns the element.
+ */
+ public Element getElement() {
+ return e;
+ }
+
+ /**
+ * Updates a property value in this target.
+ */
+ public void updatePropertyValue(String pn, AnimatableValue val) {
+ AbstractStylableDocument doc =
+ (AbstractStylableDocument) e.getOwnerDocument();
+ CSSStyleDeclaration over = doc.getOverrideStyle(e, null);
+ //System.err.println(e.getAttributeNS(null, "id") + "." + pn + " val is " + val);
+ if (val == null) {
+ over.removeProperty(pn);
+ } else {
+ over.setProperty(pn, val.getCssText(), "");
+ }
+ }
+
+ /**
+ * Updates an attribute value in this target.
+ */
+ public void updateAttributeValue(String ns, String ln,
+ AnimatableValue val) {
+ // XXX ...
+ }
+
+ /**
+ * Gets how percentage values are interpreted by the given attribute
+ * or property.
+ */
+ public int getPercentageInterpretation(String ns, String an, boolean isCSS) {
+ // XXX
+ return 0;
+ }
+
+ /**
+ * Returns whether color interpolations should be done in linear RGB
+ * color space rather than sRGB.
+ */
+ public boolean useLinearRGBColorInterpolation() {
+ // XXX
+ return false;
+ }
+
+ /**
+ * Converts a length from one unit to another. The {@code fromType}
+ * and {@code toType} parameters should be one of the constants defined
+ * in {@link org.w3c.dom.svg.SVGLength}.
+ */
+ public float convertLength(int fromType, float value, int toType) {
+ // XXX
+ return 0;
+ }
+
+ /**
+ * Adds a listener for changes to the given attribute value.
+ */
+ public void addTargetListener(String attributeName, boolean isCSS,
+ AnimationTargetListener l) {
+ // XXX
+ }
+
+ /**
+ * Removes a listener for changes to the given attribute value.
+ */
+ public void removeTargetListener(String attributeName, boolean isCSS,
+ AnimationTargetListener l) {
+ // XXX
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimatableSVGBridge.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimationSupport.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimationSupport.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimationSupport.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimationSupport.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,93 @@
+/*
+
+ Copyright 2006 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.batik.bridge;
+
+import java.util.Calendar;
+
+import org.apache.batik.anim.timing.TimedElement;
+import org.apache.batik.dom.events.DOMTimeEvent;
+import org.apache.batik.dom.svg.IdContainer;
+import org.apache.batik.dom.svg.SVGOMAnimationElement;
+import org.apache.batik.util.XMLConstants;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.events.DocumentEvent;
+import org.w3c.dom.events.EventTarget;
+import org.w3c.dom.smil.TimeEvent;
+
+/**
+ * Class that provides utilities for animation support.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public abstract class AnimationSupport {
+
+ /**
+ * Fires a {@link TimeEvent} on the given {@link EventTarget}.
+ */
+ public static void fireTimeEvent(EventTarget target, String eventType,
+ Calendar time, int detail) {
+ DocumentEvent de = (DocumentEvent) ((Node) target).getOwnerDocument();
+ DOMTimeEvent evt = (DOMTimeEvent) de.createEvent("TimeEvent");
+ evt.initTimeEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI, eventType,
+ null,
+ detail);
+ evt.setTimestamp(time.getTimeInMillis());
+ target.dispatchEvent(evt);
+ }
+
+ /**
+ * Returns the timed element with the given ID, using the given node
+ * as the context for the lookup.
+ */
+ public static TimedElement getTimedElementById(String id, Node n) {
+ Element e = getElementById(id, n);
+ if (e instanceof SVGOMAnimationElement) {
+ SVGAnimationElementBridge b = (SVGAnimationElementBridge)
+ ((SVGOMAnimationElement) e).getSVGContext();
+ return b.getTimedElement();
+ }
+ return null;
+ }
+
+ /**
+ * Returns the event target with the given ID, using the given
+ * node as the context for the lookup.
+ */
+ public static EventTarget getEventTargetById(String id, Node n) {
+ return (EventTarget) getElementById(id, n);
+ }
+
+ /**
+ * Returns the element with the given ID, using the given node
+ * as the context for the lookup.
+ */
+ protected static Element getElementById(String id, Node n) {
+ Node p = n.getParentNode();
+ while (p != null) {
+ n = p;
+ p = n.getParentNode();
+ }
+ if (n instanceof IdContainer) {
+ return ((IdContainer) n).getElementById(id);
+ }
+ return null;
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimationSupport.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/RepaintManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/RepaintManager.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/RepaintManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/RepaintManager.java Tue Mar 14 23:20:42 2006
@@ -74,7 +74,7 @@
int x1 = (int)Math.ceil(r2d.getX()+r2d.getWidth());
int y1 = (int)Math.ceil(r2d.getY()+r2d.getHeight());
// This rectangle must be outset one pixel to ensure
- // it includes the effects of anti-aliasing on object.s
+ // it includes the effects of anti-aliasing on objects.
Rectangle r = new Rectangle(x0-1, y0-1, x1-x0+3, y1-y0+3);
rects.add(r);
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimateElementBridge.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimateElementBridge.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimateElementBridge.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimateElementBridge.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,88 @@
+package org.apache.batik.bridge;
+
+import org.apache.batik.anim.AbstractAnimation;
+import org.apache.batik.anim.SimpleAnimation;
+import org.apache.batik.anim.values.AnimatableValue;
+import org.apache.batik.util.SVGConstants;
+
+public class SVGAnimateElementBridge extends SVGAnimationElementBridge {
+
+ /**
+ * Returns 'set'.
+ */
+ public String getLocalName() {
+ return SVG_ANIMATE_TAG;
+ }
+
+ /**
+ * Returns a new instance of this bridge.
+ */
+ public Bridge getInstance() {
+ return new SVGAnimateElementBridge();
+ }
+
+ /**
+ * Creates the animation object for the animation element.
+ */
+ protected AbstractAnimation createAnimation() {
+ AnimatableValue from =
+ parseAnimatableValue(SVGConstants.SVG_FROM_ATTRIBUTE);
+ AnimatableValue to =
+ parseAnimatableValue(SVGConstants.SVG_TO_ATTRIBUTE);
+ return new SimpleAnimation(timedElement,
+ this,
+ parseCalcMode(),
+ null,
+ null,
+ parseAdditive(),
+ false,
+ null,
+ from,
+ to,
+ null);
+ }
+
+ /**
+ * Returns the parsed calcMode attribute from the animation element.
+ */
+ protected int parseCalcMode() {
+ String calcModeString =
+ element.getAttributeNS(null, SVGConstants.SVG_CALC_MODE_ATTRIBUTE);
+ if (calcModeString.length() == 0) {
+ return getDefaultCalcMode();
+ } else if (calcModeString.equals("linear")) {
+ return SimpleAnimation.CALC_MODE_LINEAR;
+ } else if (calcModeString.equals("discrete")) {
+ return SimpleAnimation.CALC_MODE_DISCRETE;
+ } else if (calcModeString.equals("paced")) {
+ return SimpleAnimation.CALC_MODE_PACED;
+ } else if (calcModeString.equals("spline")) {
+ return SimpleAnimation.CALC_MODE_SPLINE;
+ }
+ // XXX
+ throw new RuntimeException("Invalid value for 'calcMode' attribute: \"" + calcModeString + "\"");
+ }
+
+ /**
+ * Returns the parsed 'additive' attribute from the animation element.
+ */
+ protected boolean parseAdditive() {
+ String additiveString =
+ element.getAttributeNS(null, SVGConstants.SVG_ADDITIVE_ATTRIBUTE);
+ if (additiveString.length() == 0
+ || additiveString.equals("replace")) {
+ return false;
+ } else if (additiveString.equals("sum")) {
+ return true;
+ }
+ // XXX
+ throw new RuntimeException("Invalid value for 'additive' attribute: \"" + additiveString + "\"");
+ }
+
+ /**
+ * Returns the calcMode that the animation defaults to if none is specified.
+ */
+ protected int getDefaultCalcMode() {
+ return SimpleAnimation.CALC_MODE_LINEAR;
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimateElementBridge.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimationElementBridge.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimationElementBridge.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimationElementBridge.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimationElementBridge.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,410 @@
+package org.apache.batik.bridge;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+import java.util.Calendar;
+
+import org.apache.batik.anim.AbstractAnimation;
+import org.apache.batik.anim.AnimatableElement;
+import org.apache.batik.anim.AnimationTarget;
+import org.apache.batik.anim.timing.TimedElement;
+import org.apache.batik.anim.values.AnimatableValue;
+import org.apache.batik.css.engine.CSSEngineEvent;
+import org.apache.batik.dom.svg.SVGContext;
+import org.apache.batik.dom.svg.SVGOMElement;
+import org.apache.batik.dom.util.XLinkSupport;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.events.EventTarget;
+import org.w3c.dom.events.MutationEvent;
+
+/**
+ * An abstract base class for the SVG animation element bridges.
+ */
+public abstract class SVGAnimationElementBridge extends AbstractSVGBridge
+ implements GenericBridge,
+ BridgeUpdateHandler,
+ SVGContext,
+ AnimatableElement {
+
+ /**
+ * The animation element.
+ */
+ protected SVGOMElement element;
+
+ /**
+ * The BridgeContext to be used.
+ */
+ protected BridgeContext ctx;
+
+ /**
+ * The AnimationEngine that manages all of the animations in the document.
+ */
+ protected SVGAnimationEngine eng;
+
+ /**
+ * The TimedElement object that provides the timing for the animation.
+ */
+ protected TimedElement timedElement;
+
+ /**
+ * The animation object that provides the values for the animation.
+ */
+ protected AbstractAnimation animation;
+
+ /**
+ * The namespace URI of the attribute being animated.
+ */
+ protected String attributeNamespaceURI;
+
+ /**
+ * The local name of the attribute or the name of the property being
+ * animated.
+ */
+ protected String attributeLocalName;
+
+ /**
+ * Whether the animation targets a CSS property.
+ */
+ protected boolean isCSS;
+
+ /**
+ * The target element of the animation.
+ */
+ protected SVGOMElement targetElement;
+
+ /**
+ * The AnimationTarget the provides a context to the animation engine.
+ */
+ protected AnimationTarget animationTarget;
+
+ /**
+ * Returns the TimedElement for the animation.
+ */
+ public TimedElement getTimedElement() {
+ return timedElement;
+ }
+
+ // AnimatableElement /////////////////////////////////////////////////////
+
+ /**
+ * Returns the underlying value of the animated attribute. Used for
+ * composition of additive animations.
+ */
+ public AnimatableValue getUnderlyingValue() {
+ if (isCSS) {
+ return eng.getUnderlyingCSSValue
+ (animationTarget, attributeLocalName);
+ } else {
+ // XXX
+ return null;
+ }
+ }
+
+ // GenericBridge /////////////////////////////////////////////////////////
+
+ /**
+ * Handles this animation element.
+ *
+ * @param ctx the bridge context to use
+ * @param e the element being handled
+ */
+ public void handleElement(BridgeContext ctx, Element e) {
+ if (ctx.isDynamic()) {
+ SVGAnimationElementBridge b =
+ (SVGAnimationElementBridge) getInstance();
+ b.element = (SVGOMElement) e;
+ b.ctx = ctx;
+ b.eng = ctx.getAnimationEngine();
+ b.element.setSVGContext(b);
+ b.eng.addInitialBridge(b);
+ }
+ }
+
+ /**
+ * Parses the animation element's attributes and adds it to the
+ * document's AnimationEngine.
+ */
+ protected void initializeAnimation() {
+ // target element
+ String uri = XLinkSupport.getXLinkHref(element);
+ Node t;
+ if (uri.length() == 0) {
+ t = element.getParentNode();
+ } else {
+ t = ctx.getReferencedElement(element, uri);
+ if (t.getOwnerDocument() != element.getOwnerDocument()) {
+ // XXX
+ throw new RuntimeException("Reference must be local");
+ }
+ }
+ animationTarget = null;
+ if (t instanceof SVGOMElement) {
+ targetElement = (SVGOMElement) t;
+ Object svgContext = targetElement.getSVGContext();
+ if (svgContext instanceof AnimationTarget) {
+ animationTarget = (AnimationTarget) svgContext;
+ }
+ }
+ if (animationTarget == null) {
+ // XXX
+ throw new RuntimeException("Element cannot be the target of an animation");
+ }
+
+ // attribute name
+ String an = element.getAttributeNS(null, SVG_ATTRIBUTE_NAME_ATTRIBUTE);
+ int ci = an.indexOf(':');
+ if (ci == -1) {
+ if (element.hasProperty(an)) {
+ isCSS = true;
+ attributeLocalName = an;
+ } else {
+ isCSS = false;
+ attributeLocalName = an;
+ }
+ } else {
+ isCSS = false;
+ String prefix = an.substring(0, ci);
+ attributeNamespaceURI = element.lookupNamespaceURI(prefix);
+ attributeLocalName = an.substring(ci + 1);
+ }
+ if (isCSS && !element.isPropertyAnimatable(attributeLocalName)
+ || !isCSS && !element.isAttributeAnimatable
+ (attributeNamespaceURI, attributeLocalName)) {
+ // XXX
+ throw new RuntimeException("Attribute '" + an + "' cannot be animated");
+ }
+
+ timedElement = createTimedElement();
+ animation = createAnimation();
+ if (isCSS) {
+ eng.addCSSAnimation(animationTarget, attributeLocalName, animation);
+ } else {
+ eng.addXMLAnimation(animationTarget, attributeNamespaceURI,
+ attributeLocalName, animation);
+ }
+ initializeTimedElement(timedElement);
+ timedElement.initialize();
+ }
+
+ /**
+ * Creates a TimedElement for the animation element.
+ */
+ protected TimedElement createTimedElement() {
+ return new SVGTimedElement();
+ }
+
+ /**
+ * Creates the animation object for the animation element.
+ */
+ protected abstract AbstractAnimation createAnimation();
+
+ /**
+ * Parses an attribute as an AnimatableValue.
+ */
+ protected AnimatableValue parseAnimatableValue(String an) {
+ String s = element.getAttributeNS(null, an);
+ int type;
+ if (isCSS) {
+ type = element.getPropertyType(attributeLocalName);
+ } else {
+ type = element.getAttributeType(attributeNamespaceURI,
+ attributeLocalName);
+ }
+ return eng.parseAnimatableValue(animationTarget, type, s);
+ }
+
+ /**
+ * Initializes the timing attributes of the timed element.
+ */
+ protected void initializeTimedElement(TimedElement timedElement) {
+ timedElement.parseAttributes
+ (element.getAttributeNS(null, "begin"),
+ element.getAttributeNS(null, "dur"),
+ element.getAttributeNS(null, "end"),
+ element.getAttributeNS(null, "min"),
+ element.getAttributeNS(null, "max"),
+ element.getAttributeNS(null, "repeatCount"),
+ element.getAttributeNS(null, "repeatDur"),
+ element.getAttributeNS(null, "fill"),
+ element.getAttributeNS(null, "restart"));
+ }
+
+ // BridgeUpdateHandler ///////////////////////////////////////////////////
+
+ /**
+ * Invoked when an MutationEvent of type 'DOMAttrModified' is fired.
+ */
+ public void handleDOMAttrModifiedEvent(MutationEvent evt) {
+ }
+
+ /**
+ * Invoked when an MutationEvent of type 'DOMNodeInserted' is fired.
+ */
+ public void handleDOMNodeInsertedEvent(MutationEvent evt) {
+ }
+
+ /**
+ * Invoked when an MutationEvent of type 'DOMNodeRemoved' is fired.
+ */
+ public void handleDOMNodeRemovedEvent(MutationEvent evt) {
+ // XXX correct?
+ dispose();
+ }
+
+ /**
+ * Invoked when an MutationEvent of type 'DOMCharacterDataModified'
+ * is fired.
+ */
+ public void handleDOMCharacterDataModified(MutationEvent evt) {
+ }
+
+ /**
+ * Invoked when an CSSEngineEvent is fired.
+ */
+ public void handleCSSEngineEvent(CSSEngineEvent evt) {
+ }
+
+ /**
+ * Disposes this BridgeUpdateHandler and releases all resources.
+ */
+ public void dispose() {
+ element = null;
+ }
+
+ // SVGContext ///////////////////////////////////////////////////////////
+
+ /**
+ * Returns the size of a px CSS unit in millimeters.
+ */
+ public float getPixelUnitToMillimeter() {
+ return ctx.getUserAgent().getPixelUnitToMillimeter();
+ }
+
+ /**
+ * Returns the size of a px CSS unit in millimeters.
+ * This will be removed after next release.
+ * @see #getPixelUnitToMillimeter()
+ */
+ public float getPixelToMM() {
+ return getPixelUnitToMillimeter();
+
+ }
+
+ public Rectangle2D getBBox() { return null; }
+ public AffineTransform getScreenTransform() {
+ return ctx.getUserAgent().getTransform();
+ }
+ public void setScreenTransform(AffineTransform at) {
+ ctx.getUserAgent().setTransform(at);
+ }
+ public AffineTransform getCTM() { return null; }
+ public AffineTransform getGlobalTransform() { return null; }
+ public float getViewportWidth() {
+ return ctx.getBlockWidth(element);
+ }
+ public float getViewportHeight() {
+ return ctx.getBlockHeight(element);
+ }
+ public float getFontSize() { return 0; }
+
+ /**
+ * A TimedElement class for SVG animation elements.
+ */
+ protected class SVGTimedElement extends TimedElement {
+
+ /**
+ * Fires a TimeEvent of the given type on this element.
+ * @param eventType the type of TimeEvent ("beginEvent", "endEvent"
+ * or "repeatEvent").
+ * @param time the timestamp of the event object
+ */
+ protected void fireTimeEvent(String eventType, Calendar time,
+ int detail) {
+ AnimationSupport.fireTimeEvent(element, eventType, time, detail);
+ }
+
+ /**
+ * Invoked to indicate this timed element became active at the
+ * specified time.
+ * @param begin the time the element became active, in document
+ * simple time
+ */
+ protected void toActive(float begin) {
+ eng.toActive(animation, begin);
+ }
+
+ /**
+ * Invoked to indicate that this timed element became inactive.
+ * @param isFrozen whether the element is frozen or not
+ */
+ protected void toInactive(boolean isFrozen) {
+ eng.toInactive(animation, isFrozen);
+ }
+
+ /**
+ * Invoked to indicate that this timed element has had its fill removed.
+ */
+ protected void removeFill() {
+ eng.removeFill(animation);
+ }
+
+ /**
+ * Invoked to indicate that this timed element has been sampled at the
+ * given time.
+ * @param simpleTime the sample time in local simple time
+ * @param simpleDur the simple duration of the element
+ * @param repeatIteration the repeat iteration during which the element
+ * was sampled
+ */
+ protected void sampledAt(float simpleTime, float simpleDur,
+ int repeatIteration) {
+ eng.sampledAt(animation, simpleTime, simpleDur, repeatIteration);
+ }
+
+ /**
+ * Invoked to indicate that this timed element has been sampled
+ * at the end of its active time, at an integer multiple of the
+ * simple duration. This is the "last" value that will be used
+ * for filling, which cannot be sampled normally.
+ */
+ protected void sampledLastValue(int repeatIteration) {
+ eng.sampledLastValue(animation, repeatIteration);
+ }
+
+ /**
+ * Returns the timed element with the given ID.
+ */
+ protected TimedElement getTimedElementById(String id) {
+ return AnimationSupport.getTimedElementById(id, element);
+ }
+
+ /**
+ * Returns the event target with the given ID.
+ */
+ protected EventTarget getEventTargetById(String id) {
+ return AnimationSupport.getEventTargetById(id, element);
+ }
+
+ /**
+ * Returns the event target that should be listened to for
+ * access key events.
+ */
+ protected EventTarget getRootEventTarget() {
+ return (EventTarget) element.getOwnerDocument();
+ }
+
+ /**
+ * Returns a string representation of this animation.
+ */
+ public String toString() {
+ String id = element.getAttributeNS(null, "id");
+ if (id.length() != 0) {
+ return id;
+ }
+ return super.toString();
+ }
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimationElementBridge.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimationEngine.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimationEngine.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimationEngine.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimationEngine.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,617 @@
+package org.apache.batik.bridge;
+
+import java.awt.Color;
+import java.awt.Paint;
+import java.util.Calendar;
+import java.util.HashSet;
+import java.util.LinkedList;
+
+import org.apache.batik.anim.AnimationEngine;
+import org.apache.batik.anim.AnimationTarget;
+import org.apache.batik.anim.timing.TimedDocumentRoot;
+import org.apache.batik.anim.timing.TimedElement;
+import org.apache.batik.anim.values.AnimatableLengthOrIdentValue;
+import org.apache.batik.anim.values.AnimatableValue;
+import org.apache.batik.anim.values.AnimatableColorValue;
+import org.apache.batik.anim.values.AnimatablePaintValue;
+import org.apache.batik.css.engine.CSSEngine;
+import org.apache.batik.css.engine.CSSStylableElement;
+import org.apache.batik.css.engine.StyleMap;
+import org.apache.batik.css.engine.value.FloatValue;
+import org.apache.batik.css.engine.value.Value;
+import org.apache.batik.css.engine.value.ValueManager;
+import org.apache.batik.css.engine.value.svg.SVGValueConstants;
+import org.apache.batik.dom.svg.SVGOMDocument;
+import org.apache.batik.dom.svg.SVGOMElement;
+import org.apache.batik.util.CSSConstants;
+import org.apache.batik.util.RunnableQueue;
+import org.apache.batik.util.XMLConstants;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.css.CSSPrimitiveValue;
+import org.w3c.dom.css.CSSValue;
+import org.w3c.dom.events.Event;
+import org.w3c.dom.events.EventListener;
+import org.w3c.dom.events.EventTarget;
+
+/**
+ * An AnimationEngine for SVG documents.
+ */
+public class SVGAnimationEngine extends AnimationEngine {
+
+ /**
+ * The BridgeContext to use for value parsing.
+ */
+ protected BridgeContext ctx;
+
+ /**
+ * The CSSEngine used for CSS value parsing.
+ */
+ protected CSSEngine cssEngine;
+
+ /**
+ * Factories for AnimatableValue parsing.
+ */
+ protected Factory[] factories = {
+ null, // TYPE_UNKNOWN
+ null, // TYPE_INTEGER
+ null, // TYPE_NUMBER
+ null, // TYPE_LENGTH
+ null, // TYPE_NUMBER_OPTIONAL_NUMBER
+ null, // TYPE_ANGLE
+ new AnimatableColorValueFactory(), // TYPE_COLOR
+ new AnimatablePaintValueFactory(), // TYPE_PAINT
+ null, // TYPE_PERCENTAGE
+ null, // TYPE_TRANSFORM_LIST
+ null, // TYPE_URI
+ null, // TYPE_FREQUENCY
+ null, // TYPE_TIME
+ null, // TYPE_NUMBER_LIST
+ null, // TYPE_LENGTH_LIST
+ null, // TYPE_IDENT
+ null, // TYPE_CDATA
+ new AnimatableLengthOrIdentFactory(), // TYPE_LENGTH_OR_IDENT
+ null, // TYPE_IDENT_LIST
+ null, // TYPE_CLIP_VALUE
+ null, // TYPE_URI_OR_IDENT
+ null, // TYPE_CURSOR_VALUE
+ null, // TYPE_PATH_DATA
+ null, // TYPE_ENABLE_BACKGROUND_VALUE
+ null, // TYPE_TIME_VALUE_LIST
+ null, // TYPE_NUMBER_OR_IDENT
+ null, // TYPE_FONT_FAMILY_VALUE
+ null, // TYPE_FONT_FACE_FONT_SIZE_VALUE
+ null, // TYPE_FONT_WEIGHT_VALUE
+ null, // TYPE_ANGLE_OR_IDENT
+ null, // TYPE_KEY_SPLINES_VALUE
+ null, // TYPE_POINTS_VALUE
+ null, // TYPE_PRESERVE_ASPECT_RATIO_VALUE
+ null, // TYPE_URI_LIST
+ null, // TYPE_LENGTH_LIST_OR_IDENT
+ null, // TYPE_CHARACTER_OR_UNICODE_RANGE_LIST
+ null, // TYPE_UNICODE_RANGE_LIST
+ null, // TYPE_FONT_VALUE
+ null, // TYPE_FONT_DECSRIPTOR_SRC_VALUE
+ };
+
+ /**
+ * Whether the document is an SVG 1.2 document.
+ */
+ protected boolean isSVG12;
+
+ /**
+ * List of bridges that will be initialized when the document is started.
+ */
+ protected LinkedList initialBridges = new LinkedList();
+
+ /**
+ * Event listener for the document 'load' event.
+ */
+ protected EventListener loadEventListener = new LoadListener();
+
+ /**
+ * A StyleMap used by the {@link Factory}s when computing CSS values.
+ */
+ protected StyleMap dummyStyleMap = new StyleMap(1);
+
+ /**
+ * The thread that ticks the animation engine.
+ */
+ protected AnimationThread animationThread;
+
+ /**
+ * Set of SMIL animation event names for SVG 1.1.
+ */
+ protected static HashSet animationEventNames11 = new HashSet();
+
+ /**
+ * Set of SMIL animation event names for SVG 1.2.
+ */
+ protected static HashSet animationEventNames12 = new HashSet();
+
+ static {
+ String[] eventNamesCommon = {
+ "click", "mousedown", "mouseup", "mouseover", "mousemove",
+ "mouseout", "beginEvent", "endEvent"
+ };
+ String[] eventNamesSVG11 = {
+ "DOMSubtreeModified", "DOMNodeInserted", "DOMNodeRemoved",
+ "DOMNodeRemovedFromDocument", "DOMNodeInsertedIntoDocument",
+ "DOMAttrModified", "DOMCharacterDataModified", "SVGLoad",
+ "SVGUnload", "SVGAbort", "SVGError", "SVGResize", "SVGScroll",
+ "repeatEvent"
+ };
+ String[] eventNamesSVG12 = {
+ "load", "resize", "scroll", "zoom"
+ };
+ for (int i = 0; i < eventNamesCommon.length; i++) {
+ animationEventNames11.add(eventNamesCommon[i]);
+ animationEventNames12.add(eventNamesCommon[i]);
+ }
+ for (int i = 0; i < eventNamesSVG11.length; i++) {
+ animationEventNames11.add(eventNamesSVG11[i]);
+ }
+ for (int i = 0; i < eventNamesSVG12.length; i++) {
+ animationEventNames12.add(eventNamesSVG12[i]);
+ }
+ }
+
+ /**
+ * Creates a new SVGAnimationEngine.
+ */
+ public SVGAnimationEngine(Document doc, BridgeContext ctx) {
+ super(doc);
+ this.ctx = ctx;
+ SVGOMDocument d = (SVGOMDocument) doc;
+ cssEngine = d.getCSSEngine();
+ isSVG12 = d.isSVG12();
+
+ SVGOMElement svg = (SVGOMElement) d.getDocumentElement();
+ svg.addEventListener("SVGLoad", loadEventListener, false);
+ }
+
+ /**
+ * Disposes this animation engine.
+ */
+ public void dispose() {
+ SVGOMElement svg = (SVGOMElement) document.getDocumentElement();
+ svg.removeEventListener("SVGLoad", loadEventListener, false);
+ }
+
+ /**
+ * Adds an animation element bridge to the list of bridges that
+ * require initializing when the document is started.
+ */
+ public void addInitialBridge(SVGAnimationElementBridge b) {
+ if (initialBridges != null) {
+ initialBridges.add(b);
+ }
+ }
+
+ /**
+ * Parses an AnimatableValue.
+ */
+ public AnimatableValue parseAnimatableValue(AnimationTarget target,
+ int type, String s) {
+ Factory factory = factories[type];
+ if (factory == null) {
+ // XXX
+ throw new RuntimeException("Attribute type " + type + " is not animatable");
+ }
+ return factories[type].createValue(target, s);
+ }
+
+ /**
+ * Returns an AnimatableValue for the underlying value of a CSS property.
+ */
+ public AnimatableValue getUnderlyingCSSValue(AnimationTarget target,
+ String pn) {
+ ValueManager vms[] = cssEngine.getValueManagers();
+ int idx = cssEngine.getPropertyIndex(pn);
+ if (idx != -1) {
+ int type = vms[idx].getPropertyType();
+ Factory factory = factories[type];
+ if (factory == null) {
+ // XXX
+ throw new RuntimeException("Attribute type " + type + " is not animatable");
+ }
+ Value v = cssEngine.getComputedStyle
+ ((CSSStylableElement) target.getElement(), null, idx);
+ return factories[type].createValue(target, v);
+ }
+ // XXX doesn't handle shorthands
+ return null;
+ }
+
+ /**
+ * Creates a new returns a new TimedDocumentRoot object for the document.
+ */
+ protected TimedDocumentRoot createDocumentRoot() {
+ return new AnimationRoot();
+ }
+
+ /**
+ * Interface for AnimatableValue factories.
+ */
+ protected interface Factory {
+ AnimatableValue createValue(AnimationTarget target, String s);
+ AnimatableValue createValue(AnimationTarget target, Value v);
+ }
+
+ /**
+ * Factory class for AnimatableValues constructed from CSS Value objects.
+ */
+ protected abstract class CSSValueFactory implements Factory {
+ public AnimatableValue createValue(AnimationTarget target, String s) {
+ return createValue(target, createCSSValue(target, s));
+ }
+ protected abstract String getPropertyName();
+ protected Value createCSSValue(AnimationTarget t, String s) {
+ CSSStylableElement elt = (CSSStylableElement) t.getElement();
+ String pn = getPropertyName();
+ Value v = cssEngine.parsePropertyValue(elt, pn, s);
+ ValueManager[] vms = cssEngine.getValueManagers();
+ int idx = cssEngine.getPropertyIndex(pn);
+ if (idx != -1) {
+ v = vms[idx].computeValue(elt, null, cssEngine, 0,
+ dummyStyleMap, v);
+ }
+ // XXX doesn't handle shorthands
+ return v;
+ }
+ }
+
+ /**
+ * Factory class for AnimatableLengthOrIdent values.
+ */
+ protected class AnimatableLengthOrIdentFactory extends CSSValueFactory {
+ protected String getPropertyName() {
+ return CSSConstants.CSS_STROKE_WIDTH_PROPERTY;
+ }
+ public AnimatableValue createValue(AnimationTarget target, Value v) {
+ if (v == SVGValueConstants.INHERIT_VALUE) {
+ return new AnimatableLengthOrIdentValue(target, "inherit");
+ }
+ FloatValue fv = (FloatValue) v;
+ return new AnimatableLengthOrIdentValue
+ (target, fv.getPrimitiveType() + 1, fv.getFloatValue());
+ }
+ }
+
+ /**
+ * Factory class for AnimatableColorValues.
+ */
+ protected class AnimatableColorValueFactory extends CSSValueFactory {
+ protected String getPropertyName() {
+ return CSSConstants.CSS_STOP_COLOR_PROPERTY;
+ }
+ public AnimatableValue createValue(AnimationTarget target, Value v) {
+ Paint p = PaintServer.convertPaint
+ (target.getElement(), null, v, 1f, ctx);
+ if (p instanceof Color) {
+ Color c = (Color) p;
+ return new AnimatableColorValue(target,
+ c.getRed() / 255f,
+ c.getGreen() / 255f,
+ c.getBlue() / 255f);
+ }
+ // XXX
+ return null;
+ }
+ }
+
+ /**
+ * Factory class for AnimatablePaintValues.
+ */
+ protected class AnimatablePaintValueFactory extends CSSValueFactory {
+ protected String getPropertyName() {
+ return CSSConstants.CSS_FILL_PROPERTY;
+ }
+ protected AnimatablePaintValue createColorPaintValue(AnimationTarget t,
+ Color c) {
+ return AnimatablePaintValue.createColorPaintValue
+ (t, c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f);
+ }
+ public AnimatableValue createValue(AnimationTarget target, Value v) {
+ if (v.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
+ switch (v.getPrimitiveType()) {
+ case CSSPrimitiveValue.CSS_IDENT:
+ return AnimatablePaintValue.createNonePaintValue(target);
+ case CSSPrimitiveValue.CSS_RGBCOLOR: {
+ Paint p = PaintServer.convertPaint
+ (target.getElement(), null, v, 1f, ctx);
+ return createColorPaintValue(target, (Color) p);
+ }
+ case CSSPrimitiveValue.CSS_URI:
+ return AnimatablePaintValue.createURIPaintValue
+ (target, v.getStringValue());
+ }
+ } else {
+ Value v1 = v.item(0);
+ switch (v1.getPrimitiveType()) {
+ case CSSPrimitiveValue.CSS_RGBCOLOR: {
+ Paint p = PaintServer.convertPaint
+ (target.getElement(), null, v, 1f, ctx);
+ return createColorPaintValue(target, (Color) p);
+ }
+ case CSSPrimitiveValue.CSS_URI: {
+ Value v2 = v.item(1);
+ switch (v2.getPrimitiveType()) {
+ case CSSPrimitiveValue.CSS_IDENT:
+ return AnimatablePaintValue.createURINonePaintValue
+ (target, v1.getStringValue());
+ case CSSPrimitiveValue.CSS_RGBCOLOR: {
+ Paint p = PaintServer.convertPaint
+ (target.getElement(), null, v.item(1), 1f, ctx);
+ return createColorPaintValue(target, (Color) p);
+ }
+ }
+ }
+ }
+ }
+ // XXX
+ return null;
+ }
+ }
+
+ /**
+ * A class for the root time container.
+ */
+ protected class AnimationRoot extends TimedDocumentRoot {
+
+ /**
+ * Creates a new AnimationRoot object.
+ */
+ public AnimationRoot() {
+ super(!isSVG12, isSVG12);
+ }
+
+ /**
+ * Returns the namespace URI of the event that corresponds to the given
+ * animation event name.
+ */
+ protected String getEventNamespaceURI(String eventName) {
+ if (!isSVG12) {
+ return null;
+ }
+ if (eventName.equals("focusin")
+ || eventName.equals("focusout")
+ || eventName.equals("activate")
+ || animationEventNames12.contains(eventName)) {
+ return XMLConstants.XML_EVENTS_NAMESPACE_URI;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the type of the event that corresponds to the given
+ * animation event name.
+ */
+ protected String getEventType(String eventName) {
+ if (eventName.equals("focusin")) {
+ return "DOMFocusIn";
+ } else if (eventName.equals("focusout")) {
+ return "DOMFocusOut";
+ } else if (eventName.equals("activate")) {
+ return "DOMActivate";
+ }
+ if (isSVG12) {
+ if (animationEventNames12.contains(eventName)) {
+ return eventName;
+ }
+ } else {
+ if (animationEventNames11.contains(eventName)) {
+ return eventName;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the name of the repeat event.
+ * @return "repeatEvent" for SVG
+ */
+ protected String getRepeatEventName() {
+ return "repeatEvent";
+ }
+
+ /**
+ * Fires a TimeEvent of the given type on this element.
+ * @param eventType the type of TimeEvent ("beginEvent", "endEvent"
+ * or "repeatEvent"/"repeat").
+ * @param time the timestamp of the event object
+ */
+ protected void fireTimeEvent(String eventType, Calendar time,
+ int detail) {
+ AnimationSupport.fireTimeEvent
+ ((EventTarget) document, eventType, time, detail);
+ }
+
+ /**
+ * Invoked to indicate this timed element became active at the
+ * specified time.
+ * @param begin the time the element became active, in document simple time
+ */
+ protected void toActive(float begin) {
+ }
+
+ /**
+ * Invoked to indicate that this timed element became inactive.
+ * @param isFrozen whether the element is frozen or not
+ */
+ protected void toInactive(boolean isFrozen) {
+ }
+
+ /**
+ * Invoked to indicate that this timed element has had its fill removed.
+ */
+ protected void removeFill() {
+ }
+
+ /**
+ * Invoked to indicate that this timed element has been sampled at the
+ * given time.
+ * @param simpleTime the sample time in local simple time
+ * @param simpleDur the simple duration of the element
+ * @param repeatIteration the repeat iteration during which the element
+ * was sampled
+ */
+ protected void sampledAt(float simpleTime, float simpleDur,
+ int repeatIteration) {
+ }
+
+ /**
+ * Invoked to indicate that this timed element has been sampled
+ * at the end of its active time, at an integer multiple of the
+ * simple duration. This is the "last" value that will be used
+ * for filling, which cannot be sampled normally.
+ */
+ protected void sampledLastValue(int repeatIteration) {
+ }
+
+ /**
+ * Returns the timed element with the given ID.
+ */
+ protected TimedElement getTimedElementById(String id) {
+ return AnimationSupport.getTimedElementById(id, document);
+ }
+
+ /**
+ * Returns the event target with the given ID.
+ */
+ protected EventTarget getEventTargetById(String id) {
+ return AnimationSupport.getEventTargetById(id, document);
+ }
+
+ /**
+ * Returns the event target that should be listened to for
+ * access key events.
+ */
+ protected EventTarget getRootEventTarget() {
+ return (EventTarget) document;
+ }
+ }
+
+ /**
+ * Listener class for the document 'load' event.
+ */
+ protected class LoadListener implements EventListener {
+
+ /**
+ * Handles the event.
+ */
+ public void handleEvent(Event evt) {
+ if (evt.getTarget() != evt.getCurrentTarget()) {
+ return;
+ }
+ Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(evt.getTimeStamp());
+ timedDocumentRoot.resetDocument(cal);
+ Object[] bridges = initialBridges.toArray();
+ initialBridges = null;
+ for (int i = 0; i < bridges.length; i++) {
+ SVGAnimationElementBridge bridge =
+ (SVGAnimationElementBridge) bridges[i];
+ bridge.initializeAnimation();
+ }
+ tick(0);
+ // animationThread = new AnimationThread();
+ // animationThread.start();
+ ctx.getUpdateManager().getUpdateRunnableQueue().setIdleRunnable
+ (new AnimationTickRunnable());
+ }
+ }
+
+ /**
+ * Idle runnable to tick the animation.
+ */
+ protected class AnimationTickRunnable implements Runnable {
+ protected Calendar time = Calendar.getInstance();
+ double second = -1.;
+ public void run() {
+ time.setTimeInMillis(System.currentTimeMillis());
+ float t = timedDocumentRoot.convertWallclockTime(time);
+ /*if (Math.floor(t) > second) {
+ second = Math.floor(t);
+ tick(t);
+ }*/
+ tick(t);
+ try {
+ Thread.sleep(1);
+ } catch (InterruptedException ie) {
+ }
+ }
+ }
+
+ /**
+ * The thread that ticks the animation.
+ */
+ protected class AnimationThread extends Thread {
+
+ /**
+ * The current time.
+ */
+ protected Calendar time = Calendar.getInstance();
+
+ /**
+ * The RunnableQueue to perform the animation in.
+ */
+ protected RunnableQueue runnableQueue =
+ ctx.getUpdateManager().getUpdateRunnableQueue();
+
+ /**
+ * The animation ticker Runnable.
+ */
+ protected Ticker ticker = new Ticker();
+
+ /**
+ * Ticks the animation over as fast as possible.
+ */
+ public void run() {
+ if (true) {
+ for (;;) {
+ time.setTimeInMillis(System.currentTimeMillis());
+ ticker.t = timedDocumentRoot.convertWallclockTime(time);
+ try {
+ runnableQueue.invokeAndWait(ticker);
+ } catch (InterruptedException e) {
+ return;
+ }
+ }
+ } else {
+ ticker.t = 1;
+ while (ticker.t < 10) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ie) {
+ }
+ try {
+ runnableQueue.invokeAndWait(ticker);
+ } catch (InterruptedException e) {
+ return;
+ }
+ ticker.t++;
+ }
+ }
+ }
+
+ /**
+ * A runnable that ticks the animation engine.
+ */
+ protected class Ticker implements Runnable {
+
+ /**
+ * The document time to tick at next.
+ */
+ protected float t;
+
+ /**
+ * Ticks the animation over.
+ */
+ public void run() {
+ System.err.println("TICK " + t);
+ tick(t);
+ }
+ }
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimationEngine.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGBridgeExtension.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGBridgeExtension.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGBridgeExtension.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGBridgeExtension.java Tue Mar 14 23:20:42 2006
@@ -148,7 +148,7 @@
ctx.putBridge(new SVGUseElementBridge());
ctx.putBridge(new SVGVKernElementBridge());
ctx.putBridge(new SVGSetElementBridge());
- System.err.println("added");
+ ctx.putBridge(new SVGAnimateElementBridge());
}
/**
@@ -166,7 +166,7 @@
String ln = e.getLocalName();
if (ln.equals(SVGConstants.SVG_SCRIPT_TAG)
|| ln.startsWith("animate")
- || ln.equals("set")) {
+ || ln.equals(SVGConstants.SVG_SET_TAG)) {
return true;
}
return false;
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGSetElementBridge.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGSetElementBridge.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGSetElementBridge.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGSetElementBridge.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,35 @@
+package org.apache.batik.bridge;
+
+import org.apache.batik.anim.AbstractAnimation;
+import org.apache.batik.anim.SetAnimation;
+import org.apache.batik.anim.values.AnimatableValue;
+import org.apache.batik.util.SVGConstants;
+
+/**
+ * A bridge class for the 'set' animation element.
+ */
+public class SVGSetElementBridge extends SVGAnimationElementBridge {
+
+ /**
+ * Returns 'set'.
+ */
+ public String getLocalName() {
+ return SVG_SET_TAG;
+ }
+
+ /**
+ * Returns a new instance of this bridge.
+ */
+ public Bridge getInstance() {
+ return new SVGSetElementBridge();
+ }
+
+ /**
+ * Creates the animation object for the animation element.
+ */
+ protected AbstractAnimation createAnimation() {
+ AnimatableValue to =
+ parseAnimatableValue(SVGConstants.SVG_TO_ATTRIBUTE);
+ return new SetAnimation(timedElement, this, to);
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGSetElementBridge.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/LengthManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/LengthManager.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/LengthManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/LengthManager.java Tue Mar 14 23:20:42 2006
@@ -34,7 +34,7 @@
* @version $Id$
*/
public abstract class LengthManager extends AbstractValueManager {
-
+
/**
* Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}.
*/
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeWidthManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeWidthManager.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeWidthManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeWidthManager.java Tue Mar 14 23:20:42 2006
@@ -34,7 +34,7 @@
* @version $Id$
*/
public class StrokeWidthManager extends LengthManager {
-
+
/**
* Implements {@link ValueManager#isInheritedProperty()}.
*/
@@ -87,7 +87,6 @@
}
return super.createValue(lu, engine);
}
-
/**
* Indicates the orientation of the property associated with
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/TextRenderingManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/TextRenderingManager.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/TextRenderingManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/TextRenderingManager.java Tue Mar 14 23:20:42 2006
@@ -20,6 +20,7 @@
import org.apache.batik.css.engine.value.IdentifierManager;
import org.apache.batik.css.engine.value.StringMap;
import org.apache.batik.css.engine.value.Value;
+import org.apache.batik.css.engine.value.ValueManager;
import org.apache.batik.util.CSSConstants;
import org.apache.batik.util.SVGTypes;
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/GenericElementNS.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/GenericElementNS.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/GenericElementNS.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/GenericElementNS.java Tue Mar 14 23:20:42 2006
@@ -17,6 +17,7 @@
*/
package org.apache.batik.dom;
+import org.w3c.dom.DOMException;
import org.w3c.dom.Node;
/**
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/events/DOMTimeEvent.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/events/DOMTimeEvent.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/events/DOMTimeEvent.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/events/DOMTimeEvent.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,86 @@
+/*
+
+ Copyright 2006 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.batik.dom.events;
+
+import org.w3c.dom.views.AbstractView;
+import org.w3c.dom.smil.TimeEvent;
+
+/**
+ * An event class for SMIL timing events.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public class DOMTimeEvent extends AbstractEvent implements TimeEvent {
+
+ /**
+ * The view from which the event was generated.
+ */
+ protected AbstractView view;
+
+ /**
+ * For repeat events this is the repeat iteration. Unused for the
+ * other time events.
+ */
+ protected int detail;
+
+ /**
+ * Returns the view from which the event was generated.
+ */
+ public AbstractView getView() {
+ return view;
+ }
+
+ /**
+ * Returns the repeat iteration if this is a repeat event.
+ */
+ public int getDetail() {
+ return detail;
+ }
+
+ /**
+ * Initializes the values of the TimeEvent object.
+ */
+ public void initTimeEvent(String typeArg,
+ AbstractView viewArg,
+ int detailArg) {
+ initEvent(typeArg, false, false);
+ this.view = viewArg;
+ this.detail = detailArg;
+ }
+
+ /**
+ * Initializes the values of the TimeEvent object.
+ */
+ public void initTimeEventNS(String namespaceURIArg,
+ String typeArg,
+ AbstractView viewArg,
+ int detailArg) {
+ initEventNS(namespaceURIArg, typeArg, false, false);
+ this.view = viewArg;
+ this.detail = detailArg;
+ }
+
+ /**
+ * Sets the timestamp of this time event. This is required for
+ * synchronization of time events in the SMIL timing model.
+ */
+ public void setTimestamp(long timeStamp) {
+ this.timeStamp = timeStamp;
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/events/DOMTimeEvent.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/ExtendedTraitAccess.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/ExtendedTraitAccess.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/ExtendedTraitAccess.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/ExtendedTraitAccess.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,48 @@
+package org.apache.batik.dom.svg;
+
+/**
+ * Interface for SVG DOM classes to expose information about the traits
+ * (XML attributes and CSS properties) their elements support.
+ */
+public interface ExtendedTraitAccess extends TraitAccess {
+
+ /**
+ * Returns whether the given CSS property is available on this element.
+ */
+ boolean hasProperty(String pn);
+
+ /**
+ * Returns whether the given trait is available on this element.
+ */
+ boolean hasTrait(String ns, String ln);
+
+ /**
+ * Returns whether the given CSS property is animatable.
+ */
+ boolean isPropertyAnimatable(String pn);
+
+ /**
+ * Returns whether the given XML attribute is animatable.
+ */
+ boolean isAttributeAnimatable(String ns, String ln);
+
+ /**
+ * Returns whether the given CSS property is additive.
+ */
+ boolean isPropertyAdditive(String pn);
+
+ /**
+ * Returns whether the given XML attribute is additive.
+ */
+ boolean isAttributeAdditive(String ns, String ln);
+
+ /**
+ * Returns whether the given trait is animatable.
+ */
+ boolean isTraitAnimatable(String ns, String tn);
+
+ /**
+ * Returns whether the given trait is additive.
+ */
+ boolean isTraitAdditive(String ns, String tn);
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/ExtendedTraitAccess.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/IdContainer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/IdContainer.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/IdContainer.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/IdContainer.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,36 @@
+/*
+
+ Copyright 2006 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.batik.dom.svg;
+
+import org.w3c.dom.Element;
+
+/**
+ * An interface for DOM nodes that can look up elements with IDs. This is
+ * used to give common interface to {@link org.w3c.dom.Document} and
+ * {@link org.apache.batik.dom.xbl.XBLShadowTreeElement} objects.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public interface IdContainer {
+
+ /**
+ * Returns the element with the given ID that exists in this subtree.
+ */
+ Element getElementById(String id);
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/IdContainer.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/SVGDOMImplementation.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/SVGDOMImplementation.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/SVGDOMImplementation.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/SVGDOMImplementation.java Tue Mar 14 23:20:42 2006
@@ -26,24 +26,19 @@
import org.apache.batik.css.engine.value.ShorthandManager;
import org.apache.batik.css.engine.value.ValueManager;
import org.apache.batik.css.parser.ExtendedParser;
-import org.apache.batik.css.parser.ExtendedParserWrapper;
import org.apache.batik.dom.AbstractDocument;
import org.apache.batik.dom.AbstractStylableDocument;
import org.apache.batik.dom.ExtensibleDOMImplementation;
import org.apache.batik.dom.GenericDocumentType;
-import org.apache.batik.dom.GenericElement;
-import org.apache.batik.dom.GenericElementNS;
-import org.apache.batik.dom.StyleSheetFactory;
+import org.apache.batik.dom.events.DOMTimeEvent;
import org.apache.batik.dom.events.DocumentEventSupport;
import org.apache.batik.dom.util.CSSStyleDeclarationFactory;
import org.apache.batik.dom.util.DOMUtilities;
import org.apache.batik.dom.util.HashTable;
import org.apache.batik.i18n.LocalizableSupport;
import org.apache.batik.util.SVGConstants;
-import org.apache.batik.util.XMLResourceDescriptor;
import org.w3c.css.sac.InputSource;
-import org.w3c.css.sac.Parser;
import org.w3c.dom.DOMException;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
@@ -225,6 +220,12 @@
new DocumentEventSupport.EventFactory() {
public Event createEvent() {
return new SVGOMEvent();
+ }
+ });
+ result.registerEventFactory("TimeEvent",
+ new DocumentEventSupport.EventFactory() {
+ public Event createEvent() {
+ return new DOMTimeEvent();
}
});
return result;
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/SVGOMAnimationElement.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/SVGOMAnimationElement.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/SVGOMAnimationElement.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/SVGOMAnimationElement.java Tue Mar 14 23:20:42 2006
@@ -17,13 +17,10 @@
*/
package org.apache.batik.dom.svg;
-import java.util.Calendar;
-
-import org.apache.batik.anim.timing.TimedElement;
+// import org.apache.batik.anim.timing.TimedElement;
import org.apache.batik.dom.AbstractDocument;
import org.w3c.dom.DOMException;
-import org.w3c.dom.events.EventTarget;
import org.w3c.dom.svg.SVGAnimatedBoolean;
import org.w3c.dom.svg.SVGAnimationElement;
import org.w3c.dom.svg.SVGElement;
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/TraitAccess.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/TraitAccess.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/TraitAccess.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/TraitAccess.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,10 @@
+package org.apache.batik.dom.svg;
+
+/**
+ * Interface for accessing traits on an element. This interface should move
+ * to org.w3c.dom.svg (presumably).
+ */
+public interface TraitAccess {
+
+ // XXX TBD
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/TraitAccess.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingParser.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingParser.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingParser.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingParser.java Tue Mar 14 23:20:42 2006
@@ -19,7 +19,6 @@
import java.io.IOException;
import java.util.Calendar;
-import java.util.TimeZone;
import java.util.SimpleTimeZone;
import org.apache.batik.xml.XMLUtilities;
@@ -59,7 +58,7 @@
* Creates a new TimingParser.
* @param useSVG11AccessKeys allows the use of accessKey() timing
* specifiers with a single character
- * @param useSVG12Accesskeys allows the use of accessKey() with a
+ * @param useSVG12AccessKeys allows the use of accessKey() with a
* DOM 3 key name
*/
public TimingParser(boolean useSVG11AccessKeys,
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingSpecifierListParser.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingSpecifierListParser.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingSpecifierListParser.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingSpecifierListParser.java Tue Mar 14 23:20:42 2006
@@ -32,7 +32,7 @@
* Creates a new TimingSpecifierListParser.
* @param useSVG11AccessKeys allows the use of accessKey() timing
* specifiers with a single character
- * @param useSVG12Accesskeys allows the use of accessKey() with a
+ * @param useSVG12AccessKeys allows the use of accessKey() with a
* DOM 3 key name
*/
public TimingSpecifierListParser(boolean useSVG11AccessKeys,
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingSpecifierParser.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingSpecifierParser.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingSpecifierParser.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingSpecifierParser.java Tue Mar 14 23:20:42 2006
@@ -38,7 +38,7 @@
* Creates a new TimingSpecifierParser.
* @param useSVG11AccessKeys allows the use of accessKey() timing
* specifiers with a single character
- * @param useSVG12Accesskeys allows the use of accessKey() with a
+ * @param useSVG12AccessKeys allows the use of accessKey() with a
* DOM 3 key name
*/
public TimingSpecifierParser(boolean useSVG11AccessKeys,
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/wmf/tosvg/WMFPainter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/wmf/tosvg/WMFPainter.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/wmf/tosvg/WMFPainter.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/wmf/tosvg/WMFPainter.java Tue Mar 14 23:20:42 2006
@@ -19,41 +19,39 @@
package org.apache.batik.transcoder.wmf.tosvg;
import java.awt.BasicStroke;
-import java.awt.Stroke;
import java.awt.Color;
-import java.awt.Font;
-import java.awt.Paint;
-import java.awt.Image;
import java.awt.Dimension;
-import java.awt.TexturePaint;
+import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
-import java.awt.Polygon;
+import java.awt.Image;
+import java.awt.Paint;
import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.TexturePaint;
import java.awt.Toolkit;
-import java.awt.image.BufferedImage;
-import java.awt.image.ImageObserver;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
-import java.awt.font.TextAttribute;
import java.awt.geom.AffineTransform;
-import java.awt.geom.GeneralPath;
-import java.awt.geom.Point2D;
import java.awt.geom.Arc2D;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.GeneralPath;
import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;
-import java.awt.geom.Ellipse2D;
-import java.text.AttributedString;
-import java.text.AttributedCharacterIterator;
+import java.awt.image.BufferedImage;
+import java.awt.image.ImageObserver;
import java.io.BufferedInputStream;
+import java.text.AttributedCharacterIterator;
+import java.util.Iterator;
import java.util.Stack;
import java.util.Vector;
-import java.util.Iterator;
-import org.apache.batik.transcoder.wmf.WMFConstants;
import org.apache.batik.ext.awt.geom.Polygon2D;
import org.apache.batik.ext.awt.geom.Polyline2D;
+import org.apache.batik.transcoder.wmf.WMFConstants;
+
/**
* Core class for rendering the WMF image. It is able to render a
* WMF file in a <tt>Graphics</tt> object.
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/RunnableQueue.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/RunnableQueue.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/RunnableQueue.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/RunnableQueue.java Tue Mar 14 23:20:42 2006
@@ -31,7 +31,7 @@
/**
* Type-safe enumeration of queue states.
*/
- public static class RunnableQueueState extends Object {
+ public static class RunnableQueueState {
final String value;
private RunnableQueueState(String value) {
this.value = value.intern(); }
@@ -41,7 +41,7 @@
}
/**
- * The queue is in the processes of running tasks.
+ * The queue is in the process of running tasks.
*/
public static final RunnableQueueState RUNNING
= new RunnableQueueState("Running");
@@ -100,8 +100,13 @@
protected HaltingThread runnableQueueThread;
/**
+ * The Runnable to run if the queue is empty.
+ */
+ protected Runnable idleRunnable;
+
+ /**
* Creates a new RunnableQueue started in a new thread.
- * @return a RunnableQueue which is garanteed to have entered its
+ * @return a RunnableQueue which is guaranteed to have entered its
* <tt>run()</tt> method.
*/
public static RunnableQueue createRunnableQueue() {
@@ -139,7 +144,7 @@
while (!HaltingThread.hasBeenHalted()) {
boolean callSuspended = false;
boolean callResumed = false;
- // Mutex for suspention work.
+ // Mutex for suspension work.
synchronized (stateLock) {
if (state != RUNNING) {
state = SUSPENDED;
@@ -185,16 +190,22 @@
l = (Link)list.pop();
if (preemptCount != 0) preemptCount--;
if (l == null) {
- // No item to run, wait till there is one.
- try {
- list.wait();
- } catch (InterruptedException ie) {
- // just loop again.
+ // No item to run, see if there is an idle runnable
+ // to run instead.
+ if (idleRunnable != null) {
+ rable = idleRunnable;
+ } else {
+ // Wait for a runnable.
+ try {
+ list.wait();
+ } catch (InterruptedException ie) {
+ // just loop again.
+ }
+ continue; // start loop over again...
}
- continue; // start loop over again...
+ } else {
+ rable = l.runnable;
}
-
- rable = l.runnable;
}
runnableStart(rable);
@@ -209,7 +220,11 @@
// But this is more or less what Swing does.
t.printStackTrace();
}
- l.unlock();
+ // Notify something waiting on the runnable just completed,
+ // if we just ran one from the queue.
+ if (l != null) {
+ l.unlock();
+ }
runnableInvoked(rable);
}
} finally {
@@ -450,6 +465,13 @@
return runHandler;
}
+ /**
+ * Sets a Runnable to be run whenever the queue is empty.
+ */
+ public synchronized void setIdleRunnable(Runnable r) {
+ idleRunnable = r;
+ }
+
/**
* Called when execution is being suspended.
* Currently just notifies runHandler
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/SVGConstants.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/SVGConstants.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/SVGConstants.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/SVGConstants.java Tue Mar 14 23:20:42 2006
@@ -374,6 +374,7 @@
/////////////////////////////////////////////////////////////////////////
String SVG_ACCENT_HEIGHT_ATTRIBUTE = "accent-height";
+ String SVG_ADDITIVE_ATTRIBUTE = "additive";
String SVG_AMPLITUDE_ATTRIBUTE = "amplitude";
String SVG_ARABIC_FORM_ATTRIBUTE = "arabic-form";
String SVG_ASCENT_ATTRIBUTE = "ascent";
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/SVGTypes.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/SVGTypes.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/SVGTypes.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/SVGTypes.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,48 @@
+package org.apache.batik.util;
+
+/**
+ * Abstract class for SVG type related constants.
+ */
+public abstract class SVGTypes {
+
+ // Constants for SVG attribute and property types.
+ public final static int TYPE_UNKNOWN = 0;
+ public final static int TYPE_INTEGER = 1;
+ public final static int TYPE_NUMBER = 2;
+ public final static int TYPE_LENGTH = 3;
+ public final static int TYPE_NUMBER_OPTIONAL_NUMBER = 4;
+ public final static int TYPE_ANGLE = 5;
+ public final static int TYPE_COLOR = 6;
+ public final static int TYPE_PAINT = 7;
+ public final static int TYPE_PERCENTAGE = 8;
+ public final static int TYPE_TRANSFORM_LIST = 9;
+ public final static int TYPE_URI = 10;
+ public final static int TYPE_FREQUENCY = 11;
+ public final static int TYPE_TIME = 12;
+ public final static int TYPE_NUMBER_LIST = 13;
+ public final static int TYPE_LENGTH_LIST = 14;
+ public final static int TYPE_IDENT = 15;
+ public final static int TYPE_CDATA = 16;
+ public final static int TYPE_LENGTH_OR_IDENT = 17;
+ public final static int TYPE_IDENT_LIST = 18;
+ public final static int TYPE_CLIP_VALUE = 19;
+ public final static int TYPE_URI_OR_IDENT = 20;
+ public final static int TYPE_CURSOR_VALUE = 21;
+ public final static int TYPE_PATH_DATA = 22;
+ public final static int TYPE_ENABLE_BACKGROUND_VALUE = 23;
+ public final static int TYPE_TIME_VALUE_LIST = 24;
+ public final static int TYPE_NUMBER_OR_IDENT = 25;
+ public final static int TYPE_FONT_FAMILY_VALUE = 26;
+ public final static int TYPE_FONT_FACE_FONT_SIZE_VALUE = 27;
+ public final static int TYPE_FONT_WEIGHT_VALUE = 28;
+ public final static int TYPE_ANGLE_OR_IDENT = 29;
+ public final static int TYPE_KEY_SPLINES_VALUE = 30;
+ public final static int TYPE_POINTS_VALUE = 31;
+ public final static int TYPE_PRESERVE_ASPECT_RATIO_VALUE = 32;
+ public final static int TYPE_URI_LIST = 33;
+ public final static int TYPE_LENGTH_LIST_OR_IDENT = 34;
+ public final static int TYPE_CHARACTER_OR_UNICODE_RANGE_LIST = 35;
+ public final static int TYPE_UNICODE_RANGE_LIST = 36;
+ public final static int TYPE_FONT_VALUE = 37;
+ public final static int TYPE_FONT_DESCRIPTOR_SRC_VALUE = 38;
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/SVGTypes.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision