These changes look great (and are very timely for me).

Thanks!

On Jul 18, 2016, at 6:45 PM, p...@apache.org wrote:

> Repository: flex-asjs
> Updated Branches:
>  refs/heads/develop bfd3a240f -> af84e52e8
> 
> 
> Changes to Graphics package that allows SVG elements to be resumed.
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/2da30efb
> Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/2da30efb
> Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/2da30efb
> 
> Branch: refs/heads/develop
> Commit: 2da30efb7e2e91c8896b180a8639b6b0cd504a96
> Parents: ff84654
> Author: Peter Ent <p...@apache.org>
> Authored: Mon Jul 18 09:58:22 2016 -0400
> Committer: Peter Ent <p...@apache.org>
> Committed: Mon Jul 18 09:58:22 2016 -0400
> 
> ----------------------------------------------------------------------
> .../org/apache/flex/core/graphics/Circle.as     | 28 ++++++++++++--------
> .../org/apache/flex/core/graphics/Ellipse.as    | 27 +++++++++++--------
> .../flex/org/apache/flex/core/graphics/Path.as  | 17 +++++++-----
> .../flex/org/apache/flex/core/graphics/Rect.as  | 27 +++++++++++--------
> .../flex/org/apache/flex/core/graphics/Text.as  | 26 +++++++++++-------
> 5 files changed, 77 insertions(+), 48 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/2da30efb/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Circle.as
> ----------------------------------------------------------------------
> diff --git 
> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Circle.as
>  
> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Circle.as
> index 9f067f1..aa01f77 100644
> --- 
> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Circle.as
> +++ 
> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Circle.as
> @@ -37,6 +37,9 @@ package org.apache.flex.core.graphics
>               {
>                       _radius = value;
>               }
> +             
> +             COMPILE::JS
> +             private var _circle:WrappedHTMLElement;
> 
>               /**
>                *  Draw the circle.
> @@ -64,25 +67,28 @@ package org.apache.flex.core.graphics
>             COMPILE::JS                
>             {
>                 var style:String = getStyleStr();
> -                var circle:WrappedHTMLElement = 
> document.createElementNS('http://www.w3.org/2000/svg', 'ellipse') as 
> WrappedHTMLElement;
> -                circle.flexjs_wrapper = this;
> -                circle.setAttribute('style', style);
> +
> +                             if (_circle == null) {
> +                                     _circle = 
> document.createElementNS('http://www.w3.org/2000/svg', 'ellipse') as 
> WrappedHTMLElement;
> +                                     _circle.flexjs_wrapper = this;
> +                                     element.appendChild(_circle);
> +                             }
> +                             _circle.setAttribute('style', style);
>                 if (stroke)
>                 {
> -                    circle.setAttribute('cx', String(radius + 
> stroke.weight));
> -                    circle.setAttribute('cy', String(radius + 
> stroke.weight));
> +                                     _circle.setAttribute('cx', 
> String(radius + stroke.weight));
> +                                     _circle.setAttribute('cy', 
> String(radius + stroke.weight));
>                 }
>                 else
>                 {
> -                    circle.setAttribute('cx', String(radius));
> -                    circle.setAttribute('cy', String(radius));
> +                                     _circle.setAttribute('cx', 
> String(radius));
> +                                     _circle.setAttribute('cy', 
> String(radius));
>                 }
> 
> -                circle.setAttribute('rx', String(radius));
> -                circle.setAttribute('ry', String(radius));
> -                element.appendChild(circle);
> +                             _circle.setAttribute('rx', String(radius));
> +                             _circle.setAttribute('ry', String(radius));
> 
> -                resize(x-radius, y-radius, (circle as 
> SVGCircleElement).getBBox());
> +                resize(x-radius, y-radius, (_circle as 
> SVGCircleElement).getBBox());
> 
>             }
>               }
> 
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/2da30efb/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Ellipse.as
> ----------------------------------------------------------------------
> diff --git 
> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Ellipse.as
>  
> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Ellipse.as
> index f3c6c90..732d2c0 100644
> --- 
> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Ellipse.as
> +++ 
> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Ellipse.as
> @@ -31,6 +31,9 @@ package org.apache.flex.core.graphics
>       public class Ellipse extends GraphicShape
>       {
>               
> +             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.
> @@ -58,24 +61,26 @@ package org.apache.flex.core.graphics
>             COMPILE::JS
>             {
>                 var style:String = getStyleStr();
> -                var ellipse:WrappedHTMLElement = 
> document.createElementNS('http://www.w3.org/2000/svg', 'ellipse') as 
> WrappedHTMLElement;
> -                ellipse.flexjs_wrapper = this;
> -                ellipse.setAttribute('style', style);
> +                             if (_ellipse == null) {
> +                                     _ellipse = 
> document.createElementNS('http://www.w3.org/2000/svg', 'ellipse') as 
> WrappedHTMLElement;
> +                                     _ellipse.flexjs_wrapper = this;
> +                                     element.appendChild(_ellipse);
> +                             }
> +                             _ellipse.setAttribute('style', style);
>                 if (stroke)
>                 {
> -                    ellipse.setAttribute('cx', String(width / 2 + 
> stroke.weight));
> -                    ellipse.setAttribute('cy', String(height / 2 + 
> stroke.weight));
> +                                     _ellipse.setAttribute('cx', 
> String(width / 2 + stroke.weight));
> +                                     _ellipse.setAttribute('cy', 
> String(height / 2 + stroke.weight));
>                 }
>                 else
>                 {
> -                    ellipse.setAttribute('cx', String(width / 2));
> -                    ellipse.setAttribute('cy', String(height / 2));
> +                                     _ellipse.setAttribute('cx', 
> String(width / 2));
> +                                     _ellipse.setAttribute('cy', 
> String(height / 2));
>                 }
> -                ellipse.setAttribute('rx', String(width / 2));
> -                ellipse.setAttribute('ry', String(height / 2));
> -                element.appendChild(ellipse);
> +                             _ellipse.setAttribute('rx', String(width / 2));
> +                             _ellipse.setAttribute('ry', String(height / 2));
> 
> -                resize(x, y, (ellipse as SVGEllipseElement).getBBox());
> +                resize(x, y, (_ellipse as SVGEllipseElement).getBBox());
> 
>             }
>               }
> 
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/2da30efb/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Path.as
> ----------------------------------------------------------------------
> diff --git 
> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Path.as
>  
> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Path.as
> index 0a152bb..15e6f0f 100644
> --- 
> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Path.as
> +++ 
> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Path.as
> @@ -41,6 +41,9 @@ package org.apache.flex.core.graphics
>               {
>                       _data = value;
>               }
> +             
> +             COMPILE::JS
> +             private var _path:WrappedHTMLElement;
> 
>               /**
>                *  Draw the path.
> @@ -76,13 +79,15 @@ package org.apache.flex.core.graphics
>             {
>                 if (data == null || data.length === 0) return;
>                 var style:String = getStyleStr();
> -                var path:WrappedHTMLElement = 
> document.createElementNS('http://www.w3.org/2000/svg', 'path') as 
> WrappedHTMLElement;
> -                path.flexjs_wrapper = this;
> -                path.setAttribute('style', style);
> -                path.setAttribute('d', data);
> -                element.appendChild(path);
> +                             if (_path == null) {
> +                     _path = 
> document.createElementNS('http://www.w3.org/2000/svg', 'path') as 
> WrappedHTMLElement;
> +                                     _path.flexjs_wrapper = this;
> +                                     element.appendChild(_path);
> +                             }
> +                             _path.setAttribute('style', style);
> +                             _path.setAttribute('d', data);
> 
> -                resize(x, y, path['getBBox']());
> +                resize(x, y, _path['getBBox']());
> 
>             }
>               }
> 
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/2da30efb/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Rect.as
> ----------------------------------------------------------------------
> diff --git 
> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Rect.as
>  
> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Rect.as
> index 3556459..0355c27 100644
> --- 
> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Rect.as
> +++ 
> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Rect.as
> @@ -28,6 +28,8 @@ package org.apache.flex.core.graphics
> 
>       public class Rect extends GraphicShape
>       {
> +             COMPILE::JS
> +             private var _rect:WrappedHTMLElement;
>               
>               /**
>                *  Draw the rectangle.
> @@ -55,24 +57,27 @@ package org.apache.flex.core.graphics
>             COMPILE::JS
>             {
>                 var style:String = this.getStyleStr();
> -                var rect:WrappedHTMLElement = 
> document.createElementNS('http://www.w3.org/2000/svg', 'rect') as 
> WrappedHTMLElement;
> -                rect.flexjs_wrapper = this;
> -                rect.setAttribute('style', style);
> +                             
> +                             if (_rect == null) {
> +                     _rect = 
> document.createElementNS('http://www.w3.org/2000/svg', 'rect') as 
> WrappedHTMLElement;
> +                     _rect.flexjs_wrapper = this;
> +                                     element.appendChild(_rect);
> +                             }
> +                _rect.setAttribute('style', style);
>                 if (stroke)
>                 {
> -                    rect.setAttribute('x', String(stroke.weight / 2) + 'px');
> -                    rect.setAttribute('y', String(stroke.weight / 2) + 'px');
> +                                     _rect.setAttribute('x', 
> String(stroke.weight / 2) + 'px');
> +                                     _rect.setAttribute('y', 
> String(stroke.weight / 2) + 'px');
>                 }
>                 else
>                 {
> -                    rect.setAttribute('x', '0' + 'px');
> -                    rect.setAttribute('y', '0' + 'px');
> +                                     _rect.setAttribute('x', '0' + 'px');
> +                                     _rect.setAttribute('y', '0' + 'px');
>                 }
> -                rect.setAttribute('width', String(width) + 'px');
> -                rect.setAttribute('height', String(height) + 'px');
> -                element.appendChild(rect);
> +                             _rect.setAttribute('width', String(width) + 
> 'px');
> +                             _rect.setAttribute('height', String(height) + 
> 'px');
> 
> -                resize(x, y, rect['getBBox']());
> +                resize(x, y, _rect['getBBox']());
>             }
>               }
>               
> 
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/2da30efb/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Text.as
> ----------------------------------------------------------------------
> diff --git 
> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Text.as
>  
> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Text.as
> index b493488..e864a11 100644
> --- 
> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Text.as
> +++ 
> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/core/graphics/Text.as
> @@ -64,6 +64,9 @@ package org.apache.flex.core.graphics
>         COMPILE::SWF
>               private var _textField:CSSTextField;
>               
> +             COMPILE::JS
> +             private var _text:WrappedHTMLElement;
> +             
>               /**
>                *  @copy org.apache.flex.core.ITextModel#textField
>                *  
> @@ -115,16 +118,21 @@ package org.apache.flex.core.graphics
>             COMPILE::JS
>             {
>                 var style:String = this.getStyleStr();
> -                var text:WrappedHTMLElement = 
> document.createElementNS('http://www.w3.org/2000/svg', 'text') as 
> WrappedHTMLElement;
> -                text.flexjs_wrapper = this;
> -                text.setAttribute('style', style);
> -                text.setAttribute('x', String(xt) + 'px');
> -                text.setAttribute('y', String(yt) + 'px');
> -                var textNode:Text = document.createTextNode(value) as Text;
> -                text.appendChild(textNode as Node);
> -                element.appendChild(text);
> +                             if (_text == null) {
> +                     _text = 
> document.createElementNS('http://www.w3.org/2000/svg', 'text') as 
> WrappedHTMLElement;
> +                     _text.flexjs_wrapper = this;
> +                                     element.appendChild(_text);
> +                             }
> +                             else {
> +                                     _text.removeChild(_text.childNodes[0]);
> +                             }
> +                _text.setAttribute('style', style);
> +                _text.setAttribute('x', String(xt) + 'px');
> +                _text.setAttribute('y', String(yt) + 'px');
> +                             var textNode:Text = 
> document.createTextNode(value) as Text;
> +                             _text.appendChild(textNode as Node);
> 
> -                resize(x, y, (text as SVGLocatable).getBBox());
> +                resize(x, y, (_text as SVGLocatable).getBBox());
> 
>             }
>               }
> 

Reply via email to