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 vh...@apache.org on 2001/02/12 19:12:58 UTC
cvs commit: xml-batik/sources/org/apache/batik/gvt/filter GraphicsNodeRable8Bit.java
vhardy 01/02/12 10:12:58
Modified: sources/org/apache/batik/gvt/filter
GraphicsNodeRable8Bit.java
Log:
Fix for sometimes null bounds.
Revision Changes Path
1.5 +30 -11 xml-batik/sources/org/apache/batik/gvt/filter/GraphicsNodeRable8Bit.java
Index: GraphicsNodeRable8Bit.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/filter/GraphicsNodeRable8Bit.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- GraphicsNodeRable8Bit.java 2001/02/07 19:13:59 1.4
+++ GraphicsNodeRable8Bit.java 2001/02/12 18:12:56 1.5
@@ -39,7 +39,7 @@
* createRendering methods.
*
* @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: GraphicsNodeRable8Bit.java,v 1.4 2001/02/07 19:13:59 deweese Exp $
+ * @version $Id: GraphicsNodeRable8Bit.java,v 1.5 2001/02/12 18:12:56 vhardy Exp $
*/
public class GraphicsNodeRable8Bit
extends AbstractRable
@@ -130,9 +130,16 @@
* Returns the bounds of this Rable in the user coordinate system.
*/
public Rectangle2D getBounds2D(){
- if (usePrimitivePaint)
- return (Rectangle2D)(node.getPrimitiveBounds(
- getGraphicsNodeRenderContext()).clone());
+ if (usePrimitivePaint){
+ Rectangle2D primitiveBounds
+ = node.getPrimitiveBounds(getGraphicsNodeRenderContext());
+ if(primitiveBounds != null){
+ return (Rectangle2D)(primitiveBounds.clone());
+ }
+ else{
+ return new Rectangle2D.Double(0, 0, 0, 0);
+ }
+ }
// When not using Primitive paint we return out bounds in our
// parent's user space. This makes sense since this is the
@@ -140,9 +147,15 @@
// primitivePaint incorporates the transform from our user
// space to our parents user space).
Rectangle2D bounds = node.getBounds(getGraphicsNodeRenderContext());
+ if(bounds == null){
+ return new Rectangle2D.Double(0, 0, 0, 0);
+ }
+
AffineTransform at = node.getTransform();
- if (at != null)
- bounds = at.createTransformedShape(bounds).getBounds2D();
+ if (at != null){
+ bounds = at.createTransformedShape(bounds).getBounds2D();
+ }
+
return bounds;
}
@@ -254,11 +267,17 @@
System.out.println("Not using Cached Red: " + usr2dev);
System.out.println("Old: " + cachedUsr2dev);
}
- cachedUsr2dev = (AffineTransform)usr2dev.clone();
- cachedRed = new GraphicsNodeRed8Bit
- (node, usr2dev, getGraphicsNodeRenderContext(),
- usePrimitivePaint, renderContext.getRenderingHints());
- return cachedRed;
+
+ Rectangle2D bounds2D = getBounds2D();
+ if(bounds2D.getWidth() > 0 && bounds2D.getHeight() > 0){
+ cachedUsr2dev = (AffineTransform)usr2dev.clone();
+ cachedRed = new GraphicsNodeRed8Bit
+ (node, usr2dev, getGraphicsNodeRenderContext(),
+ usePrimitivePaint, renderContext.getRenderingHints());
+ return cachedRed;
+ }
+
+ return null;
}
protected void setGraphicsNodeRenderContext(GraphicsNodeRenderContext rc) {