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/09/10 09:43:24 UTC

git commit: [flex-asjs] [refs/heads/develop] - If fill or stroke is null, handle it correctly

Repository: flex-asjs
Updated Branches:
  refs/heads/develop eed930cbd -> ea9aac222


If fill or stroke is null, handle it correctly


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

Branch: refs/heads/develop
Commit: ea9aac222ce4dc8287f254e513522894768f8b6a
Parents: eed930c
Author: Om <bi...@gmail.com>
Authored: Wed Sep 10 00:42:05 2014 -0700
Committer: Om <bi...@gmail.com>
Committed: Wed Sep 10 00:42:05 2014 -0700

----------------------------------------------------------------------
 .../src/org/apache/flex/core/graphics/Circle.js | 17 ++++++--
 .../org/apache/flex/core/graphics/Ellipse.js    | 15 +++++--
 .../apache/flex/core/graphics/GraphicShape.js   | 42 +++++++++++++++-----
 .../src/org/apache/flex/core/graphics/Path.js   |  9 ++++-
 .../src/org/apache/flex/core/graphics/Rect.js   | 15 +++++--
 5 files changed, 78 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ea9aac22/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 b02b371..13fb6f3 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
@@ -50,10 +50,21 @@ org.apache.flex.core.graphics.Circle.prototype.drawCircle = function(x, y, radiu
     var style = this.getStyleStr();
     var circle = document.createElementNS('http://www.w3.org/2000/svg', 'ellipse');
     circle.setAttribute('style', style);
-    circle.setAttribute('cx', String(radius + this.get_stroke().get_weight()));
-    circle.setAttribute('cy', String(radius + this.get_stroke().get_weight()));
+	if(this.get_stroke())
+	{
+	  circle.setAttribute('cx', String(radius + this.get_stroke().get_weight()));
+      circle.setAttribute('cy', String(radius + this.get_stroke().get_weight()));
+	  this.setPosition(x-radius, y-radius, this.get_stroke().get_weight(), this.get_stroke().get_weight());
+	}
+	else
+	{
+	  circle.setAttribute('cx', String(radius));
+      circle.setAttribute('cy', String(radius));
+	  this.setPosition(x-radius, y-radius, 0, 0);
+	}
+
     circle.setAttribute('rx', String(radius));
     circle.setAttribute('ry', String(radius));
     this.element.appendChild(circle);
-    this.setPosition(x-radius, y-radius, this.get_stroke().get_weight(), this.get_stroke().get_weight());
+    
   };

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ea9aac22/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 2366194..12b58ae 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
@@ -51,10 +51,19 @@ org.apache.flex.core.graphics.Ellipse.prototype.drawEllipse = function(x, y, wid
     var style = this.getStyleStr();
     var ellipse = document.createElementNS('http://www.w3.org/2000/svg', 'ellipse');
     ellipse.setAttribute('style', style);
-    ellipse.setAttribute('cx', String(width / 2 + this.get_stroke().get_weight()));
-    ellipse.setAttribute('cy', String(height / 2 + this.get_stroke().get_weight()));
+	if(this.get_stroke())
+	{
+	  ellipse.setAttribute('cx', String(width / 2 + this.get_stroke().get_weight()));
+      ellipse.setAttribute('cy', String(height / 2 + this.get_stroke().get_weight()));
+	  this.setPosition(x, y, this.get_stroke().get_weight()*2, this.get_stroke().get_weight()*2);
+	}
+	else
+	{
+	  ellipse.setAttribute('cx', String(width / 2));
+      ellipse.setAttribute('cy', String(height / 2));
+	  this.setPosition(x, y, 0, 0);
+	}
     ellipse.setAttribute('rx', String(width / 2));
     ellipse.setAttribute('ry', String(height / 2));
     this.element.appendChild(ellipse);
-	this.setPosition(x, y, this.get_stroke().get_weight()*2, this.get_stroke().get_weight()*2);
   };

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ea9aac22/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 8d514fa..61b11a3 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
@@ -62,7 +62,7 @@ org.apache.flex.core.graphics.GraphicShape = function() {
   
     /**
    * @expose
-   * @type {SVGElement}
+   * @type {Object}
    */
   this.element = document.createElementNS("http://www.w3.org/2000/svg","svg");
 
@@ -121,15 +121,37 @@ org.apache.flex.core.graphics.GraphicShape.prototype.addedToParent = function()
  * @return {string} The style attribute.
  */
 org.apache.flex.core.graphics.GraphicShape.prototype.getStyleStr = function() {
-  var color = Number(this.get_fill().get_color()).toString(16);
-  if (color.length == 2) color = '00' + color;
-  if (color.length == 4) color = '00' + color;
-  var strokeColor = Number(this.get_stroke().get_color()).toString(16);
-  if (strokeColor.length == 2) strokeColor = '00' + strokeColor;
-  if (strokeColor.length == 4) strokeColor = '00' + strokeColor;
-
-  return 'fill:#' + String(color) + ';fill-opacity:' + String(this.get_fill().get_alpha()) + ';stroke:#' + String(strokeColor) + ';stroke-width:' +
-         String(this.get_stroke().get_weight()) + ';stroke-opacity:' + String(this.get_stroke().get_alpha()) ;
+  var fillStr;
+  if(this.get_fill())
+  {
+    var color = Number(this.get_fill().get_color()).toString(16);
+    if (color.length == 1) color = '00' + color;
+	if (color.length == 2) color = '00' + color;
+    if (color.length == 4) color = '00' + color;
+	fillStr = 'fill:#' + String(color) + ';fill-opacity:' + String(this.get_fill().get_alpha());
+  }
+  else
+  {
+    fillStr = 'fill:none';
+  }
+
+  var strokeStr;
+  if(this.get_stroke())
+  {
+    var strokeColor = Number(this.get_stroke().get_color()).toString(16);
+    if (strokeColor.length == 1) strokeColor = '00' + strokeColor;
+    if (strokeColor.length == 2) strokeColor = '00' + strokeColor;
+    if (strokeColor.length == 4) strokeColor = '00' + strokeColor;
+	strokeStr = 'stroke:#' + String(strokeColor) + ';stroke-width:' +
+         String(this.get_stroke().get_weight()) + ';stroke-opacity:' + String(this.get_stroke().get_alpha())
+  }
+  else
+  {
+    strokeStr = 'stroke:none';
+  }
+  
+
+  return fillStr + ';' + strokeStr ;
 };
 
 /**

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ea9aac22/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 fd38630..a5c4336 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
@@ -58,5 +58,12 @@ org.apache.flex.core.graphics.Path.prototype.drawPath = function(x, y, data) {
     path.setAttribute('style', style);
     path.setAttribute('d', data);
     this.element.appendChild(path);
-    this.setPosition(x, y, this.get_stroke().get_weight(), this.get_stroke().get_weight());
+	if(this.get_stroke())
+	{
+	  this.setPosition(x, y, this.get_stroke().get_weight(), this.get_stroke().get_weight());
+	}
+    else
+	{
+	  this.setPosition(x, y, 0, 0);
+	}
   };

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ea9aac22/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 016480b..a3e4c37 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
@@ -51,10 +51,19 @@ org.apache.flex.core.graphics.Rect.prototype.drawRect = function(x, y, width, he
     var style = this.getStyleStr();
     var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
     rect.setAttribute('style', style);
-    rect.setAttribute('x', String(this.get_stroke().get_weight() / 2));
-    rect.setAttribute('y', String(this.get_stroke().get_weight() / 2));
+	if(this.get_stroke())
+	{
+	  rect.setAttribute('x', String(this.get_stroke().get_weight() / 2));
+	  rect.setAttribute('y', String(this.get_stroke().get_weight() / 2));
+      this.setPosition(x, y, this.get_stroke().get_weight(), this.get_stroke().get_weight());
+	}
+	else
+	{
+	  rect.setAttribute('x', '0');
+	  rect.setAttribute('y', '0');
+	  this.setPosition(x, y, 0, 0);
+	}
     rect.setAttribute('width', String(width));
     rect.setAttribute('height', String(height));
     this.element.appendChild(rect);
-	this.setPosition(x, y, this.get_stroke().get_weight(), this.get_stroke().get_weight());
   };