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:18 UTC
[03/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/svg12/XBLShadowTreeElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/XBLShadowTreeElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/XBLShadowTreeElementBridge.java
new file mode 100644
index 0000000..8c9410d
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/XBLShadowTreeElementBridge.java
@@ -0,0 +1,176 @@
+/*
+
+ 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
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.flex.forks.batik.bridge.svg12;
+
+import org.apache.flex.forks.batik.bridge.AbstractGraphicsNodeBridge;
+import org.apache.flex.forks.batik.bridge.Bridge;
+import org.apache.flex.forks.batik.bridge.BridgeContext;
+import org.apache.flex.forks.batik.bridge.GVTBuilder;
+import org.apache.flex.forks.batik.bridge.SVGUtilities;
+import org.apache.flex.forks.batik.gvt.CompositeGraphicsNode;
+import org.apache.flex.forks.batik.gvt.GraphicsNode;
+import org.apache.flex.forks.batik.util.XBLConstants;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.events.MutationEvent;
+
+/**
+ * Bridge class for the <xbl:shadowTree> element.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: XBLShadowTreeElementBridge.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class XBLShadowTreeElementBridge extends AbstractGraphicsNodeBridge {
+
+ /**
+ * Constructs a new bridge for the <xbl:shadowTree> element.
+ */
+ public XBLShadowTreeElementBridge() {}
+
+ /**
+ * Returns 'shadowTree'.
+ */
+ public String getLocalName() {
+ return XBLConstants.XBL_SHADOW_TREE_TAG;
+ }
+
+ /**
+ * Returns the XBL namespace.
+ */
+ public String getNamespaceURI() {
+ return XBLConstants.XBL_NAMESPACE_URI;
+ }
+
+ /**
+ * Returns a new instance of this bridge.
+ */
+ public Bridge getInstance() {
+ return new XBLShadowTreeElementBridge();
+ }
+
+ /**
+ * Creates a <tt>GraphicsNode</tt> according to the specified parameters.
+ *
+ * @param ctx the bridge context to use
+ * @param e the element that describes the graphics node to build
+ * @return a graphics node that represents the specified element
+ */
+ public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {
+ // 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
+ if (!SVGUtilities.matchUserAgent(e, ctx.getUserAgent())) {
+ return null;
+ }
+
+ CompositeGraphicsNode cgn = new CompositeGraphicsNode();
+
+ associateSVGContext(ctx, e, cgn);
+
+ return cgn;
+ }
+
+ /**
+ * Creates a <tt>CompositeGraphicsNode</tt>.
+ */
+ protected GraphicsNode instantiateGraphicsNode() {
+ // Not needed, since createGraphicsNode is overridden
+ return null;
+ }
+
+ /**
+ * Builds using the specified BridgeContext and element, the
+ * specified graphics node.
+ *
+ * @param ctx the bridge context to use
+ * @param e the element that describes the graphics node to build
+ * @param node the graphics node to build
+ */
+ public void buildGraphicsNode(BridgeContext ctx,
+ Element e,
+ GraphicsNode node) {
+ initializeDynamicSupport(ctx, e, node);
+ }
+
+ /**
+ * Returns true if the graphics node has to be displayed, false
+ * otherwise.
+ */
+ public boolean getDisplay(Element e) {
+ return true;
+ }
+
+ /**
+ * Returns true as the <xbl:template> element is a container.
+ */
+ public boolean isComposite() {
+ return true;
+ }
+
+ // BridgeUpdateHandler implementation //////////////////////////////////
+
+ /**
+ * Invoked when an MutationEvent of type 'DOMNodeInserted' is fired.
+ */
+ public void handleDOMNodeInsertedEvent(MutationEvent evt) {
+ if (evt.getTarget() instanceof Element) {
+ handleElementAdded((CompositeGraphicsNode)node,
+ e,
+ (Element)evt.getTarget());
+ }
+ }
+
+ /**
+ * Invoked when an MutationEvent of type 'DOMNodeInserted' is fired.
+ */
+ public void handleElementAdded(CompositeGraphicsNode gn,
+ Node parent,
+ Element childElt) {
+ // build the graphics node
+ GVTBuilder builder = ctx.getGVTBuilder();
+ GraphicsNode childNode = builder.build(ctx, childElt);
+ if (childNode == null) {
+ return; // the added element is not a graphic element
+ }
+
+ // Find the index where the GraphicsNode should be added
+ int idx = -1;
+ for(Node ps = childElt.getPreviousSibling(); ps != null;
+ ps = ps.getPreviousSibling()) {
+ if (ps.getNodeType() != Node.ELEMENT_NODE)
+ continue;
+ Element pse = (Element)ps;
+ GraphicsNode psgn = ctx.getGraphicsNode(pse);
+ while ((psgn != null) && (psgn.getParent() != gn)) {
+ // In some cases the GN linked is
+ // a child (in particular for images).
+ psgn = psgn.getParent();
+ }
+ if (psgn == null)
+ continue;
+ idx = gn.indexOf(psgn);
+ if (idx == -1)
+ continue;
+ break;
+ }
+ // insert after prevSibling, if
+ // it was -1 this becomes 0 (first slot)
+ idx++;
+ gn.add(idx, childNode);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/XPathPatternContentSelector.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/XPathPatternContentSelector.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/XPathPatternContentSelector.java
new file mode 100644
index 0000000..9c09dbd
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/XPathPatternContentSelector.java
@@ -0,0 +1,252 @@
+/*
+
+ 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
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.flex.forks.batik.bridge.svg12;
+
+import java.util.ArrayList;
+
+import org.apache.xml.utils.PrefixResolver;
+import org.apache.xpath.XPath;
+import org.apache.xpath.XPathContext;
+
+import org.apache.flex.forks.batik.dom.AbstractDocument;
+import org.apache.flex.forks.batik.dom.svg12.XBLOMContentElement;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.xpath.XPathException;
+
+/**
+ * A class to handle the XPath Pattern syntax for XBL content elements.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: XPathPatternContentSelector.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class XPathPatternContentSelector extends AbstractContentSelector {
+
+ /**
+ * The Xalan prefix resolver.
+ */
+ protected NSPrefixResolver prefixResolver = new NSPrefixResolver();
+
+ /**
+ * The XPath expression.
+ */
+ protected XPath xpath;
+
+ /**
+ * The XPath context.
+ */
+ protected XPathContext context;
+
+ /**
+ * The selected nodes.
+ */
+ protected SelectedNodes selectedContent;
+
+ /**
+ * The expression string.
+ */
+ protected String expression;
+
+ /**
+ * Creates a new XPathPatternContentSelector.
+ */
+ public XPathPatternContentSelector(ContentManager cm,
+ XBLOMContentElement content,
+ Element bound,
+ String selector) {
+ super(cm, content, bound);
+ expression = selector;
+ parse();
+ }
+
+ /**
+ * Parses the XPath selector.
+ */
+ protected void parse() {
+ context = new XPathContext();
+ try {
+ xpath = new XPath(expression, null, prefixResolver, XPath.MATCH);
+ } catch (javax.xml.transform.TransformerException te) {
+ AbstractDocument doc
+ = (AbstractDocument) contentElement.getOwnerDocument();
+ throw doc.createXPathException
+ (XPathException.INVALID_EXPRESSION_ERR,
+ "xpath.invalid.expression",
+ new Object[] { expression, te.getMessage() });
+ }
+ }
+
+ /**
+ * Returns a list of nodes that were matched by the given selector
+ * string.
+ */
+ public NodeList getSelectedContent() {
+ if (selectedContent == null) {
+ selectedContent = new SelectedNodes();
+ }
+ return selectedContent;
+ }
+
+ /**
+ * Forces this selector to update its selected nodes list.
+ * Returns true if the selected node list needed updating.
+ * This assumes that the previous content elements in this
+ * shadow tree (in document order) have up-to-date selectedContent
+ * lists.
+ */
+ boolean update() {
+ if (selectedContent == null) {
+ selectedContent = new SelectedNodes();
+ return true;
+ }
+ parse();
+ return selectedContent.update();
+ }
+
+ /**
+ * Implementation of NodeList that contains the nodes that matched
+ * this selector.
+ */
+ protected class SelectedNodes implements NodeList {
+
+ /**
+ * The selected nodes.
+ */
+ protected ArrayList nodes = new ArrayList(10);
+
+ /**
+ * Creates a new SelectedNodes object.
+ */
+ public SelectedNodes() {
+ update();
+ }
+
+ protected boolean update() {
+ ArrayList oldNodes = (ArrayList) nodes.clone();
+ nodes.clear();
+ for (Node n = boundElement.getFirstChild();
+ n != null;
+ n = n.getNextSibling()) {
+ update(n);
+ }
+ int nodesSize = nodes.size();
+ if (oldNodes.size() != nodesSize) {
+ return true;
+ }
+ for (int i = 0; i < nodesSize; i++) {
+ if (oldNodes.get(i) != nodes.get(i)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected boolean descendantSelected(Node n) {
+ n = n.getFirstChild();
+ while (n != null) {
+ if (isSelected(n) || descendantSelected(n)) {
+ return true;
+ }
+ n = n.getNextSibling();
+ }
+ return false;
+ }
+
+ protected void update(Node n) {
+ if (!isSelected(n)) {
+ try {
+ double matchScore
+ = xpath.execute(context, n, prefixResolver).num();
+ if (matchScore != XPath.MATCH_SCORE_NONE) {
+ if (!descendantSelected(n)) {
+ nodes.add(n);
+ }
+ } else {
+ n = n.getFirstChild();
+ while (n != null) {
+ update(n);
+ n = n.getNextSibling();
+ }
+ }
+ } catch (javax.xml.transform.TransformerException te) {
+ AbstractDocument doc
+ = (AbstractDocument) contentElement.getOwnerDocument();
+ throw doc.createXPathException
+ (XPathException.INVALID_EXPRESSION_ERR,
+ "xpath.error",
+ new Object[] { expression, te.getMessage() });
+ }
+ }
+ }
+
+ /**
+ * <b>DOM</b>: Implements {@link org.w3c.dom.NodeList#item(int)}.
+ */
+ public Node item(int index) {
+ if (index < 0 || index >= nodes.size()) {
+ return null;
+ }
+ return (Node) nodes.get(index);
+ }
+
+ /**
+ * <b>DOM</b>: Implements {@link org.w3c.dom.NodeList#getLength()}.
+ */
+ public int getLength() {
+ return nodes.size();
+ }
+ }
+ /**
+ * Xalan prefix resolver.
+ */
+ protected class NSPrefixResolver implements PrefixResolver {
+
+ /**
+ * Get the base URI for this resolver. Since this resolver isn't
+ * associated with a particular node, returns null.
+ */
+ public String getBaseIdentifier() {
+ return null;
+ }
+
+ /**
+ * Resolves the given namespace prefix.
+ */
+ public String getNamespaceForPrefix(String prefix) {
+ return contentElement.lookupNamespaceURI(prefix);
+ }
+
+ /**
+ * Resolves the given namespace prefix.
+ */
+ public String getNamespaceForPrefix(String prefix, Node context) {
+ // ignore the context node
+ return contentElement.lookupNamespaceURI(prefix);
+ }
+
+ /**
+ * Returns whether this PrefixResolver handles a null prefix.
+ */
+ public boolean handlesNullPrefixes() {
+ return false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/XPathSubsetContentSelector.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/XPathSubsetContentSelector.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/XPathSubsetContentSelector.java
new file mode 100644
index 0000000..a6fe5eb
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/XPathSubsetContentSelector.java
@@ -0,0 +1,513 @@
+/*
+
+ 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
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.flex.forks.batik.bridge.svg12;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.apache.flex.forks.batik.dom.svg12.XBLOMContentElement;
+import org.apache.flex.forks.batik.parser.AbstractScanner;
+import org.apache.flex.forks.batik.parser.ParseException;
+import org.apache.flex.forks.batik.xml.XMLUtilities;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A class to handle the XPath subset syntax for XBL content elements.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: XPathSubsetContentSelector.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class XPathSubsetContentSelector extends AbstractContentSelector {
+
+ protected static final int SELECTOR_INVALID = -1;
+ protected static final int SELECTOR_ANY = 0;
+ protected static final int SELECTOR_QNAME = 1;
+ protected static final int SELECTOR_ID = 2;
+
+ /**
+ * The type of XPath subset expression.
+ */
+ protected int selectorType;
+
+ /**
+ * The QName prefix used for selection.
+ */
+ protected String prefix;
+
+ /**
+ * The local name or ID used for selection.
+ */
+ protected String localName;
+
+ /**
+ * The index for selection. 0 means select all elements that match.
+ */
+ protected int index;
+
+ /**
+ * The selected nodes.
+ */
+ protected SelectedNodes selectedContent;
+
+ /**
+ * Creates a new XPathSubsetContentSelector object.
+ */
+ public XPathSubsetContentSelector(ContentManager cm,
+ XBLOMContentElement content,
+ Element bound,
+ String selector) {
+ super(cm, content, bound);
+ parseSelector(selector);
+ }
+
+ /**
+ * Parses the selector string.
+ */
+ protected void parseSelector(String selector) {
+ selectorType = SELECTOR_INVALID;
+ Scanner scanner = new Scanner(selector);
+ int token = scanner.next();
+ if (token == Scanner.NAME) {
+ String name1 = scanner.getStringValue();
+ token = scanner.next();
+ if (token == Scanner.EOF) {
+ selectorType = SELECTOR_QNAME;
+ prefix = null;
+ localName = name1;
+ index = 0;
+ return;
+ } else if (token == Scanner.COLON) {
+ token = scanner.next();
+ if (token == Scanner.NAME) {
+ String name2 = scanner.getStringValue();
+ token = scanner.next();
+ if (token == Scanner.EOF) {
+ selectorType = SELECTOR_QNAME;
+ prefix = name1;
+ localName = name2;
+ index = 0;
+ return;
+ } else if (token == Scanner.LEFT_SQUARE_BRACKET) {
+ token = scanner.next();
+ if (token == Scanner.NUMBER) {
+ int number = Integer.parseInt(scanner.getStringValue());
+ token = scanner.next();
+ if (token == Scanner.RIGHT_SQUARE_BRACKET) {
+ token = scanner.next();
+ if (token == Scanner.EOF) {
+ selectorType = SELECTOR_QNAME;
+ prefix = name1;
+ localName = name2;
+ index = number;
+ return;
+ }
+ }
+ }
+ }
+ } else if (token == Scanner.LEFT_SQUARE_BRACKET) {
+ token = scanner.next();
+ if (token == Scanner.NUMBER) {
+ int number = Integer.parseInt(scanner.getStringValue());
+ token = scanner.next();
+ if (token == Scanner.RIGHT_SQUARE_BRACKET) {
+ token = scanner.next();
+ if (token == Scanner.EOF) {
+ selectorType = SELECTOR_QNAME;
+ prefix = null;
+ localName = name1;
+ index = number;
+ return;
+ }
+ }
+ }
+ } else if (token == Scanner.LEFT_PARENTHESIS) {
+ if (name1.equals("id")) {
+ token = scanner.next();
+ if (token == Scanner.STRING) {
+ String id = scanner.getStringValue();
+ token = scanner.next();
+ if (token == Scanner.RIGHT_PARENTHESIS) {
+ token = scanner.next();
+ if (token == Scanner.EOF) {
+ selectorType = SELECTOR_ID;
+ localName = id;
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+ } else if (token == Scanner.ASTERISK) {
+ token = scanner.next();
+ if (token == Scanner.EOF) {
+ selectorType = SELECTOR_ANY;
+ return;
+ } else if (token == Scanner.LEFT_SQUARE_BRACKET) {
+ token = scanner.next();
+ if (token == Scanner.NUMBER) {
+ int number = Integer.parseInt(scanner.getStringValue());
+ token = scanner.next();
+ if (token == Scanner.RIGHT_SQUARE_BRACKET) {
+ token = scanner.next();
+ if (token == Scanner.EOF) {
+ selectorType = SELECTOR_ANY;
+ index = number;
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns a list of nodes that were matched by the given selector
+ * string.
+ */
+ public NodeList getSelectedContent() {
+ if (selectedContent == null) {
+ selectedContent = new SelectedNodes();
+ }
+ return selectedContent;
+ }
+
+ /**
+ * Forces this selector to update its selected nodes list.
+ * Returns true if the selected node list needed updating.
+ * This assumes that the previous content elements in this
+ * shadow tree (in document order) have up-to-date selectedContent
+ * lists.
+ */
+ boolean update() {
+ if (selectedContent == null) {
+ selectedContent = new SelectedNodes();
+ return true;
+ }
+ return selectedContent.update();
+ }
+
+ /**
+ * Implementation of NodeList that contains the nodes that matched
+ * this selector.
+ */
+ protected class SelectedNodes implements NodeList {
+
+ /**
+ * The selected nodes.
+ */
+ protected ArrayList nodes = new ArrayList(10);
+
+ /**
+ * Creates a new SelectedNodes object.
+ */
+ public SelectedNodes() {
+ update();
+ }
+
+ protected boolean update() {
+ ArrayList oldNodes = (ArrayList) nodes.clone();
+ nodes.clear();
+ int nth = 0;
+ for (Node n = boundElement.getFirstChild(); n != null; n = n.getNextSibling()) {
+ if (n.getNodeType() != Node.ELEMENT_NODE) {
+ continue;
+ }
+ Element e = (Element) n;
+ boolean matched = selectorType == SELECTOR_ANY;
+ switch (selectorType) {
+ case SELECTOR_ID:
+ matched = e.getAttributeNS(null, "id").equals(localName);
+ break;
+ case SELECTOR_QNAME:
+ if (prefix == null) {
+ matched = e.getNamespaceURI() == null;
+ } else {
+ String ns = contentElement.lookupNamespaceURI(prefix);
+ if (ns == null) {
+ // XXX throw invalid prefix exception
+ } else {
+ matched = e.getNamespaceURI().equals(ns);
+ }
+ }
+ matched = matched && localName.equals(e.getLocalName());
+ break;
+ }
+ if (selectorType == SELECTOR_ANY
+ || selectorType == SELECTOR_QNAME) {
+ matched = matched && (index == 0 || ++nth == index);
+ }
+ if (matched && !isSelected(n)) {
+ nodes.add(e);
+ }
+ }
+ int nodesSize = nodes.size();
+ if (oldNodes.size() != nodesSize) {
+ return true;
+ }
+ for (int i = 0; i < nodesSize; i++) {
+ if (oldNodes.get(i) != nodes.get(i)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * <b>DOM</b>: Implements {@link org.w3c.dom.NodeList#item(int)}.
+ */
+ public Node item(int index) {
+ if (index < 0 || index >= nodes.size()) {
+ return null;
+ }
+ return (Node) nodes.get(index);
+ }
+
+ /**
+ * <b>DOM</b>: Implements {@link org.w3c.dom.NodeList#getLength()}.
+ */
+ public int getLength() {
+ return nodes.size();
+ }
+ }
+
+ /**
+ * A scanner for XPath subset selectors.
+ */
+ protected static class Scanner extends AbstractScanner {
+
+ public static final int EOF = 0;
+ public static final int NAME = 1;
+ public static final int COLON = 2;
+ public static final int LEFT_SQUARE_BRACKET = 3;
+ public static final int RIGHT_SQUARE_BRACKET = 4;
+ public static final int LEFT_PARENTHESIS = 5;
+ public static final int RIGHT_PARENTHESIS = 6;
+ public static final int STRING = 7;
+ public static final int NUMBER = 8;
+ public static final int ASTERISK = 9;
+
+ /**
+ * Creates a new Scanner object.
+ */
+ public Scanner(String s) {
+ super(s);
+ }
+
+ /**
+ * Returns the end gap of the current lexical unit.
+ */
+ protected int endGap() {
+ return (current == -1) ? 0 : 1;
+ }
+
+// public int next() {
+// int i = super.next();
+// System.err.print("\t\t");
+// switch (i) {
+// case EOF:
+// System.err.println("EOF");
+// break;
+// case NAME:
+// System.err.println("NAME " + getStringValue());
+// break;
+// case COLON:
+// System.err.println("COLON");
+// break;
+// case LEFT_SQUARE_BRACKET:
+// System.err.println("LEFT_SQUARE_BRACKET");
+// break;
+// case RIGHT_SQUARE_BRACKET:
+// System.err.println("RIGHT_SQUARE_BRACKET");
+// break;
+// case LEFT_PARENTHESIS:
+// System.err.println("LEFT_PARENTHESIS");
+// break;
+// case RIGHT_PARENTHESIS:
+// System.err.println("RIGHT_PARENTHESIS");
+// break;
+// case STRING:
+// System.err.println("STRING \"" + getStringValue() + "\"");
+// break;
+// case NUMBER:
+// System.err.println("NUMBER " + getStringValue());
+// break;
+// case ASTERISK:
+// System.err.println("ASTERISK");
+// break;
+// default:
+// System.err.println("?");
+// }
+// return i;
+// }
+
+ /**
+ * Returns the next token.
+ */
+ protected void nextToken() throws ParseException {
+ try {
+ switch (current) {
+ case -1:
+ type = EOF;
+ return;
+ case ':':
+ nextChar();
+ type = COLON;
+ return;
+ case '[':
+ nextChar();
+ type = LEFT_SQUARE_BRACKET;
+ return;
+ case ']':
+ nextChar();
+ type = RIGHT_SQUARE_BRACKET;
+ return;
+ case '(':
+ nextChar();
+ type = LEFT_PARENTHESIS;
+ return;
+ case ')':
+ nextChar();
+ type = RIGHT_PARENTHESIS;
+ return;
+ case '*':
+ nextChar();
+ type = ASTERISK;
+ return;
+ case ' ':
+ case '\t':
+ case '\r':
+ case '\n':
+ case '\f':
+ do {
+ nextChar();
+ } while (XMLUtilities.isXMLSpace((char) current));
+ nextToken();
+ return;
+ case '\'':
+ type = string1();
+ return;
+ case '"':
+ type = string2();
+ return;
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ type = number();
+ return;
+ default:
+ if (XMLUtilities.isXMLNameFirstCharacter((char) current)) {
+ do {
+ nextChar();
+ } while (current != -1
+ && current != ':'
+ && XMLUtilities.isXMLNameCharacter((char) current));
+ type = NAME;
+ return;
+ }
+ nextChar();
+ throw new ParseException("identifier.character",
+ reader.getLine(),
+ reader.getColumn());
+ }
+ } catch (IOException e) {
+ throw new ParseException(e);
+ }
+ }
+
+ /**
+ * Scans a single quoted string.
+ */
+ protected int string1() throws IOException {
+ start = position;
+ loop: for (;;) {
+ switch (nextChar()) {
+ case -1:
+ throw new ParseException("eof",
+ reader.getLine(),
+ reader.getColumn());
+ case '\'':
+ break loop;
+ }
+ }
+ nextChar();
+ return STRING;
+ }
+
+ /**
+ * Scans a double quoted string.
+ */
+ protected int string2() throws IOException {
+ start = position;
+ loop: for (;;) {
+ switch (nextChar()) {
+ case -1:
+ throw new ParseException("eof",
+ reader.getLine(),
+ reader.getColumn());
+ case '"':
+ break loop;
+ }
+ }
+ nextChar();
+ return STRING;
+ }
+
+ /**
+ * Scans a number.
+ */
+ protected int number() throws IOException {
+ loop: for (;;) {
+ switch (nextChar()) {
+ case '.':
+ switch (nextChar()) {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ return dotNumber();
+ }
+ throw new ParseException("character",
+ reader.getLine(),
+ reader.getColumn());
+ default:
+ break loop;
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ }
+ }
+ return NUMBER;
+ }
+
+ /**
+ * Scans the decimal part of a number.
+ */
+ protected int dotNumber() throws IOException {
+ loop: for (;;) {
+ switch (nextChar()) {
+ default:
+ break loop;
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ }
+ }
+ return NUMBER;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/css/dom/CSSOMComputedStyle.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/css/dom/CSSOMComputedStyle.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/css/dom/CSSOMComputedStyle.java
index d347086..522d6a3 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/css/dom/CSSOMComputedStyle.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/css/dom/CSSOMComputedStyle.java
@@ -1,10 +1,11 @@
/*
- Copyright 2002-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,7 +33,7 @@ import org.w3c.dom.css.CSSValue;
* This class represents the computed style of an element.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: CSSOMComputedStyle.java,v 1.6 2004/08/18 07:12:47 vhardy Exp $
+ * @version $Id: CSSOMComputedStyle.java 475685 2006-11-16 11:16:05Z cam $
*/
public class CSSOMComputedStyle implements CSSStyleDeclaration {
@@ -142,7 +143,7 @@ public class CSSOMComputedStyle implements CSSStyleDeclaration {
* org.w3c.dom.css.CSSStyleDeclaration#setProperty(String,String,String)}.
*/
public void setProperty(String propertyName, String value, String prio)
- throws DOMException {
+ throws DOMException {
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/css/dom/CSSOMSVGColor.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/css/dom/CSSOMSVGColor.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/css/dom/CSSOMSVGColor.java
index 6184f5d..23e1728 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/css/dom/CSSOMSVGColor.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/css/dom/CSSOMSVGColor.java
@@ -1,10 +1,11 @@
/*
- Copyright 2002-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
@@ -30,23 +31,23 @@ import org.w3c.dom.css.CSSValue;
import org.w3c.dom.css.Counter;
import org.w3c.dom.css.RGBColor;
import org.w3c.dom.css.Rect;
-import org.w3c.flex.forks.dom.svg.SVGColor;
-import org.w3c.flex.forks.dom.svg.SVGICCColor;
-import org.w3c.flex.forks.dom.svg.SVGNumber;
-import org.w3c.flex.forks.dom.svg.SVGNumberList;
+import org.w3c.dom.svg.SVGColor;
+import org.w3c.dom.svg.SVGICCColor;
+import org.w3c.dom.svg.SVGNumber;
+import org.w3c.dom.svg.SVGNumberList;
/**
* This class implements the {@link SVGColor} interface.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: CSSOMSVGColor.java,v 1.8 2005/03/29 02:26:36 cam Exp $
+ * @version $Id: CSSOMSVGColor.java 489226 2006-12-21 00:05:36Z cam $
*/
public class CSSOMSVGColor
implements SVGColor,
RGBColor,
SVGICCColor,
SVGNumberList {
-
+
/**
* The associated value.
*/
@@ -103,13 +104,13 @@ public class CSSOMSVGColor
* org.w3c.dom.css.CSSValue#setCssText(String)}.
*/
public void setCssText(String cssText) throws DOMException {
- if (handler == null) {
+ if (handler == null) {
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
- } else {
+ } else {
iccColors = null;
handler.textChanged(cssText);
- }
+ }
}
/**
@@ -122,13 +123,15 @@ public class CSSOMSVGColor
/**
* <b>DOM</b>: Implements {@link
- * org.w3c.flex.forks.dom.svg.SVGColor#getColorType()}.
+ * org.w3c.dom.svg.SVGColor#getColorType()}.
*/
public short getColorType() {
Value value = valueProvider.getValue();
- switch (value.getCssValueType()) {
+ int cssValueType = value.getCssValueType();
+ switch ( cssValueType ) {
case CSSValue.CSS_PRIMITIVE_VALUE:
- switch (value.getPrimitiveType()) {
+ int primitiveType = value.getPrimitiveType();
+ switch ( primitiveType ) {
case CSSPrimitiveValue.CSS_IDENT: {
if (value.getStringValue().equalsIgnoreCase
(CSSConstants.CSS_CURRENTCOLOR_VALUE))
@@ -138,17 +141,19 @@ public class CSSOMSVGColor
case CSSPrimitiveValue.CSS_RGBCOLOR:
return SVG_COLORTYPE_RGBCOLOR;
}
- break;
+ // there was no case for this primitiveType, prevent throwing the other exception
+ throw new IllegalStateException("Found unexpected PrimitiveType:" + primitiveType );
case CSSValue.CSS_VALUE_LIST:
return SVG_COLORTYPE_RGBCOLOR_ICCCOLOR;
}
- throw new InternalError();
+ // should not happen
+ throw new IllegalStateException("Found unexpected CssValueType:" + cssValueType );
}
/**
* <b>DOM</b>: Implements {@link
- * org.w3c.flex.forks.dom.svg.SVGColor#getRGBColor()}.
+ * org.w3c.dom.svg.SVGColor#getRGBColor()}.
*/
public RGBColor getRGBColor() {
return this;
@@ -164,20 +169,20 @@ public class CSSOMSVGColor
/**
* <b>DOM</b>: Implements {@link
- * org.w3c.flex.forks.dom.svg.SVGColor#setRGBColor(String)}.
+ * org.w3c.dom.svg.SVGColor#setRGBColor(String)}.
*/
public void setRGBColor(String color) {
- if (handler == null) {
+ if (handler == null) {
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
- } else {
+ } else {
handler.rgbColorChanged(color);
- }
+ }
}
/**
* <b>DOM</b>: Implements {@link
- * org.w3c.flex.forks.dom.svg.SVGColor#getICCColor()}.
+ * org.w3c.dom.svg.SVGColor#getICCColor()}.
*/
public SVGICCColor getICCColor() {
return this;
@@ -193,30 +198,30 @@ public class CSSOMSVGColor
/**
* <b>DOM</b>: Implements {@link
- * org.w3c.flex.forks.dom.svg.SVGColor#setRGBColorICCColor(String,String)}.
+ * org.w3c.dom.svg.SVGColor#setRGBColorICCColor(String,String)}.
*/
public void setRGBColorICCColor(String rgb, String icc) {
- if (handler == null) {
+ if (handler == null) {
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
- } else {
+ } else {
iccColors = null;
handler.rgbColorICCColorChanged(rgb, icc);
- }
+ }
}
/**
* <b>DOM</b>: Implements {@link
- * org.w3c.flex.forks.dom.svg.SVGColor#setColor(short,String,String)}.
+ * org.w3c.dom.svg.SVGColor#setColor(short,String,String)}.
*/
public void setColor(short type, String rgb, String icc) {
- if (handler == null) {
+ if (handler == null) {
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
- } else {
+ } else {
iccColors = null;
handler.colorChanged(type, rgb, icc);
- }
+ }
}
// RGBColor ///////////////////////////////////////////////////
@@ -258,7 +263,7 @@ public class CSSOMSVGColor
// SVGICCColor //////////////////////////////////////////////////
/**
- * <b>DOM</b>: Implements {@link org.w3c.flex.forks.dom.svg.SVGICCColor#getColorProfile()}.
+ * <b>DOM</b>: Implements {@link org.w3c.dom.svg.SVGICCColor#getColorProfile()}.
*/
public String getColorProfile() {
if (getColorType() != SVG_COLORTYPE_RGBCOLOR_ICCCOLOR) {
@@ -272,12 +277,12 @@ public class CSSOMSVGColor
* <b>DOM</b>: Implements {@link SVGICCColor#setColorProfile(String)}.
*/
public void setColorProfile(String colorProfile) throws DOMException {
- if (handler == null) {
+ if (handler == null) {
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
- } else {
+ } else {
handler.colorProfileChanged(colorProfile);
- }
+ }
}
/**
@@ -304,30 +309,30 @@ public class CSSOMSVGColor
* <b>DOM</b>: Implements {@link SVGNumberList#clear()}.
*/
public void clear() throws DOMException {
- if (handler == null) {
+ if (handler == null) {
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
- } else {
+ } else {
iccColors = null;
handler.colorsCleared();
- }
+ }
}
/**
* <b>DOM</b>: Implements {@link SVGNumberList#initialize(SVGNumber)}.
*/
public SVGNumber initialize(SVGNumber newItem) throws DOMException {
- if (handler == null) {
+ if (handler == null) {
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
- } else {
+ } else {
float f = newItem.getValue();
iccColors = new ArrayList();
SVGNumber result = new ColorNumber(f);
iccColors.add(result);
handler.colorsInitialized(f);
return result;
- }
+ }
}
/**
@@ -360,10 +365,10 @@ public class CSSOMSVGColor
*/
public SVGNumber insertItemBefore(SVGNumber newItem, int index)
throws DOMException {
- if (handler == null) {
+ if (handler == null) {
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
- } else {
+ } else {
int n = getNumberOfItems();
if (index < 0 || index > n) {
throw new DOMException(DOMException.INDEX_SIZE_ERR, "");
@@ -379,7 +384,7 @@ public class CSSOMSVGColor
iccColors.add(index, result);
handler.colorInsertedBefore(f, index);
return result;
- }
+ }
}
/**
@@ -388,10 +393,10 @@ public class CSSOMSVGColor
*/
public SVGNumber replaceItem(SVGNumber newItem, int index)
throws DOMException {
- if (handler == null) {
+ if (handler == null) {
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
- } else {
+ } else {
int n = getNumberOfItems();
if (index < 0 || index >= n) {
throw new DOMException(DOMException.INDEX_SIZE_ERR, "");
@@ -407,17 +412,17 @@ public class CSSOMSVGColor
iccColors.set(index, result);
handler.colorReplaced(f, index);
return result;
- }
+ }
}
/**
* <b>DOM</b>: Implements {@link SVGNumberList#removeItem(int)}.
*/
public SVGNumber removeItem(int index) throws DOMException {
- if (handler == null) {
+ if (handler == null) {
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
- } else {
+ } else {
int n = getNumberOfItems();
if (index < 0 || index >= n) {
throw new DOMException(DOMException.INDEX_SIZE_ERR, "");
@@ -433,17 +438,17 @@ public class CSSOMSVGColor
}
handler.colorRemoved(index);
return result;
- }
+ }
}
/**
* <b>DOM</b>: Implements {@link SVGNumberList#appendItem(SVGNumber)}.
*/
public SVGNumber appendItem (SVGNumber newItem) throws DOMException {
- if (handler == null) {
+ if (handler == null) {
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
- } else {
+ } else {
if (iccColors == null) {
int n = getNumberOfItems();
iccColors = new ArrayList(n);
@@ -456,7 +461,7 @@ public class CSSOMSVGColor
iccColors.add(result);
handler.colorAppend(f);
return result;
- }
+ }
}
/**
@@ -513,7 +518,7 @@ public class CSSOMSVGColor
}
/**
- * To provides the actual value.
+ * To provide the actual value.
*/
public interface ValueProvider {
@@ -565,7 +570,7 @@ public class CSSOMSVGColor
*/
void blueFloatValueChanged(short unit, float value)
throws DOMException;
-
+
/**
* Called when the RGBColor text has changed.
*/
@@ -634,169 +639,196 @@ public class CSSOMSVGColor
* Called when the red value text has changed.
*/
public void redTextChanged(String text) throws DOMException {
+ StringBuffer sb = new StringBuffer(40);
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR:
- text = "rgb(" +
- text + ", " +
- getValue().getGreen().getCssText() + ", " +
- getValue().getBlue().getCssText() + ")";
+ sb.append("rgb(");
+ sb.append(text); sb.append(',');
+ sb.append( value.getGreen().getCssText()); sb.append(',');
+ sb.append( value.getBlue().getCssText()); sb.append(')');
break;
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
- text = "rgb(" +
- text + ", " +
- getValue().item(0).getGreen().getCssText() + ", " +
- getValue().item(0).getBlue().getCssText() + ") " +
- getValue().item(1).getCssText();
+ sb.append("rgb(");
+ sb.append(text); sb.append(',');
+ sb.append(value.item(0).getGreen().getCssText());
+ sb.append(',');
+ sb.append(value.item(0).getBlue().getCssText());
+ sb.append(')');
+ sb.append(value.item(1).getCssText());
break;
default:
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
}
- textChanged(text);
+ textChanged(sb.toString());
}
/**
* Called when the red float value has changed.
*/
- public void redFloatValueChanged(short unit, float value)
+ public void redFloatValueChanged(short unit, float fValue)
throws DOMException {
- String text;
+ StringBuffer sb = new StringBuffer(40);
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR:
- text = "rgb(" +
- FloatValue.getCssText(unit, value) + ", " +
- getValue().getGreen().getCssText() + ", " +
- getValue().getBlue().getCssText() + ")";
+ sb.append("rgb(");
+ sb.append(FloatValue.getCssText(unit, fValue)); sb.append(',');
+ sb.append(value.getGreen().getCssText()); sb.append(',');
+ sb.append(value.getBlue().getCssText()); sb.append(')');
break;
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
- text = "rgb(" +
- FloatValue.getCssText(unit, value) + ", " +
- getValue().item(0).getGreen().getCssText() + ", " +
- getValue().item(0).getBlue().getCssText() + ") " +
- getValue().item(1).getCssText();
+ sb.append("rgb(");
+ sb.append(FloatValue.getCssText(unit, fValue));
+ sb.append(',');
+ sb.append(value.item(0).getGreen().getCssText());
+ sb.append(',');
+ sb.append(value.item(0).getBlue().getCssText());
+ sb.append(')');
+ sb.append(value.item(1).getCssText());
break;
default:
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
}
- textChanged(text);
+ textChanged(sb.toString());
}
/**
* Called when the green value text has changed.
*/
public void greenTextChanged(String text) throws DOMException {
+ StringBuffer sb = new StringBuffer(40);
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR:
- text = "rgb(" +
- getValue().getRed().getCssText() + ", " +
- text + ", " +
- getValue().getBlue().getCssText() + ")";
+ sb.append("rgb(");
+ sb.append(value.getRed().getCssText()); sb.append(',');
+ sb.append(text); sb.append(',');
+ sb.append(value.getBlue().getCssText()); sb.append(')');
break;
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
- text = "rgb(" +
- getValue().item(0).getRed().getCssText() + ", " +
- text + ", " +
- getValue().item(0).getBlue().getCssText() + ") " +
- getValue().item(1).getCssText();
+ sb.append("rgb(");
+ sb.append(value.item(0).getRed().getCssText());
+ sb.append(',');
+ sb.append(text);
+ sb.append(',');
+ sb.append(value.item(0).getBlue().getCssText());
+ sb.append(')');
+ sb.append(value.item(1).getCssText());
break;
default:
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
}
- textChanged(text);
+ textChanged(sb.toString());
}
/**
* Called when the green float value has changed.
*/
- public void greenFloatValueChanged(short unit, float value)
+ public void greenFloatValueChanged(short unit, float fValue)
throws DOMException {
- String text;
+ StringBuffer sb = new StringBuffer(40);
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR:
- text = "rgb(" +
- getValue().getRed().getCssText() + ", " +
- FloatValue.getCssText(unit, value) + ", " +
- getValue().getBlue().getCssText() + ")";
+ sb.append("rgb(");
+ sb.append(value.getRed().getCssText()); sb.append(',');
+ sb.append(FloatValue.getCssText(unit, fValue)); sb.append(',');
+ sb.append(value.getBlue().getCssText()); sb.append(')');
break;
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
- text = "rgb(" +
- getValue().item(0).getRed().getCssText() + ", " +
- FloatValue.getCssText(unit, value) + ", " +
- getValue().item(0).getBlue().getCssText() + ") " +
- getValue().item(1).getCssText();
+ sb.append("rgb(");
+ sb.append(value.item(0).getRed().getCssText());
+ sb.append(',');
+ sb.append(FloatValue.getCssText(unit, fValue));
+ sb.append(',');
+ sb.append(value.item(0).getBlue().getCssText());
+ sb.append(')');
+ sb.append(value.item(1).getCssText());
break;
default:
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
}
- textChanged(text);
+ textChanged(sb.toString());
}
/**
* Called when the blue value text has changed.
*/
public void blueTextChanged(String text) throws DOMException {
+ StringBuffer sb = new StringBuffer(40);
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR:
- text = "rgb(" +
- getValue().getRed().getCssText() + ", " +
- getValue().getGreen().getCssText() + ", " +
- text + ")";
+ sb.append("rgb(");
+ sb.append(value.getRed().getCssText()); sb.append(',');
+ sb.append(value.getGreen().getCssText()); sb.append(',');
+ sb.append(text); sb.append(')');
break;
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
- text = "rgb(" +
- getValue().item(0).getRed().getCssText() + ", " +
- getValue().item(0).getGreen().getCssText() + ", " +
- text + ") " +
- getValue().item(1).getCssText();
+ sb.append("rgb(");
+ sb.append(value.item(0).getRed().getCssText());
+ sb.append(',');
+ sb.append(value.item(0).getGreen().getCssText());
+ sb.append(',');
+ sb.append(text);
+ sb.append(')');
+ sb.append(value.item(1).getCssText());
+ break;
default:
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
}
- textChanged(text);
+ textChanged(sb.toString());
}
/**
* Called when the blue float value has changed.
*/
- public void blueFloatValueChanged(short unit, float value)
+ public void blueFloatValueChanged(short unit, float fValue)
throws DOMException {
- String text;
+ StringBuffer sb = new StringBuffer(40);
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR:
- text = "rgb(" +
- getValue().getRed().getCssText() + ", " +
- getValue().getGreen().getCssText() + ", " +
- FloatValue.getCssText(unit, value) + ")";
+ sb.append("rgb(");
+ sb.append(value.getRed().getCssText()); sb.append(',');
+ sb.append(value.getGreen().getCssText()); sb.append(',');
+ sb.append(FloatValue.getCssText(unit, fValue)); sb.append(')');
break;
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
- text = "rgb(" +
- getValue().item(0).getRed().getCssText() + ", " +
- getValue().item(0).getGreen().getCssText() + ", " +
- FloatValue.getCssText(unit, value) + ") " +
- getValue().item(1).getCssText();
+ sb.append("rgb(");
+ sb.append(value.item(0).getRed().getCssText());
+ sb.append(',');
+ sb.append(value.item(0).getGreen().getCssText());
+ sb.append(',');
+ sb.append(FloatValue.getCssText(unit, fValue));
+ sb.append(')');
+ sb.append(value.item(1).getCssText());
break;
default:
throw new DOMException
(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
}
- textChanged(text);
+ textChanged(sb.toString());
}
-
+
/**
* Called when the RGBColor text has changed.
*/
@@ -823,7 +855,7 @@ public class CSSOMSVGColor
throws DOMException {
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
- textChanged(rgb + " " + icc);
+ textChanged(rgb + ' ' + icc);
break;
default:
@@ -847,7 +879,7 @@ public class CSSOMSVGColor
break;
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
- textChanged(rgb + " " + icc);
+ textChanged(rgb + ' ' + icc);
break;
default:
@@ -859,18 +891,19 @@ public class CSSOMSVGColor
* Called when the ICC color profile has changed.
*/
public void colorProfileChanged(String cp) throws DOMException {
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
StringBuffer sb =
- new StringBuffer(getValue().item(0).getCssText());
+ new StringBuffer( value.item(0).getCssText());
sb.append(" icc-color(");
sb.append(cp);
- ICCColor iccc = (ICCColor)getValue().item(1);
+ ICCColor iccc = (ICCColor)value.item(1);
for (int i = 0; i < iccc.getLength(); i++) {
- sb.append(",");
+ sb.append(',');
sb.append(iccc.getColor(i));
}
- sb.append(")");
+ sb.append(')');
textChanged(sb.toString());
break;
@@ -884,14 +917,15 @@ public class CSSOMSVGColor
* Called when the ICC colors has changed.
*/
public void colorsCleared() throws DOMException {
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
StringBuffer sb =
- new StringBuffer(getValue().item(0).getCssText());
+ new StringBuffer( value.item(0).getCssText());
sb.append(" icc-color(");
- ICCColor iccc = (ICCColor)getValue().item(1);
+ ICCColor iccc = (ICCColor)value.item(1);
sb.append(iccc.getColorProfile());
- sb.append(")");
+ sb.append(')');
textChanged(sb.toString());
break;
@@ -905,16 +939,17 @@ public class CSSOMSVGColor
* Called when the ICC colors has been initialized.
*/
public void colorsInitialized(float f) throws DOMException {
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
StringBuffer sb =
- new StringBuffer(getValue().item(0).getCssText());
+ new StringBuffer( value.item(0).getCssText());
sb.append(" icc-color(");
- ICCColor iccc = (ICCColor)getValue().item(1);
+ ICCColor iccc = (ICCColor)value.item(1);
sb.append(iccc.getColorProfile());
- sb.append(",");
+ sb.append(',');
sb.append(f);
- sb.append(")");
+ sb.append(')');
textChanged(sb.toString());
break;
@@ -928,24 +963,25 @@ public class CSSOMSVGColor
* Called when the ICC color has been inserted.
*/
public void colorInsertedBefore(float f, int idx) throws DOMException {
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
StringBuffer sb =
- new StringBuffer(getValue().item(0).getCssText());
+ new StringBuffer( value.item(0).getCssText());
sb.append(" icc-color(");
- ICCColor iccc = (ICCColor)getValue().item(1);
+ ICCColor iccc = (ICCColor)value.item(1);
sb.append(iccc.getColorProfile());
for (int i = 0; i < idx; i++) {
- sb.append(",");
+ sb.append(',');
sb.append(iccc.getColor(i));
}
- sb.append(",");
+ sb.append(',');
sb.append(f);
for (int i = idx; i < iccc.getLength(); i++) {
- sb.append(",");
+ sb.append(',');
sb.append(iccc.getColor(i));
}
- sb.append(")");
+ sb.append(')');
textChanged(sb.toString());
break;
@@ -959,24 +995,25 @@ public class CSSOMSVGColor
* Called when the ICC color has been replaced.
*/
public void colorReplaced(float f, int idx) throws DOMException {
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
StringBuffer sb =
- new StringBuffer(getValue().item(0).getCssText());
+ new StringBuffer( value.item(0).getCssText());
sb.append(" icc-color(");
- ICCColor iccc = (ICCColor)getValue().item(1);
+ ICCColor iccc = (ICCColor)value.item(1);
sb.append(iccc.getColorProfile());
for (int i = 0; i < idx; i++) {
- sb.append(",");
+ sb.append(',');
sb.append(iccc.getColor(i));
}
- sb.append(",");
+ sb.append(',');
sb.append(f);
for (int i = idx + 1; i < iccc.getLength(); i++) {
- sb.append(",");
+ sb.append(',');
sb.append(iccc.getColor(i));
}
- sb.append(")");
+ sb.append(')');
textChanged(sb.toString());
break;
@@ -990,22 +1027,23 @@ public class CSSOMSVGColor
* Called when the ICC color has been removed.
*/
public void colorRemoved(int idx) throws DOMException {
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
StringBuffer sb =
- new StringBuffer(getValue().item(0).getCssText());
+ new StringBuffer( value.item(0).getCssText());
sb.append(" icc-color(");
- ICCColor iccc = (ICCColor)getValue().item(1);
+ ICCColor iccc = (ICCColor)value.item(1);
sb.append(iccc.getColorProfile());
for (int i = 0; i < idx; i++) {
- sb.append(",");
+ sb.append(',');
sb.append(iccc.getColor(i));
}
for (int i = idx + 1; i < iccc.getLength(); i++) {
- sb.append(",");
+ sb.append(',');
sb.append(iccc.getColor(i));
}
- sb.append(")");
+ sb.append(')');
textChanged(sb.toString());
break;
@@ -1019,20 +1057,21 @@ public class CSSOMSVGColor
* Called when the ICC color has been append.
*/
public void colorAppend(float f) throws DOMException {
+ Value value = getValue();
switch (getColorType()) {
case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
StringBuffer sb =
- new StringBuffer(getValue().item(0).getCssText());
+ new StringBuffer( value.item(0).getCssText());
sb.append(" icc-color(");
- ICCColor iccc = (ICCColor)getValue().item(1);
+ ICCColor iccc = (ICCColor)value.item(1);
sb.append(iccc.getColorProfile());
for (int i = 0; i < iccc.getLength(); i++) {
- sb.append(",");
+ sb.append(',');
sb.append(iccc.getColor(i));
}
- sb.append(",");
+ sb.append(',');
sb.append(f);
- sb.append(")");
+ sb.append(')');
textChanged(sb.toString());
break;
@@ -1092,7 +1131,7 @@ public class CSSOMSVGColor
public String getStringValue() throws DOMException {
return valueProvider.getValue().getStringValue();
}
-
+
/**
* <b>DOM</b>: Implements {@link
* org.w3c.dom.css.CSSPrimitiveValue#getCounterValue()}.
@@ -1100,7 +1139,7 @@ public class CSSOMSVGColor
public Counter getCounterValue() throws DOMException {
throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
}
-
+
/**
* <b>DOM</b>: Implements {@link
* org.w3c.dom.css.CSSPrimitiveValue#getRectValue()}.
@@ -1126,7 +1165,7 @@ public class CSSOMSVGColor
public int getLength() {
throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
}
-
+
/**
* <b>DOM</b>: Implements {@link
* org.w3c.dom.css.CSSValueList#item(int)}.
@@ -1155,7 +1194,7 @@ public class CSSOMSVGColor
* To represents a red component.
*/
protected class RedComponent extends FloatComponent {
-
+
/**
* The returns the actual value of this component.
*/
@@ -1199,7 +1238,7 @@ public class CSSOMSVGColor
* To represents a green component.
*/
protected class GreenComponent extends FloatComponent {
-
+
/**
* The returns the actual value of this component.
*/
@@ -1242,7 +1281,7 @@ public class CSSOMSVGColor
* To represents a blue component.
*/
protected class BlueComponent extends FloatComponent {
-
+
/**
* The returns the actual value of this component.
*/
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/css/dom/CSSOMSVGComputedStyle.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/css/dom/CSSOMSVGComputedStyle.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/css/dom/CSSOMSVGComputedStyle.java
index 219e139..d194d0a 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/css/dom/CSSOMSVGComputedStyle.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/css/dom/CSSOMSVGComputedStyle.java
@@ -1,10 +1,11 @@
/*
- Copyright 2002-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
@@ -29,7 +30,7 @@ import org.w3c.dom.css.CSSValue;
* This class represents the computed style of an SVG element.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: CSSOMSVGComputedStyle.java,v 1.6 2004/08/18 07:12:47 vhardy Exp $
+ * @version $Id: CSSOMSVGComputedStyle.java 475477 2006-11-15 22:44:28Z cam $
*/
public class CSSOMSVGComputedStyle extends CSSOMComputedStyle {