Repository: flex-asjs
Updated Branches:
  refs/heads/tlf 1163f690b -> 550062ab0


Added simple HTMLTextFactory


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

Branch: refs/heads/tlf
Commit: 550062ab047d146bbe53825c51dcf73073291027
Parents: 1163f69
Author: Harbs <ha...@in-tools.com>
Authored: Sat Mar 25 21:18:30 2017 +0300
Committer: Harbs <ha...@in-tools.com>
Committed: Sat Mar 25 21:18:30 2017 +0300

----------------------------------------------------------------------
 .../textLayout/factory/StandardTLFFactory.as    |  3 ++
 .../projects/Text/src/main/flex/TextClasses.as  |  5 ++-
 .../apache/flex/text/html/HTMLTextFactory.as    | 46 ++++++++++++++++++++
 .../flex/org/apache/flex/text/html/TextBlock.as | 14 +++++-
 .../flex/org/apache/flex/text/html/TextLine.as  |  3 +-
 5 files changed, 67 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/550062ab/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/StandardTLFFactory.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/StandardTLFFactory.as
 
b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/StandardTLFFactory.as
index 2277f85..460621b 100644
--- 
a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/StandardTLFFactory.as
+++ 
b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/StandardTLFFactory.as
@@ -25,6 +25,7 @@ package org.apache.flex.textLayout.factory {
        import org.apache.flex.graphics.ICompoundGraphic;
        import org.apache.flex.graphics.IRect;
        import org.apache.flex.text.engine.ITextFactory;
+       import org.apache.flex.text.html.HTMLTextFactory;
 
        public class StandardTLFFactory implements ITLFFactory {
                public function getRect() : IRect {
@@ -42,6 +43,8 @@ package org.apache.flex.textLayout.factory {
 //TODO add a basic factory when it's ready             
                private static var factory:ITextFactory;
                public function get textFactory() : ITextFactory {
+                       if(!factory)
+                               factory = new HTMLTextFactory();
                        return factory;
                }
        }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/550062ab/frameworks/projects/Text/src/main/flex/TextClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Text/src/main/flex/TextClasses.as 
b/frameworks/projects/Text/src/main/flex/TextClasses.as
index 6ad2045..bbc41a6 100644
--- a/frameworks/projects/Text/src/main/flex/TextClasses.as
+++ b/frameworks/projects/Text/src/main/flex/TextClasses.as
@@ -26,8 +26,9 @@ package
        */
        internal class TextClasses
        {
-               import 
org.apache.flex.text.html.TextLine;org.apache.flex.text.html.TextLine;
-               import 
org.apache.flex.text.html.TextBlock;org.apache.flex.text.html.TextBlock;
+               import org.apache.flex.text.html.TextLine; TextLine;
+               import org.apache.flex.text.html.TextBlock; TextBlock;
+               import org.apache.flex.text.html.HTMLTextFactory; 
HTMLTextFactory;
 
                import 
org.apache.flex.text.engine.BreakOpportunity;BreakOpportunity;
                import org.apache.flex.text.engine.CFFHinting;CFFHinting;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/550062ab/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/HTMLTextFactory.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/HTMLTextFactory.as
 
b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/HTMLTextFactory.as
new file mode 100644
index 0000000..e7021b7
--- /dev/null
+++ 
b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/HTMLTextFactory.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.text.html
+{
+    import org.apache.flex.text.engine.ITextFactory;
+    import org.apache.flex.text.engine.ITextBlock;
+    import org.apache.flex.core.IUIBase;
+    import org.apache.flex.html.Div;
+    import org.apache.flex.text.engine.IFontLoader;
+
+    public class HTMLTextFactory implements ITextFactory
+    {
+
+        public function getTextBlock():ITextBlock
+        {
+            return new TextBlock(this);
+        }
+        public function getTextContainer():IUIBase
+        {
+            return new Div();
+        }
+        private var _fontLoader:IFontLoader;
+        public function getFontLoader():IFontLoader
+        {
+            // no fontLoader for this factory at this point. It uses standard 
broswer fonts.
+            return _fontLoader;
+        }        
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/550062ab/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextBlock.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextBlock.as 
b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextBlock.as
index 9d2f491..7c1faa6 100644
--- 
a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextBlock.as
+++ 
b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextBlock.as
@@ -25,6 +25,10 @@ package org.apache.flex.text.html
        import org.apache.flex.text.engine.TabStop;
        import org.apache.flex.text.engine.TextJustifier;
        import org.apache.flex.text.engine.ITextFactory;
+       import org.apache.flex.text.engine.TextElement;
+       import org.apache.flex.text.engine.ElementFormat;
+       import org.apache.flex.text.html.TextLine;
+       import org.apache.flex.html.Span;
        
        public class TextBlock implements ITextBlock
        {
@@ -178,7 +182,15 @@ package org.apache.flex.text.html
                
                public function createTextLine(previousLine:ITextLine = null, 
width:Number = 1000000, lineOffset:Number = 0.0, fitSomething:Boolean = 
false):ITextLine
                {
-                       return null;
+                       // Not a very good implementation at this point...
+                       var textElem:TextElement = content as TextElement;
+                       var format:ElementFormat = content.elementFormat;
+                       var tl:TextLine = new TextLine();
+                       var span:Span = new Span();
+                       span.text = textElem.text;
+                       tl.addElement(span);
+
+                       return tl;
                }
                public function dump():String{
                        return null;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/550062ab/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextLine.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextLine.as 
b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextLine.as
index fa2d5b4..f533641 100644
--- 
a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextLine.as
+++ 
b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextLine.as
@@ -23,8 +23,9 @@ package org.apache.flex.text.html
        import org.apache.flex.core.IUIBase;
        import org.apache.flex.geom.Rectangle;
        import org.apache.flex.core.UIBase;
+       import org.apache.flex.html.Div;
        
-       public class TextLine extends UIBase implements ITextLine
+       public class TextLine extends Div implements ITextLine
        {
                public function TextLine()
                {

Reply via email to