You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by yi...@apache.org on 2016/09/29 07:13:58 UTC

git commit: [flex-asjs] [refs/heads/refactor-sprite] - Binary image refactor.

Repository: flex-asjs
Updated Branches:
  refs/heads/refactor-sprite 26bc15194 -> 07c6c36e0


Binary image refactor.


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

Branch: refs/heads/refactor-sprite
Commit: 07c6c36e06907e64f93b37ec5688a2f93877e0a1
Parents: 26bc151
Author: yishayw <yi...@hotmail.com>
Authored: Thu Sep 29 10:13:46 2016 +0300
Committer: yishayw <yi...@hotmail.com>
Committed: Thu Sep 29 10:13:46 2016 +0300

----------------------------------------------------------------------
 .../flex/org/apache/flex/core/IImageView.as     |  54 ++++++++
 .../apache/flex/html/beads/BinaryImageLoader.as | 122 +++++++++++++++++++
 .../flex/html/beads/IBinaryImageLoader.as       |  35 ++++++
 3 files changed, 211 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/07c6c36e/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IImageView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IImageView.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IImageView.as
new file mode 100644
index 0000000..5993faf
--- /dev/null
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IImageView.as
@@ -0,0 +1,54 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+{
+	COMPILE::SWF
+	{
+		import flash.display.Loader;
+	}
+
+    /**
+     *  The IImageView interface is the interface for beads that 
+     *  represent image views.  
+     *  It is used to find the view bead on the strand via calls to getBeadByType.
+     * 
+     *  @see org.apache.flex.core.IStrand#getBeadByType
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.0
+     */
+	public interface IImageView extends IBeadView
+	{
+        /**
+         *  The loader where images are implemented. 
+         * 
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		COMPILE::SWF
+		function get loader():Loader
+			
+		COMPILE::SWF
+		function setupLoader():void
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/07c6c36e/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/BinaryImageLoader.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/BinaryImageLoader.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/BinaryImageLoader.as
new file mode 100644
index 0000000..1de8a5a
--- /dev/null
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/BinaryImageLoader.as
@@ -0,0 +1,122 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.html.beads
+{
+    COMPILE::SWF
+    {
+        import flash.display.Bitmap;
+        import flash.display.Loader;
+        import flash.display.LoaderInfo;
+        import flash.events.IOErrorEvent;
+        import flash.net.URLRequest;            
+    }
+    COMPILE::JS
+    {
+        import goog.events;
+        import org.apache.flex.utils.URLUtils;
+    }
+	
+	import org.apache.flex.core.BeadViewBase;
+	import org.apache.flex.core.IBeadView;
+	import org.apache.flex.core.IBinaryImageModel;
+	import org.apache.flex.core.IStrand;
+	import org.apache.flex.core.IUIBase;
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.IEventDispatcher;
+    import org.apache.flex.utils.BinaryData;
+    import org.apache.flex.core.IBead;
+    import org.apache.flex.core.IImageView;
+	
+	/**
+	 *  The ImageView class creates the visual elements of the org.apache.flex.html.Image component.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion FlexJS 0.0
+	 */
+	public class BinaryImageLoader implements IBinaryImageLoader
+	{
+		/**
+		 *  constructor.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function BinaryImageLoader()
+		{
+		}
+		
+        private var _objectURL:String;
+        private var _strand:IStrand;
+		
+		private function get model():IBinaryImageModel
+		{
+			return _strand.getBeadByType(IBinaryImageModel) as IBinaryImageModel;
+		}
+		
+		/**
+		 *  @copy org.apache.flex.core.IBead#strand
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+			model.addEventListener("binaryChanged", handleBinaryChange);
+		}
+
+		/**
+		 * @private
+         * @flexjsignorecoercion HTMLImageELement
+         * @flexjsignorecoercion BinaryImageModel
+		 */
+        private function handleBinaryChange(event:Event):void
+        {
+            var m:IBinaryImageModel = model;
+           COMPILE::SWF
+            {
+                if (m.binary) {
+					var imageView:IImageView = _strand.getBeadByType(IImageView) as IImageView;
+					imageView.setupLoader();
+					imageView.loader.loadBytes(m.binary.array);
+                }                    
+            }
+            COMPILE::JS
+            {
+                if (m.binary) {
+                    setupLoader();
+                    if(_objectURL)
+                        URLUtils.revokeObjectURL(_objectURL);
+                    var blob:Blob = new Blob([m.binary.array]);
+// I don't think we need to specify the type.
+//                    var blob = new Blob([response], {type: "image/png"});
+                    _objectURL = URLUtils.createObjectURL(blob);
+                    (host.element as HTMLImageElement).src = _objectURL;
+                }
+            }
+        }
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/07c6c36e/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IBinaryImageLoader.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IBinaryImageLoader.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IBinaryImageLoader.as
new file mode 100644
index 0000000..045d263
--- /dev/null
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IBinaryImageLoader.as
@@ -0,0 +1,35 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.html.beads
+{	
+	import org.apache.flex.core.IBead;
+
+	/**
+	 *  The IBinaryImageLoader interface marks classes 
+	 *  that are used for loading binary data to image views
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion FlexJS 0.0
+	 */
+	public interface IBinaryImageLoader extends IBead
+	{
+		
+	}
+}