Repository: flex-asjs
Updated Branches:
  refs/heads/develop e881d7424 -> d69d03914


Added Text to the FlexJS core.graphics package.


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

Branch: refs/heads/develop
Commit: d69d039146012c896f1b31b0046c3676ae19565a
Parents: e881d74
Author: Peter Ent <[email protected]>
Authored: Tue Oct 28 15:36:28 2014 -0400
Committer: Peter Ent <[email protected]>
Committed: Tue Oct 28 15:36:28 2014 -0400

----------------------------------------------------------------------
 .../as/projects/FlexJSUI/src/FlexJSUIClasses.as |  1 +
 .../flex/core/graphics/GraphicsContainer.as     | 34 +++++++
 .../src/org/apache/flex/core/graphics/Text.as   | 97 ++++++++++++++++++++
 .../flex/core/graphics/GraphicsContainer.js     | 17 ++++
 .../src/org/apache/flex/core/graphics/Text.js   | 66 +++++++++++++
 5 files changed, 215 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d69d0391/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as 
b/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as
index e2a3904..481e149 100644
--- a/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as
+++ b/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as
@@ -126,6 +126,7 @@ internal class FlexJSUIClasses
        import org.apache.flex.core.graphics.Path; Path;
        import org.apache.flex.core.graphics.SolidColor; SolidColor;
        import org.apache.flex.core.graphics.SolidColorStroke; SolidColorStroke;
+       import org.apache.flex.core.graphics.Text; Text;
        import org.apache.flex.core.graphics.GraphicsContainer; 
GraphicsContainer;
        import org.apache.flex.core.graphics.LinearGradient; LinearGradient;
     import org.apache.flex.core.DropType; DropType;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d69d0391/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicsContainer.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicsContainer.as
 
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicsContainer.as
index 7277b85..605fcd8 100644
--- 
a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicsContainer.as
+++ 
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicsContainer.as
@@ -17,7 +17,9 @@ package org.apache.flex.core.graphics
        import flash.display.GraphicsPath;
        import flash.geom.Point;
        import flash.geom.Rectangle;
+       import flash.text.TextFieldType;
        
