You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by de...@apache.org on 2005/11/08 03:13:16 UTC
svn commit: r331670 - in /xmlgraphics/batik/trunk:
samples/tests/spec/scripting/ sources/org/apache/batik/dom/svg/
test-references/samples/tests/spec/scripting/
test-resources/org/apache/batik/test/
Author: deweese
Date: Mon Nov 7 18:13:00 2005
New Revision: 331670
URL: http://svn.apache.org/viewcvs?rev=331670&view=rev
Log:
Added Normalized Path support from Andres Toussaint, Thanks!
PR: 35773
Added:
xmlgraphics/batik/trunk/samples/tests/spec/scripting/normalizedPathTest.svg
- copied unchanged from r331665, xmlgraphics/batik/branches/svg11/samples/tests/spec/scripting/normalizedPathTest.svg
xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/AbstractSVGNormPathSegList.java
- copied unchanged from r331665, xmlgraphics/batik/branches/svg11/sources/org/apache/batik/dom/svg/AbstractSVGNormPathSegList.java
xmlgraphics/batik/trunk/test-references/samples/tests/spec/scripting/normalizedPathTest.png
- copied unchanged from r331665, xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/scripting/normalizedPathTest.png
Modified:
xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGOMAnimatedPathData.java
xmlgraphics/batik/trunk/test-resources/org/apache/batik/test/samplesRendering.xml
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGOMAnimatedPathData.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGOMAnimatedPathData.java?rev=331670&r1=331669&r2=331670&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGOMAnimatedPathData.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGOMAnimatedPathData.java Mon Nov 7 18:13:00 2005
@@ -27,7 +27,8 @@
* This class is the implementation of
* the SVGAnimatedPathData interface.
*
- * @author <a href="mailto:nicolas.socheleau@bitflash.com">Nicolas Socheleau</a>
+ * @author <a href="mailto:nicolas.socheleau@bitflash.com">Nicolas Socheleau</a>,
+ * <a href="mailto:andrest@world-affair.com">Andres Toussaint</a>
* @version $Id$
*/
public class SVGOMAnimatedPathData
@@ -60,6 +61,11 @@
protected AbstractSVGPathSegList pathSegs;
/**
+ * SVGNormPathSegList mapping the static 'd' attribute.
+ */
+ protected AbstractSVGNormPathSegList normalizedPathSegs;
+
+ /**
* Default value for the 'd' attribute.
*/
protected String defaultValue;
@@ -91,9 +97,30 @@
}
/**
+ * returns the SVGPathSegList mapping
+ * the normalized static 'd' attribute
+ * of the element.
+ * <p>A normalized path is composed only of
+ * ABSOLUTE Moveto, Lineto and Cubicto segments (M,L,C).
+ * Using this subset, you can preserve the path description
+ * with less segment types. Be aware that the normalized d
+ * attribute will be a larger String that the original.</p>
+ * <p>Relative values are transformed into Absoulte,
+ * Quadratic curves are promoted to Cubic curves, and
+ * Arcs are converted into one or more Cubic curves
+ * (one per quadrant).</p>
+ * <p>Modifications to the normalized SVGPathSegList will result
+ * in substituting the original path with a set of normalized path
+ * segments.
+ * </p>
+ *
+ * @return a path seg list containing the normalized version of the path.
*/
public SVGPathSegList getNormalizedPathSegList(){
- throw new RuntimeException("TODO : getNormalizedPathSegList() !!");
+ if ( normalizedPathSegs == null ){
+ normalizedPathSegs = new SVGOMNormalizedPathSegList();
+ }
+ return normalizedPathSegs;
}
@@ -117,6 +144,7 @@
public void attrAdded(Attr node, String newv) {
if (!changing && pathSegs != null) {
pathSegs.invalidate();
+ if (normalizedPathSegs != null) normalizedPathSegs.invalidate();
}
}
@@ -126,6 +154,7 @@
public void attrModified(Attr node, String oldv, String newv) {
if (!changing && pathSegs != null) {
pathSegs.invalidate();
+ if (normalizedPathSegs != null) normalizedPathSegs.invalidate();
}
}
@@ -135,6 +164,7 @@
public void attrRemoved(Attr node, String oldv) {
if (!changing && pathSegs != null) {
pathSegs.invalidate();
+ if (normalizedPathSegs != null) normalizedPathSegs.invalidate();
}
}
@@ -187,4 +217,57 @@
}
}
}
+
+
+ /**
+ * SVGPointList implementation for the
+ * static normalized 'points' attribute of the element.
+ * @author <a href="mailto:andrest@world-affair.com">Andres Toussaint</a>
+ */
+ public class SVGOMNormalizedPathSegList extends AbstractSVGNormPathSegList {
+
+ /**
+ * Create a DOMException.
+ */
+ protected DOMException createDOMException(short type,
+ String key,
+ Object[] args){
+ return element.createDOMException(type,key,args);
+ }
+
+ /**
+ * Create a SVGException.
+ */
+ protected SVGException createSVGException(short type,
+ String key,
+ Object[] args){
+
+ return ((SVGOMElement)element).createSVGException(type,key,args);
+ }
+
+ /**
+ * Retrieve the normalized value of the attribute 'points'.
+ */
+ protected String getValueAsString() throws SVGException {
+ Attr attr = element.getAttributeNodeNS(namespaceURI, localName);
+ if (attr == null) {
+ return defaultValue;
+ }
+ return attr.getValue();
+ }
+
+ /**
+ * Set the value of the attribute 'points'
+ */
+ protected void setAttributeValue(String value){
+ try{
+ changing = true;
+ element.setAttributeNS(namespaceURI, localName, value);
+ }
+ finally{
+ changing = false;
+ }
+ }
+ }
+
}
Modified: xmlgraphics/batik/trunk/test-resources/org/apache/batik/test/samplesRendering.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/test-resources/org/apache/batik/test/samplesRendering.xml?rev=331670&r1=331669&r2=331670&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/test-resources/org/apache/batik/test/samplesRendering.xml (original)
+++ xmlgraphics/batik/trunk/test-resources/org/apache/batik/test/samplesRendering.xml Mon Nov 7 18:13:00 2005
@@ -375,6 +375,7 @@
<test id="samples/tests/spec/scripting/intersectionList2.svg" />
<test id="samples/tests/spec/scripting/line.svg" />
<test id="samples/tests/spec/scripting/nestedsvg.svg" />
+ <test id="samples/tests/spec/scripting/normalizedPathTest.svg" />
<test id="samples/tests/spec/scripting/paintType.svg" />
<test id="samples/tests/spec/scripting/path.svg" />
<test id="samples/tests/spec/scripting/pathLength.svg" />