You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by bi...@apache.org on 2014/10/16 10:49:42 UTC

[4/5] git commit: [flex-asjs] [refs/heads/develop] - Update Shape classes to support declaration in MXML

Update Shape classes to support declaration in MXML


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

Branch: refs/heads/develop
Commit: 58cbb52c1839e6bda5e012474c0002502ad1cc6c
Parents: 019f95d
Author: OmPrakash Muppirala <bi...@gmail.com>
Authored: Thu Oct 16 01:37:29 2014 -0700
Committer: OmPrakash Muppirala <bi...@gmail.com>
Committed: Thu Oct 16 01:37:29 2014 -0700

----------------------------------------------------------------------
 .../src/org/apache/flex/core/graphics/Circle.as | 18 ++++++++-
 .../org/apache/flex/core/graphics/Ellipse.as    |  7 +++-
 .../apache/flex/core/graphics/GradientEntry.as  |  2 +-
 .../apache/flex/core/graphics/GraphicShape.as   | 14 +++++++
 .../src/org/apache/flex/core/graphics/Path.as   | 20 +++++++++-
 .../src/org/apache/flex/core/graphics/Rect.as   |  5 +++
 .../src/org/apache/flex/core/graphics/Circle.js | 28 ++++++++++++++
 .../org/apache/flex/core/graphics/Ellipse.js    |  7 ++++
 .../apache/flex/core/graphics/GraphicShape.js   | 39 +++++++-------------
 .../src/org/apache/flex/core/graphics/Path.js   | 33 ++++++++++++++++-
 .../src/org/apache/flex/core/graphics/Rect.js   |  7 ++++
 11 files changed, 148 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/58cbb52c/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Circle.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Circle.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Circle.as
