summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkitfox2014-06-25 18:49:44 +0200
committerkitfox2014-06-25 18:49:44 +0200
commit21f4905a7440f21965fb447ae30f1ed4e856b289 (patch)
tree710133c1f73a4726b090d1ef87742f8c13d320db
parentClipPath now propegates updateTime() to children. (diff)
downloadsvg-salamander-core-21f4905a7440f21965fb447ae30f1ed4e856b289.tar.gz
svg-salamander-core-21f4905a7440f21965fb447ae30f1ed4e856b289.tar.xz
svg-salamander-core-21f4905a7440f21965fb447ae30f1ed4e856b289.zip
Fixing JIRA SVGSALAMANDER-37 and SVGSALAMANDER-38. Viewbox now maps to full viewport. Calculating the group bounding box now ignores rectangles of zero size. (This is itself an error - shapes with no content should instead indicate a bounding box of null, but making that change would likely break a lot of things).
git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@177 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b
-rw-r--r--src/main/java/com/kitfox/svg/Group.java18
-rw-r--r--src/main/java/com/kitfox/svg/SVGRoot.java35
2 files changed, 39 insertions, 14 deletions
diff --git a/src/main/java/com/kitfox/svg/Group.java b/src/main/java/com/kitfox/svg/Group.java
index 78320ff..3fb8710 100644
--- a/src/main/java/com/kitfox/svg/Group.java
+++ b/src/main/java/com/kitfox/svg/Group.java
@@ -159,10 +159,10 @@ 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);
@@ -270,14 +270,18 @@ public class Group extends ShapeElement
{
RenderableElement rendEle = (RenderableElement) ele;
Rectangle2D bounds = rendEle.getBoundingBox();
- if (bounds != null)
+ if (bounds != null && (bounds.getWidth() != 0 || bounds.getHeight() != 0))
{
if (retRect == null)
{
retRect = bounds;
- } else
+ }
+ else
{
- retRect = retRect.createUnion(bounds);
+ if (retRect.getWidth() != 0 || retRect.getHeight() != 0)
+ {
+ retRect = retRect.createUnion(bounds);
+ }
}
}
}
diff --git a/src/main/java/com/kitfox/svg/SVGRoot.java b/src/main/java/com/kitfox/svg/SVGRoot.java
index fdd5065..a4ccfb0 100644
--- a/src/main/java/com/kitfox/svg/SVGRoot.java
+++ b/src/main/java/com/kitfox/svg/SVGRoot.java
@@ -241,22 +241,43 @@ public class SVGRoot extends Group
clipRect.setRect(xx, yy, ww, hh);
+// if (viewBox == null)
+// {
+// viewXform.setToIdentity();
+// }
+// else
+// {
+// //If viewport window is set, we are drawing to entire viewport
+// clipRect.setRect(deviceViewport);
+//
+// viewXform.setToIdentity();
+// viewXform.setToTranslation(deviceViewport.x, deviceViewport.y);
+// viewXform.scale(deviceViewport.width, deviceViewport.height);
+// viewXform.scale(1 / viewBox.width, 1 / viewBox.height);
+// viewXform.translate(-viewBox.x, -viewBox.y);
+// }
+ }
+
+ public void render(Graphics2D g) throws SVGException
+ {
+ prepareViewport();
+
if (viewBox == null)
{
viewXform.setToIdentity();
}
else
{
- viewXform.setToTranslation(clipRect.x, clipRect.y);
- viewXform.scale(clipRect.width, clipRect.height);
+ Rectangle deviceViewport = g.getClipBounds();
+ //If viewport window is set, we are drawing to entire viewport
+ clipRect.setRect(deviceViewport);
+
+ viewXform.setToIdentity();
+ viewXform.setToTranslation(deviceViewport.x, deviceViewport.y);
+ viewXform.scale(deviceViewport.width, deviceViewport.height);
viewXform.scale(1 / viewBox.width, 1 / viewBox.height);
viewXform.translate(-viewBox.x, -viewBox.y);
}
- }
-
- public void render(Graphics2D g) throws SVGException
- {
- prepareViewport();
AffineTransform cachedXform = g.getTransform();
g.transform(viewXform);