Index: trunk/src/com/kitfox/svg/Group.java
===================================================================
--- trunk/src/com/kitfox/svg/Group.java	(revision 4256)
+++ trunk/src/com/kitfox/svg/Group.java	(revision 6002)
@@ -1,34 +1,41 @@
 /*
- * Stop.java
+ * SVG Salamander
+ * Copyright (c) 2004, Mark McKay
+ * All rights reserved.
  *
+ * Redistribution and use in source and binary forms, with or 
+ * without modification, are permitted provided that the following
+ * conditions are met:
  *
- *  The Salamander Project - 2D and 3D graphics libraries in Java
- *  Copyright (C) 2004 Mark McKay
+ *   - Redistributions of source code must retain the above 
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer.
+ *   - Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials 
+ *     provided with the distribution.
  *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2.1 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
- *  projects can be found at http://www.kitfox.com
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE. 
+ * 
+ * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
+ * projects can be found at http://www.kitfox.com
  *
  * Created on January 26, 2004, 1:56 AM
  */
-
 package com.kitfox.svg;
 
 import com.kitfox.svg.xml.StyleAttribute;
 import java.awt.Graphics2D;
-import java.awt.Rectangle;
 import java.awt.Shape;
 import java.awt.geom.AffineTransform;
@@ -40,5 +47,4 @@
 import java.util.List;
 
-
 /**
  * @author Mark McKay
@@ -47,25 +53,21 @@
 public class Group extends ShapeElement
 {
-
+    public static final String TAG_NAME = "group";
+    
     //Cache bounding box for faster clip testing
     Rectangle2D boundingBox;
     Shape cachedShape;
 
-    //Cache clip bounds
-    final Rectangle clipBounds = new Rectangle();
-
-    /** Creates a new instance of Stop */
-    public Group() {
-    }
-
-    /*
-    public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
-    {
-        //Load style string
-        super.loaderStartElement(helper, attrs, parent);
-
-        //String transform = attrs.getValue("transform");
-    }
-     */
+    /**
+     * Creates a new instance of Stop
+     */
+    public Group()
+    {
+    }
+
+    public String getTagName()
+    {
+        return TAG_NAME;
+    }
 
     /**
@@ -76,20 +78,17 @@
     {
         super.loaderAddChild(helper, child);
-
-//        members.add(child);
     }
 
     protected boolean outsideClip(Graphics2D g) throws SVGException
     {
-        g.getClipBounds(clipBounds);
+        Shape clip = g.getClip();
+        if (clip == null)
+        {
+            return false;
+        }
+        //g.getClipBounds(clipBounds);
         Rectangle2D rect = getBoundingBox();
 
-//if (rect == null)
-//{
-//    rect = getBoundingBox();
-//}
-
-//        if (rect.intersects(clipBounds))
-        if (rect.intersects(clipBounds))
+        if (clip.intersects(rect))
         {
             return false;
@@ -107,19 +106,18 @@
             {
                 xform.inverseTransform(point, xPoint);
-            } 
-            catch (NoninvertibleTransformException ex)
+            } catch (NoninvertibleTransformException ex)
             {
                 throw new SVGException(ex);
             }
         }
-        
-        
+
+
         for (Iterator it = children.iterator(); it.hasNext();)
         {
-            SVGElement ele = (SVGElement)it.next();
-            if (ele instanceof RenderableElement)
-            {
-                RenderableElement rendEle = (RenderableElement)ele;
-                
+            SVGElement ele = (SVGElement) it.next();
+            if (ele instanceof RenderableElement)
+            {
+                RenderableElement rendEle = (RenderableElement) ele;
+
                 rendEle.pick(xPoint, boundingBox, retVec);
             }
@@ -134,13 +132,13 @@
             ltw.concatenate(xform);
         }
-        
-        
+
+
         for (Iterator it = children.iterator(); it.hasNext();)
         {
-            SVGElement ele = (SVGElement)it.next();
-            if (ele instanceof RenderableElement)
-            {
-                RenderableElement rendEle = (RenderableElement)ele;
-                
+            SVGElement ele = (SVGElement) it.next();
+            if (ele instanceof RenderableElement)
+            {
+                RenderableElement rendEle = (RenderableElement) ele;
+
                 rendEle.pick(pickArea, ltw, boundingBox, retVec);
             }
@@ -154,10 +152,16 @@
         if (getStyle(styleAttrib.setName("visibility")))
         {
-            if (!styleAttrib.getStringValue().equals("visible")) return;
-        }
-        
+            if (!styleAttrib.getStringValue().equals("visible"))
+            {
+                return;
+            }
+        }
+
         //Do not process offscreen groups
         boolean ignoreClip = diagram.ignoringClipHeuristic();
-        if (!ignoreClip && outsideClip(g)) return;
+        if (!ignoreClip && outsideClip(g))
+        {
+            return;
+        }
 
         beginLayer(g);
@@ -165,21 +169,22 @@
         Iterator it = children.iterator();
 
-        try
-        {
-            g.getClipBounds(clipBounds);
-        }
-        catch (Exception e)
-        {
-            //For some reason, getClipBounds can throw a null pointer exception for 
-            // some types of Graphics2D
-            ignoreClip = true;
-        }
-
+//        try
+//        {
+//            g.getClipBounds(clipBounds);
+//        }
+//        catch (Exception e)
+//        {
+//            //For some reason, getClipBounds can throw a null pointer exception for
+//            // some types of Graphics2D
+//            ignoreClip = true;
+//        }
+
+        Shape clip = g.getClip();
         while (it.hasNext())
         {
-            SVGElement ele = (SVGElement)it.next();
-            if (ele instanceof RenderableElement)
-            {
-                RenderableElement rendEle = (RenderableElement)ele;
+            SVGElement ele = (SVGElement) it.next();
+            if (ele instanceof RenderableElement)
+            {
+                RenderableElement rendEle = (RenderableElement) ele;
 
 //                if (shapeEle == null) continue;
@@ -188,5 +193,6 @@
                 {
                     //Skip if clipping area is outside our bounds
-                    if (!ignoreClip && !rendEle.getBoundingBox().intersects(clipBounds)) 
+                    if (!ignoreClip && clip != null
+                        && !clip.intersects(rendEle.getBoundingBox()))
                     {
                         continue;
@@ -201,5 +207,4 @@
     }
 
-
     /**
      * Retrieves the cached bounding box of this group
@@ -207,5 +212,8 @@
     public Shape getShape()
     {
-        if (cachedShape == null) calcShape();
+        if (cachedShape == null)
+        {
+            calcShape();
+        }
         return cachedShape;
     }
@@ -217,9 +225,9 @@
         for (Iterator it = children.iterator(); it.hasNext();)
         {
-            SVGElement ele = (SVGElement)it.next();
+            SVGElement ele = (SVGElement) it.next();
 
             if (ele instanceof ShapeElement)
             {
-                ShapeElement shpEle = (ShapeElement)ele;
+                ShapeElement shpEle = (ShapeElement) ele;
                 Shape shape = shpEle.getShape();
                 if (shape != null)
@@ -238,5 +246,8 @@
     public Rectangle2D getBoundingBox() throws SVGException
     {
-        if (boundingBox == null) calcBoundingBox();
+        if (boundingBox == null)
+        {
+            calcBoundingBox();
+        }
 //        calcBoundingBox();
         return boundingBox;
@@ -245,5 +256,5 @@
     /**
      * Recalculates the bounding box by taking the union of the bounding boxes
-     * of all children.  Caches the result.
+     * of all children. Caches the result.
      */
     public void calcBoundingBox() throws SVGException
