You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ha...@apache.org on 2017/05/07 06:46:21 UTC
git commit: [flex-asjs] [refs/heads/tlf] - Added fix for Firefox bug.
Repository: flex-asjs
Updated Branches:
refs/heads/tlf 3b3097de4 -> f589a57f3
Added fix for Firefox bug.
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/f589a57f
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/f589a57f
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/f589a57f
Branch: refs/heads/tlf
Commit: f589a57f3bafba3f904a00b11fa72de6a39d133d
Parents: 3b3097d
Author: Harbs <ha...@in-tools.com>
Authored: Sun May 7 09:46:16 2017 +0300
Committer: Harbs <ha...@in-tools.com>
Committed: Sun May 7 09:46:16 2017 +0300
----------------------------------------------------------------------
.../src/main/flex/org/apache/flex/svg/Circle.as | 30 ++++--
.../main/flex/org/apache/flex/svg/Ellipse.as | 70 ++++++++-----
.../org/apache/flex/svg/GraphicContainer.as | 103 ++++++++++---------
.../flex/org/apache/flex/svg/GraphicShape.as | 58 ++++++++---
.../src/main/flex/org/apache/flex/svg/Path.as | 17 ++-
.../src/main/flex/org/apache/flex/svg/Rect.as | 22 +++-
.../src/main/flex/org/apache/flex/svg/Text.as | 48 +++++----
.../src/main/flex/org/apache/flex/svg/Circle.as | 9 +-
.../main/flex/org/apache/flex/svg/Ellipse.as | 7 +-
.../org/apache/flex/svg/GraphicContainer.as | 25 ++---
.../flex/org/apache/flex/svg/GraphicShape.as | 16 ++-
.../src/main/flex/org/apache/flex/svg/Path.as | 3 +-
.../src/main/flex/org/apache/flex/svg/Rect.as | 2 +-
.../src/main/flex/org/apache/flex/svg/Text.as | 7 +-
14 files changed, 259 insertions(+), 158 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f589a57f/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Circle.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Circle.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Circle.as
index f76b5c8..77511a3 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Circle.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Circle.as
@@ -15,18 +15,20 @@
package org.apache.flex.svg
{
import org.apache.flex.graphics.ICircle;
+ import org.apache.flex.graphics.IDrawable;
COMPILE::SWF
{
+ import flash.display.Graphics;
import flash.geom.Point;
- import flash.geom.Rectangle;
+ import flash.geom.Rectangle;
}
COMPILE::JS
{
import org.apache.flex.core.WrappedHTMLElement;
}
- public class Circle extends GraphicShape implements ICircle
+ public class Circle extends GraphicShape implements ICircle, IDrawable
{
/**
* constructor.
@@ -54,7 +56,7 @@ package org.apache.flex.svg
{
_radius = value;
}
-
+
COMPILE::JS
private var _circle:WrappedHTMLElement;
@@ -78,10 +80,10 @@ package org.apache.flex.svg
graphics.clear();
applyStroke();
beginFill(new Rectangle(cx,cy,radius*2, radius*2),new Point(cx-radius,cy-radius));
- graphics.drawCircle(cx,cy,radius);
+ graphics.drawCircle(cx+radius,cy+radius,radius);
endFill();
}
- COMPILE::JS
+ COMPILE::JS
{
var style:String = getStyleStr();
@@ -101,18 +103,24 @@ package org.apache.flex.svg
_circle.setAttribute('cx', radius);
_circle.setAttribute('cy', radius);
}
-
+
_circle.setAttribute('r', radius);
-
- resize(x-radius, y-radius, (_circle as SVGCircleElement).getBBox());
+
+ //resize(x-radius, y-radius, (_circle as SVGCircleElement).getBBox());
+ resize(x-radius, y-radius, getBBox(_circle));
}
}
-
- override protected function draw():void
+
+ override protected function drawImpl():void
{
drawCircle(0, 0, radius);
}
-
+
+ public function draw():void
+ {
+ drawImpl();
+ }
+
}
}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f589a57f/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Ellipse.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Ellipse.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Ellipse.as
index c2fbabc..2ccf505 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Ellipse.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Ellipse.as
@@ -18,19 +18,20 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.svg
{
+ import org.apache.flex.graphics.IDrawable;
import org.apache.flex.graphics.IEllipse;
COMPILE::SWF
{
import flash.geom.Point;
- import flash.geom.Rectangle;
+ import flash.geom.Rectangle;
}
COMPILE::JS
{
import org.apache.flex.core.WrappedHTMLElement;
}
- public class Ellipse extends GraphicShape implements IEllipse
+ public class Ellipse extends GraphicShape implements IEllipse, IDrawable
{
/**
* constructor.
@@ -47,12 +48,12 @@ package org.apache.flex.svg
this.rx = rx;
this.ry = ry;
}
-
+
private var _rx:Number;
/**
* The horizontal radius of the ellipse.
- *
+ *
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
@@ -68,11 +69,11 @@ package org.apache.flex.svg
_rx = value;
}
- private var _ry:Number;
+ private var _ry:Number;
/**
* The vertical radius of the ellipse.
- *
+ *
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
@@ -88,16 +89,33 @@ package org.apache.flex.svg
_ry = value;
}
-
+ override public function get width():Number
+ {
+ return _rx*2;
+ }
+
+ override public function set width(value:Number):void
+ {
+ _rx = value/2;
+ }
+
+ override public function get height():Number
+ {
+ return _ry*2;
+ }
+
+ override public function set height(value:Number):void
+ {
+ _ry = value/2;
+ }
+
COMPILE::JS
private var _ellipse:WrappedHTMLElement;
-
+
/**
* Draw the ellipse.
* @param xp The x position of the top-left corner of the bounding box of the ellipse.
* @param yp The y position of the top-left corner of the bounding box of the ellipse.
- * @param width The width of the ellipse.
- * @param height The height of the ellipse.
*
* @langversion 3.0
* @playerversion Flash 10.2
@@ -114,7 +132,7 @@ package org.apache.flex.svg
applyStroke();
beginFill(new Rectangle(xp, yp, width, height), new Point(xp,yp));
graphics.drawEllipse(xp,yp,width,height);
- endFill();
+ endFill();
}
COMPILE::JS
{
@@ -127,26 +145,32 @@ package org.apache.flex.svg
_ellipse.setAttribute('style', style);
if (stroke)
{
- _ellipse.setAttribute('cx', width / 2 + stroke.weight);
- _ellipse.setAttribute('cy', height / 2 + stroke.weight);
+ _ellipse.setAttribute('cx', rx + stroke.weight);
+ _ellipse.setAttribute('cy', ry + stroke.weight);
}
else
{
- _ellipse.setAttribute('cx', width / 2);
- _ellipse.setAttribute('cy', height / 2);
+ _ellipse.setAttribute('cx', rx);
+ _ellipse.setAttribute('cy', ry);
}
- _ellipse.setAttribute('rx', width / 2);
- _ellipse.setAttribute('ry', height / 2);
-
- resize(x, y, (_ellipse as SVGEllipseElement).getBBox());
+ _ellipse.setAttribute('rx', rx);
+ _ellipse.setAttribute('ry', ry);
+
+ //resize(x, y, (_ellipse as SVGEllipseElement).getBBox());
+ resize(x, y, getBBox(_ellipse));
}
}
-
- override protected function draw():void
+
+ override protected function drawImpl():void
{
- drawEllipse(0, 0);
+ drawEllipse(0, 0);
}
-
+
+ public function draw():void
+ {
+ drawImpl();
+ }
+
}
}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f589a57f/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicContainer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicContainer.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicContainer.as
index 8e8498f..0cd57e2 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicContainer.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicContainer.as
@@ -13,7 +13,8 @@
*/
package org.apache.flex.svg
{
- import org.apache.flex.core.ContainerBase;
+ import org.apache.flex.core.GroupBase;
+ import org.apache.flex.core.IChild;
import org.apache.flex.core.IFlexJSElement;
import org.apache.flex.core.ITransformHost;
@@ -21,13 +22,12 @@ package org.apache.flex.svg
{
import org.apache.flex.core.IContainer;
import org.apache.flex.core.UIBase;
- import org.apache.flex.core.IChild;
}
[DefaultProperty("mxmlContent")]
COMPILE::SWF
- public class GraphicContainer extends ContainerBase
+ public class GraphicContainer extends GroupBase implements ITransformHost
{
public function GraphicContainer()
{
@@ -35,39 +35,44 @@ package org.apache.flex.svg
}
}
-
+
COMPILE::JS
- public class GraphicContainer extends UIBase implements IContainer
+ public class GraphicContainer extends GroupBase implements ITransformHost
{
- private var graphicGroup:ContainerBase;
-
+ private var graphicGroup:GroupBase;
+
public function GraphicContainer()
{
super();
}
-
+
/**
* @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
*/
override protected function createElement():org.apache.flex.core.WrappedHTMLElement
{
element = document.createElementNS('http://www.w3.org/2000/svg', 'svg') as org.apache.flex.core.WrappedHTMLElement;
-
+
positioner = element;
-
+
// absolute positioned children need a non-null
// position value in the parent. It might
// get set to 'absolute' if the container is
// also absolutely positioned
- positioner.style.position = 'relative';
+ //positioner.style.position = 'relative';
element.flexjs_wrapper = this;
-
+
graphicGroup = new GraphicGroup();
super.addElement(graphicGroup);
return element;
}
-
+ COMPILE::JS
+ override protected function setClassName(value:String):void
+ {
+ element.setAttribute('class', value);
+ }
+
override public function get transformElement():org.apache.flex.core.WrappedHTMLElement
{
return graphicGroup.element;
@@ -75,7 +80,7 @@ package org.apache.flex.svg
/**
* @copy org.apache.flex.core.IParent#getElementAt()
- *
+ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@ -84,11 +89,11 @@ package org.apache.flex.svg
override public function getElementAt(index:int):IChild
{
return graphicGroup.getElementAt(index);
- }
-
+ }
+
/**
* @copy org.apache.flex.core.IParent#addElement()
- *
+ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@ -100,10 +105,10 @@ package org.apache.flex.svg
if (dispatchEvent)
this.dispatchEvent(new Event("childrenAdded"));
}
-
+
/**
* @copy org.apache.flex.core.IParent#addElementAt()
- *
+ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@ -115,10 +120,10 @@ package org.apache.flex.svg
if (dispatchEvent)
this.dispatchEvent(new Event("childrenAdded"));
}
-
+
/**
* @copy org.apache.flex.core.IParent#removeElement()
- *
+ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@ -130,23 +135,10 @@ package org.apache.flex.svg
if (dispatchEvent)
this.dispatchEvent(new Event("childrenRemoved"));
}
-
- /**
- * @copy org.apache.flex.core.IContainer#childrenAdded()
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public function childrenAdded():void
- {
- dispatchEvent(new Event("childrenAdded"));
- }
-
+
/**
* @copy org.apache.flex.core.IParent#getElementIndex()
- *
+ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@ -156,11 +148,11 @@ package org.apache.flex.svg
{
return graphicGroup.getElementIndex(c);
}
-
-
+
+
/**
* The number of elements in the parent.
- *
+ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@ -170,12 +162,29 @@ package org.apache.flex.svg
{
return graphicGroup.numElements;
}
+
+ COMPILE::JS
+ override public function set x(value:Number):void
+ {
+ super.x = value;
+ // Needed for SVG inside SVG
+ element.setAttribute("x", value);
+ }
+
+ COMPILE::JS
+ override public function set y(value:Number):void
+ {
+ super.y = value;
+ // Needed for SVG inside SVG
+ element.setAttribute("y", value);
+ }
+
}
}
-import org.apache.flex.core.ContainerBase;
+import org.apache.flex.core.GroupBase;
-class GraphicGroup extends ContainerBase
+class GraphicGroup extends GroupBase
{
/**
* @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
@@ -184,21 +193,21 @@ class GraphicGroup extends ContainerBase
override protected function createElement():org.apache.flex.core.WrappedHTMLElement
{
element = document.createElementNS('http://www.w3.org/2000/svg', 'g') as org.apache.flex.core.WrappedHTMLElement;
-
+
positioner = element;
-
+
// absolute positioned children need a non-null
// position value in the parent. It might
// get set to 'absolute' if the container is
// also absolutely positioned
- positioner.style.position = 'relative';
+ //positioner.style.position = 'relative';
element.flexjs_wrapper = this;
-
+
/*addEventListener('childrenAdded',
runLayoutHandler);
addEventListener('elementRemoved',
runLayoutHandler);*/
-
+
return element;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f589a57f/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicShape.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicShape.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicShape.as
index eb1acc1..73d8dfe 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicShape.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicShape.as
@@ -16,14 +16,18 @@ package org.apache.flex.svg
{
COMPILE::SWF
{
- import flash.geom.Point;
- import flash.geom.Rectangle;
+ import flash.display.Graphics;
+ import flash.display.Sprite;
+ import flash.geom.Point;
+ import flash.geom.Rectangle;
+ import org.apache.flex.core.WrappedSprite;
}
COMPILE::JS
{
import org.apache.flex.core.WrappedHTMLElement;
}
+ import org.apache.flex.core.IFlexJSElement;
import org.apache.flex.core.UIBase;
import org.apache.flex.graphics.IFill;
import org.apache.flex.graphics.IStroke;
@@ -31,6 +35,7 @@ package org.apache.flex.svg
public class GraphicShape extends UIBase implements IGraphicShape
{
+
private var _fill:IFill;
private var _stroke:IStroke;
@@ -78,7 +83,7 @@ package org.apache.flex.svg
{
super();
}
-
+
/**
* @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
*/
@@ -87,14 +92,26 @@ package org.apache.flex.svg
{
element = document.createElementNS('http://www.w3.org/2000/svg', 'svg') as WrappedHTMLElement;
element.flexjs_wrapper = this;
- element.style.left = "0px";
- element.style.top = "0px";
//element.offsetParent = null;
positioner = element;
- positioner.style.position = 'relative';
-
+ //positioner.style.position = 'relative';
+
return element;
}
+
+ /**
+ * @private
+ * @flexjsignorecoercion SVGRect
+ */
+ COMPILE::JS
+ protected function getBBox(svgElement:WrappedHTMLElement):Object
+ {
+ try {
+ return svgElement['getBBox']();
+ } catch (err) {
+ return {x: 0, y:0, width:this.width, height:this.height};
+ }
+ }
COMPILE::SWF
@@ -127,18 +144,15 @@ package org.apache.flex.svg
/**
* This is where the drawing methods get called from
*/
- protected function draw():void
+ protected function drawImpl():void
{
//Overwrite in subclass
}
override public function addedToParent():void
{
- COMPILE::SWF
- {
- super.addedToParent();
- }
- draw();
+ super.addedToParent();
+ drawImpl();
COMPILE::JS
{
element.style.overflow = 'visible';
@@ -175,6 +189,12 @@ package org.apache.flex.svg
return fillStr + ';' + strokeStr;
}
+ COMPILE::JS
+ override protected function setClassName(value:String):void
+ {
+ element.setAttribute('class', value);
+ }
+
/**
* @param x X position.
@@ -182,7 +202,7 @@ package org.apache.flex.svg
* @param bbox The bounding box of the svg element.
*/
COMPILE::JS
- public function resize(x:Number, y:Number, bbox:SVGRect):void
+ public function resize(x:Number, y:Number, bbox:Object):void
{
var useWidth:Number = Math.max(this.width, bbox.width);
var useHeight:Number = Math.max(this.height, bbox.height);
@@ -190,8 +210,14 @@ package org.apache.flex.svg
element.style.position = 'absolute';
if (!isNaN(x)) element.style.top = x + "px";
if (!isNaN(y)) element.style.left = y + "px";
+ // element.setAttribute("width", useWidth);
+ // element.setAttribute("height", useHeight);
element.style.width = useWidth;
element.style.height = useHeight;
+ // Needed for SVG inside SVG
+ element.setAttribute("x", x);
+ element.setAttribute("y", y);
+ //Needed for SVG inside DOM elements
element.style.left = x + "px";
element.style.top = y + "px";
}
@@ -218,6 +244,10 @@ package org.apache.flex.svg
_y = y;
_xOffset = xOffset;
_yOffset = yOffset;
+ // Needed for SVG inside SVG
+ element.setAttribute("x", xOffset);
+ element.setAttribute("y", yOffset);
+ //Needed for SVG inside DOM elements
element.style.left = xOffset + "px";
element.style.top = yOffset + "px";
}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f589a57f/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Path.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Path.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Path.as
index fe6b74a..2d882a3 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Path.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Path.as
@@ -14,6 +14,7 @@
package org.apache.flex.svg
{
+ import org.apache.flex.graphics.IDrawable;
import org.apache.flex.graphics.IPath;
import org.apache.flex.graphics.PathBuilder;
@@ -30,7 +31,7 @@ package org.apache.flex.svg
}
- public class Path extends GraphicShape implements IPath
+ public class Path extends GraphicShape implements IPath, IDrawable
{
private var _data:String;
@@ -45,7 +46,7 @@ package org.apache.flex.svg
_data = value;
_pathCommands = null;
}
-
+
private var _pathCommands:PathBuilder;
public function get pathCommands():PathBuilder
@@ -59,7 +60,7 @@ package org.apache.flex.svg
_data = _pathCommands.getPathString();
}
-
+
COMPILE::JS
private var _path:WrappedHTMLElement;
@@ -120,14 +121,20 @@ package org.apache.flex.svg
_path.setAttribute('style', style);
_path.setAttribute('d', data);
- resize(x, y, _path['getBBox']());
+ //resize(x, y, _path['getBBox']());
+ resize(x, y, getBBox(_path));
}
}
- override protected function draw():void
+ override protected function drawImpl():void
{
drawStringPath(0, 0, data);
}
+
+ public function draw():void
+ {
+ drawImpl();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f589a57f/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Rect.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Rect.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Rect.as
index 64f888d..09ce190 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Rect.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Rect.as
@@ -14,6 +14,7 @@
package org.apache.flex.svg
{
+ import org.apache.flex.graphics.IDrawable;
import org.apache.flex.graphics.IRect;
COMPILE::SWF
@@ -26,7 +27,7 @@ package org.apache.flex.svg
import org.apache.flex.core.WrappedHTMLElement;
}
- public class Rect extends GraphicShape implements IRect
+ public class Rect extends GraphicShape implements IRect, IDrawable
{
/**
* constructor.
@@ -111,12 +112,12 @@ package org.apache.flex.svg
applyStroke();
beginFill(new Rectangle(xp, yp, width, height), new Point(xp,yp));
if(isNaN(rx))
- graphics.drawRect(x, y, width, height);
+ graphics.drawRect(0, 0, width, height);
else
{
var dx:Number = rx*2;
var dy:Number = isNaN(ry) ? ry : ry*2;
- graphics.drawRoundRect(x, y, width, height,dx ,dy);
+ graphics.drawRoundRect(0, 0, width, height,dx ,dy);
}
endFill();
}
@@ -143,14 +144,25 @@ package org.apache.flex.svg
_rect.setAttribute('width', width);
_rect.setAttribute('height', height);
- resize(x, y, _rect['getBBox']());
+ resize(x, y, getBBox(_rect));
}
}
- override protected function draw():void
+ COMPILE::JS
+ override public function get transformElement():WrappedHTMLElement
+ {
+ return _rect;
+ }
+
+ override protected function drawImpl():void
{
drawRect(0,0,width,height);
}
+
+ public function draw():void
+ {
+ drawImpl();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f589a57f/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Text.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Text.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Text.as
index 278dcc0..0b5c907 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Text.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Text.as
@@ -18,21 +18,22 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.svg
{
+ import org.apache.flex.graphics.IDrawable;
import org.apache.flex.graphics.IText;
import org.apache.flex.graphics.SolidColor;
COMPILE::SWF
{
- import flash.text.TextFieldType;
- import org.apache.flex.core.CSSTextField;
+ import flash.text.TextFieldType;
+ import org.apache.flex.core.CSSTextField;
}
COMPILE::JS
{
import org.apache.flex.core.WrappedHTMLElement;
}
-
+
/**
- * Draws a string of characters at a specific location using the stroke
+ * Draws a string of characters at a specific location using the fill
* value of color and alpha.
*
* @langversion 3.0
@@ -42,7 +43,7 @@ package org.apache.flex.svg
* // TODO (aharui) ignore imports of external linkage interfaces?
* @flexjsignoreimport SVGLocatable
*/
- public class Text extends GraphicShape implements IText
+ public class Text extends GraphicShape implements IText, IDrawable
{
/**
* constructor.
@@ -55,14 +56,14 @@ package org.apache.flex.svg
public function Text()
{
super();
-
+
COMPILE::SWF
{
_textField = new CSSTextField();
- addChild(_textField);
+ addChild(_textField);
}
}
-
+
private var _text:String;
public function get text():String
{
@@ -75,13 +76,13 @@ package org.apache.flex.svg
COMPILE::SWF
private var _textField:CSSTextField;
-
+
COMPILE::JS
private var _textElem:WrappedHTMLElement;
-
+
/**
* @copy org.apache.flex.core.ITextModel#textField
- *
+ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@ -92,7 +93,7 @@ package org.apache.flex.svg
{
return _textField;
}
-
+
/**
* Draws text at the given point.
* @param value The string to draw.
@@ -117,15 +118,15 @@ package org.apache.flex.svg
textField.mouseEnabled = false;
textField.autoSize = "left";
textField.text = value;
-
+
var color:SolidColor = fill as SolidColor;
if (color) {
textField.textColor = color.color;
textField.alpha = color.alpha;
}
-
+
textField.x = xt;
- textField.y = yt;
+ textField.y = yt;
}
COMPILE::JS
{
@@ -143,17 +144,22 @@ package org.apache.flex.svg
_textElem.setAttribute('y', yt);
var textNode:Text = document.createTextNode(value) as Text;
_textElem.appendChild(textNode as Node);
-
- resize(x, y, (_textElem as SVGLocatable).getBBox());
+
+ //resize(x, y, (_textElem as SVGLocatable).getBBox());
+ resize(x, y, getBBox(_textElem));
}
}
-
- COMPILE::JS
- override protected function draw():void
+
+ override protected function drawImpl():void
{
- drawText(text, x, y);
+ drawText(text,x,y);
}
+ public function draw():void
+ {
+ drawImpl();
+ }
+
}
}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f589a57f/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Circle.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Circle.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Circle.as
index 8f8876a..c256ff8 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Circle.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Circle.as
@@ -103,14 +103,15 @@ package org.apache.flex.svg
_circle.setAttribute('cx', radius);
_circle.setAttribute('cy', radius);
}
-
+
_circle.setAttribute('r', radius);
-
- resize(x-radius, y-radius, (_circle as SVGCircleElement).getBBox());
+
+ //resize(x-radius, y-radius, (_circle as SVGCircleElement).getBBox());
+ resize(x-radius, y-radius, getBBox(_circle));
}
}
-
+
override protected function drawImpl():void
{
drawCircle(0, 0, radius);
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f589a57f/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Ellipse.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Ellipse.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Ellipse.as
index 2c25c61..a71a150 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Ellipse.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Ellipse.as
@@ -155,12 +155,13 @@ package org.apache.flex.svg
}
_ellipse.setAttribute('rx', rx);
_ellipse.setAttribute('ry', ry);
-
- resize(x, y, (_ellipse as SVGEllipseElement).getBBox());
+
+ //resize(x, y, (_ellipse as SVGEllipseElement).getBBox());
+ resize(x, y, getBBox(_ellipse));
}
}
-
+
override protected function drawImpl():void
{
drawEllipse(0, 0);
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f589a57f/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/GraphicContainer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/GraphicContainer.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/GraphicContainer.as
index 6b05fea..0cd57e2 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/GraphicContainer.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/GraphicContainer.as
@@ -13,7 +13,7 @@
*/
package org.apache.flex.svg
{
- import org.apache.flex.core.ContainerBase;
+ import org.apache.flex.core.GroupBase;
import org.apache.flex.core.IChild;
import org.apache.flex.core.IFlexJSElement;
import org.apache.flex.core.ITransformHost;
@@ -27,7 +27,7 @@ package org.apache.flex.svg
[DefaultProperty("mxmlContent")]
COMPILE::SWF
- public class GraphicContainer extends ContainerBase implements ITransformHost
+ public class GraphicContainer extends GroupBase implements ITransformHost
{
public function GraphicContainer()
{
@@ -37,9 +37,9 @@ package org.apache.flex.svg
}
COMPILE::JS
- public class GraphicContainer extends UIBase implements ITransformHost, IContainer
+ public class GraphicContainer extends GroupBase implements ITransformHost
{
- private var graphicGroup:ContainerBase;
+ private var graphicGroup:GroupBase;
public function GraphicContainer()
{
@@ -137,19 +137,6 @@ package org.apache.flex.svg
}
/**
- * @copy org.apache.flex.core.IContainer#childrenAdded()
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public function childrenAdded():void
- {
- dispatchEvent(new Event("childrenAdded"));
- }
-
- /**
* @copy org.apache.flex.core.IParent#getElementIndex()
*
* @langversion 3.0
@@ -195,9 +182,9 @@ package org.apache.flex.svg
}
}
-import org.apache.flex.core.ContainerBase;
+import org.apache.flex.core.GroupBase;
-class GraphicGroup extends ContainerBase
+class GraphicGroup extends GroupBase
{
/**
* @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f589a57f/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/GraphicShape.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/GraphicShape.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/GraphicShape.as
index da8d0a9..3ae1485 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/GraphicShape.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/GraphicShape.as
@@ -98,6 +98,20 @@ package org.apache.flex.svg
return element;
}
+
+ /**
+ * @private
+ * @flexjsignorecoercion SVGRect
+ */
+ COMPILE::JS
+ protected function getBBox(svgElement:WrappedHTMLElement):Object
+ {
+ try {
+ return svgElement['getBBox']();
+ } catch (err) {
+ return {x: 0, y:0, width:this.width, height:this.height};
+ }
+ }
COMPILE::SWF
@@ -188,7 +202,7 @@ package org.apache.flex.svg
* @param bbox The bounding box of the svg element.
*/
COMPILE::JS
- public function resize(x:Number, y:Number, bbox:SVGRect):void
+ public function resize(x:Number, y:Number, bbox:Object):void
{
var useWidth:Number = Math.max(this.width, bbox.width);
var useHeight:Number = Math.max(this.height, bbox.height);
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f589a57f/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Path.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Path.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Path.as
index 4134b55..14d01b0 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Path.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Path.as
@@ -121,7 +121,8 @@ package org.apache.flex.svg
_path.setAttribute('style', style);
_path.setAttribute('d', data);
- resize(x, y, _path['getBBox']());
+ //resize(x, y, _path['getBBox']());
+ resize(x, y, getBBox(_path));
}
}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f589a57f/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Rect.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Rect.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Rect.as
index 889f76d..4791208 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Rect.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Rect.as
@@ -144,7 +144,7 @@ package org.apache.flex.svg
_rect.setAttribute('width', width);
_rect.setAttribute('height', height);
- resize(x, y, _rect['getBBox']());
+ resize(x, y, getBBox(_rect));
}
}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f589a57f/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Text.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Text.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Text.as
index ba03ccf..d4cfd1d 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Text.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/svg/Text.as
@@ -144,12 +144,13 @@ package org.apache.flex.svg
_textElem.setAttribute('y', yt);
var textNode:Text = document.createTextNode(value) as Text;
_textElem.appendChild(textNode as Node);
-
- resize(x, y, (_textElem as SVGLocatable).getBBox());
+
+ //resize(x, y, (_textElem as SVGLocatable).getBBox());
+ resize(x, y, getBBox(_textElem));
}
}
-
+
override protected function drawImpl():void
{
drawText(text,x,y);