flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject [13/21] git commit: [flex-asjs] [refs/heads/develop] - Added GraphicContainer
Date Mon, 25 Jul 2016 10:09:31 GMT
Added GraphicContainer


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/58bb1535
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/58bb1535
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/58bb1535

Branch: refs/heads/develop
Commit: 58bb153540b3ede5aed0586eb97e9521ce5383d7
Parents: 6a28675
Author: Harbs <harbs@in-tools.com>
Authored: Sun Jul 24 10:19:13 2016 +0300
Committer: Harbs <harbs@in-tools.com>
Committed: Sun Jul 24 10:19:13 2016 +0300

----------------------------------------------------------------------
 .../Graphics/src/main/flex/GraphicsClasses.as   |  1 +
 .../org/apache/flex/svg/GraphicContainer.as     | 79 ++++++++++++++++++++
 .../flex/org/apache/flex/svg/GraphicShape.as    | 29 ++++---
 .../flex/org/apache/flex/svg/LinearGradient.as  |  8 +-
 4 files changed, 102 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/58bb1535/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 1f71851..0cc1db9 100644
--- a/frameworks/projects/Graphics/src/main/flex/GraphicsClasses.as
+++ b/frameworks/projects/Graphics/src/main/flex/GraphicsClasses.as
@@ -28,6 +28,7 @@ package
 internal class GraphicsClasses
 {	
 
+	import org.apache.flex.svg.GraphicContainer; GraphicContainer;
 	import org.apache.flex.svg.GraphicShape; GraphicShape;
 	import org.apache.flex.svg.Rect; Rect;
 	import org.apache.flex.svg.Ellipse; Ellipse;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/58bb1535/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
new file mode 100644
index 0000000..d156f2d
--- /dev/null
+++ b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/GraphicContainer.as
@@ -0,0 +1,79 @@
+/**
+ * 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
+ *
+ *     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.svg
+{
+    import org.apache.flex.core.ContainerBase;
+    import org.apache.flex.core.IParent;
+    import org.apache.flex.events.Event;
+
+	COMPILE::JS
+	{
+		import org.apache.flex.core.WrappedHTMLElement;
+	}
+
+    public class GraphicContainer extends ContainerBase
+    {
+        public function GraphicContainer()
+        {
+            super();
+        }
+
+		/**
+		 * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
+		 */
+		COMPILE::JS
+		override protected function createElement():WrappedHTMLElement
+		{
+			element = document.createElementNS('http://www.w3.org/2000/svg', 'svg') as 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;
+		}
+		/**
+		 *  @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");
+		}
+
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/58bb1535/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/GraphicShape.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/GraphicShape.as
b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/GraphicShape.as
index 8d14b67..d0fd171 100644
--- a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/GraphicShape.as
+++ b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/GraphicShape.as
@@ -76,17 +76,26 @@ package org.apache.flex.svg
 		 */
         public function GraphicShape()
         {
-            COMPILE::JS
-            {
-                element = document.createElementNS('http://www.w3.org/2000/svg', 'svg') as
WrappedHTMLElement;
-                element.flexjs_wrapper = this;
-                element.style.left = 0;
-                element.style.top = 0;
-                //element.offsetParent = null;
-                positioner = element;
-                positioner.style.position = 'relative';
-            }
+			super();
         }
+		
+		/**
+		 * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
+		 */
+		COMPILE::JS
+		override protected function createElement():WrappedHTMLElement
+		{
+			element = document.createElementNS('http://www.w3.org/2000/svg', 'svg') as WrappedHTMLElement;
+			element.flexjs_wrapper = this;
+			element.style.left = 0;
+			element.style.top = 0;
+			//element.offsetParent = null;
+			positioner = element;
+			positioner.style.position = 'relative';
+			
+			return element;
+		}
+
 
         COMPILE::SWF
 		protected function applyStroke():void

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/58bb1535/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/LinearGradient.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/LinearGradient.as
b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/LinearGradient.as
index 619ae26..affee7a 100644
--- a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/LinearGradient.as
+++ b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/LinearGradient.as
@@ -18,6 +18,7 @@ package org.apache.flex.svg
 	import org.apache.flex.graphics.GradientEntry;
 	import org.apache.flex.graphics.IFill;
 	import org.apache.flex.graphics.IGraphicShape;
+	import org.apache.flex.utils.CSSUtils;
 
     COMPILE::SWF
     {
@@ -103,11 +104,8 @@ package org.apache.flex.svg
                 //Set Offset
                 stop.setAttribute('offset', String(gradientEntry.ratio * 100) + '%');
                 //Set Color
-                var color:String = Number(gradientEntry.color).toString(16);
-                if (color.length == 1) color = '00' + color;
-                if (color.length == 2) color = '00' + color;
-                if (color.length == 4) color = '00' + color;
-                stop.setAttribute('stop-color', '#' + String(color));
+				CSSUtils.attributeFromColor(gradientEntry.color)
+                stop.setAttribute('stop-color', CSSUtils.attributeFromColor(gradientEntry.color));
                 //Set Alpha
                 stop.setAttribute('stop-opacity', String(gradientEntry.alpha));
                 


Mime
View raw message