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/03/13 18:20:24 UTC
cvs commit: xml-batik/sources/org/apache/batik/gvt PatternPaint.java
vhardy 01/03/13 09:20:24
Modified: sources/org/apache/batik/gvt PatternPaint.java
Log:
Simplified pattern code.
Revision Changes Path
1.4 +29 -43 xml-batik/sources/org/apache/batik/gvt/PatternPaint.java
Index: PatternPaint.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/PatternPaint.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PatternPaint.java 2001/02/03 16:26:15 1.3
+++ PatternPaint.java 2001/03/13 17:20:19 1.4
@@ -30,7 +30,7 @@
* Concrete implementation of the <tt>PatternPaint</tt> interface
*
* @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: PatternPaint.java,v 1.3 2001/02/03 16:26:15 deweese Exp $
+ * @version $Id: PatternPaint.java,v 1.4 2001/03/13 17:20:19 vhardy Exp $
*/
public class PatternPaint implements Paint {
@@ -58,12 +58,6 @@
*/
private AffineTransform patternTransform;
- /**
- * Controls whether or not the pattern clips the
- * the node
- */
- private boolean overflow;
-
/*
* The basic tile to fill the region with.
* we replicate this out in the Context.
@@ -71,18 +65,21 @@
private Filter tile;
/**
+ * Controls whether or not the pattern overflows
+ * the pattern tile
+ */
+ private boolean overflow;
+
+ /**
* @param node Used to generate the paint pixel pattern
- * @param nodeTransform Additional transform to
- * set on the pattern content node.
* @param patternRegion Region to which this paint is constrained
- * @param overflow controls whether or not the patternRegion
- * clips the pattern node.
+ * @param overflow controls whether or not the node can overflow
+ * the patternRegion.
* @param patternTransform additional transform added on
* top of the user space to device space transform.
*/
public PatternPaint(GraphicsNode node,
GraphicsNodeRenderContext gnrc,
- AffineTransform nodeTransform,
Rectangle2D patternRegion,
boolean overflow,
AffineTransform patternTransform){
@@ -94,44 +91,34 @@
throw new IllegalArgumentException();
}
- if (nodeTransform == null)
- nodeTransform = new AffineTransform();
-
this.node = node;
this.gnrc = gnrc;
this.patternRegion = patternRegion;
this.overflow = overflow;
this.patternTransform = patternTransform;
+
+ // Wrap the input node so that the primitivePaint
+ // in GraphicsNodeRable takes the filter, clip....
+ // into account.
+ CompositeGraphicsNode comp = new CompositeGraphicsNode();
+ comp.getChildren().add(node);
+ GraphicsNodeRable gnr = new GraphicsNodeRable8Bit(comp, gnrc);
+
+ Rectangle2D padBounds = (Rectangle2D)patternRegion.clone();
//
- // adjustTxf applies the nodeTransform first, then
- // the translation to move the node rendering into
- // the pattern region space
+ // When there is overflow, make sure we take the
+ // full node bounds into account.
//
- AffineTransform adjustTxf = new AffineTransform();
- adjustTxf.translate(patternRegion.getX(), patternRegion.getY());
- adjustTxf.concatenate(nodeTransform);
-
- GraphicsNodeRable gnr = new GraphicsNodeRable8Bit(node, gnrc);
-
- AffineRable atr = new AffineRable8Bit(gnr, adjustTxf);
-
-
- Rectangle2D padBounds = (Rectangle2D)patternRegion.clone();
if(overflow){
- //
- // When there is overflow, make sure we take the
- // full node bounds into account.
- //
- Rectangle2D nodeBounds = node.getBounds(gnrc);
- Rectangle2D adjustedNodeBounds
- = adjustTxf.createTransformedShape(nodeBounds).getBounds2D();
-
- //System.out.println("adjustedBounds : " + adjustedNodeBounds);
- padBounds.add(adjustedNodeBounds);
+ Rectangle2D nodeBounds = comp.getBounds(gnrc);
+ // System.out.println("Node Bounds : " + nodeBounds);
+ padBounds.add(nodeBounds);
}
- tile = new PadRable8Bit(atr, padBounds, PadMode.ZERO_PAD);
+ // System.out.println("Pattern region : " + patternRegion);
+ // System.out.println("Node txf : " + node.getTransform());
+ tile = new PadRable8Bit(gnr, padBounds, PadMode.ZERO_PAD);
}
public GraphicsNode getGraphicsNode(){
@@ -142,10 +129,6 @@
return (Rectangle2D)patternRegion.clone();
}
- public boolean isOverflow(){
- return overflow;
- }
-
public AffineTransform getPatternTransform(){
return patternTransform;
}
@@ -155,6 +138,9 @@
Rectangle2D userBounds,
AffineTransform xform,
RenderingHints hints) {
+ // System.out.println("userBounds : " + userBounds);
+ // System.out.println("patternTransform : " + patternTransform);
+
//
// Concatenate the patternTransform to xform
//
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org