index fdbb336..e67e97f 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Circle.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Circle.as
@@ -19,7 +19,18 @@ package org.apache.flex.core.graphics
 
 	public class Circle extends GraphicShape
 	{
-		
+		private var _radius:Number;
+
+		public function get radius():Number
+		{
+			return _radius;
+		}
+
+		public function set radius(value:Number):void
+		{
+			_radius = value;
+		}
+
 		/**
 		 *  Draw the circle.
 		 *  @param x The x location of the center of the circle
@@ -40,5 +51,10 @@ package org.apache.flex.core.graphics
 			endFill();
 		}
 		
+		override public function addedToParent():void
+		{
+			drawCircle(0, 0, radius);
+		}
+		
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/58cbb52c/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Ellipse.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Ellipse.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Ellipse.as
index 32dc73a..8226363 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Ellipse.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Ellipse.as
@@ -1,7 +1,5 @@
 package org.apache.flex.core.graphics
 {
-	import flash.display.CapsStyle;
-	import flash.display.JointStyle;
 	import flash.geom.Point;
 	import flash.geom.Rectangle;
 
@@ -29,5 +27,10 @@ package org.apache.flex.core.graphics
 			endFill();
 		}
 		
+		override protected function draw():void
+		{
+			this.drawEllipse(0, 0, width, height);	
+		}
+		
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/58cbb52c/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GradientEntry.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GradientEntry.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GradientEntry.as
index 92a1765..0124c13 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GradientEntry.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GradientEntry.as
@@ -34,7 +34,7 @@ package org.apache.flex.core.graphics
 		private var _ratio:Number = 0x000000;
 		
 		
-		public function GradientEntry(alpha:Number, color:uint, ratio:Number)
+		public function GradientEntry(alpha:Number = 1.0, color:uint = 0x000000, ratio:Number = 1.0)
 		{
 			_alpha = alpha;
 			_color = color;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/58cbb52c/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicShape.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicShape.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicShape.as
index b5decbc..0b04b39 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicShape.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicShape.as
@@ -84,5 +84,19 @@ package org.apache.flex.core.graphics
 			}
 		}
 		
+		/**
+		 * This is where the drawing methods get called from
+		 */
+		protected function draw():void
+		{
+			//Overwrite in subclass
+		}
+		
+		override public function addedToParent():void
+		{
+			super.addedToParent();
+			draw();
+		}
+		
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/58cbb52c/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Path.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Path.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Path.as
index 7d1eb53..e02dd95 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Path.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Path.as
@@ -23,6 +23,18 @@ package org.apache.flex.core.graphics
 	public class Path extends GraphicShape
 	{
 		
+		private var _data:String;
+		
+		public function get data():String
+		{
+			return _data;
+		}
+
+		public function set data(value:String):void
+		{
+			_data = value;
+		}
+
 		/**
 		 *  Draw the path.
 		 *  @param data A string containing a compact represention of the path segments.
@@ -44,11 +56,17 @@ package org.apache.flex.core.graphics
 			graphics.clear();
 			applyStroke();
 			var bounds:Rectangle = PathHelper.getBounds(data);
+			this.width = bounds.width;
+			this.height = bounds.height;
 			beginFill(bounds,new Point(bounds.left + x, bounds.top + y) );
 			var graphicsPath:GraphicsPath = PathHelper.getSegments(data,x,y);
 			graphics.drawPath(graphicsPath.commands, graphicsPath.data);
 			endFill();
-			
+		}
+		
+		override protected function draw():void
+		{
+			drawPath(0, 0, data);
 		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/58cbb52c/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Rect.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Rect.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Rect.as
index d30a599..fd8d636 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Rect.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Rect.as
@@ -43,5 +43,10 @@ package org.apache.flex.core.graphics
 			endFill();
 		}
 		
+		override protected function draw():void
+		{
+			drawRect(0,0,width,height);
+		}
+		
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/58cbb52c/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Circle.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Circle.js b/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Circle.js
index 71d4716..1d56a8c 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Circle.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Circle.js
@@ -25,6 +25,11 @@ goog.require('org.apache.flex.core.graphics.GraphicShape');
 org.apache.flex.core.graphics.Circle = function() {
   org.apache.flex.core.graphics.Circle.base(this, 'constructor');
 
+   /**
+   * @private
+   * @type {number}
+   */
+  this.radius_ = 0;
 };
 goog.inherits(org.apache.flex.core.graphics.Circle,
     org.apache.flex.core.graphics.GraphicShape);
@@ -39,6 +44,22 @@ org.apache.flex.core.graphics.Circle.prototype.FLEXJS_CLASS_INFO =
     { names: [{ name: 'Circle',
                 qName: 'org.apache.flex.core.graphics.Circle' }] };
 
+/**
+ * @expose
+ * @param {number} v The radius of the circle
+ */
+org.apache.flex.core.graphics.Circle.prototype.set_radius = function(v) {
+  this.radius_ = v;
+};
+
+
+/**
+ * @expose
+ * @return {number} The radius of the circle
+ */
+org.apache.flex.core.graphics.Circle.prototype.get_radius = function() {
+  return this.radius_;
+};				
 
 /**
  * @expose
@@ -67,3 +88,10 @@ org.apache.flex.core.graphics.Circle.prototype.drawCircle = function(x, y, radiu
     circle.setAttribute('ry', String(radius));
     this.element.appendChild(circle);
   };
+
+/**
+ * @override
+*/
+  org.apache.flex.core.graphics.Circle.prototype.draw = function() {
+    this.drawCircle(this.get_x(), this.get_y(), this.get_radius());
+  };
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/58cbb52c/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Ellipse.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Ellipse.js b/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Ellipse.js
index 00a7400..c2d45cd 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Ellipse.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Ellipse.js
@@ -67,3 +67,10 @@ org.apache.flex.core.graphics.Ellipse.prototype.drawEllipse = function(x, y, wid
     ellipse.setAttribute('ry', String(height / 2));
     this.element.appendChild(ellipse);
   };
+
+/**
+ * @override
+*/
+  org.apache.flex.core.graphics.Ellipse.prototype.draw = function() {
+    this.drawEllipse(this.get_x(), this.get_y(), this.get_width(), this.get_height());
+  };
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/58cbb52c/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/GraphicShape.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/GraphicShape.js b/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/GraphicShape.js
index 1580e43..a869062 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/GraphicShape.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/GraphicShape.js
@@ -12,19 +12,19 @@
  * limitations under the License.
  */
 
-//TODO Should implment IUIBase
 goog.provide('org.apache.flex.core.graphics.GraphicShape');
-
+goog.require('org.apache.flex.core.UIBase');
 goog.require('org.apache.flex.core.graphics.SolidColor');
 goog.require('org.apache.flex.core.graphics.SolidColorStroke');
 
-
-
 /**
  * @constructor
+ * @extends {org.apache.flex.core.UIBase}
  */
 org.apache.flex.core.graphics.GraphicShape = function() {
-
+  
+  org.apache.flex.core.graphics.GraphicShape.base(this, 'constructor');
+  
   /**
    * @private
    * @type {org.apache.flex.core.graphics.IFill}
@@ -66,27 +66,9 @@ org.apache.flex.core.graphics.GraphicShape = function() {
    * @type {SVGElement}
    */
   this.element = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
-
-
-};
-
-
-/**
- * @expose
- * @param {number} value New X position.
- */
-org.apache.flex.core.graphics.GraphicShape.prototype.set_x = function(value) {
-  this.x_ = value;
-};
-
-
-/**
- * @expose
- * @param {number} value New Y position.
- */
-org.apache.flex.core.graphics.GraphicShape.prototype.set_y = function(value) {
-  this.y_ = value;
 };
+goog.inherits(org.apache.flex.core.graphics.GraphicShape,
+    org.apache.flex.core.UIBase);
 
 
 /**
@@ -138,10 +120,17 @@ org.apache.flex.core.graphics.GraphicShape.prototype.set_stroke = function(value
  *
  */
 org.apache.flex.core.graphics.GraphicShape.prototype.addedToParent = function() {
+  this.draw();
   var bbox = this.element.getBBox();
   this.resize(this.x_, this.y_, bbox);
 };
 
+/**
+ * This is where the drawing methods get called from 
+ */
+org.apache.flex.core.graphics.GraphicShape.prototype.draw = function() {
+  //Overwrite in subclass
+};
 
 /**
  * @expose

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/58cbb52c/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Path.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Path.js b/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Path.js
index d530ef3..776370d 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Path.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Path.js
@@ -25,6 +25,11 @@ goog.require('org.apache.flex.core.graphics.GraphicShape');
 org.apache.flex.core.graphics.Path = function() {
   org.apache.flex.core.graphics.Path.base(this, 'constructor');
 
+   /**
+   * @private
+   * @type {string}
+   */
+  this.data_ = "";
 };
 goog.inherits(org.apache.flex.core.graphics.Path,
     org.apache.flex.core.graphics.GraphicShape);
