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:26 UTC
[11/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/SVGPolygonElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGPolygonElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGPolygonElementBridge.java
index 58e4dba..dfc7fa3 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGPolygonElementBridge.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGPolygonElementBridge.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
@@ -20,20 +21,23 @@ package org.apache.flex.forks.batik.bridge;
import java.awt.Shape;
import java.awt.geom.GeneralPath;
-import org.apache.flex.forks.batik.css.engine.CSSEngineEvent;
import org.apache.flex.forks.batik.css.engine.SVGCSSEngine;
+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.SVGOMAnimatedPoints;
+import org.apache.flex.forks.batik.dom.svg.SVGOMPolygonElement;
import org.apache.flex.forks.batik.gvt.ShapeNode;
import org.apache.flex.forks.batik.parser.AWTPolygonProducer;
-import org.apache.flex.forks.batik.parser.ParseException;
-import org.apache.flex.forks.batik.parser.PointsParser;
+
import org.w3c.dom.Element;
-import org.w3c.dom.events.MutationEvent;
+import org.w3c.dom.svg.SVGPoint;
+import org.w3c.dom.svg.SVGPointList;
/**
* Bridge class for the <polygon> element.
*
* @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
- * @version $Id: SVGPolygonElementBridge.java,v 1.20 2004/08/18 07:12:35 vhardy Exp $
+ * @version $Id: SVGPolygonElementBridge.java 594018 2007-11-12 04:17:41Z cam $
*/
public class SVGPolygonElementBridge extends SVGDecoratedShapeElementBridge {
@@ -73,44 +77,46 @@ public class SVGPolygonElementBridge extends SVGDecoratedShapeElementBridge {
Element e,
ShapeNode shapeNode) {
- String s = e.getAttributeNS(null, SVG_POINTS_ATTRIBUTE);
- if (s.length() != 0) {
- AWTPolygonProducer app = new AWTPolygonProducer();
- app.setWindingRule(CSSUtilities.convertFillRule(e));
- try {
- PointsParser pp = new PointsParser();
- pp.setPointsHandler(app);
- pp.parse(s);
- } catch (ParseException ex) {
- BridgeException bex
- = new BridgeException(e, ERR_ATTRIBUTE_VALUE_MALFORMED,
- new Object[] {SVG_POINTS_ATTRIBUTE});
- bex.setGraphicsNode(shapeNode);
- throw bex;
- } finally {
+ SVGOMPolygonElement pe = (SVGOMPolygonElement) e;
+ try {
+ SVGOMAnimatedPoints _points = pe.getSVGOMAnimatedPoints();
+ _points.check();
+ SVGPointList pl = _points.getAnimatedPoints();
+ int size = pl.getNumberOfItems();
+ if (size == 0) {
+ shapeNode.setShape(DEFAULT_SHAPE);
+ } else {
+ AWTPolygonProducer app = new AWTPolygonProducer();
+ app.setWindingRule(CSSUtilities.convertFillRule(e));
+ app.startPoints();
+ for (int i = 0; i < size; i++) {
+ SVGPoint p = pl.getItem(i);
+ app.point(p.getX(), p.getY());
+ }
+ app.endPoints();
shapeNode.setShape(app.getShape());
}
+ } catch (LiveAttributeException ex) {
+ throw new BridgeException(ctx, ex);
}
}
// 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();
- if (attrName.equals(SVG_POINTS_ATTRIBUTE)) {
- if ( evt.getNewValue().length() == 0 ){
- ((ShapeNode)node).setShape(DEFAULT_SHAPE);
- }
- else{
+ public void handleAnimatedAttributeChanged
+ (AnimatedLiveAttributeValue alav) {
+ if (alav.getNamespaceURI() == null) {
+ String ln = alav.getLocalName();
+ if (ln.equals(SVG_POINTS_ATTRIBUTE)) {
buildShape(ctx, e, (ShapeNode)node);
+ handleGeometryChanged();
+ return;
}
- handleGeometryChanged();
- } else {
- super.handleDOMAttrModifiedEvent(evt);
}
+ super.handleAnimatedAttributeChanged(alav);
}
protected void handleCSSPropertyChanged(int property) {
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGPolylineElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGPolylineElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGPolylineElementBridge.java
index 321ef76..5b8dbea 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGPolylineElementBridge.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGPolylineElementBridge.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
@@ -20,20 +21,23 @@ package org.apache.flex.forks.batik.bridge;
import java.awt.Shape;
import java.awt.geom.GeneralPath;
-import org.apache.flex.forks.batik.css.engine.CSSEngineEvent;
import org.apache.flex.forks.batik.css.engine.SVGCSSEngine;
+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.SVGOMAnimatedPoints;
+import org.apache.flex.forks.batik.dom.svg.SVGOMPolylineElement;
import org.apache.flex.forks.batik.gvt.ShapeNode;
import org.apache.flex.forks.batik.parser.AWTPolylineProducer;
-import org.apache.flex.forks.batik.parser.ParseException;
-import org.apache.flex.forks.batik.parser.PointsParser;
+
import org.w3c.dom.Element;
-import org.w3c.dom.events.MutationEvent;
+import org.w3c.dom.svg.SVGPoint;
+import org.w3c.dom.svg.SVGPointList;
/**
* Bridge class for the <polyline> element.
*
* @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
- * @version $Id: SVGPolylineElementBridge.java,v 1.19 2004/08/18 07:12:35 vhardy Exp $
+ * @version $Id: SVGPolylineElementBridge.java 594018 2007-11-12 04:17:41Z cam $
*/
public class SVGPolylineElementBridge extends SVGDecoratedShapeElementBridge {
@@ -73,44 +77,46 @@ public class SVGPolylineElementBridge extends SVGDecoratedShapeElementBridge {
Element e,
ShapeNode shapeNode) {
- String s = e.getAttributeNS(null, SVG_POINTS_ATTRIBUTE);
- if (s.length() != 0) {
- AWTPolylineProducer app = new AWTPolylineProducer();
- app.setWindingRule(CSSUtilities.convertFillRule(e));
- try {
- PointsParser pp = new PointsParser();
- pp.setPointsHandler(app);
- pp.parse(s);
- } catch (ParseException ex) {
- BridgeException bex
- = new BridgeException(e, ERR_ATTRIBUTE_VALUE_MALFORMED,
- new Object[] {SVG_POINTS_ATTRIBUTE});
- bex.setGraphicsNode(shapeNode);
- throw bex;
- } finally {
+ SVGOMPolylineElement pe = (SVGOMPolylineElement) e;
+ try {
+ SVGOMAnimatedPoints _points = pe.getSVGOMAnimatedPoints();
+ _points.check();
+ SVGPointList pl = _points.getAnimatedPoints();
+ int size = pl.getNumberOfItems();
+ if (size == 0) {
+ shapeNode.setShape(DEFAULT_SHAPE);
+ } else {
+ AWTPolylineProducer app = new AWTPolylineProducer();
+ app.setWindingRule(CSSUtilities.convertFillRule(e));
+ app.startPoints();
+ for (int i = 0; i < size; i++) {
+ SVGPoint p = pl.getItem(i);
+ app.point(p.getX(), p.getY());
+ }
+ app.endPoints();
shapeNode.setShape(app.getShape());
}
+ } catch (LiveAttributeException ex) {
+ throw new BridgeException(ctx, ex);
}
}
// 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();
- if (attrName.equals(SVG_POINTS_ATTRIBUTE)) {
- if ( evt.getNewValue().length() == 0 ){
- ((ShapeNode)node).setShape(DEFAULT_SHAPE);
- }
- else{
+ public void handleAnimatedAttributeChanged
+ (AnimatedLiveAttributeValue alav) {
+ if (alav.getNamespaceURI() == null) {
+ String ln = alav.getLocalName();
+ if (ln.equals(SVG_POINTS_ATTRIBUTE)) {
buildShape(ctx, e, (ShapeNode)node);
+ handleGeometryChanged();
+ return;
}
- handleGeometryChanged();
- } else {
- super.handleDOMAttrModifiedEvent(evt);
}
+ super.handleAnimatedAttributeChanged(alav);
}
protected void handleCSSPropertyChanged(int property) {
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGRadialGradientElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGRadialGradientElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGRadialGradientElementBridge.java
index e05e08c..5a83793 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGRadialGradientElementBridge.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGRadialGradientElementBridge.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
@@ -21,17 +22,20 @@ import java.awt.Color;
import java.awt.Paint;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import org.apache.flex.forks.batik.dom.svg.SVGContext;
import org.apache.flex.forks.batik.ext.awt.MultipleGradientPaint;
import org.apache.flex.forks.batik.ext.awt.RadialGradientPaint;
import org.apache.flex.forks.batik.gvt.GraphicsNode;
+
import org.w3c.dom.Element;
/**
* Bridge class for the <radialGradient> element.
*
* @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
- * @version $Id: SVGRadialGradientElementBridge.java,v 1.11 2004/08/18 07:12:35 vhardy Exp $
+ * @version $Id: SVGRadialGradientElementBridge.java 594776 2007-11-14 05:34:02Z cam $
*/
public class SVGRadialGradientElementBridge
extends AbstractSVGGradientElementBridge {
@@ -116,7 +120,21 @@ public class SVGRadialGradientElementBridge
coordSystemType = SVGUtilities.OBJECT_BOUNDING_BOX;
} else {
coordSystemType = SVGUtilities.parseCoordinateSystem
- (paintElement, SVG_GRADIENT_UNITS_ATTRIBUTE, s);
+ (paintElement, SVG_GRADIENT_UNITS_ATTRIBUTE, s, ctx);
+ }
+
+ // The last paragraph of section 7.11 in SVG 1.1 states that objects
+ // with zero width or height bounding boxes that use gradients with
+ // gradientUnits="objectBoundingBox" must not use the gradient.
+ SVGContext bridge = BridgeContext.getSVGContext(paintedElement);
+ if (coordSystemType == SVGUtilities.OBJECT_BOUNDING_BOX
+ && bridge instanceof AbstractGraphicsNodeBridge) {
+ // XXX Make this work for non-AbstractGraphicsNodeBridges, like
+ // the various text child bridges.
+ Rectangle2D bbox = ((AbstractGraphicsNodeBridge) bridge).getBBox();
+ if (bbox != null && bbox.getWidth() == 0 || bbox.getHeight() == 0) {
+ return null;
+ }
}
// additional transform to move to objectBoundingBox coordinate system
@@ -131,8 +149,8 @@ public class SVGRadialGradientElementBridge
SVG_R_ATTRIBUTE,
coordSystemType,
uctx);
- // A value of zero will cause the area to be painted as a single color
- // using the color and opacity of the last gradient stop.
+ // A value of zero will cause the area to be painted as a single color
+ // using the color and opacity of the last gradient stop.
if (r == 0) {
return colors[colors.length-1];
} else {
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGRectElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGRectElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGRectElementBridge.java
index c2a3cea..1ecc395 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGRectElementBridge.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGRectElementBridge.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
@@ -21,17 +22,20 @@ import java.awt.Shape;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;
+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.SVGOMRectElement;
import org.apache.flex.forks.batik.gvt.ShapeNode;
import org.apache.flex.forks.batik.gvt.ShapePainter;
import org.w3c.dom.Element;
-import org.w3c.dom.events.MutationEvent;
/**
* Bridge class for the <rect> element.
*
* @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
- * @version $Id: SVGRectElementBridge.java,v 1.16 2004/08/18 07:12:35 vhardy Exp $
+ * @version $Id: SVGRectElementBridge.java 527382 2007-04-11 04:31:58Z cam $
*/
public class SVGRectElementBridge extends SVGShapeElementBridge {
@@ -65,114 +69,80 @@ public class SVGRectElementBridge extends SVGShapeElementBridge {
Element e,
ShapeNode shapeNode) {
- UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e);
- String s;
-
- // 'x' attribute - default is 0
- s = e.getAttributeNS(null, SVG_X_ATTRIBUTE);
- float x = 0;
- if (s.length() != 0) {
- x = UnitProcessor.svgHorizontalCoordinateToUserSpace
- (s, SVG_X_ATTRIBUTE, uctx);
- }
-
- // 'y' attribute - default is 0
- s = e.getAttributeNS(null, SVG_Y_ATTRIBUTE);
- float y = 0;
- if (s.length() != 0) {
- y = UnitProcessor.svgVerticalCoordinateToUserSpace
- (s, SVG_Y_ATTRIBUTE, uctx);
- }
-
- // 'width' attribute - required
- s = e.getAttributeNS(null, SVG_WIDTH_ATTRIBUTE);
- float w;
- if (s.length() != 0) {
- w = UnitProcessor.svgHorizontalLengthToUserSpace
- (s, SVG_WIDTH_ATTRIBUTE, uctx);
- } else {
- throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
- new Object[] {SVG_WIDTH_ATTRIBUTE, s});
- }
-
- // 'height' attribute - required
- s = e.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE);
- float h;
- if (s.length() != 0) {
- h = UnitProcessor.svgVerticalLengthToUserSpace
- (s, SVG_HEIGHT_ATTRIBUTE, uctx);
- } else {
- throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
- new Object[] {SVG_HEIGHT_ATTRIBUTE, s});
- }
+ try {
+ SVGOMRectElement re = (SVGOMRectElement) e;
+
+ // 'x' attribute - default is 0
+ AbstractSVGAnimatedLength _x =
+ (AbstractSVGAnimatedLength) re.getX();
+ float x = _x.getCheckedValue();
+
+ // 'y' attribute - default is 0
+ AbstractSVGAnimatedLength _y =
+ (AbstractSVGAnimatedLength) re.getY();
+ float y = _y.getCheckedValue();
+
+ // 'width' attribute - required
+ AbstractSVGAnimatedLength _width =
+ (AbstractSVGAnimatedLength) re.getWidth();
+ float w = _width.getCheckedValue();
+
+ // 'height' attribute - required
+ AbstractSVGAnimatedLength _height =
+ (AbstractSVGAnimatedLength) re.getHeight();
+ float h = _height.getCheckedValue();
+
+ // 'rx' attribute - default is 0
+ AbstractSVGAnimatedLength _rx =
+ (AbstractSVGAnimatedLength) re.getRx();
+ float rx = _rx.getCheckedValue();
+ if (rx > w / 2) {
+ rx = w / 2;
+ }
- // 'rx' attribute - default is 0
- s = e.getAttributeNS(null, SVG_RX_ATTRIBUTE);
- boolean rxs = (s.length() != 0);
- float rx = 0;
- if (rxs) {
- rx = UnitProcessor.svgHorizontalLengthToUserSpace
- (s, SVG_RX_ATTRIBUTE, uctx);
- }
- rx = (rx > w / 2) ? w / 2 : rx;
-
- // 'ry' attribute - default is 0
- s = e.getAttributeNS(null, SVG_RY_ATTRIBUTE);
- boolean rys = (s.length() != 0);
- float ry = 0;
- if (rys) {
- ry = UnitProcessor.svgVerticalLengthToUserSpace
- (s, SVG_RY_ATTRIBUTE, uctx);
- }
- ry = (ry > h / 2) ? h / 2 : ry;
+ // 'ry' attribute - default is rx
+ AbstractSVGAnimatedLength _ry =
+ (AbstractSVGAnimatedLength) re.getRy();
+ float ry = _ry.getCheckedValue();
+ if (ry > h / 2) {
+ ry = h / 2;
+ }
- Shape shape = null;
- if (rxs && rys) {
+ Shape shape;
if (rx == 0 || ry == 0) {
shape = new Rectangle2D.Float(x, y, w, h);
} else {
- shape = new RoundRectangle2D.Float(x, y, w, h, rx*2, ry*2);
- }
- } else if (rxs) {
- if (rx == 0) {
- shape = new Rectangle2D.Float(x, y, w, h);
- } else {
- shape = new RoundRectangle2D.Float(x, y, w, h, rx*2, rx*2);
+ shape = new RoundRectangle2D.Float(x, y, w, h, rx * 2, ry * 2);
}
- } else if (rys) {
- if (ry == 0) {
- shape = new Rectangle2D.Float(x, y, w, h);
- } else {
- shape = new RoundRectangle2D.Float(x, y, w, h, ry*2, ry*2);
- }
- } else {
- shape = new Rectangle2D.Float(x, y, w, h);
+ shapeNode.setShape(shape);
+ } catch (LiveAttributeException ex) {
+ throw new BridgeException(ctx, ex);
}
- shapeNode.setShape(shape);
}
// 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();
- if (attrName.equals(SVG_X_ATTRIBUTE) ||
- attrName.equals(SVG_Y_ATTRIBUTE) ||
- attrName.equals(SVG_WIDTH_ATTRIBUTE) ||
- attrName.equals(SVG_HEIGHT_ATTRIBUTE) ||
- attrName.equals(SVG_RX_ATTRIBUTE) ||
- attrName.equals(SVG_RY_ATTRIBUTE)) {
-
- buildShape(ctx, e, (ShapeNode)node);
- handleGeometryChanged();
- } else {
- super.handleDOMAttrModifiedEvent(evt);
+ public void handleAnimatedAttributeChanged
+ (AnimatedLiveAttributeValue alav) {
+ if (alav.getNamespaceURI() == null) {
+ String ln = alav.getLocalName();
+ if (ln.equals(SVG_X_ATTRIBUTE)
+ || ln.equals(SVG_Y_ATTRIBUTE)
+ || ln.equals(SVG_WIDTH_ATTRIBUTE)
+ || ln.equals(SVG_HEIGHT_ATTRIBUTE)
+ || ln.equals(SVG_RX_ATTRIBUTE)
+ || ln.equals(SVG_RY_ATTRIBUTE)) {
+ buildShape(ctx, e, (ShapeNode)node);
+ handleGeometryChanged();
+ return;
+ }
}
+ super.handleAnimatedAttributeChanged(alav);
}
-
protected ShapePainter createShapePainter(BridgeContext ctx,
Element e,
ShapeNode shapeNode) {
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGSVGElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGSVGElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGSVGElementBridge.java
index 30a214e..ecaf0dd 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGSVGElementBridge.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGSVGElementBridge.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
@@ -23,15 +24,19 @@ import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.Rectangle2D;
-import java.text.AttributedCharacterIterator;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.apache.flex.forks.batik.dom.svg.SVGSVGContext;
+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.SVGContext;
+import org.apache.flex.forks.batik.dom.svg.SVGOMAnimatedRect;
import org.apache.flex.forks.batik.dom.svg.SVGOMElement;
+import org.apache.flex.forks.batik.dom.svg.SVGOMSVGElement;
+import org.apache.flex.forks.batik.dom.svg.SVGSVGContext;
import org.apache.flex.forks.batik.ext.awt.image.renderable.ClipRable8Bit;
import org.apache.flex.forks.batik.ext.awt.image.renderable.Filter;
import org.apache.flex.forks.batik.gvt.CanvasGraphicsNode;
@@ -39,23 +44,18 @@ import org.apache.flex.forks.batik.gvt.CompositeGraphicsNode;
import org.apache.flex.forks.batik.gvt.GraphicsNode;
import org.apache.flex.forks.batik.gvt.ShapeNode;
import org.apache.flex.forks.batik.gvt.TextNode;
-import org.apache.flex.forks.batik.gvt.font.GVTGlyphVector;
-import org.apache.flex.forks.batik.gvt.renderer.StrokingTextPainter;
-import org.apache.flex.forks.batik.gvt.text.GVTAttributedCharacterIterator;
-import org.apache.flex.forks.batik.gvt.text.TextSpanLayout;
-import org.apache.flex.forks.batik.util.SVGConstants;
+
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.w3c.dom.events.MutationEvent;
-import org.w3c.flex.forks.dom.svg.SVGDocument;
-import org.w3c.flex.forks.dom.svg.SVGSVGElement;
-import org.w3c.flex.forks.dom.svg.SVGRect;
+import org.w3c.dom.svg.SVGAnimatedPreserveAspectRatio;
+import org.w3c.dom.svg.SVGDocument;
+import org.w3c.dom.svg.SVGRect;
/**
* Bridge class for the <svg> element.
*
* @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
- * @version $Id: SVGSVGElementBridge.java,v 1.47 2005/03/27 08:58:30 cam Exp $
+ * @version $Id: SVGSVGElementBridge.java 579487 2007-09-26 06:40:16Z cam $
*/
public class SVGSVGElementBridge
extends SVGGElementBridge
@@ -95,130 +95,133 @@ public class SVGSVGElementBridge
* @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;
- }
+ // 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
+ if (!SVGUtilities.matchUserAgent(e, ctx.getUserAgent())) {
+ return null;
+ }
CanvasGraphicsNode cgn;
cgn = (CanvasGraphicsNode)instantiateGraphicsNode();
- UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e);
- String s;
-
- // In some cases we converted document fragments which didn't
- // have a parent SVG element, this check makes sure only the
- // real root of the SVG Document tries to do negotiation with
- // the UA.
- SVGDocument doc = (SVGDocument)e.getOwnerDocument();
- boolean isOutermost = (doc.getRootElement() == e);
- float x = 0;
- float y = 0;
- // x and y have no meaning on the outermost 'svg' element
- if (!isOutermost) {
- // 'x' attribute - default is 0
- s = e.getAttributeNS(null, SVG_X_ATTRIBUTE);
- if (s.length() != 0) {
- x = UnitProcessor.svgHorizontalCoordinateToUserSpace
- (s, SVG_X_ATTRIBUTE, uctx);
- }
- // 'y' attribute - default is 0
- s = e.getAttributeNS(null, SVG_Y_ATTRIBUTE);
- if (s.length() != 0) {
- y = UnitProcessor.svgVerticalCoordinateToUserSpace
- (s, SVG_Y_ATTRIBUTE, uctx);
- }
- }
+ associateSVGContext(ctx, e, cgn);
- // 'width' attribute - default is 100%
- s = e.getAttributeNS(null, SVG_WIDTH_ATTRIBUTE);
- if (s.length() == 0) {
- s = SVG_SVG_WIDTH_DEFAULT_VALUE;
- }
- float w = UnitProcessor.svgHorizontalLengthToUserSpace
- (s, SVG_WIDTH_ATTRIBUTE, uctx);
+ try {
+ // In some cases we converted document fragments which didn't
+ // have a parent SVG element, this check makes sure only the
+ // real root of the SVG Document tries to do negotiation with
+ // the UA.
+ SVGDocument doc = (SVGDocument)e.getOwnerDocument();
+ SVGOMSVGElement se = (SVGOMSVGElement) e;
+ boolean isOutermost = (doc.getRootElement() == e);
+ float x = 0;
+ float y = 0;
+ // x and y have no meaning on the outermost 'svg' element
+ if (!isOutermost) {
+ // 'x' attribute - default is 0
+ AbstractSVGAnimatedLength _x =
+ (AbstractSVGAnimatedLength) se.getX();
+ x = _x.getCheckedValue();
- // 'height' attribute - default is 100%
- s = e.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE);
- if (s.length() == 0) {
- s = SVG_SVG_HEIGHT_DEFAULT_VALUE;
- }
- float h = UnitProcessor.svgVerticalLengthToUserSpace
- (s, SVG_HEIGHT_ATTRIBUTE, uctx);
+ // 'y' attribute - default is 0
+ AbstractSVGAnimatedLength _y =
+ (AbstractSVGAnimatedLength) se.getY();
+ y = _y.getCheckedValue();
+ }
- // 'visibility'
- cgn.setVisible(CSSUtilities.convertVisibility(e));
+ // 'width' attribute - default is 100%
+ AbstractSVGAnimatedLength _width =
+ (AbstractSVGAnimatedLength) se.getWidth();
+ float w = _width.getCheckedValue();
- // 'viewBox' and "preserveAspectRatio' attributes
- AffineTransform viewingTransform =
- ViewBox.getPreserveAspectRatioTransform(e, w, h);
+ // 'height' attribute - default is 100%
+ AbstractSVGAnimatedLength _height =
+ (AbstractSVGAnimatedLength) se.getHeight();
+ float h = _height.getCheckedValue();
- float actualWidth = w;
- float actualHeight = h;
- try {
- AffineTransform vtInv = viewingTransform.createInverse();
- actualWidth = (float) (w*vtInv.getScaleX());
- actualHeight = (float) (h*vtInv.getScaleY());
- } catch (NoninvertibleTransformException ex) {}
-
- AffineTransform positionTransform =
- AffineTransform.getTranslateInstance(x, y);
- // The outermost preserveAspectRatio matrix is set by the user
- // agent, so we don't need to set the transform for outermost svg
- if (!isOutermost) {
- // X & Y are ignored on outermost SVG.
- cgn.setPositionTransform(positionTransform);
- } else if (doc == ctx.getDocument()) {
- // <!> FIXME: hack to compute the original document's size
- ctx.setDocumentSize(new Dimension((int)(w+0.5f), (int)(h+0.5f)));
- }
- // Set the viewing transform, this is often updated when the
- // component prepares for rendering.
- cgn.setViewingTransform(viewingTransform);
-
- // 'overflow' and 'clip'
- Shape clip = null;
- if (CSSUtilities.convertOverflow(e)) { // overflow:hidden
- float [] offsets = CSSUtilities.convertClip(e);
- if (offsets == null) { // clip:auto
- clip = new Rectangle2D.Float(x, y, w, h);
- } else { // clip:rect(<x> <y> <w> <h>)
- // offsets[0] = top
- // offsets[1] = right
- // offsets[2] = bottom
- // offsets[3] = left
- clip = new Rectangle2D.Float(x+offsets[3],
- y+offsets[0],
- w-offsets[1]-offsets[3],
- h-offsets[2]-offsets[0]);
- }
- }
+ // 'visibility'
+ cgn.setVisible(CSSUtilities.convertVisibility(e));
+
+ // 'viewBox' and "preserveAspectRatio' attributes
+ SVGOMAnimatedRect vb = (SVGOMAnimatedRect) se.getViewBox();
+ SVGAnimatedPreserveAspectRatio par = se.getPreserveAspectRatio();
+ AffineTransform viewingTransform =
+ ViewBox.getPreserveAspectRatioTransform(e, vb, par, w, h, ctx);
- if (clip != null) {
+ float actualWidth = w;
+ float actualHeight = h;
try {
- AffineTransform at = new AffineTransform(positionTransform);
- at.concatenate(viewingTransform);
- at = at.createInverse(); // clip in user space
- clip = at.createTransformedShape(clip);
- Filter filter = cgn.getGraphicsNodeRable(true);
- cgn.setClip(new ClipRable8Bit(filter, clip));
+ AffineTransform vtInv = viewingTransform.createInverse();
+ actualWidth = (float) (w*vtInv.getScaleX());
+ actualHeight = (float) (h*vtInv.getScaleY());
} catch (NoninvertibleTransformException ex) {}
- }
- RenderingHints hints = null;
- hints = CSSUtilities.convertColorRendering(e, hints);
- if (hints != null)
- cgn.setRenderingHints(hints);
-
- // 'enable-background'
- Rectangle2D r = CSSUtilities.convertEnableBackground(e);
- if (r != null) {
- cgn.setBackgroundEnable(r);
- }
- ctx.openViewport
- (e, new SVGSVGElementViewport(actualWidth,
- actualHeight));
- return cgn;
+ AffineTransform positionTransform =
+ AffineTransform.getTranslateInstance(x, y);
+ // The outermost preserveAspectRatio matrix is set by the user
+ // agent, so we don't need to set the transform for outermost svg
+ if (!isOutermost) {
+ // X & Y are ignored on outermost SVG.
+ cgn.setPositionTransform(positionTransform);
+ } else if (doc == ctx.getDocument()) {
+ // <!> FIXME: hack to compute the original document's size
+ ctx.setDocumentSize(new Dimension((int) (w + 0.5f),
+ (int) (h + 0.5f)));
+ }
+ // Set the viewing transform, this is often updated when the
+ // component prepares for rendering.
+ cgn.setViewingTransform(viewingTransform);
+
+ // 'overflow' and 'clip'
+ Shape clip = null;
+ if (CSSUtilities.convertOverflow(e)) { // overflow:hidden
+ float [] offsets = CSSUtilities.convertClip(e);
+ if (offsets == null) { // clip:auto
+ clip = new Rectangle2D.Float(x, y, w, h);
+ } else { // clip:rect(<x> <y> <w> <h>)
+ // offsets[0] = top
+ // offsets[1] = right
+ // offsets[2] = bottom
+ // offsets[3] = left
+ clip = new Rectangle2D.Float(x+offsets[3],
+ y+offsets[0],
+ w-offsets[1]-offsets[3],
+ h-offsets[2]-offsets[0]);
+ }
+ }
+
+ if (clip != null) {
+ try {
+ AffineTransform at = new AffineTransform(positionTransform);
+ at.concatenate(viewingTransform);
+ at = at.createInverse(); // clip in user space
+ clip = at.createTransformedShape(clip);
+ Filter filter = cgn.getGraphicsNodeRable(true);
+ cgn.setClip(new ClipRable8Bit(filter, clip));
+ } catch (NoninvertibleTransformException ex) {}
+ }
+ RenderingHints hints = null;
+ hints = CSSUtilities.convertColorRendering(e, hints);
+ if (hints != null)
+ cgn.setRenderingHints(hints);
+
+ // 'enable-background'
+ Rectangle2D r = CSSUtilities.convertEnableBackground(e);
+ if (r != null) {
+ cgn.setBackgroundEnable(r);
+ }
+
+ if (vb.isSpecified()) {
+ SVGRect vbr = vb.getAnimVal();
+ actualWidth = vbr.getWidth();
+ actualHeight = vbr.getHeight();
+ }
+ ctx.openViewport
+ (e, new SVGSVGElementViewport(actualWidth,
+ actualHeight));
+ return cgn;
+ } catch (LiveAttributeException ex) {
+ throw new BridgeException(ctx, ex);
+ }
}
/**
@@ -258,144 +261,139 @@ public class SVGSVGElementBridge
}
/**
- * 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) {
- // Don't call 'super' because there is no 'transform'
- // attribute on <svg>
- String attrName = evt.getAttrName();
- boolean rebuild = false;
- if (attrName.equals(SVG_WIDTH_ATTRIBUTE) ||
- attrName.equals(SVG_HEIGHT_ATTRIBUTE) ) {
- rebuild = true;
- } else if (attrName.equals(SVG_X_ATTRIBUTE) ||
- attrName.equals(SVG_Y_ATTRIBUTE)) {
- SVGDocument doc = (SVGDocument)e.getOwnerDocument();
- boolean isOutermost = (doc.getRootElement() == e);
- if (!isOutermost) {
- // X & Y are ignored on outermost SVG.
- float x = 0;
- float y = 0;
- UnitProcessor.Context uctx;
- uctx = UnitProcessor.createContext(ctx, e);
- // 'x' attribute - default is 0
- String s = e.getAttributeNS(null, SVG_X_ATTRIBUTE);
- if (s.length() != 0) {
- x = UnitProcessor.svgHorizontalCoordinateToUserSpace
- (s, SVG_X_ATTRIBUTE, uctx);
- }
- // 'y' attribute - default is 0
- s = e.getAttributeNS(null, SVG_Y_ATTRIBUTE);
- if (s.length() != 0) {
- y = UnitProcessor.svgVerticalCoordinateToUserSpace
- (s, SVG_Y_ATTRIBUTE, uctx);
+ public void handleAnimatedAttributeChanged
+ (AnimatedLiveAttributeValue alav) {
+ try {
+ boolean rebuild = false;
+ if (alav.getNamespaceURI() == null) {
+ String ln = alav.getLocalName();
+ if (ln.equals(SVG_WIDTH_ATTRIBUTE)
+ || ln.equals(SVG_HEIGHT_ATTRIBUTE)) {
+ rebuild = true;
+ } else if (ln.equals(SVG_X_ATTRIBUTE)
+ || ln.equals(SVG_Y_ATTRIBUTE)) {
+ SVGDocument doc = (SVGDocument)e.getOwnerDocument();
+ SVGOMSVGElement se = (SVGOMSVGElement) e;
+ // X & Y are ignored on outermost SVG.
+ boolean isOutermost = doc.getRootElement() == e;
+ if (!isOutermost) {
+ // 'x' attribute - default is 0
+ AbstractSVGAnimatedLength _x =
+ (AbstractSVGAnimatedLength) se.getX();
+ float x = _x.getCheckedValue();
+
+ // 'y' attribute - default is 0
+ AbstractSVGAnimatedLength _y =
+ (AbstractSVGAnimatedLength) se.getY();
+ float y = _y.getCheckedValue();
+
+ AffineTransform positionTransform =
+ AffineTransform.getTranslateInstance(x, y);
+ CanvasGraphicsNode cgn;
+ cgn = (CanvasGraphicsNode)node;
+
+ cgn.setPositionTransform(positionTransform);
+ return;
+ }
+ } else if (ln.equals(SVG_VIEW_BOX_ATTRIBUTE)
+ || ln.equals(SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE)) {
+ SVGDocument doc = (SVGDocument)e.getOwnerDocument();
+ SVGOMSVGElement se = (SVGOMSVGElement) e;
+ boolean isOutermost = doc.getRootElement() == e;
+
+ // X & Y are ignored on outermost SVG.
+ float x = 0;
+ float y = 0;
+ if (!isOutermost) {
+ // 'x' attribute - default is 0
+ AbstractSVGAnimatedLength _x =
+ (AbstractSVGAnimatedLength) se.getX();
+ x = _x.getCheckedValue();
+
+ // 'y' attribute - default is 0
+ AbstractSVGAnimatedLength _y =
+ (AbstractSVGAnimatedLength) se.getY();
+ y = _y.getCheckedValue();
+ }
+
+ // 'width' attribute - default is 100%
+ AbstractSVGAnimatedLength _width =
+ (AbstractSVGAnimatedLength) se.getWidth();
+ float w = _width.getCheckedValue();
+
+ // 'height' attribute - default is 100%
+ AbstractSVGAnimatedLength _height =
+ (AbstractSVGAnimatedLength) se.getHeight();
+ float h = _height.getCheckedValue();
+
+ CanvasGraphicsNode cgn;
+ cgn = (CanvasGraphicsNode)node;
+
+ // 'viewBox' and "preserveAspectRatio' attributes
+ SVGOMAnimatedRect vb = (SVGOMAnimatedRect) se.getViewBox();
+ SVGAnimatedPreserveAspectRatio par = se.getPreserveAspectRatio();
+ AffineTransform newVT = ViewBox.getPreserveAspectRatioTransform
+ (e, vb, par, w, h, ctx);
+
+ AffineTransform oldVT = cgn.getViewingTransform();
+ if ((newVT.getScaleX() != oldVT.getScaleX()) ||
+ (newVT.getScaleY() != oldVT.getScaleY()) ||
+ (newVT.getShearX() != oldVT.getShearX()) ||
+ (newVT.getShearY() != oldVT.getShearY()))
+ rebuild = true;
+ else {
+ // Only differs in translate.
+ cgn.setViewingTransform(newVT);
+
+ // 'overflow' and 'clip'
+ Shape clip = null;
+ if (CSSUtilities.convertOverflow(e)) { // overflow:hidden
+ float [] offsets = CSSUtilities.convertClip(e);
+ if (offsets == null) { // clip:auto
+ clip = new Rectangle2D.Float(x, y, w, h);
+ } else { // clip:rect(<x> <y> <w> <h>)
+ // offsets[0] = top
+ // offsets[1] = right
+ // offsets[2] = bottom
+ // offsets[3] = left
+ clip = new Rectangle2D.Float(x+offsets[3],
+ y+offsets[0],
+ w-offsets[1]-offsets[3],
+ h-offsets[2]-offsets[0]);
+ }
+ }
+
+ if (clip != null) {
+ try {
+ AffineTransform at;
+ at = cgn.getPositionTransform();
+ if (at == null) at = new AffineTransform();
+ else at = new AffineTransform(at);
+ at.concatenate(newVT);
+ at = at.createInverse(); // clip in user space
+ clip = at.createTransformedShape(clip);
+ Filter filter = cgn.getGraphicsNodeRable(true);
+ cgn.setClip(new ClipRable8Bit(filter, clip));
+ } catch (NoninvertibleTransformException ex) {}
+ }
+ }
}
- AffineTransform positionTransform =
- AffineTransform.getTranslateInstance(x, y);
- CanvasGraphicsNode cgn;
- cgn = (CanvasGraphicsNode)node;
-
- cgn.setPositionTransform(positionTransform);
- }
- } else if (attrName.equals(SVG_VIEW_BOX_ATTRIBUTE) ||
- attrName.equals(SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE)) {
- SVGDocument doc = (SVGDocument)e.getOwnerDocument();
- boolean isOutermost = (doc.getRootElement() == e);
+ if (rebuild) {
+ CompositeGraphicsNode gn = node.getParent();
+ gn.remove(node);
+ disposeTree(e, false);
- String s;
- UnitProcessor.Context uctx;
- uctx = UnitProcessor.createContext(ctx, e);
- // X & Y are ignored on outermost SVG.
- float x = 0;
- float y = 0;
- if (!isOutermost) {
- // 'x' attribute - default is 0
- s = e.getAttributeNS(null, SVG_X_ATTRIBUTE);
- if (s.length() != 0) {
- x = UnitProcessor.svgHorizontalCoordinateToUserSpace
- (s, SVG_X_ATTRIBUTE, uctx);
- }
- // 'y' attribute - default is 0
- s = e.getAttributeNS(null, SVG_Y_ATTRIBUTE);
- if (s.length() != 0) {
- y = UnitProcessor.svgVerticalCoordinateToUserSpace
- (s, SVG_Y_ATTRIBUTE, uctx);
+ handleElementAdded(gn, e.getParentNode(), e);
+ return;
}
}
-
- // 'width' attribute - default is 100%
- s = e.getAttributeNS(null, SVG_WIDTH_ATTRIBUTE);
- if (s.length() == 0) {
- s = SVG_SVG_WIDTH_DEFAULT_VALUE;
- }
- float w = UnitProcessor.svgHorizontalLengthToUserSpace
- (s, SVG_WIDTH_ATTRIBUTE, uctx);
-
- // 'height' attribute - default is 100%
- s = e.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE);
- if (s.length() == 0) {
- s = SVG_SVG_HEIGHT_DEFAULT_VALUE;
- }
- float h = UnitProcessor.svgVerticalLengthToUserSpace
- (s, SVG_HEIGHT_ATTRIBUTE, uctx);
-
- CanvasGraphicsNode cgn;
- cgn = (CanvasGraphicsNode)node;
-
- // 'viewBox' and "preserveAspectRatio' attributes
- AffineTransform newVT =
- ViewBox.getPreserveAspectRatioTransform(e, w, h);
- AffineTransform oldVT = cgn.getViewingTransform();
- if ((newVT.getScaleX() != oldVT.getScaleX()) ||
- (newVT.getScaleY() != oldVT.getScaleY()) ||
- (newVT.getShearX() != oldVT.getShearX()) ||
- (newVT.getShearY() != oldVT.getShearY()))
- rebuild = true;
- else {
- // Only differs in translate.
- cgn.setViewingTransform(newVT);
-
- // 'overflow' and 'clip'
- Shape clip = null;
- if (CSSUtilities.convertOverflow(e)) { // overflow:hidden
- float [] offsets = CSSUtilities.convertClip(e);
- if (offsets == null) { // clip:auto
- clip = new Rectangle2D.Float(x, y, w, h);
- } else { // clip:rect(<x> <y> <w> <h>)
- // offsets[0] = top
- // offsets[1] = right
- // offsets[2] = bottom
- // offsets[3] = left
- clip = new Rectangle2D.Float(x+offsets[3],
- y+offsets[0],
- w-offsets[1]-offsets[3],
- h-offsets[2]-offsets[0]);
- }
- }
-
- if (clip != null) {
- try {
- AffineTransform at;
- at = cgn.getPositionTransform();
- at = new AffineTransform(at);
- at.concatenate(newVT);
- at = at.createInverse(); // clip in user space
- clip = at.createTransformedShape(clip);
- Filter filter = cgn.getGraphicsNodeRable(true);
- cgn.setClip(new ClipRable8Bit(filter, clip));
- } catch (NoninvertibleTransformException ex) {}
- }
- }
- }
-
- if (rebuild) {
- CompositeGraphicsNode gn = node.getParent();
- gn.remove(node);
- disposeTree(e);
-
- handleElementAdded(gn, e.getParentNode(), e);
+ } catch (LiveAttributeException ex) {
+ throw new BridgeException(ctx, ex);
}
+ super.handleAnimatedAttributeChanged(alav);
}
/**
@@ -430,10 +428,6 @@ public class SVGSVGElementBridge
}
}
- public static final
- AttributedCharacterIterator.Attribute TEXT_COMPOUND_DELIMITER
- = GVTAttributedCharacterIterator.TextAttribute.TEXT_COMPOUND_DELIMITER;
-
public List getIntersectionList(SVGRect svgRect, Element end) {
List ret = new ArrayList();
Rectangle2D rect = new Rectangle2D.Float(svgRect.getX(),
@@ -480,10 +474,10 @@ public class SVGSVGElementBridge
String nsURI = curr.getNamespaceURI();
String tag = curr.getLocalName();
boolean isGroup;
- isGroup = (SVGConstants.SVG_NAMESPACE_URI.equals(nsURI) &&
- ((SVGConstants.SVG_G_TAG.equals(tag)) ||
- (SVGConstants.SVG_SVG_TAG.equals(tag)) ||
- (SVGConstants.SVG_A_TAG.equals(tag))));
+ isGroup = SVG_NAMESPACE_URI.equals(nsURI)
+ && (SVG_G_TAG.equals(tag)
+ || SVG_SVG_TAG.equals(tag)
+ || SVG_A_TAG.equals(tag));
GraphicsNode gn = ctx.getGraphicsNode(curr);
if (gn == null) {
@@ -531,8 +525,8 @@ public class SVGSVGElementBridge
if (curr == end) break;
// Otherwise check this node for intersection more
// carefully and if it still intersects add it.
- if (SVGConstants.SVG_NAMESPACE_URI.equals(nsURI) &&
- SVGConstants.SVG_USE_TAG.equals(tag)) {
+ if (SVG_NAMESPACE_URI.equals(nsURI)
+ && SVG_USE_TAG.equals(tag)) {
// FIXX: This really isn't right we need to
// Add the proxy children.
if (rect.contains(gnBounds))
@@ -616,10 +610,10 @@ public class SVGSVGElementBridge
String nsURI = curr.getNamespaceURI();
String tag = curr.getLocalName();
boolean isGroup;
- isGroup = (SVGConstants.SVG_NAMESPACE_URI.equals(nsURI) &&
- ((SVGConstants.SVG_G_TAG.equals(tag)) ||
- (SVGConstants.SVG_SVG_TAG.equals(tag)) ||
- (SVGConstants.SVG_A_TAG.equals(tag))));
+ isGroup = SVG_NAMESPACE_URI.equals(nsURI)
+ && (SVG_G_TAG.equals(tag)
+ || SVG_SVG_TAG.equals(tag)
+ || SVG_A_TAG.equals(tag));
GraphicsNode gn = ctx.getGraphicsNode(curr);
if (gn == null) {
@@ -664,8 +658,8 @@ public class SVGSVGElementBridge
}
} else {
if (curr == end) break;
- if (SVGConstants.SVG_NAMESPACE_URI.equals(nsURI) &&
- SVGConstants.SVG_USE_TAG.equals(tag)) {
+ if (SVG_NAMESPACE_URI.equals(nsURI)
+ && SVG_USE_TAG.equals(tag)) {
// FIXX: This really isn't right we need to
// Add the proxy children.
if (rect.contains(gnBounds))
@@ -855,4 +849,63 @@ public class SVGSVGElementBridge
public void deselectAll() {
ctx.getUserAgent().deselectAll();
}
+
+ public int suspendRedraw ( int max_wait_milliseconds ) {
+ UpdateManager um = ctx.getUpdateManager();
+ if (um != null)
+ return um.addRedrawSuspension(max_wait_milliseconds);
+ return -1;
+ }
+ public boolean unsuspendRedraw ( int suspend_handle_id ) {
+ UpdateManager um = ctx.getUpdateManager();
+ if (um != null)
+ return um.releaseRedrawSuspension(suspend_handle_id);
+ return false; // no UM so couldn't have issued an id...
+ }
+ public void unsuspendRedrawAll ( ) {
+ UpdateManager um = ctx.getUpdateManager();
+ if (um != null)
+ um.releaseAllRedrawSuspension();
+ }
+
+ public void forceRedraw ( ) {
+ UpdateManager um = ctx.getUpdateManager();
+ if (um != null)
+ um.forceRepaint();
+ }
+
+ /**
+ * Pauses animations in the document.
+ */
+ public void pauseAnimations() {
+ ctx.getAnimationEngine().pause();
+ }
+
+ /**
+ * Unpauses animations in the document.
+ */
+ public void unpauseAnimations() {
+ ctx.getAnimationEngine().unpause();
+ }
+
+ /**
+ * Returns whether animations are currently paused.
+ */
+ public boolean animationsPaused() {
+ return ctx.getAnimationEngine().isPaused();
+ }
+
+ /**
+ * Returns the current document time.
+ */
+ public float getCurrentTime() {
+ return ctx.getAnimationEngine().getCurrentTime();
+ }
+
+ /**
+ * Sets the current document time.
+ */
+ public void setCurrentTime(float t) {
+ ctx.getAnimationEngine().setCurrentTime(t);
+ }
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGSetElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGSetElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGSetElementBridge.java
new file mode 100644
index 0000000..93a1fbf
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGSetElementBridge.java
@@ -0,0 +1,71 @@
+/*
+
+ 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;
+
+import org.apache.flex.forks.batik.anim.AbstractAnimation;
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+import org.apache.flex.forks.batik.anim.SetAnimation;
+import org.apache.flex.forks.batik.anim.values.AnimatableValue;
+
+/**
+ * A bridge class for the 'set' animation element.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: SVGSetElementBridge.java 478160 2006-11-22 13:35:06Z dvholten $
+ */
+public class SVGSetElementBridge extends SVGAnimationElementBridge {
+
+ /**
+ * Returns 'set'.
+ */
+ public String getLocalName() {
+ return SVG_SET_TAG;
+ }
+
+ /**
+ * Returns a new instance of this bridge.
+ */
+ public Bridge getInstance() {
+ return new SVGSetElementBridge();
+ }
+
+ /**
+ * Creates the animation object for the animation element.
+ */
+ protected AbstractAnimation createAnimation(AnimationTarget target) {
+ AnimatableValue to = parseAnimatableValue(SVG_TO_ATTRIBUTE);
+ return new SetAnimation(timedElement, this, to);
+ }
+
+ /**
+ * Returns whether the animation element being handled by this bridge can
+ * animate attributes of the specified type.
+ * @param type one of the TYPE_ constants defined in {@link org.apache.flex.forks.batik.util.SVGTypes}.
+ */
+ protected boolean canAnimateType(int type) {
+ return true;
+ }
+
+ /**
+ * Returns whether this is a constant animation (i.e., a 'set' animation).
+ */
+ protected boolean isConstantAnimation() {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGShapeElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGShapeElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGShapeElementBridge.java
index 94f172b..985dd4e 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGShapeElementBridge.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGShapeElementBridge.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
@@ -30,7 +31,7 @@ import org.w3c.dom.Element;
* The base bridge class for shapes. Subclasses bridge <tt>ShapeNode</tt>.
*
* @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
- * @version $Id: SVGShapeElementBridge.java,v 1.28 2004/08/20 19:29:46 deweese Exp $
+ * @version $Id: SVGShapeElementBridge.java 475477 2006-11-15 22:44:28Z cam $
*/
public abstract class SVGShapeElementBridge extends AbstractGraphicsNodeBridge {
@@ -49,9 +50,12 @@ public abstract class SVGShapeElementBridge extends AbstractGraphicsNodeBridge {
*/
public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {
ShapeNode shapeNode = (ShapeNode)super.createGraphicsNode(ctx, e);
- if (shapeNode == null) {
- return null;
- }
+ if (shapeNode == null) {
+ return null;
+ }
+
+ associateSVGContext(ctx, e, shapeNode);
+
// delegates to subclasses the shape construction
buildShape(ctx, e, shapeNode);
@@ -137,7 +141,7 @@ public abstract class SVGShapeElementBridge extends AbstractGraphicsNodeBridge {
/**
* Invoked when the geometry of an graphical element has changed.
*/
- protected void handleGeometryChanged() {
+ protected void handleGeometryChanged() {
super.handleGeometryChanged();
ShapeNode shapeNode = (ShapeNode)node;
shapeNode.setShapePainter(createShapePainter(ctx, e, shapeNode));
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGSwitchElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGSwitchElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGSwitchElementBridge.java
index d4f72b2..259c4d2 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGSwitchElementBridge.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/SVGSwitchElementBridge.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
@@ -19,18 +20,24 @@ package org.apache.flex.forks.batik.bridge;
import org.apache.flex.forks.batik.gvt.CompositeGraphicsNode;
import org.apache.flex.forks.batik.gvt.GraphicsNode;
+
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.w3c.flex.forks.dom.svg.SVGTests;
+import org.w3c.dom.svg.SVGTests;
/**
* Bridge class for the <switch> element.
*
* @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
- * @version $Id: SVGSwitchElementBridge.java,v 1.17 2004/08/18 07:12:35 vhardy Exp $
+ * @version $Id: SVGSwitchElementBridge.java 491178 2006-12-30 06:18:34Z cam $
*/
-public class SVGSwitchElementBridge extends AbstractSVGBridge
- implements GraphicsNodeBridge {
+public class SVGSwitchElementBridge extends SVGGElementBridge {
+
+ /**
+ * The child element that was chosen for rendering according to the
+ * test attributes.
+ */
+ protected Element selectedChild;
/**
* Constructs a new bridge for the <switch> element.
@@ -44,8 +51,11 @@ public class SVGSwitchElementBridge extends AbstractSVGBridge
return SVG_SWITCH_TAG;
}
- public Bridge getInstance(){
- return this;
+ /**
+ * Returns a new instance of this bridge.
+ */
+ public Bridge getInstance() {
+ return new SVGSwitchElementBridge();
}
/**
@@ -58,59 +68,110 @@ public class SVGSwitchElementBridge extends AbstractSVGBridge
public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {
GraphicsNode refNode = null;
GVTBuilder builder = ctx.getGVTBuilder();
+ selectedChild = null;
for (Node n = e.getFirstChild(); n != null; n = n.getNextSibling()) {
if (n.getNodeType() == Node.ELEMENT_NODE) {
Element ref = (Element)n;
- if (n instanceof SVGTests
- && SVGUtilities.matchUserAgent(ref, ctx.getUserAgent())) {
+ if (n instanceof SVGTests &&
+ SVGUtilities.matchUserAgent(ref, ctx.getUserAgent())) {
+ selectedChild = ref;
refNode = builder.build(ctx, ref);
break;
}
}
}
+
if (refNode == null) {
return null;
}
- CompositeGraphicsNode group = new CompositeGraphicsNode();
- group.add(refNode);
- // 'transform'
- String s = e.getAttributeNS(null, SVG_TRANSFORM_ATTRIBUTE);
- if (s.length() != 0) {
- group.setTransform
- (SVGUtilities.convertTransform(e, SVG_TRANSFORM_ATTRIBUTE, s));
+
+ CompositeGraphicsNode group =
+ (CompositeGraphicsNode) super.createGraphicsNode(ctx, e);
+ if (group == null) {
+ return null;
}
+
+ group.add(refNode);
+
return group;
}
/**
- * 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
+ * Returns true as the <switch> element is not a container.
*/
- public void buildGraphicsNode(BridgeContext ctx,
- Element e,
- GraphicsNode node) {
- // bind the specified element and its associated graphics node if needed
- if (ctx.isInteractive()) {
- ctx.bind(e, node);
- }
+ public boolean isComposite() {
+ return false;
}
+ // BridgeUpdateHandler implementation //////////////////////////////////
+
/**
- * Returns true if the graphics node has to be displayed, false
- * otherwise.
+ * Disposes this BridgeUpdateHandler and releases all resources.
*/
- public boolean getDisplay(Element e) {
- return CSSUtilities.convertDisplay(e);
+ public void dispose() {
+ selectedChild = null;
+ super.dispose();
}
/**
- * Returns false as the <switch> element is not a container.
+ * Responds to the insertion of a child element by re-evaluating the
+ * test attributes.
*/
- public boolean isComposite() {
- return false;
+ protected void handleElementAdded(CompositeGraphicsNode gn,
+ Node parent,
+ Element childElt) {
+ for (Node n = childElt.getPreviousSibling(); n
+ != null;
+ n = n.getPreviousSibling()) {
+ if (n == childElt) {
+ return;
+ }
+ }
+ if (childElt instanceof SVGTests
+ && SVGUtilities.matchUserAgent(childElt, ctx.getUserAgent())) {
+ if (selectedChild != null) {
+ gn.remove(0);
+ disposeTree(selectedChild);
+ }
+ selectedChild = childElt;
+ GVTBuilder builder = ctx.getGVTBuilder();
+ GraphicsNode refNode = builder.build(ctx, childElt);
+ if (refNode != null) {
+ gn.add(refNode);
+ }
+ }
+ }
+
+ /**
+ * Responds to the removal of a child element by re-evaluating the
+ * test attributes.
+ */
+ protected void handleChildElementRemoved(Element e) {
+ CompositeGraphicsNode gn = (CompositeGraphicsNode) node;
+ if (selectedChild == e) {
+ gn.remove(0);
+ disposeTree(selectedChild);
+ selectedChild = null;
+ GraphicsNode refNode = null;
+ GVTBuilder builder = ctx.getGVTBuilder();
+ for (Node n = e.getNextSibling();
+ n != null;
+ n = n.getNextSibling()) {
+ if (n.getNodeType() == Node.ELEMENT_NODE) {
+ Element ref = (Element) n;
+ if (n instanceof SVGTests &&
+ SVGUtilities.matchUserAgent
+ (ref, ctx.getUserAgent())) {
+ refNode = builder.build(ctx, ref);
+ selectedChild = ref;
+ break;
+ }
+ }
+ }
+
+ if (refNode != null) {
+ gn.add(refNode);
+ }
+ }
}
}