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/01/09 12:45:25 UTC
svn commit: r367280 [1/3] - in /xmlgraphics/batik/branches/anim: ./
sources/org/apache/batik/anim/ sources/org/apache/batik/anim/timing/
sources/org/apache/batik/parser/ sources/org/w3c/dom/smil/
Author: cam
Date: Mon Jan 9 03:45:00 2006
New Revision: 367280
URL: http://svn.apache.org/viewcvs?rev=367280&view=rev
Log:
1. SMIL timing and synchronization.
Added:
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/AccesskeyTimingSpecifier.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/EventbaseTimingSpecifier.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/IndefiniteTimingSpecifier.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/InstanceTime.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/Interval.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/MediaMarkerTimingSpecifier.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/OffsetTimingSpecifier.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/RepeatTimingSpecifier.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/SyncbaseTimingSpecifier.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/Test.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimeContainer.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedDocumentRoot.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedElement.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimingSpecifier.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimingSpecifierListProducer.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/WallclockTimingSpecifier.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/DefaultTimingSpecifierHandler.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/DefaultTimingSpecifierListHandler.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingParser.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingSpecifierHandler.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingSpecifierListHandler.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingSpecifierListParser.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingSpecifierParser.java (with props)
xmlgraphics/batik/branches/anim/sources/org/w3c/dom/smil/TimeEvent.java (with props)
Modified:
xmlgraphics/batik/branches/anim/build.xml
xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/AbstractParser.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/ClockHandler.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/ClockParser.java
Modified: xmlgraphics/batik/branches/anim/build.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/build.xml?rev=367280&r1=367279&r2=367280&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/build.xml (original)
+++ xmlgraphics/batik/branches/anim/build.xml Mon Jan 9 03:45:00 2006
@@ -494,6 +494,7 @@
transcoder-jar,
bridge-jar,
swing-jar,
+ anim-jar,
extension-jar,
xml-jar,
root-jar,
@@ -820,6 +821,18 @@
</fileset>
<fileset dir="${resources}" excludes="**/.svn/">
<include name="${package-prefix}/swing/**/resources/*"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <!-- Animation (dependencies: dom, util, xml, parser) -->
+ <target name="anim-jar" depends="compile, prepare-build">
+ <jar jarfile="${build}/lib/${project}-anim.jar">
+ <fileset dir="${dest}">
+ <include name="${package-prefix}/anim/*.class"/>
+ </fileset>
+ <fileset dir="${resources}" excludes="**/.svn/">
+ <include name="${package-prefix}/anim/**/resources/*"/>
</fileset>
</jar>
</target>
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/AccesskeyTimingSpecifier.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/AccesskeyTimingSpecifier.java?rev=367280&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/AccesskeyTimingSpecifier.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/AccesskeyTimingSpecifier.java Mon Jan 9 03:45:00 2006
@@ -0,0 +1,144 @@
+/*
+
+ 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.anim.timing;
+
+import org.apache.batik.dom.events.DOMKeyEvent;
+import org.apache.batik.dom.events.NodeEventTarget;
+import org.apache.batik.util.XMLConstants;
+
+import org.w3c.dom.events.Event;
+import org.w3c.dom.events.EventListener;
+import org.w3c.dom.events.EventTarget;
+import org.w3c.dom.events.KeyboardEvent;
+
+/**
+ * A class to handle SMIL access key timing specifiers.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public class AccesskeyTimingSpecifier
+ extends OffsetTimingSpecifier
+ implements EventListener {
+
+ /**
+ * The accesskey.
+ */
+ protected char accesskey;
+
+ /**
+ * Whether this access key specifier uses SVG 1.2 syntax.
+ */
+ protected boolean isSVG12AccessKey;
+
+ /**
+ * The DOM 3 key name for SVG 1.2 access key specifiers.
+ */
+ protected String keyName;
+
+ /**
+ * Creates a new AccesskeyTimingSpecifier object using SVG 1.1
+ * or SMIL syntax.
+ */
+ public AccesskeyTimingSpecifier(TimedElement owner, boolean isBegin,
+ float offset, char accesskey) {
+ super(owner, isBegin, offset);
+ this.accesskey = accesskey;
+ }
+
+ /**
+ * Creates a new AccesskeyTimingSpecifier object using SVG 1.2 syntax.
+ */
+ public AccesskeyTimingSpecifier(TimedElement owner, boolean isBegin,
+ float offset, String keyName) {
+ super(owner, isBegin, offset);
+ this.isSVG12AccessKey = true;
+ this.keyName = keyName;
+ }
+
+ /**
+ * Returns a string representation of this timing specifier.
+ */
+ public String toString() {
+ if (isSVG12AccessKey) {
+ return "accessKey(" + keyName + ")"
+ + (offset != 0 ? super.toString() : "");
+ }
+ return "accesskey(" + accesskey + ")"
+ + (offset != 0 ? super.toString() : "");
+ }
+
+ /**
+ * Initializes this timing specifier by adding the initial instance time
+ * to the owner's instance time list or setting up any event listeners.
+ */
+ public void initialize() {
+ if (isSVG12AccessKey) {
+ NodeEventTarget eventTarget =
+ (NodeEventTarget) owner.getRootEventTarget();
+ eventTarget.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "keydown",
+ this, false, null);
+ } else {
+ EventTarget eventTarget = owner.getRootEventTarget();
+ eventTarget.addEventListener("keypress", this, false);
+ }
+ }
+
+ /**
+ * Deinitializes this timing specifier by removing any event listeners.
+ */
+ public void deinitialize() {
+ if (isSVG12AccessKey) {
+ NodeEventTarget eventTarget =
+ (NodeEventTarget) owner.getRootEventTarget();
+ eventTarget.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "keydown",
+ this, false);
+ } else {
+ EventTarget eventTarget = owner.getRootEventTarget();
+ eventTarget.removeEventListener("keypress", this, false);
+ }
+ }
+
+ // EventListener /////////////////////////////////////////////////////////
+
+ /**
+ * Handles key events fired by the eventbase element.
+ */
+ public void handleEvent(Event e) {
+ boolean matched;
+ if (e.getType().charAt(4) == 'p') {
+ // DOM 2 key draft keypress
+ DOMKeyEvent evt = (DOMKeyEvent) e;
+ matched = evt.getCharCode() == accesskey;
+ } else {
+ // DOM 3 keydown
+ KeyboardEvent evt = (KeyboardEvent) e;
+ matched = evt.getKeyIdentifier().equals(keyName);
+ }
+ if (matched) {
+ // XXX check for event sensitivity
+ long time = e.getTimeStamp() -
+ owner.getRoot().getDocumentBeginTime().getTimeInMillis();
+ InstanceTime instance =
+ new InstanceTime(this, time / 1000f, null, true);
+ owner.addInstanceTime(instance, isBegin);
+ }
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/AccesskeyTimingSpecifier.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/EventbaseTimingSpecifier.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/EventbaseTimingSpecifier.java?rev=367280&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/EventbaseTimingSpecifier.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/EventbaseTimingSpecifier.java Mon Jan 9 03:45:00 2006
@@ -0,0 +1,119 @@
+/*
+
+ 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.anim.timing;
+
+import org.apache.batik.dom.events.NodeEventTarget;
+
+import org.w3c.dom.events.Event;
+import org.w3c.dom.events.EventListener;
+import org.w3c.dom.events.EventTarget;
+
+/**
+ * A class to handle eventbase SMIL timing specifiers.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public class EventbaseTimingSpecifier
+ extends OffsetTimingSpecifier
+ implements EventListener {
+
+ /**
+ * The ID of the eventbase element.
+ */
+ protected String eventbaseID;
+
+ /**
+ * The eventbase element.
+ */
+ protected TimedElement eventbase;
+
+ /**
+ * The eventbase element as an {@link EventTarget}.
+ */
+ protected EventTarget eventTarget;
+
+ /**
+ * The namespace URI of the event to sync to.
+ */
+ protected String eventNamespaceURI;
+
+ /**
+ * The type of the event to sync to.
+ */
+ protected String eventType;
+
+ /**
+ * The animation name of the event to sync to.
+ */
+ protected String eventName;
+
+ /**
+ * Creates a new EventbaseTimingSpecifier object.
+ */
+ public EventbaseTimingSpecifier(TimedElement owner, boolean isBegin,
+ float offset, String eventbaseID,
+ String eventName) {
+ super(owner, isBegin, offset);
+ this.eventbaseID = eventbaseID;
+ TimedDocumentRoot root = owner.getRoot();
+ this.eventbase = root.getTimedElementById(eventbaseID);
+ this.eventNamespaceURI = root.getEventNamespaceURI(eventName);
+ this.eventType = root.getEventType(eventName);
+ this.eventTarget = eventbase.getEventTargetById(eventbaseID);
+ }
+
+ /**
+ * Returns a string representation of this timing specifier.
+ */
+ public String toString() {
+ return (eventbaseID == null ? "" : eventbaseID + ".") + eventName
+ + (offset != 0 ? super.toString() : "");
+ }
+
+ /**
+ * Initializes this timing specifier by adding the initial instance time
+ * to the owner's instance time list or setting up any event listeners.
+ */
+ public void initialize() {
+ ((NodeEventTarget) eventTarget).addEventListenerNS
+ (eventNamespaceURI, eventType, this, false, null);
+ }
+
+ /**
+ * Deinitializes this timing specifier by removing any event listeners.
+ */
+ public void deinitialize() {
+ ((NodeEventTarget) eventTarget).removeEventListenerNS
+ (eventNamespaceURI, eventType, this, false);
+ }
+
+ // EventListener /////////////////////////////////////////////////////////
+
+ /**
+ * Handles an event fired on the eventbase element.
+ */
+ public void handleEvent(Event e) {
+ // XXX check for event sensitivity
+ long time = e.getTimeStamp() -
+ owner.getRoot().getDocumentBeginTime().getTimeInMillis();
+ InstanceTime instance =
+ new InstanceTime(this, time / 1000f, null, true);
+ owner.addInstanceTime(instance, isBegin);
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/EventbaseTimingSpecifier.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/IndefiniteTimingSpecifier.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/IndefiniteTimingSpecifier.java?rev=367280&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/IndefiniteTimingSpecifier.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/IndefiniteTimingSpecifier.java Mon Jan 9 03:45:00 2006
@@ -0,0 +1,55 @@
+/*
+
+ 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.anim.timing;
+
+/**
+ * A class to handle the 'indefinite' SMIL timing specifier.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public class IndefiniteTimingSpecifier extends TimingSpecifier {
+
+ /**
+ * Creates a new IndefiniteTimingSpecifier object.
+ */
+ public IndefiniteTimingSpecifier(TimedElement owner, boolean isBegin) {
+ super(owner, isBegin);
+ }
+
+ /**
+ * Returns a string representation of this timing specifier.
+ */
+ public String toString() {
+ return "indefinite";
+ }
+
+ /**
+ * Initializes this timing specifier by adding the initial instance time
+ * to the owner's instance time list or setting up any event listeners.
+ */
+ public void initialize() {
+ if (!isBegin) {
+ // Only end instance lists get an 'indefinite' instance time from
+ // an indefinite timing specifier.
+ InstanceTime instance =
+ new InstanceTime(this, TimedElement.INDEFINITE, null, false);
+ owner.addInstanceTime(instance, isBegin);
+ }
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/IndefiniteTimingSpecifier.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/InstanceTime.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/InstanceTime.java?rev=367280&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/InstanceTime.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/InstanceTime.java Mon Jan 9 03:45:00 2006
@@ -0,0 +1,115 @@
+/*
+
+ 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.anim.timing;
+
+/**
+ * A class that represents an instance time created from a timing
+ * specification.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public class InstanceTime implements Comparable {
+
+ /**
+ * The time.
+ */
+ protected float time;
+
+ /**
+ * The {@link TimingSpecifier} that created this InstanceTime.
+ */
+ protected TimingSpecifier creator;
+
+ /**
+ * Whether this InstanceTime should be removed from an element's
+ * begin or end instance time lists upon reset.
+ */
+ protected boolean clearOnReset;
+
+ /**
+ * The Interval on which this InstanceTime is dependent, or null
+ * if the InstanceTime was not created from a syncbase value.
+ */
+ protected Interval timebase;
+
+ /**
+ * Creates a new InstanceTime.
+ * @param creator the TimingSpecifier that created this InstanceTime
+ * @param time the new time, in parent simple time
+ * @param timebase the interval from which this InstanceTime was created
+ * @param clearOnReset whether this InstanceTime should be removed from
+ * an instance time list upon element reset
+ */
+ public InstanceTime(TimingSpecifier creator,
+ float time,
+ Interval timebase,
+ boolean clearOnReset) {
+ this.creator = creator;
+ // XXX Convert time from the creator's syncbase's
+ // time system into this time system. Not
+ // strictly necessary in SVG.
+ this.time = time;
+ this.timebase = timebase;
+ this.clearOnReset = clearOnReset;
+ }
+
+ /**
+ * Returns whether the InstanceTime should be removed from the
+ * element's begin or end instance time list when it is reset.
+ */
+ public boolean getClearOnReset() {
+ return clearOnReset;
+ }
+
+ /**
+ * Returns the time of this instance time.
+ */
+ public float getTime() {
+ return time;
+ }
+
+ /**
+ * Called by the dependent Interval to indicate that its time
+ * has changed.
+ * @param newTime the new time, in parent simple time
+ */
+ void dependentUpdate(float newTime) {
+ // XXX Convert time from the creator's syncbase's
+ // time system into this time system. Not
+ // strictly necessary in SVG.
+ time = newTime;
+ creator.handleTimebaseUpdate(this, time);
+ }
+
+ /**
+ * Returns a string representation of this InstanceTime.
+ */
+ public String toString() {
+ return Float.toString(time);
+ }
+
+ // Comparable ////////////////////////////////////////////////////////////
+
+ /**
+ * Compares this InstanceTime with another.
+ */
+ public int compareTo(Object o) {
+ return Float.compare(time, ((InstanceTime) o).time);
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/InstanceTime.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/Interval.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/Interval.java?rev=367280&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/Interval.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/Interval.java Mon Jan 9 03:45:00 2006
@@ -0,0 +1,127 @@
+/*
+
+ 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.anim.timing;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+
+/**
+ * A class that represents an interval for a timed element.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public class Interval {
+
+ /**
+ * The begin time for the interval.
+ */
+ protected float begin;
+
+ /**
+ * The end time for the interval.
+ */
+ protected float end;
+
+ /**
+ * The list of {@link InstanceTime} objects that are dependent
+ * on the begin time of this Interval.
+ */
+ protected LinkedList beginDependents = new LinkedList();
+
+ /**
+ * The list of {@link InstanceTime} objects that are dependent
+ * on the end time of this Interval.
+ */
+ protected LinkedList endDependents = new LinkedList();
+
+ /**
+ * Creates a new Interval.
+ */
+ public Interval(float begin, float end) {
+ this.begin = begin;
+ this.end = end;
+ }
+
+ /**
+ * Returns a string representation of this Interval.
+ */
+ public String toString() {
+ return TimedElement.toString(begin) + ".." + TimedElement.toString(end);
+ }
+
+ /**
+ * Returns the begin time of this interval.
+ */
+ public float getBegin() {
+ return begin;
+ }
+
+ /**
+ * Returns the end time of this interval.
+ */
+ public float getEnd() {
+ return end;
+ }
+
+ /**
+ * Adds a dependent InstanceTime for this Interval.
+ */
+ void addDependent(InstanceTime dependent, boolean forBegin) {
+ if (forBegin) {
+ beginDependents.add(dependent);
+ } else {
+ endDependents.add(dependent);
+ }
+ }
+
+ /**
+ * Removes a dependent InstanceTime for this Interval.
+ */
+ void removeDependent(InstanceTime dependent, boolean forBegin) {
+ if (forBegin) {
+ beginDependents.remove(dependent);
+ } else {
+ endDependents.remove(dependent);
+ }
+ }
+
+ /**
+ * Updates the begin time for this interval.
+ */
+ void setBegin(float begin) {
+ this.begin = begin;
+ Iterator i = beginDependents.iterator();
+ while (i.hasNext()) {
+ InstanceTime it = (InstanceTime) i.next();
+ it.dependentUpdate(begin);
+ }
+ }
+
+ /**
+ * Updates the end time for this interval.
+ */
+ void setEnd(float end) {
+ this.end = end;
+ Iterator i = endDependents.iterator();
+ while (i.hasNext()) {
+ InstanceTime it = (InstanceTime) i.next();
+ it.dependentUpdate(end);
+ }
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/Interval.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/MediaMarkerTimingSpecifier.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/MediaMarkerTimingSpecifier.java?rev=367280&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/MediaMarkerTimingSpecifier.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/MediaMarkerTimingSpecifier.java Mon Jan 9 03:45:00 2006
@@ -0,0 +1,68 @@
+/*
+
+ 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.anim.timing;
+
+import java.util.Calendar;
+
+/**
+ * A class to handle media marker SMIL timing specifiers. This class
+ * of timing specifier is currently unused.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public class MediaMarkerTimingSpecifier extends TimingSpecifier {
+
+ /**
+ * The ID of the media element.
+ */
+ protected String syncbaseID;
+
+ /**
+ * The media element.
+ */
+ protected TimedElement mediaElement;
+
+ /**
+ * The media marker name.
+ */
+ protected String markerName;
+
+ /**
+ * The instance time.
+ */
+ protected InstanceTime instance;
+
+ /**
+ * Creates a new MediaMarkerTimingSpecifier object.
+ */
+ public MediaMarkerTimingSpecifier(TimedElement owner, boolean isBegin,
+ String syncbaseID, String markerName) {
+ super(owner, isBegin);
+ this.syncbaseID = syncbaseID;
+ this.markerName = markerName;
+ this.mediaElement = owner.getTimedElementById(syncbaseID);
+ }
+
+ /**
+ * Returns a string representation of this timing specifier.
+ */
+ public String toString() {
+ return syncbaseID + ".marker(" + markerName + ")";
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/MediaMarkerTimingSpecifier.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/OffsetTimingSpecifier.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/OffsetTimingSpecifier.java?rev=367280&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/OffsetTimingSpecifier.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/OffsetTimingSpecifier.java Mon Jan 9 03:45:00 2006
@@ -0,0 +1,57 @@
+/*
+
+ 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.anim.timing;
+
+/**
+ * A class to handle offset SMIL timing specifiers.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public class OffsetTimingSpecifier extends TimingSpecifier {
+
+ /**
+ * The offset value.
+ */
+ protected float offset;
+
+ /**
+ * Creates a new OffsetTimingSpecifier object.
+ */
+ public OffsetTimingSpecifier(TimedElement owner, boolean isBegin,
+ float offset) {
+ super(owner, isBegin);
+ this.offset = offset;
+ }
+
+ /**
+ * Returns a string representation of this timing specifier.
+ */
+ public String toString() {
+ return (offset >= 0 ? "+" : "") + offset;
+ }
+
+ /**
+ * Initializes this timing specifier by adding the initial instance time
+ * to the owner's instance time list or setting up any event listeners.
+ */
+ public void initialize() {
+ InstanceTime instance = new InstanceTime(this, offset, null, false);
+ owner.addInstanceTime(instance, isBegin);
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/OffsetTimingSpecifier.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/RepeatTimingSpecifier.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/RepeatTimingSpecifier.java?rev=367280&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/RepeatTimingSpecifier.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/RepeatTimingSpecifier.java Mon Jan 9 03:45:00 2006
@@ -0,0 +1,82 @@
+/*
+
+ 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.anim.timing;
+
+import org.w3c.dom.events.Event;
+import org.w3c.dom.smil.TimeEvent;
+
+/**
+ * A class to handle repeat event SMIL timing specifiers.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public class RepeatTimingSpecifier extends EventbaseTimingSpecifier {
+
+ /**
+ * The repeat iteration.
+ */
+ protected int repeatIteration;
+
+ /**
+ * Whether a repeat iteration was specified.
+ */
+ protected boolean repeatIterationSpecified;
+
+ /**
+ * Creates a new RepeatTimingSpecifier object without a repeat iteration.
+ */
+ public RepeatTimingSpecifier(TimedElement owner, boolean isBegin,
+ float offset, String syncbaseID) {
+ super(owner, isBegin, offset, syncbaseID,
+ owner.getRoot().getRepeatEventName());
+ }
+
+ /**
+ * Creates a new RepeatTimingSpecifier object with a repeat iteration.
+ */
+ public RepeatTimingSpecifier(TimedElement owner, boolean isBegin,
+ float offset, String syncbaseID,
+ int repeatIteration) {
+ super(owner, isBegin, offset, syncbaseID,
+ owner.getRoot().getRepeatEventName());
+ this.repeatIteration = repeatIteration;
+ this.repeatIterationSpecified = true;
+ }
+
+ /**
+ * Returns a string representation of this timing specifier.
+ */
+ public String toString() {
+ return (eventbaseID == null ? "" : eventbaseID + ".") + "repeat"
+ + (repeatIterationSpecified ? "(" + repeatIteration + ")" : "")
+ + (offset != 0 ? super.toString() : "");
+ }
+
+ // EventListener /////////////////////////////////////////////////////////
+
+ /**
+ * Handles an event fired on the eventbase element.
+ */
+ public void handleEvent(Event e) {
+ TimeEvent evt = (TimeEvent) e;
+ if (!repeatIterationSpecified || evt.getDetail() == repeatIteration) {
+ super.handleEvent(e);
+ }
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/RepeatTimingSpecifier.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/SyncbaseTimingSpecifier.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/SyncbaseTimingSpecifier.java?rev=367280&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/SyncbaseTimingSpecifier.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/SyncbaseTimingSpecifier.java Mon Jan 9 03:45:00 2006
@@ -0,0 +1,102 @@
+/*
+
+ 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.anim.timing;
+
+import java.util.HashMap;
+
+/**
+ * A class to handle syncbase SMIL timing specifiers.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public class SyncbaseTimingSpecifier extends OffsetTimingSpecifier {
+
+ /**
+ * The ID of the syncbase element.
+ */
+ protected String syncbaseID;
+
+ /**
+ * The syncbase element.
+ */
+ protected TimedElement syncbaseElement;
+
+ /**
+ * Whether this specifier specifies a sync to the begin or the end
+ * of the syncbase element.
+ */
+ protected boolean syncBegin;
+
+ /**
+ * Map of {@link Interval}s to <!--a {@link WeakReference} to -->an
+ * {@link InstanceTime}.
+ */
+ protected HashMap instances = new HashMap();
+
+ /**
+ * Creates a new SyncbaseTimingSpecifier object.
+ */
+ public SyncbaseTimingSpecifier(TimedElement owner, boolean isBegin,
+ float offset, String syncbaseID,
+ boolean syncBegin) {
+ super(owner, isBegin, offset);
+ this.syncbaseID = syncbaseID;
+ this.syncBegin = syncBegin;
+ this.syncbaseElement = owner.getTimedElementById(syncbaseID);
+ syncbaseElement.addDependent(this, syncBegin);
+ }
+
+ /**
+ * Returns a string representation of this timing specifier.
+ */
+ public String toString() {
+ return syncbaseID + "." + (syncBegin ? "begin" : "end")
+ + (offset != 0 ? super.toString() : "");
+ }
+
+ /**
+ * Called by the timebase element when it creates a new Interval.
+ */
+ void newInterval(Interval interval) {
+ InstanceTime instance =
+ new InstanceTime(this, (syncBegin ? interval.getBegin()
+ : interval.getEnd()) + offset,
+ interval, true);
+ instances.put(interval, instance);
+ interval.addDependent(instance, syncBegin);
+ owner.addInstanceTime(instance, isBegin);
+ }
+
+ /**
+ * Called by the timebase element when it deletes an Interval.
+ */
+ void removeInterval(Interval interval) {
+ InstanceTime instance = (InstanceTime) instances.get(interval);
+ interval.removeDependent(instance, syncBegin);
+ owner.removeInstanceTime(instance, isBegin);
+ }
+
+ /**
+ * Called by an {@link InstanceTime} created by this TimingSpecifier
+ * to indicate that its value has changed.
+ */
+ void handleTimebaseUpdate(InstanceTime instanceTime, float newTime) {
+ owner.instanceTimeChanged(instanceTime, isBegin);
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/SyncbaseTimingSpecifier.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/Test.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/Test.java?rev=367280&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/Test.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/Test.java Mon Jan 9 03:45:00 2006
@@ -0,0 +1,217 @@
+package org.apache.batik.anim.timing;
+
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import org.w3c.dom.events.Event;
+import org.w3c.dom.events.EventTarget;
+import org.w3c.dom.events.EventListener;
+
+public class Test {
+
+ protected HashMap elements = new HashMap();
+
+ public static void main(String[] args) {
+ new Test().go();
+ }
+
+ protected void go() {
+ Root root = new Root();
+ AnimateElement a1 = new AnimateElement();
+ AnimateElement a2 = new AnimateElement();
+ a1.id = "a1";
+ a2.id = "a2";
+ elements.put("a1", a1);
+ elements.put("a2", a2);
+ root.addChild(a2);
+ root.addChild(a1);
+ a1.parseAttributes("0s", "3s", "", "", "", "", "10s", "", "");
+ a2.parseAttributes("a1.repeat(2)", "2s", "", "", "", "", "", "", "");
+ a1.initialize();
+ a2.initialize();
+ for (int i = 0; i < 20; i++) {
+ System.err.println("* * * *\n" + i + "s");
+ root.seekTo(i);
+ }
+ a2.deinitialize();
+ a1.deinitialize();
+ root.removeChild(a2);
+ root.removeChild(a1);
+ }
+
+ protected class Root extends TimedDocumentRoot implements org.apache.batik.dom.events.NodeEventTarget {
+ public org.apache.batik.dom.events.EventSupport getEventSupport() { return null; }
+ public org.apache.batik.dom.events.NodeEventTarget getParentNodeEventTarget() { return null; }
+ public Root() {
+ super(Calendar.getInstance(), false, true);
+ }
+ protected TimedElement getTimedElementById(String id) {
+ return (TimedElement) elements.get(id);
+ }
+ protected void fireTimeEvent(String eventType, Calendar time, int detail) {
+ System.err.print("firing " + eventType + " on root");
+ if (eventType.equals("repeatEvent") || eventType.equals("repeat")) {
+ System.err.println(", repeat iteration " + detail);
+ } else {
+ System.err.println();
+ }
+ }
+ protected void toActive(float begin) {
+ System.err.println("root active at " + begin);
+ }
+ protected void toInactive(boolean isFrozen) {
+ System.err.println("root inactive, isFrozen == " + isFrozen);
+ }
+ protected void removeFill() {
+ System.err.println("root removed fill");
+ }
+ protected void sampledAt(float simpleTime, float simpleDur, int repeatIteration) {
+ System.err.println("root sampled at " + simpleTime + ", dur == " + simpleDur + ", repeat iteration " + repeatIteration);
+ }
+ protected void sampledLastValue(int repeatIteration) {
+ System.err.println("root sampled last value, repeat iteration " + repeatIteration);
+ }
+ protected EventTarget getEventTargetById(String id) {
+ return (EventTarget) elements.get(id);
+ }
+ HashSet events = new HashSet();
+ {
+ String[] ets = { "focusin", "focusout", "activate", "click", "mousedown", "mouseup",
+ "mousemove", "mouseover", "mouseout", "load", "resize", "scroll",
+ "zoom", "beginEvent", "endEvent", "repeat" };
+ for (int i = 0; i < ets.length; i++) {
+ events.add(ets[i]);
+ }
+ }
+ protected String getEventNamespaceURI(String eventName) {
+ if (events.contains(eventName)) {
+ return "http://www.w3.org/2001/xml-events";
+ }
+ return null;
+ }
+ protected String getEventType(String eventName) {
+ if (events.contains(eventName)) {
+ return eventName;
+ }
+ return null;
+ }
+ protected String getRepeatEventName() {
+ return "repeat";
+ }
+ protected EventTarget getRootEventTarget() {
+ return this;
+ }
+ // EventTarget
+ HashMap listeners = new HashMap();
+ public void addEventListenerNS(String ns, String t, EventListener l, boolean uc, Object g) {
+ LinkedList ll = (LinkedList) listeners.get(t);
+ if (ll == null) {
+ ll = new LinkedList();
+ listeners.put(t, ll);
+ }
+ ll.add(l);
+ }
+ public void removeEventListenerNS(String ns, String t, EventListener l, boolean uc) {
+ LinkedList ll = (LinkedList) listeners.get(t);
+ if (ll != null) {
+ ll.remove(l);
+ }
+ }
+ public void addEventListener(String t, EventListener l, boolean uc) { }
+ public void removeEventListener(String t, EventListener l, boolean uc) { }
+ public boolean dispatchEvent(Event e) { return true; }
+ public boolean willTriggerNS(String ns, String t) { return true; }
+ public boolean hasEventListenerNS(String ns, String t) { return true; }
+ }
+
+ protected class TimeEvent
+ extends org.apache.batik.dom.events.AbstractEvent
+ implements org.w3c.dom.smil.TimeEvent {
+ int detail;
+ public org.w3c.dom.views.AbstractView getView() { return null; }
+ public int getDetail() { return detail; }
+ public void initTimeEvent(String typeArg, org.w3c.dom.views.AbstractView viewArg, int detailArg) {
+ initEventNS("http://www.w3.org/2001/xml-events", typeArg, true, false);
+ this.detail = detailArg;
+ }
+ public void setTimestamp(Calendar ts) {
+ timeStamp = ts.getTimeInMillis();
+ }
+ }
+
+ protected class AnimateElement extends TimedElement implements org.apache.batik.dom.events.NodeEventTarget {
+ public org.apache.batik.dom.events.EventSupport getEventSupport() { return null; }
+ public org.apache.batik.dom.events.NodeEventTarget getParentNodeEventTarget() { return null; }
+ protected String id;
+ protected void fireTimeEvent(String eventType, Calendar time, int detail) {
+ System.err.print("firing " + eventType + " on " + id);
+ if (eventType.equals("repeatEvent") || eventType.equals("repeat")) {
+ System.err.println(", repeat iteration " + detail);
+ } else {
+ System.err.println();
+ }
+ LinkedList ll = (LinkedList) listeners.get(eventType);
+ System.err.println("firing listeners...");
+ if (ll != null) {
+ Iterator i = ll.iterator();
+ while (i.hasNext()) {
+ EventListener l = (EventListener) i.next();
+ TimeEvent te = new TimeEvent();
+ te.initTimeEvent(eventType, null, detail);
+ te.setTimestamp(time);
+ System.err.println("\t... one");
+ l.handleEvent(te);
+ }
+ }
+ }
+ protected void toActive(float begin) {
+ System.err.println(id + " active at " + begin);
+ }
+ protected void toInactive(boolean isFrozen) {
+ System.err.println(id + " inactive, isFrozen == " + isFrozen);
+ }
+ protected void removeFill() {
+ System.err.println(id + " removed fill");
+ }
+ protected void sampledAt(float simpleTime, float simpleDur, int repeatIteration) {
+ System.err.println(id + " sampled at " + simpleTime + ", dur == " + simpleDur + ", repeat iteration " + repeatIteration);
+ }
+ protected void sampledLastValue(int repeatIteration) {
+ System.err.println(id + " sampled last value, repeat iteration " + repeatIteration);
+ }
+ protected TimedElement getTimedElementById(String id) {
+ return (TimedElement) elements.get(id);
+ }
+ protected EventTarget getEventTargetById(String id) {
+ return (EventTarget) elements.get(id);
+ }
+ protected EventTarget getRootEventTarget() {
+ return (EventTarget) root;
+ }
+ // EventTarget
+ HashMap listeners = new HashMap();
+ public void addEventListenerNS(String ns, String t, EventListener l, boolean uc, Object g) {
+ LinkedList ll = (LinkedList) listeners.get(t);
+ if (ll == null) {
+ ll = new LinkedList();
+ listeners.put(t, ll);
+ }
+ ll.add(l);
+ System.err.println("--> adding listener for '" + t + "' on " + id);
+ }
+ public void removeEventListenerNS(String ns, String t, EventListener l, boolean uc) {
+ LinkedList ll = (LinkedList) listeners.get(t);
+ if (ll != null) {
+ ll.remove(l);
+ }
+ }
+ public void addEventListener(String t, EventListener l, boolean uc) { }
+ public void removeEventListener(String t, EventListener l, boolean uc) { }
+ public boolean dispatchEvent(Event e) { return true; }
+ public boolean willTriggerNS(String ns, String t) { return true; }
+ public boolean hasEventListenerNS(String ns, String t) { return true; }
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/Test.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimeContainer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimeContainer.java?rev=367280&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimeContainer.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimeContainer.java Mon Jan 9 03:45:00 2006
@@ -0,0 +1,112 @@
+/*
+
+ 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.anim.timing;
+
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * An abstract base class for time container elements.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public abstract class TimeContainer extends TimedElement {
+
+ /**
+ * The child {@link TimedElement}s of this time container.
+ */
+ protected HashSet children = new HashSet();
+
+ /**
+ * Adds a {@link TimedElement} to this container.
+ */
+ public void addChild(TimedElement e) {
+ children.add(e);
+ e.parent = this;
+ setRoot(e, this.root);
+ }
+
+ /**
+ * Recursively sets the {@link TimedDocumentRoot} of the given
+ * {@link TimedElement} and any of its descendants.
+ */
+ protected void setRoot(TimedElement e, TimedDocumentRoot root) {
+ e.root = root;
+ if (e instanceof TimeContainer) {
+ TimeContainer c = (TimeContainer) e;
+ TimedElement[] es = c.getChildren();
+ for (int i = 0; i < es.length; i++) {
+ setRoot(es[i], root);
+ }
+ }
+ }
+
+ /**
+ * Removes a {@link TimedElement} from this container.
+ */
+ public void removeChild(TimedElement e) {
+ children.remove(e);
+ e.parent = null;
+ setRoot(e, null);
+ }
+
+ /**
+ * Returns an array of the children of this container.
+ */
+ public TimedElement[] getChildren() {
+ return (TimedElement[]) children.toArray(new TimedElement[0]);
+ }
+
+ /**
+ * Calculates the local simple time.
+ */
+ protected void sampleAt(float parentSimpleTime) {
+ super.sampleAt(parentSimpleTime);
+ sampleChildren(parentSimpleTime);
+ }
+
+ /**
+ * Samples all the child timed elements.
+ */
+ protected void sampleChildren(float parentSimpleTime) {
+ Iterator i = children.iterator();
+ while (i.hasNext()) {
+ TimedElement e = (TimedElement) i.next();
+ e.sampleAt(parentSimpleTime);
+ }
+ }
+
+ /**
+ * Resets this element.
+ */
+ protected void reset(boolean clearCurrentBegin) {
+ super.reset(clearCurrentBegin);
+ Iterator i = children.iterator();
+ while (i.hasNext()) {
+ TimedElement e = (TimedElement) i.next();
+ e.reset(clearCurrentBegin); // XXX param correct?
+ }
+ }
+
+ /**
+ * Returns the default begin time for the given child
+ * timed element.
+ */
+ public abstract float getDefaultBegin(TimedElement child);
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimeContainer.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedDocumentRoot.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedDocumentRoot.java?rev=367280&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedDocumentRoot.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedDocumentRoot.java Mon Jan 9 03:45:00 2006
@@ -0,0 +1,152 @@
+/*
+
+ 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.anim.timing;
+
+import java.util.Calendar;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import org.w3c.dom.events.EventTarget;
+
+/**
+ * An abstract base class for the root time container element
+ * for a document.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public abstract class TimedDocumentRoot extends TimeContainer {
+
+ /**
+ * The wallclock time that the document began.
+ */
+ protected Calendar documentBeginTime;
+
+ /**
+ * Time offset that has accumulated while the document is paused.
+ */
+ protected float accumulatedOffset;
+
+ /**
+ * Set of timed elements that need to be sampled.
+ */
+ protected HashSet dirtyNodes = new HashSet();
+
+ /**
+ * Allows the use of accessKey() timing specifiers with a single
+ * character, as specified in SVG 1.1.
+ */
+ protected boolean useSVG11AccessKeys;
+
+ /**
+ * Allows the use of accessKey() timing specifiers with a DOM 3
+ * key name, as specified in SVG 1.2.
+ */
+ protected boolean useSVG12AccessKeys;
+
+ /**
+ * Creates a new TimedDocumentRoot.
+ * @param begin the document begin time
+ * @param useSVG11AccessKeys allows the use of accessKey() timing
+ * specifiers with a single character
+ * @param useSVG12Accesskeys allows the use of accessKey() with a
+ * DOM 3 key name
+ */
+ public TimedDocumentRoot(Calendar begin, boolean useSVG11AccessKeys,
+ boolean useSVG12AccessKeys) {
+ root = this;
+ documentBeginTime = begin;
+ this.useSVG11AccessKeys = useSVG11AccessKeys;
+ this.useSVG12AccessKeys = useSVG12AccessKeys;
+ }
+
+ /**
+ * Returns the implicit duration of the element. The document root
+ * has an {@link #INDEFINITE} implicit duration.
+ */
+ protected float getImplicitDur() {
+ return INDEFINITE;
+ }
+
+ /**
+ * Returns the default begin time for the given child
+ * timed element. In SVG, this is always 0, since the
+ * only time container is the root SVG element, which acts
+ * like a 'par'.
+ */
+ public float getDefaultBegin(TimedElement child) {
+ return 0.0f;
+ }
+
+ /**
+ * Samples the entire timegraph at the given time.
+ */
+ public void seekTo(float time) {
+ // No time containers in SVG, so we don't have to worry
+ // about a partial ordering of timed elements to sample.
+ TimedElement[] es = getChildren();
+ for (int i = 0; i < es.length; i++) {
+ // System.err.print("[" + ((Test.AnimateElement) es[i]).id + "] ");
+ es[i].sampleAt(time);
+ }
+ boolean needsUpdates;
+ do {
+ needsUpdates = false;
+ for (int i = 0; i < es.length; i++) {
+ if (es[i].shouldUpdateCurrentInterval) {
+ needsUpdates = true;
+ // System.err.print("{" + ((Test.AnimateElement) es[i]).id + "} ");
+ es[i].sampleAt(time);
+ }
+ }
+ } while (needsUpdates);
+ }
+
+ /**
+ * Resets the entire timegraph.
+ */
+ public void resetDocument() {
+ documentBeginTime = Calendar.getInstance();
+ reset(true);
+ }
+
+ /**
+ * Returns the wallclock time that the document began.
+ */
+ public Calendar getDocumentBeginTime() {
+ return documentBeginTime;
+ }
+
+ /**
+ * Returns the namespace URI of the event that corresponds to the given
+ * animation event name.
+ */
+ protected abstract String getEventNamespaceURI(String eventName);
+
+ /**
+ * Returns the type of the event that corresponds to the given
+ * animation event name.
+ */
+ protected abstract String getEventType(String eventName);
+
+ /**
+ * Returns the name of the repeat event.
+ * @return either "repeat" or "repeatEvent"
+ */
+ protected abstract String getRepeatEventName();
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedDocumentRoot.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision