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 2002/07/25 23:42:42 UTC
cvs commit: xml-batik/sources/org/apache/batik/gvt/event GraphicsNodeChangeEvent.java
deweese 2002/07/25 14:42:42
Modified: sources/org/apache/batik/gvt AbstractGraphicsNode.java
CompositeGraphicsNode.java UpdateTracker.java
sources/org/apache/batik/gvt/event
GraphicsNodeChangeEvent.java
Log:
1) Adding/removing children of an element no longer causes
the entire contents of the parent to be repainted, only the
region of the child effected
Revision Changes Path
1.44 +22 -1 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.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- AbstractGraphicsNode.java 12 Jun 2002 15:19:53 -0000 1.43
+++ AbstractGraphicsNode.java 25 Jul 2002 21:42:42 -0000 1.44
@@ -611,11 +611,32 @@
//
// Event support methods
//
+ public void fireGraphicsNodeChangeStarted(Rectangle2D from,
+ Rectangle2D to) {
+ if (changeStartedEvent == null)
+ changeStartedEvent = new GraphicsNodeChangeEvent
+ (this, GraphicsNodeChangeEvent.CHANGE_STARTED);
+ changeStartedEvent.setFrom(from);
+ changeStartedEvent.setTo(to);
+ fireGraphicsNodeChangeStarted(changeStartedEvent);
+ }
+
+ //
+ // Event support methods
+ //
public void fireGraphicsNodeChangeStarted() {
if (changeStartedEvent == null)
changeStartedEvent = new GraphicsNodeChangeEvent
(this, GraphicsNodeChangeEvent.CHANGE_STARTED);
+ else {
+ changeStartedEvent.setFrom(null);
+ changeStartedEvent.setTo(null);
+ }
+ fireGraphicsNodeChangeStarted(changeStartedEvent);
+ }
+ public void fireGraphicsNodeChangeStarted
+ (GraphicsNodeChangeEvent changeStartedEvent) {
// If we had per node listeners we would fire them here...
RootGraphicsNode rootGN = getRoot();
1.29 +30 -6 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.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- CompositeGraphicsNode.java 6 Mar 2002 09:06:39 -0000 1.28
+++ CompositeGraphicsNode.java 25 Jul 2002 21:42:42 -0000 1.29
@@ -473,8 +473,14 @@
throw new IllegalArgumentException(o+" is not a GraphicsNode");
}
checkRange(index);
- fireGraphicsNodeChangeStarted();
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);
+ }
// Reparent the graphics node and tidy up the tree's state
if (node.getParent() != null) {
node.getParent().getChildren().remove(node);
@@ -513,7 +519,13 @@
throw new IllegalArgumentException(o+" is not a GraphicsNode");
}
GraphicsNode node = (GraphicsNode) o;
- fireGraphicsNodeChangeStarted();
+ {
+ Rectangle2D rgn = node.getBounds();
+ AffineTransform at = node.getTransform();
+ if ((rgn != null) && (at != null))
+ rgn = at.createTransformedShape(rgn).getBounds2D();
+ fireGraphicsNodeChangeStarted(rgn,rgn);
+ }
// Reparent the graphics node and tidy up the tree's state
if (node.getParent() != null) {
node.getParent().getChildren().remove(node);
@@ -557,7 +569,13 @@
"Index: "+index+", Size: "+count);
}
GraphicsNode node = (GraphicsNode) o;
- fireGraphicsNodeChangeStarted();
+ {
+ Rectangle2D rgn = node.getBounds();
+ AffineTransform at = node.getTransform();
+ if ((rgn != null) && (at != null))
+ rgn = at.createTransformedShape(rgn).getBounds2D();
+ fireGraphicsNodeChangeStarted(rgn,rgn);
+ }
// Reparent the graphics node and tidy up the tree's state
if (node.getParent() != null) {
node.getParent().getChildren().remove(node);
@@ -631,10 +649,16 @@
public Object remove(int index) {
// Check for correct argument
checkRange(index);
- fireGraphicsNodeChangeStarted();
+ 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);
+ }
// Remove the node at the specified index
modCount++;
- GraphicsNode oldNode = children[index];
int numMoved = count - index - 1;
if (numMoved > 0) {
System.arraycopy(children, index+1, children, index, numMoved);
1.13 +22 -41 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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- UpdateTracker.java 17 Jun 2002 20:17:02 -0000 1.12
+++ UpdateTracker.java 25 Jul 2002 21:42:42 -0000 1.13
@@ -34,7 +34,8 @@
public class UpdateTracker extends GraphicsNodeChangeAdapter {
Map dirtyNodes = null;
- Map nodeBounds = new HashMap();
+ Map fromBounds = new HashMap();
+ Map toBounds = new HashMap();
public UpdateTracker(){
}
@@ -69,16 +70,16 @@
AffineTransform oat;
oat = (AffineTransform)dirtyNodes.get(gnWRef);
- Rectangle2D srcORgn = (Rectangle2D)nodeBounds.get(gnWRef);
+ Rectangle2D srcORgn = (Rectangle2D)fromBounds.remove(gnWRef);
- Rectangle2D srcNRgn = gn.getBounds();
+ Rectangle2D srcNRgn = (Rectangle2D)toBounds.remove(gnWRef);
+ if (srcNRgn == null) srcNRgn = gn.getBounds();
AffineTransform nat = gn.getTransform();
if (nat != null){
nat = (nat == null) ? null : new AffineTransform(nat);
}
- nodeBounds.put(gnWRef, srcNRgn); // remember the new bounds...
// System.out.println("Rgns: " + srcORgn + " - " + srcNRgn);
// System.out.println("ATs: " + oat + " - " + nat);
Shape oRgn = srcORgn;
@@ -101,15 +102,6 @@
gnWRef = gn.getWeakReference();
- if (dirtyNodes.containsKey(gnWRef))
- break; // We already have the parent in the list of
- // dirty nodes. so let it handle this...
-
- if (nodeBounds.containsKey(gnWRef)) {
- // Update the bounds in the nodeBounds array
- nodeBounds.put(gnWRef, gn.getBounds());
- }
-
AffineTransform at = gn.getTransform();
if (oat != null){
@@ -179,12 +171,22 @@
dirtyNodes.put(gnWRef, at);
}
-
- while (!nodeBounds.containsKey(gnWRef)) {
- nodeBounds.put(gnWRef, gn.getBounds());
- gn = gn.getParent();
- if (gn == null) break;
- gnWRef = gn.getWeakReference();
+ Rectangle2D r2d = gnce.getFrom();
+ if (r2d == null)
+ r2d = gn.getBounds();
+ if (r2d != null) {
+ Rectangle2D rgn = (Rectangle2D)fromBounds.remove(gnWRef);
+ if (rgn != null)
+ r2d.add(rgn);
+ fromBounds.put(gnWRef, r2d);
+ }
+
+ r2d = gnce.getTo();
+ if (r2d != null) {
+ Rectangle2D rgn = (Rectangle2D)toBounds.remove(gnWRef);
+ if (rgn != null)
+ r2d.add(rgn);
+ toBounds.put(gnWRef, r2d);
}
}
@@ -193,26 +195,5 @@
*/
public void clear() {
dirtyNodes = null;
- }
-
- public static class DirtyInfo {
- // Always references a GraphicsNode.
- WeakReference gn;
-
- // The transform from gn to parent at time of construction.
- AffineTransform gn2parent;
-
- public DirtyInfo(GraphicsNode gn, AffineTransform at) {
- this.gn = gn.getWeakReference();
- this.gn2parent = at;
- }
-
- public GraphicsNode getGraphicsNode() {
- return (GraphicsNode)gn.get();
- }
-
- public AffineTransform getGn2Parent() {
- return gn2parent;
- }
}
}
1.2 +9 -2 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GraphicsNodeChangeEvent.java 23 Jan 2002 14:14:09 -0000 1.1
+++ GraphicsNodeChangeEvent.java 25 Jul 2002 21:42:42 -0000 1.2
@@ -8,6 +8,7 @@
package org.apache.batik.gvt.event;
+import java.awt.geom.Rectangle2D;
import java.awt.event.InputEvent;
import org.apache.batik.gvt.GraphicsNode;
@@ -38,6 +39,9 @@
*/
public static final int CHANGE_COMPLETED = CHANGE_FIRST+1;
+ protected Rectangle2D from;
+ protected Rectangle2D to;
+
/**
* Constructs a new graphics node event with the specified source and ID.
* @param source the graphics node where the event originated
@@ -46,6 +50,9 @@
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; }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org