+       import org.apache.flex.core.CSSTextField;
        import org.apache.flex.core.graphics.utils.PathHelper;
        
        /**
@@ -123,5 +125,37 @@ package org.apache.flex.core.graphics
                {
                        
                } 
+               
+               /**
+                *  Draw a string of characters.
+                *  @param value The string to draw.
+                *  @param x The x location of the center of the circle
+                *  @param y The y location of the center of the circle.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+                */
+               public function drawText(value:String, x:Number, y:Number):void
+               {
+                       var textField:CSSTextField = new CSSTextField();
+                       addChild(textField);
+                       
+                       textField.selectable = false;
+                       textField.type = TextFieldType.DYNAMIC;
+                       textField.mouseEnabled = false;
+                       textField.autoSize = "left";
+                       textField.text = value;
+                       
+                       var lineColor:SolidColorStroke = stroke as 
SolidColorStroke;
+                       if (lineColor) {
+                               textField.textColor = lineColor.color;
+                               textField.alpha = lineColor.alpha;
+                       }
+                       
+                       textField.x = x;
+                       textField.y = y;
+               }
        }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d69d0391/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Text.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Text.as 
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Text.as
new file mode 100644
index 0000000..d24427a
--- /dev/null
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Text.as
@@ -0,0 +1,97 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.graphics
+{
+       import flash.text.TextFieldType;
+       
+       import org.apache.flex.core.CSSTextField;
+       
+       /**
+        *  Draws a string of characters at a specific location using the stroke
+        *  value of color and alpha.
+        *
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion FlexJS 0.0
+        */
+       public class Text extends GraphicShape
+       {
+               /**
+                *  constructor.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+                */
+               public function Text()
+               {
+                       super();
+                       
+                       _textField = new CSSTextField();
+                       addChild(_textField);
+               }
+               
+               
+               private var _textField:CSSTextField;
+               
+               /**
+                *  @copy org.apache.flex.core.ITextModel#textField
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+                */
+               public function get textField() : CSSTextField
+               {
+                       return _textField;
+               }
+               
+               /**
+                *  Draws text at the given point.
+                *  @param value The string to draw.
+                *  @param x The x position of the top-left corner of the 
rectangle.
+                *  @param y The y position of the top-left corner.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+                */
+               public function drawText(value:String, x:Number, y:Number):void
+               {
+                       textField.selectable = false;
+                       textField.type = TextFieldType.DYNAMIC;
+                       textField.mouseEnabled = false;
+                       textField.autoSize = "left";
+                       textField.text = value;
+                       
+                       var color:SolidColorStroke = stroke as SolidColorStroke;
+                       if (color) {
+                               textField.textColor = color.color;
+                               textField.alpha = color.alpha;
+                       }
+                       
+                       textField.x = x;
+                       textField.y = y;
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d69d0391/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/GraphicsContainer.js
----------------------------------------------------------------------
diff --git 
a/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/GraphicsContainer.js 
b/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/GraphicsContainer.js
index 6fb84c1..c48012a 100644
--- 
a/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/GraphicsContainer.js
+++ 
b/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/GraphicsContainer.js
@@ -149,6 +149,23 @@ 
org.apache.flex.core.graphics.GraphicsContainer.prototype.drawPath = function(da
 
 /**
  * @expose
+ * @param {string} value The text string to draw.
+ * @param {number} x The x position of the text.
+ * @param {number} y The y position of the text.
+ */
+org.apache.flex.core.graphics.GraphicsContainer.prototype.drawText = 
function(value, x, y) {
+  var style = this.getStyleStr();
+  var text = document.createElementNS('http://www.w3.org/2000/svg', 'text');
+  text.setAttribute('style', style);
+  text.innerHTML = value;
+  text.setAttribute('x', String(x) + 'px');
+  text.setAttribute('y', String(y) + 'px');
+  this.element.appendChild(text);
+};
+
+
+/**
+ * @expose
  */
 org.apache.flex.core.graphics.GraphicsContainer.prototype.drawLine = 
function() {
 };

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d69d0391/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Text.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Text.js 
b/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Text.js
new file mode 100644
index 0000000..106b77b
--- /dev/null
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Text.js
@@ -0,0 +1,66 @@
+/**
+ * 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.
+ */
+
+goog.provide('org.apache.flex.core.graphics.Text');
+
+goog.require('org.apache.flex.core.graphics.GraphicShape');
+
+
+
+/**
+ * @constructor
+ * @extends {org.apache.flex.core.graphics.GraphicShape}
+ */
+org.apache.flex.core.graphics.Text = function() {
+  org.apache.flex.core.graphics.Text.base(this, 'constructor');
+
+};
+goog.inherits(org.apache.flex.core.graphics.Text,
+    org.apache.flex.core.graphics.GraphicShape);
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+org.apache.flex.core.graphics.Text.prototype.FLEXJS_CLASS_INFO =
+    { names: [{ name: 'Rect',
+                qName: 'org.apache.flex.core.graphics.Text' }] };
+
+
+/**
+ * @expose
+ * @param {string} value The text to be drawn.
+ * @param {number} x The x position of the top-left corner of the rectangle.
+ * @param {number} y The y position of the top-left corner.
+ */
+org.apache.flex.core.graphics.Text.prototype.drawText = function(value, x, y) {
+    var style = this.getStyleStr();
+    var text = document.createElementNS('http://www.w3.org/2000/svg', 'text');
+    text.setAttribute('style', style);
+    text.innerHTML = value;
+    text.setAttribute('x', String(x) + 'px');
+    text.setAttribute('y', String(y) + 'px');
+    this.setPosition(x, y, 0, 0);
+    this.element.appendChild(text);
+  };
+
+
+/**
+ * @override
+*/
+org.apache.flex.core.graphics.Text.prototype.draw = function() {
+
+};
\ No newline at end of file

Reply via email to