@@ -254,14 +265,19 @@
         for (Iterator it = children.iterator(); it.hasNext();)
         {
-            SVGElement ele = (SVGElement)it.next();
-
-            if (ele instanceof RenderableElement)
-            {
-                RenderableElement rendEle = (RenderableElement)ele;
+            SVGElement ele = (SVGElement) it.next();
+
+            if (ele instanceof RenderableElement)
+            {
+                RenderableElement rendEle = (RenderableElement) ele;
                 Rectangle2D bounds = rendEle.getBoundingBox();
                 if (bounds != null)
                 {
-                    if (retRect == null) retRect = bounds;
-                    else retRect = retRect.createUnion(bounds);
+                    if (retRect == null)
+                    {
+                        retRect = bounds;
+                    } else
+                    {
+                        retRect = retRect.createUnion(bounds);
+                    }
                 }
             }
@@ -274,5 +290,8 @@
 
         //If no contents, use degenerate rectangle
-        if (retRect == null) retRect = new Rectangle2D.Float();
+        if (retRect == null)
+        {
+            retRect = new Rectangle2D.Float();
+        }
 
         boundingBox = boundsToParent(retRect);
@@ -287,5 +306,5 @@
         while (it.hasNext())
         {
-            SVGElement ele = (SVGElement)it.next();
+            SVGElement ele = (SVGElement) it.next();
             boolean updateVal = ele.updateTime(curTime);
 
@@ -293,6 +312,12 @@
 
             //Update our shape if shape aware children change
-            if (ele instanceof ShapeElement) cachedShape = null;
-            if (ele instanceof RenderableElement) boundingBox = null;
+            if (ele instanceof ShapeElement)
+            {
+                cachedShape = null;
+            }
+            if (ele instanceof RenderableElement)
+            {
+                boundingBox = null;
+            }
         }
 
