You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2013/10/08 16:03:24 UTC
[09/62] [abbrv] [partial] Merged Apache Flex 4.9.0 release branch
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGTextPathElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGTextPathElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGTextPathElementBridge.java
index a33c5bd..3e1260f 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGTextPathElementBridge.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGTextPathElementBridge.java
@@ -1,10 +1,11 @@
/*
- Copyright 2001,2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@@ -32,9 +33,9 @@ import org.w3c.dom.Element;
* Bridge class for the <textPath> element.
*
* @author <a href="mailto:bella.robinson@cmis.csiro.au">Bella Robinson</a>
- * @version $Id: SVGTextPathElementBridge.java,v 1.8 2005/03/03 01:19:53 deweese Exp $
+ * @version $Id: SVGTextPathElementBridge.java 501922 2007-01-31 17:47:47Z dvholten $
*/
-public class SVGTextPathElementBridge extends AbstractSVGBridge
+public class SVGTextPathElementBridge extends AnimatableGenericSVGBridge
implements ErrorConstants {
/**
@@ -49,6 +50,10 @@ public class SVGTextPathElementBridge extends AbstractSVGBridge
return SVG_TEXT_PATH_TAG;
}
+ public void handleElement(BridgeContext ctx, Element e) {
+ // We don't want to take over from the text content element.
+ }
+
/**
* Creates a TextPath object that represents the path along which the text
* is to be rendered.
@@ -64,13 +69,13 @@ public class SVGTextPathElementBridge extends AbstractSVGBridge
String uri = XLinkSupport.getXLinkHref(textPathElement);
Element pathElement = ctx.getReferencedElement(textPathElement, uri);
- if ((pathElement == null) ||
+ if ((pathElement == null) ||
(!SVG_NAMESPACE_URI.equals(pathElement.getNamespaceURI())) ||
(!pathElement.getLocalName().equals(SVG_PATH_TAG))) {
// couldn't find the referenced element
// or the referenced element was not a path
- throw new BridgeException(textPathElement, ERR_URI_BAD_TARGET,
- new Object[] {uri});
+ throw new BridgeException(ctx, textPathElement, ERR_URI_BAD_TARGET,
+ new Object[] {uri});
}
// construct a shape for the referenced path element
@@ -83,14 +88,15 @@ public class SVGTextPathElementBridge extends AbstractSVGBridge
PathParser pathParser = new PathParser();
pathParser.setPathHandler(app);
pathParser.parse(s);
- } catch (ParseException ex) {
- throw new BridgeException(pathElement, ERR_ATTRIBUTE_VALUE_MALFORMED,
- new Object[] {SVG_D_ATTRIBUTE});
+ } catch (ParseException pEx ) {
+ throw new BridgeException
+ (ctx, pathElement, pEx, ERR_ATTRIBUTE_VALUE_MALFORMED,
+ new Object[] {SVG_D_ATTRIBUTE});
} finally {
pathShape = app.getShape();
}
} else {
- throw new BridgeException(pathElement, ERR_ATTRIBUTE_MISSING,
+ throw new BridgeException(ctx, pathElement, ERR_ATTRIBUTE_MISSING,
new Object[] {SVG_D_ATTRIBUTE});
}
@@ -98,8 +104,9 @@ public class SVGTextPathElementBridge extends AbstractSVGBridge
// to the path shape
s = pathElement.getAttributeNS(null, SVG_TRANSFORM_ATTRIBUTE);
if (s.length() != 0) {
- AffineTransform tr = SVGUtilities.convertTransform(pathElement,
- SVG_TRANSFORM_ATTRIBUTE, s);
+ AffineTransform tr =
+ SVGUtilities.convertTransform(pathElement,
+ SVG_TRANSFORM_ATTRIBUTE, s, ctx);
pathShape = tr.createTransformedShape(pathShape);
}
@@ -110,7 +117,7 @@ public class SVGTextPathElementBridge extends AbstractSVGBridge
s = textPathElement.getAttributeNS(null, SVG_START_OFFSET_ATTRIBUTE);
if (s.length() > 0) {
float startOffset = 0;
- int percentIndex = s.indexOf("%");
+ int percentIndex = s.indexOf('%');
if (percentIndex != -1) {
// its a percentage of the length of the path
float pathLength = textPath.lengthOfPath();
@@ -122,8 +129,9 @@ public class SVGTextPathElementBridge extends AbstractSVGBridge
startOffsetPercent = -1;
}
if (startOffsetPercent < 0) {
- throw new BridgeException(textPathElement, ERR_ATTRIBUTE_VALUE_MALFORMED,
- new Object[] {SVG_START_OFFSET_ATTRIBUTE, s});
+ throw new BridgeException
+ (ctx, textPathElement, ERR_ATTRIBUTE_VALUE_MALFORMED,
+ new Object[] {SVG_START_OFFSET_ATTRIBUTE, s});
}
startOffset = (float)(startOffsetPercent * pathLength/100.0);
@@ -137,7 +145,4 @@ public class SVGTextPathElementBridge extends AbstractSVGBridge
return textPath;
}
-
-
}
-
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGTitleElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGTitleElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGTitleElementBridge.java
index aa92f5a..c9e349a 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGTitleElementBridge.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGTitleElementBridge.java
@@ -1,10 +1,11 @@
/*
- Copyright 2001,2005 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@@ -17,14 +18,12 @@
*/
package org.apache.flex.forks.batik.bridge;
-import org.w3c.dom.Element;
-
/**
* Bridge class for the <title> element.
*
* @author <a href="mailto:vhardy@apache.org">Vincent Hardy</a>
* @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
- * @version $Id: SVGTitleElementBridge.java,v 1.4 2005/02/27 02:08:51 deweese Exp $
+ * @version $Id: SVGTitleElementBridge.java 475477 2006-11-15 22:44:28Z cam $
*/
public class SVGTitleElementBridge extends SVGDescriptiveElementBridge {
@@ -45,4 +44,3 @@ public class SVGTitleElementBridge extends SVGDescriptiveElementBridge {
*/
public Bridge getInstance() { return new SVGTitleElementBridge(); }
}
-
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGUseElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGUseElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGUseElementBridge.java
index 54f3e54..1837c7c 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGUseElementBridge.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGUseElementBridge.java
@@ -1,10 +1,11 @@
/*
- Copyright 2001-2004 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@@ -22,37 +23,46 @@ import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
-import org.apache.flex.forks.batik.css.engine.CSSEngine;
-import org.apache.flex.forks.batik.dom.svg.SVGOMCSSImportedElementRoot;
+import org.apache.flex.forks.batik.dom.events.NodeEventTarget;
+import org.apache.flex.forks.batik.dom.svg.AbstractSVGAnimatedLength;
+import org.apache.flex.forks.batik.dom.svg.AnimatedLiveAttributeValue;
+import org.apache.flex.forks.batik.dom.svg.LiveAttributeException;
+import org.apache.flex.forks.batik.dom.svg.SVGOMAnimatedLength;
import org.apache.flex.forks.batik.dom.svg.SVGOMDocument;
import org.apache.flex.forks.batik.dom.svg.SVGOMUseElement;
-import org.apache.flex.forks.batik.dom.util.XLinkSupport;
+import org.apache.flex.forks.batik.dom.svg.SVGOMUseShadowRoot;
import org.apache.flex.forks.batik.gvt.CompositeGraphicsNode;
import org.apache.flex.forks.batik.gvt.GraphicsNode;
+import org.apache.flex.forks.batik.util.XMLConstants;
+
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
-import org.w3c.dom.events.EventTarget;
-import org.w3c.dom.events.MutationEvent;
+import org.w3c.dom.svg.SVGTransformable;
+import org.w3c.dom.svg.SVGUseElement;
/**
* Bridge class for the <use> element.
*
* @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
- * @version $Id: SVGUseElementBridge.java,v 1.47 2005/03/03 01:19:53 deweese Exp $
+ * @version $Id: SVGUseElementBridge.java 580678 2007-09-30 05:10:20Z cam $
*/
public class SVGUseElementBridge extends AbstractGraphicsNodeBridge {
- /*
+
+ /**
* Used to handle mutation of the referenced content. This is
* only used in dynamic context and only for reference to local
* content.
*/
protected ReferencedElementMutationListener l;
- protected BridgeContext subCtx=null;
+ /**
+ * The bridge context for the referenced document.
+ */
+ protected BridgeContext subCtx;
/**
* Constructs a new bridge for the <use> element.
@@ -86,6 +96,7 @@ public class SVGUseElementBridge extends AbstractGraphicsNodeBridge {
return null;
CompositeGraphicsNode gn = buildCompositeGraphicsNode(ctx, e, null);
+ associateSVGContext(ctx, e, gn);
return gn;
}
@@ -101,41 +112,40 @@ public class SVGUseElementBridge extends AbstractGraphicsNodeBridge {
* before appending new content.
*/
public CompositeGraphicsNode buildCompositeGraphicsNode
- (BridgeContext ctx, Element e,
- CompositeGraphicsNode gn) {
+ (BridgeContext ctx, Element e, CompositeGraphicsNode gn) {
// get the referenced element
- String uri = XLinkSupport.getXLinkHref(e);
+ SVGOMUseElement ue = (SVGOMUseElement) e;
+ String uri = ue.getHref().getAnimVal();
if (uri.length() == 0) {
- throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
+ throw new BridgeException(ctx, e, ERR_ATTRIBUTE_MISSING,
new Object[] {"xlink:href"});
}
Element refElement = ctx.getReferencedElement(e, uri);
- SVGOMDocument document
- = (SVGOMDocument)e.getOwnerDocument();
- SVGOMDocument refDocument
- = (SVGOMDocument)refElement.getOwnerDocument();
+ SVGOMDocument document, refDocument;
+ document = (SVGOMDocument)e.getOwnerDocument();
+ refDocument = (SVGOMDocument)refElement.getOwnerDocument();
boolean isLocal = (refDocument == document);
BridgeContext theCtx = ctx;
subCtx = null;
if (!isLocal) {
- CSSEngine eng = refDocument.getCSSEngine();
subCtx = (BridgeContext)refDocument.getCSSEngine().getCSSContext();
theCtx = subCtx;
}
// import or clone the referenced element in current document
- Element localRefElement =
- (Element)document.importNode(refElement, true, true);
+ Element localRefElement;
+ localRefElement = (Element)document.importNode(refElement, true, true);
if (SVG_SYMBOL_TAG.equals(localRefElement.getLocalName())) {
// The referenced 'symbol' and its contents are deep-cloned into
// the generated tree, with the exception that the 'symbol' is
// replaced by an 'svg'.
- Element svgElement
- = document.createElementNS(SVG_NAMESPACE_URI, SVG_SVG_TAG);
+ Element svgElement = document.createElementNS(SVG_NAMESPACE_URI,
+ SVG_SVG_TAG);
+
// move the attributes from <symbol> to the <svg> element
NamedNodeMap attrs = localRefElement.getAttributes();
int len = attrs.getLength();
@@ -159,37 +169,43 @@ public class SVGUseElementBridge extends AbstractGraphicsNodeBridge {
// generated tree. If attributes width and/or height are provided
// on the 'use' element, then these values will override the
// corresponding attributes on the 'svg' in the generated tree.
- String wStr = e.getAttributeNS(null, SVG_WIDTH_ATTRIBUTE);
- if (wStr.length() != 0) {
- localRefElement.setAttributeNS
- (null, SVG_WIDTH_ATTRIBUTE, wStr);
- }
- String hStr = e.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE);
- if (hStr.length() != 0) {
- localRefElement.setAttributeNS
- (null, SVG_HEIGHT_ATTRIBUTE, hStr);
+ try {
+ SVGOMAnimatedLength al = (SVGOMAnimatedLength) ue.getWidth();
+ if (al.isSpecified()) {
+ localRefElement.setAttributeNS
+ (null, SVG_WIDTH_ATTRIBUTE,
+ al.getAnimVal().getValueAsString());
+ }
+ al = (SVGOMAnimatedLength) ue.getHeight();
+ if (al.isSpecified()) {
+ localRefElement.setAttributeNS
+ (null, SVG_HEIGHT_ATTRIBUTE,
+ al.getAnimVal().getValueAsString());
+ }
+ } catch (LiveAttributeException ex) {
+ throw new BridgeException(ctx, ex);
}
}
// attach the referenced element to the current document
- SVGOMCSSImportedElementRoot root;
- root = new SVGOMCSSImportedElementRoot(document, e, isLocal);
+ SVGOMUseShadowRoot root;
+ root = new SVGOMUseShadowRoot(document, e, isLocal);
root.appendChild(localRefElement);
if (gn == null) {
gn = new CompositeGraphicsNode();
+ associateSVGContext(ctx, e, node);
} else {
int s = gn.size();
for (int i=0; i<s; i++)
gn.remove(0);
}
- SVGOMUseElement ue = (SVGOMUseElement)e;
- Node oldRoot = ue.getCSSImportedElementRoot();
+ Node oldRoot = ue.getCSSFirstChild();
if (oldRoot != null) {
disposeTree(oldRoot);
}
- ue.setCSSImportedElementRoot(root);
+ ue.setUseShadowTree(root);
Element g = localRefElement;
@@ -203,7 +219,7 @@ public class SVGUseElementBridge extends AbstractGraphicsNodeBridge {
gn.getChildren().add(refNode);
- gn.setTransform(computeTransform(e, ctx));
+ gn.setTransform(computeTransform((SVGTransformable) e, ctx));
// set an affine transform to take into account the (x, y)
// coordinates of the <use> element
@@ -223,11 +239,19 @@ public class SVGUseElementBridge extends AbstractGraphicsNodeBridge {
if (l != null) {
// Remove event listeners
- EventTarget target = l.target;
- target.removeEventListener("DOMAttrModified", l, true);
- target.removeEventListener("DOMNodeInserted", l, true);
- target.removeEventListener("DOMNodeRemoved", l, true);
- target.removeEventListener("DOMCharacterDataModified",l, true);
+ NodeEventTarget target = l.target;
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMAttrModified",
+ l, true);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeInserted",
+ l, true);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeRemoved",
+ l, true);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMCharacterDataModified",
+ l, true);
l = null;
}
@@ -238,21 +262,36 @@ public class SVGUseElementBridge extends AbstractGraphicsNodeBridge {
if (isLocal && ctx.isDynamic()) {
l = new ReferencedElementMutationListener();
- EventTarget target = (EventTarget)refElement;
+ NodeEventTarget target = (NodeEventTarget)refElement;
l.target = target;
- target.addEventListener("DOMAttrModified", l, true);
- theCtx.storeEventListener(target, "DOMAttrModified", l, true);
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMAttrModified",
+ l, true, null);
+ theCtx.storeEventListenerNS
+ (target, XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMAttrModified",
+ l, true);
- target.addEventListener("DOMNodeInserted", l, true);
- theCtx.storeEventListener(target, "DOMNodeInserted", l, true);
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeInserted",
+ l, true, null);
+ theCtx.storeEventListenerNS
+ (target, XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeInserted",
+ l, true);
- target.addEventListener("DOMNodeRemoved", l, true);
- theCtx.storeEventListener(target, "DOMNodeRemoved", l, true);
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeRemoved",
+ l, true, null);
+ theCtx.storeEventListenerNS
+ (target, XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeRemoved",
+ l, true);
- target.addEventListener("DOMCharacterDataModified", l, true);
- theCtx.storeEventListener
- (target, "DOMCharacterDataModified", l, true);
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMCharacterDataModified",
+ l, true, null);
+ theCtx.storeEventListenerNS
+ (target, XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMCharacterDataModified",
+ l, true);
}
return gn;
@@ -261,17 +300,25 @@ public class SVGUseElementBridge extends AbstractGraphicsNodeBridge {
public void dispose() {
if (l != null) {
// Remove event listeners
- EventTarget target = l.target;
- target.removeEventListener("DOMAttrModified", l, true);
- target.removeEventListener("DOMNodeInserted", l, true);
- target.removeEventListener("DOMNodeRemoved", l, true);
- target.removeEventListener("DOMCharacterDataModified",l, true);
+ NodeEventTarget target = l.target;
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMAttrModified",
+ l, true);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeInserted",
+ l, true);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeRemoved",
+ l, true);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMCharacterDataModified",
+ l, true);
l = null;
}
SVGOMUseElement ue = (SVGOMUseElement)e;
- if ((ue != null) && (ue.getCSSImportedElementRoot() != null)) {
- disposeTree(ue.getCSSImportedElementRoot());
+ if (ue != null && ue.getCSSFirstChild() != null) {
+ disposeTree(ue.getCSSFirstChild());
}
super.dispose();
@@ -280,39 +327,30 @@ public class SVGUseElementBridge extends AbstractGraphicsNodeBridge {
}
/**
- * Computes the AffineTransform for the node
+ * Returns an {@link AffineTransform} that is the transformation to
+ * be applied to the node.
*/
- protected AffineTransform computeTransform(Element e, BridgeContext ctx) {
- UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e);
-
- // 'x' attribute - default is 0
- float x = 0;
- String s = e.getAttributeNS(null, SVG_X_ATTRIBUTE);
- if (s.length() != 0) {
- x = UnitProcessor.svgHorizontalCoordinateToUserSpace
- (s, SVG_X_ATTRIBUTE, uctx);
+ protected AffineTransform computeTransform(SVGTransformable e,
+ BridgeContext ctx) {
+ AffineTransform at = super.computeTransform(e, ctx);
+ SVGUseElement ue = (SVGUseElement) e;
+ try {
+ // 'x' attribute - default is 0
+ AbstractSVGAnimatedLength _x =
+ (AbstractSVGAnimatedLength) ue.getX();
+ float x = _x.getCheckedValue();
+
+ // 'y' attribute - default is 0
+ AbstractSVGAnimatedLength _y =
+ (AbstractSVGAnimatedLength) ue.getY();
+ float y = _y.getCheckedValue();
+
+ AffineTransform xy = AffineTransform.getTranslateInstance(x, y);
+ xy.preConcatenate(at);
+ return xy;
+ } catch (LiveAttributeException ex) {
+ throw new BridgeException(ctx, ex);
}
-
- // 'y' attribute - default is 0
- float y = 0;
- s = e.getAttributeNS(null, SVG_Y_ATTRIBUTE);
- if (s.length() != 0) {
- y = UnitProcessor.svgVerticalCoordinateToUserSpace
- (s, SVG_Y_ATTRIBUTE, uctx);
- }
-
- // set an affine transform to take into account the (x, y)
- // coordinates of the <use> element
- s = e.getAttributeNS(null, SVG_TRANSFORM_ATTRIBUTE);
- AffineTransform at = AffineTransform.getTranslateInstance(x, y);
-
- // 'transform'
- if (s.length() != 0) {
- at.preConcatenate
- (SVGUtilities.convertTransform(e, SVG_TRANSFORM_ATTRIBUTE, s));
- }
-
- return at;
}
/**
@@ -320,7 +358,7 @@ public class SVGUseElementBridge extends AbstractGraphicsNodeBridge {
* implementation.
*/
protected GraphicsNode instantiateGraphicsNode() {
- return null; // nothing to do, createGraphicsNode is fully overriden
+ return null; // nothing to do, createGraphicsNode is fully overridden
}
/**
@@ -345,10 +383,14 @@ public class SVGUseElementBridge extends AbstractGraphicsNodeBridge {
super.buildGraphicsNode(ctx, e, node);
if (ctx.isInteractive()) {
- EventTarget target = (EventTarget)e;
+ NodeEventTarget target = (NodeEventTarget)e;
EventListener l = new CursorMouseOverListener(ctx);
- target.addEventListener(SVG_EVENT_MOUSEOVER, l, false);
- ctx.storeEventListener(target, SVG_EVENT_MOUSEOVER, l, false);
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEOVER,
+ l, false, null);
+ ctx.storeEventListenerNS
+ (target, XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEOVER,
+ l, false);
}
}
@@ -382,8 +424,8 @@ public class SVGUseElementBridge extends AbstractGraphicsNodeBridge {
/**
* Used to handle modifications to the referenced content
*/
- public class ReferencedElementMutationListener implements EventListener {
- EventTarget target;
+ protected class ReferencedElementMutationListener implements EventListener {
+ protected NodeEventTarget target;
public void handleEvent(Event evt) {
// We got a mutation in the referenced content. We need to
@@ -398,25 +440,29 @@ public class SVGUseElementBridge extends AbstractGraphicsNodeBridge {
// BridgeUpdateHandler implementation //////////////////////////////////
/**
- * Invoked when an MutationEvent of type 'DOMAttrModified' is fired.
+ * Invoked when the animated value of an animatable attribute has changed.
*/
- public void handleDOMAttrModifiedEvent(MutationEvent evt) {
- String attrName = evt.getAttrName();
- Node evtNode = evt.getRelatedNode();
-
- if ((evtNode.getNamespaceURI() == null) &&
- (attrName.equals(SVG_X_ATTRIBUTE) ||
- attrName.equals(SVG_Y_ATTRIBUTE) ||
- attrName.equals(SVG_TRANSFORM_ATTRIBUTE))) {
- node.setTransform(computeTransform(e, ctx));
- handleGeometryChanged();
- } else if (((evtNode.getNamespaceURI() == null) &&
- (attrName.equals(SVG_WIDTH_ATTRIBUTE) ||
- attrName.equals(SVG_HEIGHT_ATTRIBUTE))) ||
- (( XLinkSupport.XLINK_NAMESPACE_URI.equals
- (evtNode.getNamespaceURI()) ) &&
- SVG_HREF_ATTRIBUTE.equals(evtNode.getLocalName()))) {
- buildCompositeGraphicsNode(ctx, e, (CompositeGraphicsNode)node);
+ public void handleAnimatedAttributeChanged
+ (AnimatedLiveAttributeValue alav) {
+ try {
+ String ns = alav.getNamespaceURI();
+ String ln = alav.getLocalName();
+ if (ns == null
+ && (ln.equals(SVG_X_ATTRIBUTE)
+ || ln.equals(SVG_Y_ATTRIBUTE)
+ || ln.equals(SVG_TRANSFORM_ATTRIBUTE))) {
+ node.setTransform(computeTransform((SVGTransformable) e, ctx));
+ handleGeometryChanged();
+ } else if (ns == null
+ && (ln.equals(SVG_WIDTH_ATTRIBUTE)
+ || ln.equals(SVG_HEIGHT_ATTRIBUTE))
+ || ns.equals(XLINK_NAMESPACE_URI)
+ && (ln.equals(XLINK_HREF_ATTRIBUTE))) {
+ buildCompositeGraphicsNode(ctx, e, (CompositeGraphicsNode)node);
+ }
+ } catch (LiveAttributeException ex) {
+ throw new BridgeException(ctx, ex);
}
+ super.handleAnimatedAttributeChanged(alav);
}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGUtilities.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGUtilities.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGUtilities.java
index b91aed8..5f24625 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGUtilities.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGUtilities.java
@@ -1,10 +1,11 @@
/*
- Copyright 2001-2004 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@@ -27,28 +28,30 @@ import java.util.List;
import java.util.StringTokenizer;
import org.apache.flex.forks.batik.css.engine.CSSEngine;
-import org.apache.flex.forks.batik.dom.svg.SVGOMDocument;
+import org.apache.flex.forks.batik.dom.AbstractNode;
import org.apache.flex.forks.batik.dom.util.XLinkSupport;
import org.apache.flex.forks.batik.dom.util.XMLSupport;
import org.apache.flex.forks.batik.gvt.GraphicsNode;
import org.apache.flex.forks.batik.parser.AWTTransformProducer;
+import org.apache.flex.forks.batik.parser.ClockHandler;
+import org.apache.flex.forks.batik.parser.ClockParser;
import org.apache.flex.forks.batik.parser.ParseException;
import org.apache.flex.forks.batik.util.ParsedURL;
import org.apache.flex.forks.batik.util.SVG12Constants;
import org.apache.flex.forks.batik.util.SVGConstants;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.w3c.flex.forks.dom.svg.SVGDocument;
-import org.w3c.flex.forks.dom.svg.SVGElement;
-import org.w3c.flex.forks.dom.svg.SVGLangSpace;
-import org.w3c.flex.forks.dom.svg.SVGNumberList;
+import org.w3c.dom.svg.SVGDocument;
+import org.w3c.dom.svg.SVGElement;
+import org.w3c.dom.svg.SVGLangSpace;
+import org.w3c.dom.svg.SVGNumberList;
/**
* A collection of utility methods for SVG.
*
* @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: SVGUtilities.java,v 1.32 2005/03/27 08:58:30 cam Exp $
+ * @version $Id: SVGUtilities.java 594740 2007-11-14 02:55:05Z cam $
*/
public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
@@ -62,19 +65,16 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
////////////////////////////////////////////////////////////////////////
/**
- * Returns the node imported by the given node, or null.
- */
- public static Node getImportedChild(Node n) {
- return CSSEngine.getImportedChild(n);
- }
-
- /**
* Returns the logical parent element of the given element.
* The parent element of a used element is the <use> element
* which reference it.
*/
public static Element getParentElement(Element elt) {
- return CSSEngine.getParentElement(elt);
+ Node n = CSSEngine.getCSSParentNode(elt);
+ while (n != null && n.getNodeType() != Node.ELEMENT_NODE) {
+ n = CSSEngine.getCSSParentNode(n);
+ }
+ return (Element) n;
}
/**
@@ -86,7 +86,7 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
if (n == 0) {
return null;
}
- float fl[] = new float[n];
+ float[] fl = new float[n];
for (int i=0; i < n; i++) {
fl[i] = l.getItem(i).getValue();
}
@@ -260,31 +260,27 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
if (uriStr.length() == 0) { // exit if no more xlink:href
return "";
}
- SVGDocument svgDoc = (SVGDocument)e.getOwnerDocument();
- String baseURI = ((SVGOMDocument)svgDoc).getURL();
-
+ String baseURI = ((AbstractNode) e).getBaseURI();
ParsedURL purl = new ParsedURL(baseURI, uriStr);
- if (!purl.complete())
- throw new BridgeException(e, ERR_URI_MALFORMED,
- new Object[] {uriStr});
Iterator iter = refs.iterator();
while (iter.hasNext()) {
- if (purl.equals(iter.next()))
+ if (purl.equals(iter.next()))
throw new BridgeException
- (e, ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES,
+ (ctx, e, ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES,
new Object[] {uriStr});
}
try {
- URIResolver resolver = new URIResolver(svgDoc, loader);
+ SVGDocument svgDoc = (SVGDocument)e.getOwnerDocument();
+ URIResolver resolver = ctx.createURIResolver(svgDoc, loader);
e = resolver.getElement(purl.toString(), e);
refs.add(purl);
- } catch(IOException ex) {
- throw new BridgeException(e, ERR_URI_IO,
+ } catch(IOException ioEx ) {
+ throw new BridgeException(ctx, e, ioEx, ERR_URI_IO,
new Object[] {uriStr});
- } catch(SecurityException ex) {
- throw new BridgeException(e, ERR_URI_UNSECURE,
+ } catch(SecurityException secEx ) {
+ throw new BridgeException(ctx, e, secEx, ERR_URI_UNSECURE,
new Object[] {uriStr});
}
}
@@ -326,7 +322,7 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
(yStr, yAttr, uctx);
break;
default:
- throw new Error(); // can't be reached
+ throw new IllegalArgumentException("Invalid unit type");
}
return new Point2D.Float(x, y);
}
@@ -346,12 +342,12 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
UnitProcessor.Context uctx) {
switch (unitsType) {
case OBJECT_BOUNDING_BOX:
- return UnitProcessor.svgOtherLengthToObjectBoundingBox
+ return UnitProcessor.svgOtherLengthToObjectBoundingBox
(length, attr, uctx);
case USER_SPACE_ON_USE:
return UnitProcessor.svgOtherLengthToUserSpace(length, attr, uctx);
default:
- throw new Error(); // can't be reached
+ throw new IllegalArgumentException("Invalid unit type");
}
}
@@ -401,7 +397,7 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
unitsType = OBJECT_BOUNDING_BOX;
} else {
unitsType = parseCoordinateSystem
- (maskElement, SVG_MASK_UNITS_ATTRIBUTE, units);
+ (maskElement, SVG_MASK_UNITS_ATTRIBUTE, units, ctx);
}
// resolve units in the (referenced) maskedElement's coordinate system
@@ -451,15 +447,17 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
String wStr = getChainableAttributeNS
(patternElement, null, SVG_WIDTH_ATTRIBUTE, ctx);
if (wStr.length() == 0) {
- throw new BridgeException(patternElement, ERR_ATTRIBUTE_MISSING,
- new Object[] {SVG_WIDTH_ATTRIBUTE});
+ throw new BridgeException
+ (ctx, patternElement, ERR_ATTRIBUTE_MISSING,
+ new Object[] {SVG_WIDTH_ATTRIBUTE});
}
// 'height' attribute - required
String hStr = getChainableAttributeNS
(patternElement, null, SVG_HEIGHT_ATTRIBUTE, ctx);
if (hStr.length() == 0) {
- throw new BridgeException(patternElement, ERR_ATTRIBUTE_MISSING,
- new Object[] {SVG_HEIGHT_ATTRIBUTE});
+ throw new BridgeException
+ (ctx, patternElement, ERR_ATTRIBUTE_MISSING,
+ new Object[] {SVG_HEIGHT_ATTRIBUTE});
}
// 'patternUnits' attribute - default is 'objectBoundingBox'
short unitsType;
@@ -469,7 +467,7 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
unitsType = OBJECT_BOUNDING_BOX;
} else {
unitsType = parseCoordinateSystem
- (patternElement, SVG_PATTERN_UNITS_ATTRIBUTE, units);
+ (patternElement, SVG_PATTERN_UNITS_ATTRIBUTE, units, ctx);
}
// resolve units in the (referenced) paintedElement's coordinate system
@@ -503,21 +501,21 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
String s = getChainableAttributeNS
(filterElement, null, SVG_FILTER_RES_ATTRIBUTE, ctx);
Float [] vals = convertSVGNumberOptionalNumber
- (filterElement, SVG_FILTER_RES_ATTRIBUTE, s);
+ (filterElement, SVG_FILTER_RES_ATTRIBUTE, s, ctx);
if (filterRes[0] < 0 || filterRes[1] < 0) {
throw new BridgeException
- (filterElement, ERR_ATTRIBUTE_VALUE_MALFORMED,
+ (ctx, filterElement, ERR_ATTRIBUTE_VALUE_MALFORMED,
new Object[] {SVG_FILTER_RES_ATTRIBUTE, s});
}
-
+
if (vals[0] == null)
filterRes[0] = -1;
else {
filterRes[0] = vals[0].floatValue();
if (filterRes[0] < 0)
throw new BridgeException
- (filterElement, ERR_ATTRIBUTE_VALUE_MALFORMED,
+ (ctx, filterElement, ERR_ATTRIBUTE_VALUE_MALFORMED,
new Object[] {SVG_FILTER_RES_ATTRIBUTE, s});
}
@@ -527,7 +525,7 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
filterRes[1] = vals[1].floatValue();
if (filterRes[1] < 0)
throw new BridgeException
- (filterElement, ERR_ATTRIBUTE_VALUE_MALFORMED,
+ (ctx, filterElement, ERR_ATTRIBUTE_VALUE_MALFORMED,
new Object[] {SVG_FILTER_RES_ATTRIBUTE, s});
}
return filterRes;
@@ -538,12 +536,12 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
* second Number. It always returns an array of two Floats. If either
* or both values are not provided the entries are set to null
*/
- public static Float []
- convertSVGNumberOptionalNumber(Element elem,
- String attrName,
- String attrValue) {
+ public static Float[] convertSVGNumberOptionalNumber(Element elem,
+ String attrName,
+ String attrValue,
+ BridgeContext ctx) {
- Float [] ret = new Float[2];
+ Float[] ret = new Float[2];
if (attrValue.length() == 0)
return ret;
@@ -556,13 +554,13 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
if (tokens.hasMoreTokens()) {
throw new BridgeException
- (elem, ERR_ATTRIBUTE_VALUE_MALFORMED,
+ (ctx, elem, ERR_ATTRIBUTE_VALUE_MALFORMED,
new Object[] {attrName, attrValue});
}
- } catch (NumberFormatException ex) {
+ } catch (NumberFormatException nfEx ) {
throw new BridgeException
- (elem, ERR_ATTRIBUTE_VALUE_MALFORMED,
- new Object[] {attrName, attrValue, ex});
+ (ctx, elem, nfEx, ERR_ATTRIBUTE_VALUE_MALFORMED,
+ new Object[] {attrName, attrValue, nfEx });
}
return ret;
}
@@ -615,9 +613,22 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
unitsType = OBJECT_BOUNDING_BOX;
} else {
unitsType = parseCoordinateSystem
- (filterElement, SVG_FILTER_UNITS_ATTRIBUTE, units);
+ (filterElement, SVG_FILTER_UNITS_ATTRIBUTE, units, ctx);
}
+ // The last paragraph of section 7.11 in SVG 1.1 states that objects
+ // with zero width or height bounding boxes that use filters with
+ // filterUnits="objectBoundingBox" must not use the filter.
+ // TODO: Uncomment this after confirming this is the desired behaviour.
+ /*AbstractGraphicsNodeBridge bridge =
+ (AbstractGraphicsNodeBridge) ctx.getSVGContext(filteredElement);
+ if (unitsType == OBJECT_BOUNDING_BOX && bridge != null) {
+ Rectangle2D bbox = bridge.getBBox();
+ if (bbox != null && bbox.getWidth() == 0 || bbox.getHeight() == 0) {
+ return null;
+ }
+ }*/
+
// resolve units in the (referenced) filteredElement's
// coordinate system
UnitProcessor.Context uctx
@@ -634,19 +645,19 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
// Account for region padding
//
units = getChainableAttributeNS
- (filterElement, null,
+ (filterElement, null,
SVG12Constants.SVG_FILTER_MARGINS_UNITS_ATTRIBUTE, ctx);
if (units.length() == 0) {
// Default to user space on use for margins, not objectBoundingBox
unitsType = USER_SPACE_ON_USE;
} else {
unitsType = parseCoordinateSystem
- (filterElement,
- SVG12Constants.SVG_FILTER_MARGINS_UNITS_ATTRIBUTE, units);
+ (filterElement,
+ SVG12Constants.SVG_FILTER_MARGINS_UNITS_ATTRIBUTE, units, ctx);
}
// 'batik:dx' attribute - default is 0
- String dxStr = filterElement.getAttributeNS(null,
+ String dxStr = filterElement.getAttributeNS(null,
SVG12Constants.SVG_MX_ATRIBUTE);
if (dxStr.length() == 0) {
dxStr = SVG12Constants.SVG_FILTER_MX_DEFAULT_VALUE;
@@ -666,7 +677,7 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
if (dhStr.length() == 0) {
dhStr = SVG12Constants.SVG_FILTER_MH_DEFAULT_VALUE;
}
-
+
return extendRegion(dxStr,
dyStr,
dwStr,
@@ -676,10 +687,10 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
region,
uctx);
}
-
+
/**
* Returns a rectangle that represents the region extended by the
- * specified differential coordinates.
+ * specified differential coordinates.
*
* @param dxStr the differential x coordinate of the region
* @param dyStr the differential y coordinate of the region
@@ -698,7 +709,7 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
GraphicsNode filteredNode,
Rectangle2D region,
UnitProcessor.Context uctx) {
-
+
float dx,dy,dw,dh;
switch (unitsType) {
case USER_SPACE_ON_USE:
@@ -734,9 +745,9 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
}
break;
default:
- throw new Error(); // can't be reached
+ throw new IllegalArgumentException("Invalid unit type");
}
-
+
region.setRect(region.getX() + dx,
region.getY() + dy,
region.getWidth() + dw,
@@ -745,12 +756,65 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
return region;
}
+
+ public static Rectangle2D
+ getBaseFilterPrimitiveRegion(Element filterPrimitiveElement,
+ Element filteredElement,
+ GraphicsNode filteredNode,
+ Rectangle2D defaultRegion,
+ BridgeContext ctx) {
+ String s;
+
+ // resolve units in the (referenced) filteredElement's
+ // coordinate system
+ UnitProcessor.Context uctx;
+ uctx = UnitProcessor.createContext(ctx, filteredElement);
+
+ // 'x' attribute - default is defaultRegion.getX()
+ double x = defaultRegion.getX();
+ s = filterPrimitiveElement.getAttributeNS(null, SVG_X_ATTRIBUTE);
+ if (s.length() != 0) {
+ x = UnitProcessor.svgHorizontalCoordinateToUserSpace
+ (s, SVG_X_ATTRIBUTE, uctx);
+ }
+
+ // 'y' attribute - default is defaultRegion.getY()
+ double y = defaultRegion.getY();
+ s = filterPrimitiveElement.getAttributeNS(null, SVG_Y_ATTRIBUTE);
+ if (s.length() != 0) {
+ y = UnitProcessor.svgVerticalCoordinateToUserSpace
+ (s, SVG_Y_ATTRIBUTE, uctx);
+ }
+
+ // 'width' attribute - default is defaultRegion.getWidth()
+ double w = defaultRegion.getWidth();
+ s = filterPrimitiveElement.getAttributeNS(null, SVG_WIDTH_ATTRIBUTE);
+ if (s.length() != 0) {
+ w = UnitProcessor.svgHorizontalLengthToUserSpace
+ (s, SVG_WIDTH_ATTRIBUTE, uctx);
+ }
+
+ // 'height' attribute - default is defaultRegion.getHeight()
+ double h = defaultRegion.getHeight();
+ s = filterPrimitiveElement.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE);
+ if (s.length() != 0) {
+ h = UnitProcessor.svgVerticalLengthToUserSpace
+ (s, SVG_HEIGHT_ATTRIBUTE, uctx);
+ }
+
+ // NOTE: it may be that dx/dy/dw/dh should be applied here
+ // but since this is mostly aimed at feImage I am
+ // unsure that it is really needed.
+ return new Rectangle2D.Double(x, y, w, h);
+ }
+
/**
* Returns the filter primitive region according to the x, y,
* width, height, and filterUnits attributes. Processing the
* element as the top one in the filter chain.
*
* @param filterPrimitiveElement the filter primitive element
+ * @param filterElement the filter element
* @param filteredElement the element referencing the filter
* @param filteredNode the graphics node to use (objectBoundingBox)
* @param defaultRegion the default region to filter
@@ -759,6 +823,7 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
*/
public static Rectangle2D
convertFilterPrimitiveRegion(Element filterPrimitiveElement,
+ Element filterElement,
Element filteredElement,
GraphicsNode filteredNode,
Rectangle2D defaultRegion,
@@ -766,12 +831,9 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
BridgeContext ctx) {
// 'primitiveUnits' - default is userSpaceOnUse
- Node parentNode = filterPrimitiveElement.getParentNode();
String units = "";
- if ((parentNode != null) &&
- (parentNode.getNodeType() == Node.ELEMENT_NODE)) {
- Element parent = (Element)parentNode;
- units = getChainableAttributeNS(parent,
+ if (filterElement != null) {
+ units = getChainableAttributeNS(filterElement,
null,
SVG_PRIMITIVE_UNITS_ATTRIBUTE,
ctx);
@@ -781,24 +843,28 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
unitsType = USER_SPACE_ON_USE;
} else {
unitsType = parseCoordinateSystem
- (filterPrimitiveElement, SVG_FILTER_UNITS_ATTRIBUTE, units);
+ (filterElement, SVG_FILTER_UNITS_ATTRIBUTE, units, ctx);
}
- // 'x' attribute - default is defaultRegion.getX()
- String xStr =
- filterPrimitiveElement.getAttributeNS(null, SVG_X_ATTRIBUTE);
+ String xStr = "", yStr = "", wStr = "", hStr = "";
- // 'y' attribute - default is defaultRegion.getY()
- String yStr =
- filterPrimitiveElement.getAttributeNS(null, SVG_Y_ATTRIBUTE);
+ if (filterPrimitiveElement != null) {
+ // 'x' attribute - default is defaultRegion.getX()
+ xStr = filterPrimitiveElement.getAttributeNS(null,
+ SVG_X_ATTRIBUTE);
- // 'width' attribute - default is defaultRegion.getWidth()
- String wStr =
- filterPrimitiveElement.getAttributeNS(null, SVG_WIDTH_ATTRIBUTE);
+ // 'y' attribute - default is defaultRegion.getY()
+ yStr = filterPrimitiveElement.getAttributeNS(null,
+ SVG_Y_ATTRIBUTE);
- // 'height' attribute - default is defaultRegion.getHeight()
- String hStr =
- filterPrimitiveElement.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE);
+ // 'width' attribute - default is defaultRegion.getWidth()
+ wStr = filterPrimitiveElement.getAttributeNS(null,
+ SVG_WIDTH_ATTRIBUTE);
+
+ // 'height' attribute - default is defaultRegion.getHeight()
+ hStr = filterPrimitiveElement.getAttributeNS(null,
+ SVG_HEIGHT_ATTRIBUTE);
+ }
double x = defaultRegion.getX();
double y = defaultRegion.getY();
@@ -854,21 +920,19 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
}
break;
default:
- throw new Error(); // can't be reached
+ throw new Error("invalid unitsType:" + unitsType); // can't be reached
}
Rectangle2D region = new Rectangle2D.Double(x, y, w, h);
// Now, extend filter primitive region with dx/dy/dw/dh
// settings (Batik extension). The dx/dy/dw/dh padding is
- // *always* in userSpaceOnUse space.
+ // *always* in userSpaceOnUse space.
units = "";
- if ((parentNode != null) &&
- (parentNode.getNodeType() == Node.ELEMENT_NODE)) {
- Element parent = (Element)parentNode;
+ if (filterElement != null) {
units = getChainableAttributeNS
- (parent, null,
+ (filterElement, null,
SVG12Constants.SVG_FILTER_PRIMITIVE_MARGINS_UNITS_ATTRIBUTE,
ctx);
}
@@ -877,38 +941,43 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
unitsType = USER_SPACE_ON_USE;
} else {
unitsType = parseCoordinateSystem
- (filterPrimitiveElement,
- SVG12Constants.SVG_FILTER_PRIMITIVE_MARGINS_UNITS_ATTRIBUTE, units);
+ (filterElement,
+ SVG12Constants.SVG_FILTER_PRIMITIVE_MARGINS_UNITS_ATTRIBUTE,
+ units, ctx);
}
- // 'batik:dx' attribute - default is 0
- String dxStr = filterPrimitiveElement.getAttributeNS
- (null, SVG12Constants.SVG_MX_ATRIBUTE);
+ String dxStr = "", dyStr = "", dwStr = "", dhStr = "";
+
+ if (filterPrimitiveElement != null) {
+ // 'batik:dx' attribute - default is 0
+ dxStr = filterPrimitiveElement.getAttributeNS
+ (null, SVG12Constants.SVG_MX_ATRIBUTE);
+
+ // 'batik:dy' attribute - default is 0
+ dyStr = filterPrimitiveElement.getAttributeNS
+ (null, SVG12Constants.SVG_MY_ATRIBUTE);
+
+ // 'batik:dw' attribute - default is 0
+ dwStr = filterPrimitiveElement.getAttributeNS
+ (null, SVG12Constants.SVG_MW_ATRIBUTE);
+
+ // 'batik:dh' attribute - default is 0
+ dhStr = filterPrimitiveElement.getAttributeNS
+ (null, SVG12Constants.SVG_MH_ATRIBUTE);
+ }
if (dxStr.length() == 0) {
dxStr = SVG12Constants.SVG_FILTER_MX_DEFAULT_VALUE;
}
-
- // 'batik:dy' attribute - default is 0
- String dyStr = filterPrimitiveElement.getAttributeNS
- (null, SVG12Constants.SVG_MY_ATRIBUTE);
if (dyStr.length() == 0) {
dyStr = SVG12Constants.SVG_FILTER_MY_DEFAULT_VALUE;
}
-
- // 'batik:dw' attribute - default is 0
- String dwStr = filterPrimitiveElement.getAttributeNS
- (null, SVG12Constants.SVG_MW_ATRIBUTE);
if (dwStr.length() == 0) {
dwStr = SVG12Constants.SVG_FILTER_MW_DEFAULT_VALUE;
}
-
- // 'batik:dh' attribute - default is 0
- String dhStr = filterPrimitiveElement.getAttributeNS
- (null, SVG12Constants.SVG_MH_ATRIBUTE);
if (dhStr.length() == 0) {
dhStr = SVG12Constants.SVG_FILTER_MH_DEFAULT_VALUE;
}
-
+
region = extendRegion(dxStr,
dyStr,
dwStr,
@@ -917,12 +986,47 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
filteredNode,
region,
uctx);
-
+
Rectangle2D.intersect(region, filterRegion, region);
return region;
}
+ /**
+ * Returns the filter primitive region according to the x, y,
+ * width, height, and filterUnits attributes. Processing the
+ * element as the top one in the filter chain.
+ *
+ * @param filterPrimitiveElement the filter primitive element
+ * @param filteredElement the element referencing the filter
+ * @param filteredNode the graphics node to use (objectBoundingBox)
+ * @param defaultRegion the default region to filter
+ * @param filterRegion the filter chain region
+ * @param ctx the bridge context
+ */
+ public static Rectangle2D
+ convertFilterPrimitiveRegion(Element filterPrimitiveElement,
+ Element filteredElement,
+ GraphicsNode filteredNode,
+ Rectangle2D defaultRegion,
+ Rectangle2D filterRegion,
+ BridgeContext ctx) {
+
+ Node parentNode = filterPrimitiveElement.getParentNode();
+ Element filterElement = null;
+ if (parentNode != null &&
+ parentNode.getNodeType() == Node.ELEMENT_NODE) {
+ filterElement = (Element) parentNode;
+ }
+ return convertFilterPrimitiveRegion(filterPrimitiveElement,
+ filterElement,
+ filteredElement,
+ filteredNode,
+ defaultRegion,
+ filterRegion,
+ ctx);
+ }
+
/////////////////////////////////////////////////////////////////////////
// region convenient methods
/////////////////////////////////////////////////////////////////////////
@@ -943,17 +1047,19 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
* @param e the element that defines the coordinate system
* @param attr the attribute which contains the coordinate system
* @param coordinateSystem the coordinate system to parse
+ * @param ctx the BridgeContext to use for error information
* @return OBJECT_BOUNDING_BOX | USER_SPACE_ON_USE
*/
public static short parseCoordinateSystem(Element e,
String attr,
- String coordinateSystem) {
+ String coordinateSystem,
+ BridgeContext ctx) {
if (SVG_USER_SPACE_ON_USE_VALUE.equals(coordinateSystem)) {
return USER_SPACE_ON_USE;
} else if (SVG_OBJECT_BOUNDING_BOX_VALUE.equals(coordinateSystem)) {
return OBJECT_BOUNDING_BOX;
} else {
- throw new BridgeException(e, ERR_ATTRIBUTE_VALUE_MALFORMED,
+ throw new BridgeException(ctx, e, ERR_ATTRIBUTE_VALUE_MALFORMED,
new Object[] {attr, coordinateSystem});
}
}
@@ -965,17 +1071,19 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
* @param e the element that defines the coordinate system
* @param attr the attribute which contains the coordinate system
* @param coordinateSystem the coordinate system to parse
+ * @param ctx the BridgeContext to use for error information
* @return STROKE_WIDTH | USER_SPACE_ON_USE
*/
public static short parseMarkerCoordinateSystem(Element e,
String attr,
- String coordinateSystem) {
+ String coordinateSystem,
+ BridgeContext ctx) {
if (SVG_USER_SPACE_ON_USE_VALUE.equals(coordinateSystem)) {
return USER_SPACE_ON_USE;
} else if (SVG_STROKE_WIDTH_VALUE.equals(coordinateSystem)) {
return STROKE_WIDTH;
} else {
- throw new BridgeException(e, ERR_ATTRIBUTE_VALUE_MALFORMED,
+ throw new BridgeException(ctx, e, ERR_ATTRIBUTE_VALUE_MALFORMED,
new Object[] {attr, coordinateSystem});
}
}
@@ -1033,7 +1141,7 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
(hStr, SVG_HEIGHT_ATTRIBUTE, uctx);
break;
default:
- throw new Error(); // can't be reached
+ throw new Error("invalid unitsType:" + unitsType ); // can't be reached
}
return new Rectangle2D.Double(x, y, w, h);
}
@@ -1048,16 +1156,17 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
* @param e the element that defines the transform
* @param attr the name of the attribute that represents the transform
* @param transform the transform to parse
- *
+ * @param ctx the BridgeContext to use for error information
*/
public static AffineTransform convertTransform(Element e,
String attr,
- String transform) {
+ String transform,
+ BridgeContext ctx) {
try {
return AWTTransformProducer.createAffineTransform(transform);
- } catch (ParseException ex) {
- throw new BridgeException(e, ERR_ATTRIBUTE_VALUE_MALFORMED,
- new Object[] {attr, transform, ex});
+ } catch (ParseException pEx) {
+ throw new BridgeException(ctx, e, pEx, ERR_ATTRIBUTE_VALUE_MALFORMED,
+ new Object[] {attr, transform, pEx });
}
}
@@ -1094,7 +1203,7 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
GraphicsNode node) {
Rectangle2D bounds = node.getGeometryBounds();
- if(bounds != null){
+ if (bounds != null) {
return new Rectangle2D.Double
(bounds.getX() + r.getX()*bounds.getWidth(),
bounds.getY() + r.getY()*bounds.getHeight(),
@@ -1104,4 +1213,40 @@ public abstract class SVGUtilities implements SVGConstants, ErrorConstants {
return new Rectangle2D.Double();
}
}
+
+ /**
+ * Returns the value of the 'snapshotTime' attribute on the specified
+ * element as a float, or <code>0f</code> if the attribute is missing
+ * or given as <code>"none"</code>.
+ *
+ * @param e the element from which to retrieve the 'snapshotTime' attribute
+ * @param ctx the BridgeContext to use for error information
+ */
+ public static float convertSnapshotTime(Element e, BridgeContext ctx) {
+ if (!e.hasAttributeNS(null, SVG_SNAPSHOT_TIME_ATTRIBUTE)) {
+ return 0f;
+ }
+ String t = e.getAttributeNS(null, SVG_SNAPSHOT_TIME_ATTRIBUTE);
+ if (t.equals(SVG_NONE_VALUE)) {
+ return 0f;
+ }
+
+ class Handler implements ClockHandler {
+ float time;
+ public void clockValue(float t) {
+ time = t;
+ }
+ }
+ ClockParser p = new ClockParser(false);
+ Handler h = new Handler();
+ p.setClockHandler(h);
+ try {
+ p.parse(t);
+ } catch (ParseException pEx ) {
+ throw new BridgeException
+ (null, e, pEx, ERR_ATTRIBUTE_VALUE_MALFORMED,
+ new Object[] { SVG_SNAPSHOT_TIME_ATTRIBUTE, t, pEx });
+ }
+ return h.time;
+ }
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGVKernElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGVKernElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGVKernElementBridge.java
index 44bbfad..534f524 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGVKernElementBridge.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGVKernElementBridge.java
@@ -1,10 +1,11 @@
/*
- Copyright 2001 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@@ -21,7 +22,7 @@ package org.apache.flex.forks.batik.bridge;
* Bridge class for the <vkern> element.
*
* @author <a href="mailto:dean.jackson@cmis.csiro.au">Dean Jackson</a>
- * @version $Id: SVGVKernElementBridge.java,v 1.3 2004/08/18 07:12:36 vhardy Exp $
+ * @version $Id: SVGVKernElementBridge.java 475477 2006-11-15 22:44:28Z cam $
*/
public class SVGVKernElementBridge extends SVGKernElementBridge {
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/ScriptSecurity.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/ScriptSecurity.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/ScriptSecurity.java
index 7b68d18..ef3c349 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/ScriptSecurity.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/ScriptSecurity.java
@@ -1,10 +1,11 @@
/*
- Copyright 2002 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@@ -26,7 +27,7 @@ package org.apache.flex.forks.batik.bridge;
* settings for scripts.
*
* @author <a href="mailto:vhardy@apache.org">Vincent Hardy</a>
- * @version $Id: ScriptSecurity.java,v 1.4 2004/08/18 07:12:36 vhardy Exp $
+ * @version $Id: ScriptSecurity.java 475477 2006-11-15 22:44:28Z cam $
*/
public interface ScriptSecurity {
/**