@@ -39,11 +44,28 @@ org.apache.flex.core.graphics.Path.prototype.FLEXJS_CLASS_INFO =
     { names: [{ name: 'Path',
                 qName: 'org.apache.flex.core.graphics.Path' }] };
 
+				
+/**
+ * @expose
+ * @param {string} v The string representation of the path data
+ */
+org.apache.flex.core.graphics.Path.prototype.set_data = function(v) {
+  this.data_ = v;
+};
+
 
 /**
  * @expose
- * @param {number} x The x location of the center of the Path.
- * @param {number} y The y location of the center of the Path.
+ * @return {string} The string representation of the path data
+ */
+org.apache.flex.core.graphics.Path.prototype.get_data = function() {
+  return this.data_;
+};						
+
+/**
+ * @expose
+ * @param {number} x The x location of the Path.
+ * @param {number} y The y location of the Path.
  * @param {string} data A string containing a compact represention of the path segments.
  *  The value is a space-delimited string describing each path segment. Each
  *  segment entry has a single character which denotes the segment type and
@@ -67,3 +89,10 @@ org.apache.flex.core.graphics.Path.prototype.drawPath = function(x, y, data) {
       this.setPosition(x, y, 0, 0);
     }
   };
+
+ /**
+ * @override
+*/
+  org.apache.flex.core.graphics.Path.prototype.draw = function() {
+    this.drawPath(this.get_x(), this.get_y(), this.get_data());
+  }; 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/58cbb52c/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Rect.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Rect.js b/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Rect.js
index 01f784c..7ab8078 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Rect.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Rect.js
@@ -67,3 +67,10 @@ org.apache.flex.core.graphics.Rect.prototype.drawRect = function(x, y, width, he
     rect.setAttribute('height', String(height) + 'px');
     this.element.appendChild(rect);
   };
+
+/**
+ * @override
+*/
+  org.apache.flex.core.graphics.Rect.prototype.draw = function() {
+    this.drawRect(this.get_x(), this.get_y(), this.get_width(), this.get_height());
+  };
\ No newline at end of file