deweese 2003/07/16 16:46:27
Modified: sources/org/apache/batik/ext/awt/image/renderable
PadRable8Bit.java
sources/org/apache/batik/gvt CompositeGraphicsNode.java
UpdateTracker.java
sources/org/apache/batik/gvt/filter GraphicsNodeRed8Bit.java
sources/org/apache/batik/swing/gvt JGVTComponent.java
Log:
1) Parents no longer clear themselves when a child is added/removed (again :).
2) When using progressive paint you will no longer get harmless but
distracting compaints about threads being interrupted.
3) Avoided a potential stack ovflow issue in bounds calculations.
Revision Changes Path
1.8 +3 -3
xml-batik/sources/org/apache/batik/ext/awt/image/renderable/PadRable8Bit.java
Index: PadRable8Bit.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/renderable/PadRable8Bit.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PadRable8Bit.java 11 Apr 2003 13:57:48 -0000 1.7
+++ PadRable8Bit.java 16 Jul 2003 23:46:27 -0000 1.8
@@ -38,8 +38,8 @@
Rectangle2D padRect;
public PadRable8Bit(Filter src,
- Rectangle2D padRect,
- PadMode padMode) {
+ Rectangle2D padRect,
+ PadMode padMode) {
super.init(src, null);
this.padRect = padRect;
this.padMode = padMode;
1.33 +7 -4
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.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- CompositeGraphicsNode.java 30 May 2003 01:07:15 -0000 1.32
+++ CompositeGraphicsNode.java 16 Jul 2003 23:46:27 -0000 1.33
@@ -159,9 +159,12 @@
public Rectangle2D getPrimitiveBounds() {
if (primitiveBounds == null) {
int i=0;
- while (primitiveBounds == null && i < count) {
- primitiveBounds = children[i++].getTransformedBounds(IDENTITY);
+ Rectangle2D bounds = null;
+ while ((bounds == null) && i < count) {
+ bounds = children[i++].getTransformedBounds(IDENTITY);
}
+ if (bounds == null) return null;
+ primitiveBounds = bounds;
Rectangle2D ctb = null;
while (i < count) {
@@ -170,7 +173,7 @@
if (primitiveBounds == null) {
// another thread has set the primitive bounds to null,
// need to recall this function
- return getPrimitiveBounds();
+ return null;
} else {
primitiveBounds.add(ctb);
}
1.18 +36 -26 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.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- UpdateTracker.java 14 Apr 2003 10:53:35 -0000 1.17
+++ UpdateTracker.java 16 Jul 2003 23:46:27 -0000 1.18
@@ -21,7 +21,7 @@
import org.apache.batik.gvt.event.GraphicsNodeChangeAdapter;
import org.apache.batik.gvt.event.GraphicsNodeChangeEvent;
-
+import org.apache.batik.ext.awt.image.renderable.Filter;
/**
* This class tracks the changes on a GVT tree
*
@@ -32,7 +32,6 @@
Map dirtyNodes = null;
Map fromBounds = new HashMap();
- Map toBounds = new HashMap();
public UpdateTracker(){
}
@@ -72,21 +71,20 @@
Rectangle2D srcORgn = (Rectangle2D)fromBounds.remove(gnWRef);
- Rectangle2D srcNRgn = gn.getBounds();
- AffineTransform nat = gn.getTransform();
-
- if (nat != null){
- nat = new AffineTransform(nat);
+ Rectangle2D srcNRgn = null;
+ AffineTransform nat = null;
+ if (!(srcORgn instanceof ChngSrcRect)) {
+ // For change srcs don't use the new bounds of parent node.
+ srcNRgn = gn.getBounds();
+ nat = gn.getTransform();
+ if (nat != null)
+ nat = new AffineTransform(nat);
}
+
// System.out.println("Rgns: " + srcORgn + " - " + srcNRgn);
// System.out.println("ATs: " + oat + " - " + nat);
- Shape oRgn = srcORgn;
- Shape nRgn = srcNRgn;
-
do {
- // Filter f;
- // f = gn.getGraphicsNodeRable(false);
// f.invalidateCache(oRng);
// f.invalidateCache(nRng);
@@ -99,6 +97,12 @@
if (gn == null)
break; // We reached the top of the tree
+ Filter f= gn.getFilter();
+ if ( f != null) {
+ srcNRgn = f.getBounds2D();
+ nat = null;
+ }
+
// Get the parent's current Affine
AffineTransform at = gn.getTransform();
// Get the parent's Affine last time we rendered.
@@ -118,29 +122,28 @@
else
nat = new AffineTransform(at);
}
-
} while (true);
if (gn == null) {
// We made it to the root graphics node so add them.
// System.out.println
- // ("Adding: " + oat + " - " + nat + "\n" +
- // org.ImageDisplay.stringShape(oRgn) + "\n" +
- // org.ImageDisplay.stringShape(nRgn) + "\n");
+ // ("Adding: " + oat + " - " + nat + "\n" +
+ // srcORgn + "\n" + srcNRgn + "\n");
// <!>
+ Shape oRgn = srcORgn;
if (oat != null){
oRgn = oat.createTransformedShape(srcORgn);
}
- if (nat != null){
- nRgn = nat.createTransformedShape(srcNRgn);
- }
-
if (oRgn != null) {
ret.add(oRgn);
}
-
- if (nRgn != null) {
- ret.add(nRgn);
+
+ if (srcNRgn != null) {
+ Shape nRgn = srcNRgn;
+ if (nat != null)
+ nRgn = nat.createTransformedShape(srcNRgn);
+ if (nRgn != null)
+ ret.add(nRgn);
}
}
}
@@ -219,9 +222,9 @@
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);
+ rgn = new ChngSrcRect(getNodeDirtyRegion(chngSrc));
} else {
- // Otherwise just use gn's dirty region.
+ // Otherwise just use gn's current region.
rgn = gn.getBounds();
}
// Add this dirty region to any existing dirty region.
@@ -232,6 +235,13 @@
}
// Store the bounds for the future.
fromBounds.put(gnWRef, r2d);
+ }
+
+ class ChngSrcRect extends Rectangle2D.Float {
+ ChngSrcRect(Rectangle2D r2d) {
+ super((float)r2d.getX(), (float)r2d.getY(),
+ (float)r2d.getWidth(), (float)r2d.getHeight());
+ }
}
/**
1.13 +2 -1
xml-batik/sources/org/apache/batik/gvt/filter/GraphicsNodeRed8Bit.java
Index: GraphicsNodeRed8Bit.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/gvt/filter/GraphicsNodeRed8Bit.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- GraphicsNodeRed8Bit.java 11 Apr 2003 13:58:42 -0000 1.12
+++ GraphicsNodeRed8Bit.java 16 Jul 2003 23:46:27 -0000 1.13
@@ -61,6 +61,7 @@
AffineTransform at = node2dev;
Rectangle2D bounds2D = node.getPrimitiveBounds();
+ if (bounds2D == null) bounds2D = new Rectangle2D.Float(0,0,1,1);
if (!usePrimitivePaint) {
// When not using Primitive paint we return our bounds in
// the nodes parent's user space. This makes sense since
1.37 +2 -1 xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java
Index: JGVTComponent.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- JGVTComponent.java 10 Jul 2003 02:01:27 -0000 1.36
+++ JGVTComponent.java 16 Jul 2003 23:46:27 -0000 1.37
@@ -758,6 +758,7 @@
});
sleep(200);
}
+ } catch (InterruptedException ie) {
} catch (Throwable t) {
t.printStackTrace();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]