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 tk...@apache.org on 2001/09/13 16:40:20 UTC

cvs commit: xml-batik/sources/org/apache/batik/gvt CanvasGraphicsNode.java CompositeGraphicsNode.java Marker.java Mask.java PatternPaint.java ProxyGraphicsNode.java

tkormann    01/09/13 07:40:20

  Modified:    sources/org/apache/batik/gvt CanvasGraphicsNode.java
                        CompositeGraphicsNode.java Marker.java Mask.java
                        PatternPaint.java ProxyGraphicsNode.java
  Log:
  cleanup some javadoc + code.
  
  The only change that might cause problem is that now getPrimitiveBounds and
  getGeometryBounds of the ProxyGraphicsNode returns null if there is no source (a rectangle (0, 0, 0, 0) was the previous return value).
  
  Revision  Changes    Path
  1.4       +10 -3     xml-batik/sources/org/apache/batik/gvt/CanvasGraphicsNode.java
  
  Index: CanvasGraphicsNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/CanvasGraphicsNode.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CanvasGraphicsNode.java	2001/01/29 10:28:12	1.3
  +++ CanvasGraphicsNode.java	2001/09/13 14:40:20	1.4
  @@ -17,11 +17,13 @@
    * The graphics node container with a background color.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: CanvasGraphicsNode.java,v 1.3 2001/01/29 10:28:12 tkormann Exp $
  + * @version $Id: CanvasGraphicsNode.java,v 1.4 2001/09/13 14:40:20 tkormann Exp $
    */
   public class CanvasGraphicsNode extends CompositeGraphicsNode {
   
  -    /** The background of this canvas graphics node. */
  +    /** 
  +     * The background of this canvas graphics node.
  +     */
       protected Paint backgroundPaint;
   
       /**
  @@ -35,6 +37,7 @@
   
       /**
        * Sets the background paint of this canvas graphics node.
  +     *
        * @param newBackgroundPaint the new background paint
        */
       public void setBackgroundPaint(Paint newBackgroundPaint) {
  @@ -43,7 +46,6 @@
   
       /**
        * Returns the background paint of this canvas graphics node.
  -     * @return the background paint
        */
       public Paint getBackgroundPaint() {
           return backgroundPaint;
  @@ -53,6 +55,11 @@
       // Drawing methods
       //
   
  +    /**
  +     * Paints this node without applying Filter, Mask, Composite, and clip.
  +     *
  +     * @param g2d the Graphics2D to use
  +     */
       public void primitivePaint(Graphics2D g2d, GraphicsNodeRenderContext rc) {
           if (backgroundPaint != null) {
               g2d.setPaint(backgroundPaint);
  
  
  
  1.23      +6 -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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- CompositeGraphicsNode.java	2001/09/13 09:37:23	1.22
  +++ CompositeGraphicsNode.java	2001/09/13 14:40:20	1.23
  @@ -33,7 +33,7 @@
    * A CompositeGraphicsNode is a graphics node that can contain graphics nodes.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: CompositeGraphicsNode.java,v 1.22 2001/09/13 09:37:23 tkormann Exp $
  + * @version $Id: CompositeGraphicsNode.java,v 1.23 2001/09/13 14:40:20 tkormann Exp $
    */
   public class CompositeGraphicsNode extends AbstractGraphicsNode 
       implements List {
  @@ -234,15 +234,15 @@
       public Rectangle2D getPrimitiveBounds(GraphicsNodeRenderContext rc) {
           if (primitiveBounds == null) {
               int i=0;
  -            while(primitiveBounds == null && i < count){
  +            while (primitiveBounds == null && i < count) {
                   primitiveBounds = children[i++].getTransformedBounds
                       (IDENTITY, rc);
               }
   
               Rectangle2D ctb = null;
  -            while(i < count){
  +            while (i < count) {
                   ctb = children[i++].getTransformedBounds(IDENTITY, rc);
  -                if(ctb != null){
  +                if (ctb != null) {
                       if (primitiveBounds == null) {
                           // another thread has set the primitive bounds to null,
                           // need to recall this function
  @@ -255,8 +255,8 @@
   
               // Make sure we haven't been interrupted
               if (Thread.currentThread().isInterrupted()) {
  -                // The Thread has been interrupted. Invalidate
  -                // any cached values and proceed.
  +                // The Thread has been interrupted.
  +		// Invalidate any cached values and proceed.
                   invalidateGeometryCache();
               }
           }
  
  
  
  1.3       +14 -15    xml-batik/sources/org/apache/batik/gvt/Marker.java
  
  Index: Marker.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/Marker.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Marker.java	2001/09/13 08:42:49	1.2
  +++ Marker.java	2001/09/13 14:40:20	1.3
  @@ -11,31 +11,31 @@
   import java.awt.geom.Point2D;
   
   /**
  - * A Marker describes a GraphicsNode with a reference point that can
  - * be used to position the Marker at a particular location and a 
  - * particular policy for rotating the marker when drawing it.
  + * A Marker describes a GraphicsNode with a reference point that can be used to
  + * position the Marker at a particular location and a particular policy for
  + * rotating the marker when drawing it.
    *
    * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
  - * @version $Id: Marker.java,v 1.2 2001/09/13 08:42:49 tkormann Exp $
  + * @version $Id: Marker.java,v 1.3 2001/09/13 14:40:20 tkormann Exp $ 
    */
   public class Marker {
   
       /**
  -     * Rotation angle, about (0, 0) is user space. If orient is NaN
  -     * then the marker's x-axis should be aligned with the slope
  -     * of the curve on the point where the object is drawn
  +     * Rotation angle, about (0, 0) is user space. If orient is NaN then the
  +     * marker's x-axis should be aligned with the slope of the curve on the
  +     * point where the object is drawn 
        */
  -    private double orient;
  +    protected double orient;
   
       /**
        * GraphicsNode this marker is associated to
        */
  -    private GraphicsNode markerNode;
  +    protected GraphicsNode markerNode;
   
       /**
        * Reference point about which the marker should be drawn
        */
  -    private Point2D ref;
  +    protected Point2D ref;
   
       /**
        * Constructs a new marker.
  @@ -44,14 +44,13 @@
        * @param ref the reference point
        * @param orient the orientation of the marker
        */
  -    public Marker(GraphicsNode markerNode,
  -                  Point2D ref,
  -                  double orient){
  -        if(markerNode == null){
  +    public Marker(GraphicsNode markerNode, Point2D ref, double orient){
  +
  +        if (markerNode == null) {
               throw new IllegalArgumentException();
           }
   
  -        if(ref == null){
  +        if (ref == null) {
               throw new IllegalArgumentException();
           }
   
  
  
  
  1.3       +4 -3      xml-batik/sources/org/apache/batik/gvt/Mask.java
  
  Index: Mask.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/Mask.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Mask.java	2000/10/13 11:39:12	1.2
  +++ Mask.java	2001/09/13 14:40:20	1.3
  @@ -15,11 +15,12 @@
    * Describes a mask.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: Mask.java,v 1.2 2000/10/13 11:39:12 vhardy Exp $
  + * @version $Id: Mask.java,v 1.3 2001/09/13 14:40:20 tkormann Exp $
    */
   public interface Mask extends RenderableImage {
  +
       /**
  -     * Returns the bounds of this mask
  +     * Returns the bounds of this mask.
        */
  -    public Rectangle2D getBounds2D();
  +    Rectangle2D getBounds2D();
   }
  
  
  
  1.7       +33 -14    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PatternPaint.java	2001/05/02 14:56:31	1.6
  +++ PatternPaint.java	2001/09/13 14:40:20	1.7
  @@ -13,13 +13,16 @@
   import java.awt.Rectangle;
   import java.awt.RenderingHints;
   import java.awt.Shape;
  +
   import java.awt.geom.AffineTransform;
   import java.awt.geom.NoninvertibleTransformException;
   import java.awt.geom.Rectangle2D;
  +
   import java.awt.image.ColorModel;
   
   import org.apache.batik.gvt.filter.GraphicsNodeRable8Bit;
   import org.apache.batik.gvt.filter.GraphicsNodeRable;
  +
   import org.apache.batik.ext.awt.image.PadMode;
   import org.apache.batik.ext.awt.image.renderable.Filter;
   import org.apache.batik.ext.awt.image.renderable.PadRable8Bit;
  @@ -27,10 +30,11 @@
   import org.apache.batik.ext.awt.image.renderable.AffineRable;
   
   /**
  - * Concrete implementation of the <tt>PatternPaint</tt> interface
  + * The PatternPaint class provides a way to fill a Shape with a a pattern
  + * defined as a GVT Tree.
    *
    * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
  - * @version $Id: PatternPaint.java,v 1.6 2001/05/02 14:56:31 deweese Exp $
  + * @version $Id: PatternPaint.java,v 1.7 2001/09/13 14:40:20 tkormann Exp $ 
    */
   public class PatternPaint implements Paint {
   
  @@ -71,6 +75,8 @@
       private boolean overflow;
   
       /**
  +     * Constructs a new <tt>PatternPaint</tt>.
  +     *
        * @param node Used to generate the paint pixel pattern
        * @param patternRegion Region to which this paint is constrained
        * @param overflow controls whether or not the node can overflow
  @@ -83,6 +89,7 @@
                           Rectangle2D patternRegion,
                           boolean overflow,
                           AffineTransform patternTransform){
  +
           if (node == null) {
               throw new IllegalArgumentException();
           }
  @@ -106,11 +113,9 @@
   
           Rectangle2D padBounds = (Rectangle2D)patternRegion.clone();
   
  -        //
  -        // When there is overflow, make sure we take the
  -        // full node bounds into account.
  -        //
  -        if(overflow){
  +        // When there is overflow, make sure we take the full node bounds into
  +        // account.
  +        if (overflow) {
               Rectangle2D nodeBounds = comp.getBounds(gnrc);
               // System.out.println("Comp Bounds    : " + nodeBounds);
               // System.out.println("Node Bounds    : " + node.getBounds(gnrc));
  @@ -122,36 +127,47 @@
           tile = new PadRable8Bit(gnr, padBounds, PadMode.ZERO_PAD);
       }
   
  +    /**
  +     * Returns the graphics node that define the pattern.
  +     */
       public GraphicsNode getGraphicsNode(){
           return node;
       }
   
  +    /**
  +     * Returns the pattern region.
  +     */
       public Rectangle2D getPatternRect(){
           return (Rectangle2D)patternRegion.clone();
       }
   
  +    /**
  +     * Returns the additional transform of the pattern paint.
  +     */
       public AffineTransform getPatternTransform(){
           return patternTransform;
       }
   
  +    /**
  +     * Creates and returns a context used to generate the pattern.
  +     */
       public PaintContext createContext(ColorModel      cm, 
                                         Rectangle       deviceBounds,
                                         Rectangle2D     userBounds,
                                         AffineTransform xform,
                                         RenderingHints  hints) {
  +
           // System.out.println("userBounds : " + userBounds);
           // System.out.println("patternTransform : " + patternTransform);
   
  -        //
           // Concatenate the patternTransform to xform
  -        //
  -        if(patternTransform != null) {
  +        if (patternTransform != null) {
               xform = new AffineTransform(xform);
               xform.concatenate(patternTransform);
  -
  -            try{
  -                AffineTransform patternTransformInv 
  -                    = patternTransform.createInverse();
  +	    
  +            try {
  +                AffineTransform patternTransformInv = 
  +		    patternTransform.createInverse();
                   userBounds = patternTransformInv.
                       createTransformedShape(userBounds).getBounds2D();
               }
  @@ -165,6 +181,9 @@
                                          overflow);
       }
   
  +    /**
  +     * Returns the transparency mode for this pattern paint.
  +     */
       public int getTransparency(){
           return TRANSLUCENT;
       }
  
  
  
  1.5       +16 -24    xml-batik/sources/org/apache/batik/gvt/ProxyGraphicsNode.java
  
  Index: ProxyGraphicsNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/ProxyGraphicsNode.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ProxyGraphicsNode.java	2001/03/05 22:07:01	1.4
  +++ ProxyGraphicsNode.java	2001/09/13 14:40:20	1.5
  @@ -14,13 +14,12 @@
   import java.awt.geom.Rectangle2D;
   
   /**
  - * A graphics node which provides a placeholder for another graphics
  - * node. This node is self defined except that it delegates to the
  - * enclosed (proxied) graphics node, its paint routine and bounds
  - * computation.
  + * A graphics node which provides a placeholder for another graphics node. This
  + * node is self defined except that it delegates to the enclosed (proxied)
  + * graphics node, its paint routine and bounds computation.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: ProxyGraphicsNode.java,v 1.4 2001/03/05 22:07:01 vhardy Exp $
  + * @version $Id: ProxyGraphicsNode.java,v 1.5 2001/09/13 14:40:20 tkormann Exp $ 
    */
   public class ProxyGraphicsNode extends AbstractGraphicsNode {
   
  @@ -36,6 +35,7 @@
   
       /**
        * Sets the graphics node to proxy to the specified graphics node.
  +     *
        * @param source the graphics node to proxy
        */
       public void setSource(GraphicsNode source) {
  @@ -51,8 +51,8 @@
   
       /**
        * Paints this node without applying Filter, Mask, Composite and clip.
  +     *
        * @param g2d the Graphics2D to use
  -     * @param rc the GraphicsNodeRenderContext to use
        */
       public void primitivePaint(Graphics2D g2d, GraphicsNodeRenderContext rc) {
           if (source != null) {
  @@ -61,39 +61,31 @@
       }
   
       /**
  -     * Returns the bounds of the area covered by this node's
  -     * primitive paint. ie. the proxied graphics node's bounds.
  -     * <b>Note</b>: The boundaries of some nodes (notably, text element nodes)
  -     * cannot be precisely determined independent of their
  -     * GraphicsNodeRenderContext.
  -     *
  -     * @param rc the GraphicsNodeRenderContext for which this dimension applies
  +     * Returns the bounds of the area covered by this node's primitive paint.
        */
       public Rectangle2D getPrimitiveBounds(GraphicsNodeRenderContext rc) {
           if (source != null) {
               return source.getBounds(rc);
           } else {
  -            return new Rectangle(0, 0, 0, 0);
  +            //return new Rectangle(0, 0, 0, 0);
  +            return null;
           }
       }
   
       /**
  -     * Returns the bounds of the area covered by this node, without
  -     * taking any of its rendering attribute into account, i.e., exclusive
  -     * of any clipping, masking, filtering or stroking, for example.
  -     * <b>Note</b>: The boundaries of some nodes (notably, text element nodes)
  -     * cannot be precisely determined independent of their
  -     * GraphicsNodeRenderContext.
  -     *
  -     * @param rc the GraphicsNodeRenderContext for which this dimension applies
  -      */
  +     * Returns the bounds of the area covered by this node, without taking any
  +     * of its rendering attribute into account. i.e., exclusive of any clipping,
  +     * masking, filtering or stroking, for example.
  +     */
       public Rectangle2D getGeometryBounds(GraphicsNodeRenderContext rc){
           if (source != null) {
               return source.getGeometryBounds(rc);
           } else {
  -            return new Rectangle(0, 0, 0, 0);
  +            //return new Rectangle(0, 0, 0, 0);
  +            return null;
           }
       }
  +
   
       /**
        * Returns the outline of this node.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org