summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkitfox2007-08-19 21:51:23 +0200
committerkitfox2007-08-19 21:51:23 +0200
commit5d1ddcb4951cdd30a44f9e2642197d47230bb01e (patch)
tree8deb2d20f965cfe3f9a0387837dfeadb6a469f44
parentFixed miterlimit error. (diff)
downloadsvg-salamander-core-5d1ddcb4951cdd30a44f9e2642197d47230bb01e.tar.gz
svg-salamander-core-5d1ddcb4951cdd30a44f9e2642197d47230bb01e.tar.xz
svg-salamander-core-5d1ddcb4951cdd30a44f9e2642197d47230bb01e.zip
Added pickng by rectangular areas. Fixed bug with picking by point.
git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@45 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b
-rw-r--r--src/main/java/com/kitfox/svg/Group.java21
-rw-r--r--src/main/java/com/kitfox/svg/ImageSVG.java19
-rw-r--r--src/main/java/com/kitfox/svg/RenderableElement.java2
-rw-r--r--src/main/java/com/kitfox/svg/SVGDiagram.java12
-rw-r--r--src/main/java/com/kitfox/svg/ShapeElement.java21
-rw-r--r--src/main/java/com/kitfox/svg/app/SVGPlayer.java2
-rw-r--r--src/main/java/com/kitfox/svg/app/SVGViewer.java2
-rw-r--r--src/main/res/res/help/about/about.html2
8 files changed, 55 insertions, 26 deletions
diff --git a/src/main/java/com/kitfox/svg/Group.java b/src/main/java/com/kitfox/svg/Group.java
index 8446049..5b4db2b 100644
--- a/src/main/java/com/kitfox/svg/Group.java
+++ b/src/main/java/com/kitfox/svg/Group.java
@@ -121,6 +121,27 @@ public class Group extends ShapeElement {
}
}
+ void pick(Rectangle2D pickArea, AffineTransform ltw, Vector retVec) throws SVGException
+ {
+ if (xform != null)
+ {
+ ltw = new AffineTransform(ltw);
+ ltw.concatenate(xform);
+ }
+
+
+ for (Iterator it = children.iterator(); it.hasNext();)
+ {
+ SVGElement ele = (SVGElement)it.next();
+ if (ele instanceof RenderableElement)
+ {
+ RenderableElement rendEle = (RenderableElement)ele;
+
+ rendEle.pick(pickArea, ltw, retVec);
+ }
+ }
+ }
+
public void render(Graphics2D g) throws SVGException
{
//Don't process if not visible
diff --git a/src/main/java/com/kitfox/svg/ImageSVG.java b/src/main/java/com/kitfox/svg/ImageSVG.java
index 2d981bc..eb61215 100644
--- a/src/main/java/com/kitfox/svg/ImageSVG.java
+++ b/src/main/java/com/kitfox/svg/ImageSVG.java
@@ -122,20 +122,15 @@ public class ImageSVG extends RenderableElement
void pick(Point2D point, Vector retVec) throws SVGException
{
- /*
- Point2D xPoint = new Point2D.Double();
- try
- {
- xform.inverseTransform(point, xPoint);
- }
- catch (NoninvertibleTransformException ex)
+ if (getBoundingBox().contains(point))
{
- throw new SVGException(ex);
+ retVec.add(getPath(null));
}
- */
-
-// if (bounds.contains(xPoint))
- if (getBoundingBox().contains(point))
+ }
+
+ void pick(Rectangle2D pickArea, AffineTransform ltw, Vector retVec) throws SVGException
+ {
+ if (ltw.createTransformedShape(getBoundingBox()).intersects(pickArea))
{
retVec.add(getPath(null));
}
diff --git a/src/main/java/com/kitfox/svg/RenderableElement.java b/src/main/java/com/kitfox/svg/RenderableElement.java
index 878a132..379afcf 100644
--- a/src/main/java/com/kitfox/svg/RenderableElement.java
+++ b/src/main/java/com/kitfox/svg/RenderableElement.java
@@ -87,6 +87,8 @@ abstract public class RenderableElement extends TransformableElement
abstract void pick(Point2D point, Vector retVec) throws SVGException;
+ abstract void pick(Rectangle2D pickArea, AffineTransform ltw, Vector retVec) throws SVGException;
+
abstract public Rectangle2D getBoundingBox() throws SVGException;
/*
public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
diff --git a/src/main/java/com/kitfox/svg/SVGDiagram.java b/src/main/java/com/kitfox/svg/SVGDiagram.java
index aaab400..cdbfa68 100644
--- a/src/main/java/com/kitfox/svg/SVGDiagram.java
+++ b/src/main/java/com/kitfox/svg/SVGDiagram.java
@@ -110,6 +110,18 @@ public class SVGDiagram implements Serializable
return retVec;
}
+ public Vector pick(Rectangle2D pickArea, Vector retVec) throws SVGException
+ {
+ if (retVec == null)
+ {
+ retVec = new Vector();
+ }
+
+ root.pick(pickArea, new AffineTransform(), retVec);
+
+ return retVec;
+ }
+
public SVGUniverse getUniverse()
{
return universe;
diff --git a/src/main/java/com/kitfox/svg/ShapeElement.java b/src/main/java/com/kitfox/svg/ShapeElement.java
index e122753..9bb7b27 100644
--- a/src/main/java/com/kitfox/svg/ShapeElement.java
+++ b/src/main/java/com/kitfox/svg/ShapeElement.java
@@ -66,20 +66,19 @@ abstract public class ShapeElement extends RenderableElement
void pick(Point2D point, Vector retVec) throws SVGException
{
- /*
- Point2D xPoint = new Point2D.Double();
- try
- {
- xform.inverseTransform(point, xPoint);
- }
- catch (NoninvertibleTransformException ex)
+ StyleAttribute styleAttrib = new StyleAttribute();
+// if (getStyle(styleAttrib.setName("fill")) && getShape().contains(point))
+ if (getShape().contains(point))
{
- throw new SVGException(ex);
+ retVec.add(getPath(null));
}
- */
-
+ }
+
+ void pick(Rectangle2D pickArea, AffineTransform ltw, Vector retVec) throws SVGException
+ {
StyleAttribute styleAttrib = new StyleAttribute();
- if (getStyle(styleAttrib.setName("fill")) && getShape().contains(point))
+// if (getStyle(styleAttrib.setName("fill")) && getShape().contains(point))
+ if (ltw.createTransformedShape(getShape()).intersects(pickArea))
{
retVec.add(getPath(null));
}
diff --git a/src/main/java/com/kitfox/svg/app/SVGPlayer.java b/src/main/java/com/kitfox/svg/app/SVGPlayer.java
index 5a9a86b..d2c4b33 100644
--- a/src/main/java/com/kitfox/svg/app/SVGPlayer.java
+++ b/src/main/java/com/kitfox/svg/app/SVGPlayer.java
@@ -337,7 +337,7 @@ public class SVGPlayer extends javax.swing.JFrame
try
{
- URL url = new URL(urlStrn);
+ URL url = new URL(URLEncoder.encode(urlStrn, "UTF-8"));
loadURL(url);
}
catch (Exception e)
diff --git a/src/main/java/com/kitfox/svg/app/SVGViewer.java b/src/main/java/com/kitfox/svg/app/SVGViewer.java
index a9c7507..c991f35 100644
--- a/src/main/java/com/kitfox/svg/app/SVGViewer.java
+++ b/src/main/java/com/kitfox/svg/app/SVGViewer.java
@@ -290,7 +290,7 @@ is.close();
try
{
- URL url = new URL(urlStrn);
+ URL url = new URL(URLEncoder.encode(urlStrn, "UTF-8"));
loadURL(url);
}
catch (Exception e)
diff --git a/src/main/res/res/help/about/about.html b/src/main/res/res/help/about/about.html
index 06443bc..4f57e6c 100644
--- a/src/main/res/res/help/about/about.html
+++ b/src/main/res/res/help/about/about.html
@@ -13,7 +13,7 @@
http://svgsalamander.dev.java.net<br>
http://www.kitfox.com<br>
<br>
- Last built: 2007, July, 18 11:59<br>
+ Last built: 2007, July, 30 02:07<br>
</div>
</body>
</html>