diff options
author | kitfox | 2012-01-09 23:41:46 +0100 |
---|---|---|
committer | kitfox | 2012-01-09 23:41:46 +0100 |
commit | aabf88077bf006ead57e677050b09b0c77abb9ca (patch) | |
tree | 18adc1d034432f3dacfb039cf8f0f223486a95f3 /src | |
parent | Fixes NPE when adding a track without a name. (diff) | |
download | svg-salamander-core-aabf88077bf006ead57e677050b09b0c77abb9ca.tar.gz svg-salamander-core-aabf88077bf006ead57e677050b09b0c77abb9ca.tar.xz svg-salamander-core-aabf88077bf006ead57e677050b09b0c77abb9ca.zip |
If a Graphics2D has no clip region, clipping will now be ignored.
git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@105 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/kitfox/svg/Group.java | 40 | ||||
-rw-r--r-- | src/main/java/com/kitfox/svg/Marker.java | 4 | ||||
-rw-r--r-- | src/main/java/com/kitfox/svg/Symbol.java | 5 |
3 files changed, 30 insertions, 19 deletions
diff --git a/src/main/java/com/kitfox/svg/Group.java b/src/main/java/com/kitfox/svg/Group.java index 3c3b6ee..5014c59 100644 --- a/src/main/java/com/kitfox/svg/Group.java +++ b/src/main/java/com/kitfox/svg/Group.java @@ -52,7 +52,7 @@ public class Group extends ShapeElement Shape cachedShape;
//Cache clip bounds
- final Rectangle clipBounds = new Rectangle();
+// final Rectangle clipBounds = new Rectangle();
/** Creates a new instance of Stop */
public Group() {
@@ -81,7 +81,12 @@ public class Group extends ShapeElement 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)
@@ -90,7 +95,7 @@ public class Group extends ShapeElement //}
// if (rect.intersects(clipBounds))
- if (rect.intersects(clipBounds))
+ if (clip.intersects(rect))
{
return false;
}
@@ -158,23 +163,27 @@ public class Group extends ShapeElement //Do not process offscreen groups
boolean ignoreClip = diagram.ignoringClipHeuristic();
- if (!ignoreClip && outsideClip(g)) return;
+ if (!ignoreClip && outsideClip(g))
+ {
+ return;
+ }
beginLayer(g);
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();
@@ -187,7 +196,8 @@ public class Group extends ShapeElement if (!(ele instanceof Group))
{
//Skip if clipping area is outside our bounds
- if (!ignoreClip && !rendEle.getBoundingBox().intersects(clipBounds))
+ if (!ignoreClip && clip != null
+ && !clip.intersects(rendEle.getBoundingBox()))
{
continue;
}
diff --git a/src/main/java/com/kitfox/svg/Marker.java b/src/main/java/com/kitfox/svg/Marker.java index e68a838..42e3ce8 100644 --- a/src/main/java/com/kitfox/svg/Marker.java +++ b/src/main/java/com/kitfox/svg/Marker.java @@ -77,9 +77,9 @@ public class Marker extends Group protected boolean outsideClip(Graphics2D g) throws SVGException { - g.getClipBounds(clipBounds); + Shape clip = g.getClip(); Rectangle2D rect = super.getBoundingBox(); - if (rect.intersects(clipBounds)) + if (clip == null || clip.intersects(rect)) { return false; } diff --git a/src/main/java/com/kitfox/svg/Symbol.java b/src/main/java/com/kitfox/svg/Symbol.java index 6d9e219..f71fc0c 100644 --- a/src/main/java/com/kitfox/svg/Symbol.java +++ b/src/main/java/com/kitfox/svg/Symbol.java @@ -103,9 +103,10 @@ public class Symbol extends Group protected boolean outsideClip(Graphics2D g) throws SVGException
{
- g.getClipBounds(clipBounds);
+ Shape clip = g.getClip();
+// g.getClipBounds(clipBounds);
Rectangle2D rect = super.getBoundingBox();
- if (rect.intersects(clipBounds))
+ if (clip == null || clip.intersects(rect))
{
return false;
}
|