Repository: flex-asjs Updated Branches: refs/heads/svg-rename 9cd285227 -> a94a92300
TransformBead working. Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/518995ed Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/518995ed Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/518995ed Branch: refs/heads/svg-rename Commit: 518995ed1f9fb2edba8a58b4038c85e1c8b2d4c9 Parents: 580eded Author: yishayw <yishayj...@hotmail.com> Authored: Thu Jul 28 02:47:21 2016 +0300 Committer: yishayw <yishayj...@hotmail.com> Committed: Thu Jul 28 02:47:21 2016 +0300 ---------------------------------------------------------------------- .../projects/Core/src/main/flex/CoreClasses.as | 1 + .../org/apache/flex/core/ITransformModel.as | 47 +++++ .../projects/Graphics/.actionScriptProperties | 21 -- frameworks/projects/Graphics/.flexLibProperties | 23 +-- .../Graphics/src/main/flex/GraphicsClasses.as | 2 + .../org/apache/flex/graphics/IBeadTransform.as | 46 +++++ .../org/apache/flex/graphics/ITransformHost.as | 64 ++++++ .../org/apache/flex/graphics/TransformModel.as | 31 +++ .../org/apache/flex/svg/GraphicContainer.as | 201 +++++++++++++++++-- .../flex/org/apache/flex/svg/TransformBead.as | 90 +++++++++ 10 files changed, 465 insertions(+), 61 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518995ed/frameworks/projects/Core/src/main/flex/CoreClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/CoreClasses.as b/frameworks/projects/Core/src/main/flex/CoreClasses.as index a1cfe9c..2fa67a5 100644 --- a/frameworks/projects/Core/src/main/flex/CoreClasses.as +++ b/frameworks/projects/Core/src/main/flex/CoreClasses.as @@ -67,6 +67,7 @@ internal class CoreClasses import org.apache.flex.core.IParentIUIBase; IParentIUIBase; import org.apache.flex.core.IPopUp; IPopUp; import org.apache.flex.core.IRangeModel; IRangeModel; + import org.apache.flex.core.ITransformModel; ITransformModel; import org.apache.flex.core.IRollOverModel; IRollOverModel; COMPILE::SWF { http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518995ed/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ITransformModel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ITransformModel.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ITransformModel.as new file mode 100644 index 0000000..56cb961 --- /dev/null +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ITransformModel.as @@ -0,0 +1,47 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.core +{ + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.geom.Matrix; + + /** + * The ITransformModel interface describes the minimum set of properties + * needed to define a transformation on an object. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public interface ITransformModel extends IEventDispatcher, IBeadModel + { + /** + * The matrix of the Transform + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + function get matrix():Matrix; + function set matrix(value:Matrix):void; + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518995ed/frameworks/projects/Graphics/.actionScriptProperties ---------------------------------------------------------------------- diff --git a/frameworks/projects/Graphics/.actionScriptProperties b/frameworks/projects/Graphics/.actionScriptProperties index f3a3b57..f398fbb 100644 --- a/frameworks/projects/Graphics/.actionScriptProperties +++ b/frameworks/projects/Graphics/.actionScriptProperties @@ -1,22 +1,4 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- - -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. - ---> <actionScriptProperties analytics="false" mainApplicationPath="Graphics.as" projectUUID="ff3e0531-b7c9-4b0c-9146-05c27a47f837" version="11"> <compiler additionalCompilerArguments="-locale en_US -define=COMPILE::SWF,true -define=COMPILE::JS,false -load-config=../config/compile-as-config.xml" autoRSLOrdering="true" copyDependentFiles="false" fteInMXComponents="false" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="false" htmlHistoryManagement="false" htmlPlayerVersionCheck="true" includeNetmonSwc="false" outputFolderPath="target" removeUnusedRSL="true" sourceFolderPath="src/main/flex" strict="true" targetPlayerVersion="0.0.0" useApolloConfig="false" useDebugRSLSwfs="true" useFlashSDK="false" verifyDigests="true" warn="true"> <compilerSourcePath/> @@ -31,19 +13,16 @@ limitations under the License. <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/Collections.swc" useDefaultLinkType="false"/> <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/Mobile.swc" useDefaultLinkType="false"/> <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/HTML.swc" useDefaultLinkType="false"/> - <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/Core.swc" useDefaultLinkType="false"/> <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/Binding.swc" useDefaultLinkType="false"/> <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/Charts.swc" useDefaultLinkType="false"/> <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/Graphics.swc" useDefaultLinkType="false"/> <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/flex.swc" useDefaultLinkType="false"/> - <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/core.swc" useDefaultLinkType="false"/> <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/Network.swc" useDefaultLinkType="false"/> <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/GoogleMaps.swc" useDefaultLinkType="false"/> <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/DragDrop.swc" useDefaultLinkType="false"/> <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/CreateJS.swc" useDefaultLinkType="false"/> </excludedEntries> </libraryPathEntry> - <libraryPathEntry kind="3" linkType="1" path="/Core/target/Core.swc" useDefaultLinkType="false"/> </libraryPath> <sourceAttachmentPath/> </compiler> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518995ed/frameworks/projects/Graphics/.flexLibProperties ---------------------------------------------------------------------- diff --git a/frameworks/projects/Graphics/.flexLibProperties b/frameworks/projects/Graphics/.flexLibProperties index 20339ea..096c2b5 100644 --- a/frameworks/projects/Graphics/.flexLibProperties +++ b/frameworks/projects/Graphics/.flexLibProperties @@ -1,24 +1,9 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- - - 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. - ---> <flexLibProperties includeAllClasses="true" useMultiPlatformConfig="false" version="3"> - <includeClasses/> + <includeClasses> + <classEntry path="org.apache.flex.svg.TransformBead"/> + <classEntry path="org.apache.flex.graphics.ITransformHost"/> + </includeClasses> <includeResources/> <namespaceManifests/> </flexLibProperties> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518995ed/frameworks/projects/Graphics/src/main/flex/GraphicsClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Graphics/src/main/flex/GraphicsClasses.as b/frameworks/projects/Graphics/src/main/flex/GraphicsClasses.as index 0cc1db9..b8a5765 100644 --- a/frameworks/projects/Graphics/src/main/flex/GraphicsClasses.as +++ b/frameworks/projects/Graphics/src/main/flex/GraphicsClasses.as @@ -39,6 +39,8 @@ internal class GraphicsClasses import org.apache.flex.svg.Text; Text; import org.apache.flex.svg.CompoundGraphic; CompoundGraphic; import org.apache.flex.svg.LinearGradient; LinearGradient; + import org.apache.flex.graphics.TransformModel; TransformModel; + import org.apache.flex.svg.TransformBead; TransformBead; } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518995ed/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/IBeadTransform.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/IBeadTransform.as b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/IBeadTransform.as new file mode 100644 index 0000000..1a8f61c --- /dev/null +++ b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/IBeadTransform.as @@ -0,0 +1,46 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.graphics +{ + import org.apache.flex.core.IBead; + + /** + * The IBeadTransform interface is the basic interface for the + * container views that transform drawable objects that implement ITransformHost + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public interface IBeadTransform extends IBead + { + + /** + * Transform the ITransformHost. The implementor of this method should + * have concrete knowledge of ITransformHost implementor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + function transform():void; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518995ed/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/ITransformHost.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/ITransformHost.as b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/ITransformHost.as new file mode 100644 index 0000000..6310dd0 --- /dev/null +++ b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/ITransformHost.as @@ -0,0 +1,64 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.graphics +{ + import org.apache.flex.core.IFlexJSElement; + import org.apache.flex.core.IStrand; + + + + /** + * The ITransformHost interface is the basic interface for the + * container views that have an IBeadTransform. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public interface ITransformHost extends IStrand + { + /** + * Each ITransformHost has an element that is actually added to + * the platform's display list DOM. It may not be the actual + * component itself. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::SWF + function get transformElement():IFlexJSElement; + + /** + * Each ITransformHost has an element that is actually added to + * the platform's display list DOM. It may not be the actual + * component itself. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::JS + function get transformElement():org.apache.flex.core.WrappedHTMLElement; + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518995ed/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/TransformModel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/TransformModel.as b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/TransformModel.as new file mode 100644 index 0000000..68d650b --- /dev/null +++ b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/TransformModel.as @@ -0,0 +1,31 @@ +package org.apache.flex.graphics +{ + import org.apache.flex.core.IStrand; + import org.apache.flex.core.ITransformModel; + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + import org.apache.flex.geom.Matrix; + + public class TransformModel extends EventDispatcher implements ITransformModel + { + private var _matrix:Matrix; + + public function TransformModel() + { + } + + public function get matrix():Matrix + { + return _matrix; + } + + public function set matrix(value:Matrix):void + { + _matrix = value; + dispatchEvent(new Event(Event.CHANGE)); + } + + public function set strand(value:IStrand):void {} + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518995ed/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/GraphicContainer.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/GraphicContainer.as b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/GraphicContainer.as index d156f2d..b40b53b 100644 --- a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/GraphicContainer.as +++ b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/GraphicContainer.as @@ -14,15 +14,19 @@ package org.apache.flex.svg { import org.apache.flex.core.ContainerBase; - import org.apache.flex.core.IParent; - import org.apache.flex.events.Event; + import org.apache.flex.core.IFlexJSElement; + import org.apache.flex.graphics.ITransformHost; COMPILE::JS { - import org.apache.flex.core.WrappedHTMLElement; + import org.apache.flex.core.IContainer; + import org.apache.flex.core.UIBase; } - public class GraphicContainer extends ContainerBase + [DefaultProperty("mxmlContent")] + + COMPILE::SWF + public class GraphicContainer extends ContainerBase implements ITransformHost { public function GraphicContainer() { @@ -30,12 +34,50 @@ package org.apache.flex.svg } /** + * @private + */ + override public function addElement(c:Object, dispatchEvent:Boolean = true):void + { + if(c is GraphicShape) + super.addElement(c, dispatchEvent); + else + throw new Error("Only svg elements can be added to svg containers"); + } + + /** + * @private + */ + override public function addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void + { + if(c is GraphicShape) + super.addElementAt(c, index, dispatchEvent); + else + throw new Error("Only svg elements can be added to svg containers"); + } + + public function get transformElement():IFlexJSElement + { + return element; + } + + } + + COMPILE::JS + public class GraphicContainer extends UIBase implements ITransformHost, IContainer + { + private var graphicGroup:ContainerBase; + + public function GraphicContainer() + { + super(); + } + + /** * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement */ - COMPILE::JS - override protected function createElement():WrappedHTMLElement + override protected function createElement():org.apache.flex.core.WrappedHTMLElement { - element = document.createElementNS('http://www.w3.org/2000/svg', 'svg') as WrappedHTMLElement; + element = document.createElementNS('http://www.w3.org/2000/svg', 'svg') as org.apache.flex.core.WrappedHTMLElement; positioner = element; @@ -46,34 +88,151 @@ package org.apache.flex.svg positioner.style.position = 'relative'; element.flexjs_wrapper = this; - /*addEventListener('childrenAdded', - runLayoutHandler); - addEventListener('elementRemoved', - runLayoutHandler);*/ - + graphicGroup = new GraphicGroup(); + addElement(graphicGroup); return element; } + + + public function get transformElement():org.apache.flex.core.WrappedHTMLElement + { + return graphicGroup.element; + } + /** - * @private + * @copy org.apache.flex.core.IParent#getElementAt() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function getElementAt(index:int):Object + { + return graphicGroup.getElementAt(index); + } + + /** + * @copy org.apache.flex.core.IParent#addElement() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 */ override public function addElement(c:Object, dispatchEvent:Boolean = true):void { - if(c is GraphicShape) - super.addElement(c, dispatchEvent); - else + if(!(c is GraphicShape)) + { throw new Error("Only svg elements can be added to svg containers"); + } + graphicGroup.addElement(c, dispatchEvent); + if (dispatchEvent) + this.dispatchEvent(new Event("childrenAdded")); } /** - * @private + * @copy org.apache.flex.core.IParent#addElementAt() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 */ override public function addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void { - if(c is GraphicShape) - super.addElementAt(c, index, dispatchEvent); - else + if(!(c is GraphicShape)) + { throw new Error("Only svg elements can be added to svg containers"); + } + graphicGroup.addElementAt(c, index, dispatchEvent); + 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 + * @productversion FlexJS 0.0 + */ + override public function removeElement(c:Object, dispatchEvent:Boolean = true):void + { + graphicGroup.removeElement(c, dispatchEvent); + 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 + * @productversion FlexJS 0.0 + */ + override public function getElementIndex(c:Object):int + { + return graphicGroup.getElementIndex(c); } + + + /** + * The number of elements in the parent. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function get numElements():int + { + return graphicGroup.numElements; + } + } +} - } +import org.apache.flex.core.ContainerBase; + +class GraphicGroup extends ContainerBase +{ + COMPILE::JS + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + 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'; + 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/518995ed/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/TransformBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/TransformBead.as b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/TransformBead.as new file mode 100644 index 0000000..ed9de0e --- /dev/null +++ b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/TransformBead.as @@ -0,0 +1,90 @@ +package org.apache.flex.svg +{ + import org.apache.flex.core.IStrand; + import org.apache.flex.core.ITransformModel; + import org.apache.flex.events.Event; + import org.apache.flex.geom.Matrix; + import org.apache.flex.graphics.IBeadTransform; + import org.apache.flex.graphics.ITransformHost; + + COMPILE::SWF { + import flash.display.Sprite; + import flash.geom.Matrix; + } + + + public class TransformBead implements IBeadTransform + { + private var _strand:IStrand; + private var transformModel:ITransformModel; + + public function TransformBead() + { + } + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function set strand(value:IStrand):void + { + if (!(value is GraphicContainer)) + { + throw new Error("This bead only works with svg GraphicContainers"); + return; + } + _strand = value; + transformModel = value.getBeadByType(ITransformModel) as ITransformModel; + if (!transformModel) + { + throw new Error("An ITransformModel needs to be defined."); + return; + } + transformModel.addEventListener(Event.CHANGE, changeHandler); + if (transformModel.matrix) + { + transform(); + } + } + + COMPILE::SWF + public function transform():void + { + var element:Sprite = host.transformElement as Sprite; + var fjsm:org.apache.flex.geom.Matrix = transformModel.matrix; + var flashMatrix:flash.geom.Matrix = new flash.geom.Matrix(fjsm.a, fjsm.b, fjsm.c, fjsm.d, fjsm.tx, fjsm.ty); + element.transform.matrix = flashMatrix; + } + + COMPILE::JS + public function transform():void + { + var element:org.apache.flex.core.WrappedHTMLElement = host.transformElement; + var fjsm:org.apache.flex.geom.Matrix = transformModel.matrix; + var elem:Array = [fjsm.a , fjsm.b, fjsm.c, fjsm.d, fjsm.tx, fjsm.ty]; + element.setAttribute("transform", "matrix(" +elem.join(",") + ")"; + } + + private function changeHandler(e:Event):void + { + transform(); + } + + /** + * The host component. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get host():ITransformHost + { + return _strand as ITransformHost; + } + } +} \ No newline at end of file