You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by de...@apache.org on 2003/04/14 12:53:36 UTC
cvs commit: xml-batik/sources/org/apache/batik/gvt/event GraphicsNodeChangeEvent.java
deweese 2003/04/14 03:53:35
Modified: sources/org/apache/batik/gvt AbstractGraphicsNode.java
CompositeGraphicsNode.java UpdateTracker.java
sources/org/apache/batik/gvt/event
GraphicsNodeChangeEvent.java
Log:
Fixed a bug in animation dirty regions for nodes that change size then
position in the rendering tree (where the new position has a different
rendering transform).
Revision Changes Path
1.47 +4 -7 xml-batik/sources/org/apache/batik/gvt/AbstractGraphicsNode.java
Index: AbstractGraphicsNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/AbstractGraphicsNode.java,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- AbstractGraphicsNode.java 11 Apr 2003 13:58:30 -0000 1.46
+++ AbstractGraphicsNode.java 14 Apr 2003 10:53:34 -0000 1.47
@@ -596,13 +596,11 @@
//
// Event support methods
//
- public void fireGraphicsNodeChangeStarted(Rectangle2D from,
- Rectangle2D to) {
+ public void fireGraphicsNodeChangeStarted(GraphicsNode changeSrc) {
if (changeStartedEvent == null)
changeStartedEvent = new GraphicsNodeChangeEvent
(this, GraphicsNodeChangeEvent.CHANGE_STARTED);
- changeStartedEvent.setFrom(from);
- changeStartedEvent.setTo(to);
+ changeStartedEvent.setChangeSrc(changeSrc);
fireGraphicsNodeChangeStarted(changeStartedEvent);
}
@@ -614,8 +612,7 @@
changeStartedEvent = new GraphicsNodeChangeEvent
(this, GraphicsNodeChangeEvent.CHANGE_STARTED);
else {
- changeStartedEvent.setFrom(null);
- changeStartedEvent.setTo(null);
+ changeStartedEvent.setChangeSrc(null);
}
fireGraphicsNodeChangeStarted(changeStartedEvent);
}
1.31 +5 -21 xml-batik/sources/org/apache/batik/gvt/CompositeGraphicsNode.java
Index: CompositeGraphicsNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/CompositeGraphicsNode.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- CompositeGraphicsNode.java 11 Apr 2003 13:58:30 -0000 1.30
+++ CompositeGraphicsNode.java 14 Apr 2003 10:53:35 -0000 1.31
@@ -470,11 +470,7 @@
checkRange(index);
GraphicsNode node = (GraphicsNode) o;
{
- Rectangle2D rgn = node.getBounds();
- AffineTransform at = node.getTransform();
- if ((rgn != null) && (at != null))
- rgn = at.createTransformedShape(rgn).getBounds2D();
- fireGraphicsNodeChangeStarted(rgn,rgn);
+ fireGraphicsNodeChangeStarted(node);
}
// Reparent the graphics node and tidy up the tree's state
if (node.getParent() != null) {
@@ -515,11 +511,7 @@
}
GraphicsNode node = (GraphicsNode) o;
{
- Rectangle2D rgn = node.getBounds();
- AffineTransform at = node.getTransform();
- if ((rgn != null) && (at != null))
- rgn = at.createTransformedShape(rgn).getBounds2D();
- fireGraphicsNodeChangeStarted(rgn,rgn);
+ fireGraphicsNodeChangeStarted(node);
}
// Reparent the graphics node and tidy up the tree's state
if (node.getParent() != null) {
@@ -565,11 +557,7 @@
}
GraphicsNode node = (GraphicsNode) o;
{
- Rectangle2D rgn = node.getBounds();
- AffineTransform at = node.getTransform();
- if ((rgn != null) && (at != null))
- rgn = at.createTransformedShape(rgn).getBounds2D();
- fireGraphicsNodeChangeStarted(rgn,rgn);
+ fireGraphicsNodeChangeStarted(node);
}
// Reparent the graphics node and tidy up the tree's state
if (node.getParent() != null) {
@@ -646,11 +634,7 @@
checkRange(index);
GraphicsNode oldNode = children[index];
{
- Rectangle2D rgn = oldNode.getBounds();
- AffineTransform at = oldNode.getTransform();
- if ((rgn != null) && (at != null))
- rgn = at.createTransformedShape(rgn).getBounds2D();
- fireGraphicsNodeChangeStarted(rgn,rgn);
+ fireGraphicsNodeChangeStarted(oldNode);
}
// Remove the node at the specified index
modCount++;
1.17 +63 -23 xml-batik/sources/org/apache/batik/gvt/UpdateTracker.java
Index: UpdateTracker.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/UpdateTracker.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- UpdateTracker.java 11 Apr 2003 13:58:32 -0000 1.16
+++ UpdateTracker.java 14 Apr 2003 10:53:35 -0000 1.17
@@ -72,8 +72,7 @@
Rectangle2D srcORgn = (Rectangle2D)fromBounds.remove(gnWRef);
- Rectangle2D srcNRgn = (Rectangle2D)toBounds.remove(gnWRef);
- if (srcNRgn == null) srcNRgn = gn.getBounds();
+ Rectangle2D srcNRgn = gn.getBounds();
AffineTransform nat = gn.getTransform();
if (nat != null){
@@ -149,6 +148,50 @@
}
/**
+ * This returns the dirty region for gn in the coordinate system
+ * given by <code>at</at>.
+ * @param gn Node tree to return dirty region for.
+ * @param at Affine transform to coordinate space to accumulate
+ * dirty regions in.
+ */
+ public Rectangle2D getNodeDirtyRegion(GraphicsNode gn,
+ AffineTransform at) {
+ WeakReference gnWRef = gn.getWeakReference();
+ AffineTransform nat = (AffineTransform)dirtyNodes.get(gnWRef);
+ if (nat == null) nat = gn.getTransform();
+ if (nat != null) {
+ at = new AffineTransform(at);
+ at.concatenate(nat);
+ }
+
+ Rectangle2D ret = null;
+ if (gn instanceof CompositeGraphicsNode) {
+ CompositeGraphicsNode cgn = (CompositeGraphicsNode)gn;
+ Iterator iter = cgn.iterator();
+
+ while (iter.hasNext()) {
+ GraphicsNode childGN = (GraphicsNode)iter.next();
+ Rectangle2D r2d = getNodeDirtyRegion(childGN, at);
+ if (r2d != null) {
+ if (ret == null) ret = r2d;
+ else ret = ret.createUnion(r2d);
+ }
+ }
+ } else {
+ ret = (Rectangle2D)fromBounds.remove(gnWRef);
+ if (ret == null)
+ ret = gn.getBounds();
+ if (ret != null)
+ ret = at.createTransformedShape(ret).getBounds2D();
+ }
+ return ret;
+ }
+
+ public Rectangle2D getNodeDirtyRegion(GraphicsNode gn) {
+ return getNodeDirtyRegion(gn, new AffineTransform());
+ }
+
+ /**
* Recieves notification of a change to a GraphicsNode.
* @param gn The graphics node that is changing.
*/
@@ -171,27 +214,24 @@
dirtyNodes.put(gnWRef, at);
}
- Rectangle2D r2d = gnce.getFrom();
- if (r2d == null)
- r2d = gn.getBounds();
- if (r2d != null) {
- Rectangle2D rgn = (Rectangle2D)fromBounds.remove(gnWRef);
- if (rgn != null)
- r2d = r2d.createUnion(rgn);
- else
- r2d = (Rectangle2D)r2d.clone();
- fromBounds.put(gnWRef, r2d);
- }
-
- r2d = gnce.getTo();
- if (r2d != null) {
- Rectangle2D rgn = (Rectangle2D)toBounds.remove(gnWRef);
- if (rgn != null)
- r2d = r2d.createUnion(rgn);
- else
- r2d = (Rectangle2D)r2d.clone();
- toBounds.put(gnWRef, r2d);
+ GraphicsNode chngSrc = gnce.getChangeSrc();
+ Rectangle2D rgn;
+ if (chngSrc != null) {
+ // A child node is moving in the tree so assign it's dirty
+ // regions to this node before it moves.
+ rgn = getNodeDirtyRegion(chngSrc);
+ } else {
+ // Otherwise just use gn's dirty region.
+ rgn = gn.getBounds();
+ }
+ // Add this dirty region to any existing dirty region.
+ Rectangle2D r2d = (Rectangle2D)fromBounds.remove(gnWRef);
+ if (rgn != null) {
+ if (r2d != null) r2d = r2d.createUnion(rgn);
+ else r2d = rgn;
}
+ // Store the bounds for the future.
+ fromBounds.put(gnWRef, r2d);
}
/**
1.4 +4 -8 xml-batik/sources/org/apache/batik/gvt/event/GraphicsNodeChangeEvent.java
Index: GraphicsNodeChangeEvent.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/event/GraphicsNodeChangeEvent.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- GraphicsNodeChangeEvent.java 11 Apr 2003 13:58:37 -0000 1.3
+++ GraphicsNodeChangeEvent.java 14 Apr 2003 10:53:35 -0000 1.4
@@ -39,8 +39,7 @@
*/
public static final int CHANGE_COMPLETED = CHANGE_FIRST+1;
- protected Rectangle2D from;
- protected Rectangle2D to;
+ protected GraphicsNode changeSource;
/**
* Constructs a new graphics node event with the specified source and ID.
@@ -50,9 +49,6 @@
public GraphicsNodeChangeEvent(GraphicsNode source, int id) {
super(source, id);
}
- public void setFrom(Rectangle2D from) { this.from = from; }
- public void setTo (Rectangle2D to) { this.to = to; }
-
- public Rectangle2D getFrom() { return from; }
- public Rectangle2D getTo() { return to; }
+ public void setChangeSrc(GraphicsNode gn) { this.changeSource = gn; }
+ public GraphicsNode getChangeSrc() { return changeSource; }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org