summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/kitfox/svg/Filter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/kitfox/svg/Filter.java')
-rw-r--r--src/main/java/com/kitfox/svg/Filter.java150
1 files changed, 99 insertions, 51 deletions
diff --git a/src/main/java/com/kitfox/svg/Filter.java b/src/main/java/com/kitfox/svg/Filter.java
index 590fe60..d55c643 100644
--- a/src/main/java/com/kitfox/svg/Filter.java
+++ b/src/main/java/com/kitfox/svg/Filter.java
@@ -33,44 +33,46 @@
*
* Created on March 18, 2004, 6:52 AM
*/
-
package com.kitfox.svg;
-import java.awt.geom.*;
-import java.net.*;
-import java.util.*;
-
-import com.kitfox.svg.xml.*;
+import com.kitfox.svg.xml.StyleAttribute;
+import java.awt.geom.Point2D;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
/**
* @author Mark McKay
* @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
*/
-public class Filter extends SVGElement
+public class Filter extends SVGElement
{
+
+ public static final String TAG_NAME = "filter";
public static final int FU_OBJECT_BOUNDING_BOX = 0;
public static final int FU_USER_SPACE_ON_USE = 1;
-
protected int filterUnits = FU_OBJECT_BOUNDING_BOX;
-
public static final int PU_OBJECT_BOUNDING_BOX = 0;
public static final int PU_USER_SPACE_ON_USE = 1;
-
protected int primitiveUnits = PU_OBJECT_BOUNDING_BOX;
-
float x = 0f;
float y = 0f;
float width = 1f;
float height = 1f;
-
Point2D filterRes = new Point2D.Double();
-
URL href = null;
-
final ArrayList filterEffects = new ArrayList();
- /** Creates a new instance of FillElement */
- public Filter() {
+ /**
+ * Creates a new instance of FillElement
+ */
+ public Filter()
+ {
+ }
+
+ public String getTagName()
+ {
+ return TAG_NAME;
}
/**
@@ -86,55 +88,92 @@ public class Filter extends SVGElement
filterEffects.add(child);
}
}
-
+
protected void build() throws SVGException
{
super.build();
-
+
StyleAttribute sty = new StyleAttribute();
String strn;
-
+
if (getPres(sty.setName("filterUnits")))
{
strn = sty.getStringValue().toLowerCase();
- if (strn.equals("userspaceonuse")) filterUnits = FU_USER_SPACE_ON_USE;
- else filterUnits = FU_OBJECT_BOUNDING_BOX;
+ if (strn.equals("userspaceonuse"))
+ {
+ filterUnits = FU_USER_SPACE_ON_USE;
+ } else
+ {
+ filterUnits = FU_OBJECT_BOUNDING_BOX;
+ }
}
if (getPres(sty.setName("primitiveUnits")))
{
strn = sty.getStringValue().toLowerCase();
- if (strn.equals("userspaceonuse")) primitiveUnits = PU_USER_SPACE_ON_USE;
- else primitiveUnits = PU_OBJECT_BOUNDING_BOX;
+ if (strn.equals("userspaceonuse"))
+ {
+ primitiveUnits = PU_USER_SPACE_ON_USE;
+ } else
+ {
+ primitiveUnits = PU_OBJECT_BOUNDING_BOX;
+ }
}
- if (getPres(sty.setName("x"))) x = sty.getFloatValueWithUnits();
+ if (getPres(sty.setName("x")))
+ {
+ x = sty.getFloatValueWithUnits();
+ }
- if (getPres(sty.setName("y"))) y = sty.getFloatValueWithUnits();
+ if (getPres(sty.setName("y")))
+ {
+ y = sty.getFloatValueWithUnits();
+ }
- if (getPres(sty.setName("width"))) width = sty.getFloatValueWithUnits();
+ if (getPres(sty.setName("width")))
+ {
+ width = sty.getFloatValueWithUnits();
+ }
- if (getPres(sty.setName("height"))) height = sty.getFloatValueWithUnits();
+ if (getPres(sty.setName("height")))
+ {
+ height = sty.getFloatValueWithUnits();
+ }
- try {
+ try
+ {
if (getPres(sty.setName("xlink:href")))
{
URI src = sty.getURIValue(getXMLBase());
href = src.toURL();
}
- }
- catch (Exception e)
+ } catch (Exception e)
{
throw new SVGException(e);
}
}
- public float getX() { return x; }
- public float getY() { return y; }
- public float getWidth() { return width; }
- public float getHeight() { return height; }
-
+ public float getX()
+ {
+ return x;
+ }
+
+ public float getY()
+ {
+ return y;
+ }
+
+ public float getWidth()
+ {
+ return width;
+ }
+
+ public float getHeight()
+ {
+ return height;
+ }
+
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
@@ -142,7 +181,7 @@ public class Filter extends SVGElement
//Get current values for parameters
StyleAttribute sty = new StyleAttribute();
boolean stateChange = false;
-
+
if (getPres(sty.setName("x")))
{
float newVal = sty.getFloatValueWithUnits();
@@ -152,7 +191,7 @@ public class Filter extends SVGElement
stateChange = true;
}
}
-
+
if (getPres(sty.setName("y")))
{
float newVal = sty.getFloatValueWithUnits();
@@ -162,7 +201,7 @@ public class Filter extends SVGElement
stateChange = true;
}
}
-
+
if (getPres(sty.setName("width")))
{
float newVal = sty.getFloatValueWithUnits();
@@ -172,7 +211,7 @@ public class Filter extends SVGElement
stateChange = true;
}
}
-
+
if (getPres(sty.setName("height")))
{
float newVal = sty.getFloatValueWithUnits();
@@ -182,21 +221,21 @@ public class Filter extends SVGElement
stateChange = true;
}
}
-
- try {
+
+ try
+ {
if (getPres(sty.setName("xlink:href")))
{
URI src = sty.getURIValue(getXMLBase());
URL newVal = src.toURL();
-
+
if (!newVal.equals(href))
{
href = newVal;
stateChange = true;
}
}
- }
- catch (Exception e)
+ } catch (Exception e)
{
throw new SVGException(e);
}
@@ -205,8 +244,13 @@ public class Filter extends SVGElement
{
int newVal;
String strn = sty.getStringValue().toLowerCase();
- if (strn.equals("userspaceonuse")) newVal = FU_USER_SPACE_ON_USE;
- else newVal = FU_OBJECT_BOUNDING_BOX;
+ if (strn.equals("userspaceonuse"))
+ {
+ newVal = FU_USER_SPACE_ON_USE;
+ } else
+ {
+ newVal = FU_OBJECT_BOUNDING_BOX;
+ }
if (newVal != filterUnits)
{
filterUnits = newVal;
@@ -218,8 +262,13 @@ public class Filter extends SVGElement
{
int newVal;
String strn = sty.getStringValue().toLowerCase();
- if (strn.equals("userspaceonuse")) newVal = PU_USER_SPACE_ON_USE;
- else newVal = PU_OBJECT_BOUNDING_BOX;
+ if (strn.equals("userspaceonuse"))
+ {
+ newVal = PU_USER_SPACE_ON_USE;
+ } else
+ {
+ newVal = PU_OBJECT_BOUNDING_BOX;
+ }
if (newVal != filterUnits)
{
primitiveUnits = newVal;
@@ -227,9 +276,8 @@ public class Filter extends SVGElement
}
}
-
-
+
+
return stateChange;
}
}
-