You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2016/02/13 01:14:19 UTC
[12/37] git commit: [flex-asjs] [refs/heads/spark] - copy of many
flex-sdk classes,
modified to try to compile on top of the FlexJS base classes. A COMPILE::LATER
flag is used to comment out features like multi-swf support and a few other
features that
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1f6418c4/frameworks/projects/MX/src/main/flex/mx/utils/ColorUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/utils/ColorUtil.as b/frameworks/projects/MX/src/main/flex/mx/utils/ColorUtil.as
new file mode 100644
index 0000000..315af33
--- /dev/null
+++ b/frameworks/projects/MX/src/main/flex/mx/utils/ColorUtil.as
@@ -0,0 +1,166 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 mx.utils
+{
+
+/**
+ * The ColorUtil class is an all-static class
+ * with methods for working with RGB colors within Flex.
+ * You do not create instances of ColorUtil;
+ * instead you simply call static methods such as
+ * the <code>ColorUtil.adjustBrightness()</code> method.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+public class ColorUtil
+{
+ include "../core/Version.as";
+
+ //--------------------------------------------------------------------------
+ //
+ // Class methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Performs a linear brightness adjustment of an RGB color.
+ *
+ * <p>The same amount is added to the red, green, and blue channels
+ * of an RGB color.
+ * Each color channel is limited to the range 0 through 255.</p>
+ *
+ * @param rgb Original RGB color.
+ *
+ * @param brite Amount to be added to each color channel.
+ * The range for this parameter is -255 to 255;
+ * -255 produces black while 255 produces white.
+ * If this parameter is 0, the RGB color returned
+ * is the same as the original color.
+ *
+ * @return New RGB color.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static function adjustBrightness(rgb:uint, brite:Number):uint
+ {
+ var r:Number = Math.max(Math.min(((rgb >> 16) & 0xFF) + brite, 255), 0);
+ var g:Number = Math.max(Math.min(((rgb >> 8) & 0xFF) + brite, 255), 0);
+ var b:Number = Math.max(Math.min((rgb & 0xFF) + brite, 255), 0);
+
+ return (r << 16) | (g << 8) | b;
+ }
+
+ /**
+ * Performs a scaled brightness adjustment of an RGB color.
+ *
+ * @param rgb Original RGB color.
+ *
+ * @param brite The percentage to brighten or darken the original color.
+ * If positive, the original color is brightened toward white
+ * by this percentage. If negative, it is darkened toward black
+ * by this percentage.
+ * The range for this parameter is -100 to 100;
+ * -100 produces black while 100 produces white.
+ * If this parameter is 0, the RGB color returned
+ * is the same as the original color.
+ *
+ * @return New RGB color.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static function adjustBrightness2(rgb:uint, brite:Number):uint
+ {
+ var r:Number;
+ var g:Number;
+ var b:Number;
+
+ if (brite == 0)
+ return rgb;
+
+ if (brite < 0)
+ {
+ brite = (100 + brite) / 100;
+ r = ((rgb >> 16) & 0xFF) * brite;
+ g = ((rgb >> 8) & 0xFF) * brite;
+ b = (rgb & 0xFF) * brite;
+ }
+ else // bright > 0
+ {
+ brite /= 100;
+ r = ((rgb >> 16) & 0xFF);
+ g = ((rgb >> 8) & 0xFF);
+ b = (rgb & 0xFF);
+
+ r += ((0xFF - r) * brite);
+ g += ((0xFF - g) * brite);
+ b += ((0xFF - b) * brite);
+
+ r = Math.min(r, 255);
+ g = Math.min(g, 255);
+ b = Math.min(b, 255);
+ }
+
+ return (r << 16) | (g << 8) | b;
+ }
+
+ /**
+ * Performs an RGB multiplication of two RGB colors.
+ *
+ * <p>This always results in a darker number than either
+ * original color unless one of them is white,
+ * in which case the other color is returned.</p>
+ *
+ * @param rgb1 First RGB color.
+ *
+ * @param rgb2 Second RGB color.
+ *
+ * @return RGB multiplication of the two colors.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static function rgbMultiply(rgb1:uint, rgb2:uint):uint
+ {
+ var r1:Number = (rgb1 >> 16) & 0xFF;
+ var g1:Number = (rgb1 >> 8) & 0xFF;
+ var b1:Number = rgb1 & 0xFF;
+
+ var r2:Number = (rgb2 >> 16) & 0xFF;
+ var g2:Number = (rgb2 >> 8) & 0xFF;
+ var b2:Number = rgb2 & 0xFF;
+
+ return ((r1 * r2 / 255) << 16) |
+ ((g1 * g2 / 255) << 8) |
+ (b1 * b2 / 255);
+ }
+}
+
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1f6418c4/frameworks/projects/MX/src/main/flex/mx/utils/DensityUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/utils/DensityUtil.as b/frameworks/projects/MX/src/main/flex/mx/utils/DensityUtil.as
new file mode 100644
index 0000000..e80bad5
--- /dev/null
+++ b/frameworks/projects/MX/src/main/flex/mx/utils/DensityUtil.as
@@ -0,0 +1,98 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 mx.utils
+{
+import mx.core.DPIClassification;
+import mx.core.RuntimeDPIProvider;
+import mx.core.Singleton;
+
+[ExcludeClass]
+
+/**
+ * The <code>DensityUtil</code> class is an all-static class with methods for working with
+ * density within Flex.
+ *
+ * Flex uses this class to calculate the scaling factor when automatic density
+ * scaling is enabled for the <code>Application</code>.
+ *
+ * @see mx.core.DPIClassification
+ * @see spark.components.Application#applicationDPI
+ */
+public class DensityUtil
+{
+ /**
+ * Cached runtimeDPI value, which is computed from the runtimeDPIProvider class.
+ */
+ private static var runtimeDPI:Number;
+
+ /**
+ * Returns the current runtimeDPI value which is calculated by
+ * an instance of the runtimeDPIProvider class.
+ * If a runtimeDPIProvider class is not provided to the Application,
+ * Flex uses the default class, RuntimeDPIProvider.
+ *
+ * @see #getDPIScale
+ * @see mx.core.RuntimeDPIProvider
+ */
+ public static function getRuntimeDPI():Number
+ {
+ if (!isNaN(runtimeDPI))
+ return runtimeDPI;
+
+ var runtimeDPIProviderClass:Class = Singleton.getClass("mx.core::RuntimeDPIProvider");
+
+ // Default to RuntimeDPIProvider
+ if (!runtimeDPIProviderClass)
+ runtimeDPIProviderClass = RuntimeDPIProvider;
+
+ var instance:RuntimeDPIProvider = RuntimeDPIProvider(new runtimeDPIProviderClass());
+ runtimeDPI = instance.runtimeDPI;
+
+ return runtimeDPI;
+ }
+
+ /**
+ * Calculates a scale factor to be used when element authored for
+ * <code>sourceDPI</code> is rendered at <code>targetDPI</code>.
+ *
+ * @param sourceDPI The <code>DPIClassification</code> dpi value for which
+ * a resource is optimized.
+ *
+ * @param targetDPI The <code>DPIClassification</code> dpi value at
+ * which a resource is rendered.
+ *
+ * @return The scale factor to be applied to the resource at render time.
+ *
+ * @see #getRuntimeDPI
+ * @see mx.core.DPIClassification
+ */
+ public static function getDPIScale(sourceDPI:Number, targetDPI:Number):Number
+ {
+ // Unknown dpi returns NaN
+ if ((sourceDPI != DPIClassification.DPI_120 && sourceDPI != DPIClassification.DPI_160 && sourceDPI != DPIClassification.DPI_240 && sourceDPI != DPIClassification.DPI_320 && sourceDPI != DPIClassification.DPI_480 && sourceDPI != DPIClassification.DPI_640) ||
+ (targetDPI != DPIClassification.DPI_120 && targetDPI != DPIClassification.DPI_160 && targetDPI != DPIClassification.DPI_240 && targetDPI != DPIClassification.DPI_320 && targetDPI != DPIClassification.DPI_480 && targetDPI != DPIClassification.DPI_640))
+ {
+ return NaN;
+ }
+
+ return targetDPI / sourceDPI;
+ }
+}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1f6418c4/frameworks/projects/MX/src/main/flex/mx/utils/DescribeTypeCache.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/utils/DescribeTypeCache.as b/frameworks/projects/MX/src/main/flex/mx/utils/DescribeTypeCache.as
new file mode 100644
index 0000000..f11f69d
--- /dev/null
+++ b/frameworks/projects/MX/src/main/flex/mx/utils/DescribeTypeCache.as
@@ -0,0 +1,173 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 mx.utils
+{
+
+import flash.utils.describeType;
+import flash.utils.getDefinitionByName;
+import flash.utils.getQualifiedClassName;
+import mx.binding.BindabilityInfo;
+
+[ExcludeClass]
+
+/**
+ * @private
+ * DescribeTypeCache is a convenience class that is used to
+ * cache the return values of <code>flash.utils.describeType()</code>
+ * so that calls made subsequent times return faster.
+ *
+ * This class also lets you set handler functions for specific value types.
+ * These will get called when the user tries to access these values on
+ * the <code>DescribeTypeCacheRecord</code> class.
+ *
+ * @see mx.utils.DescribeTypeCacheRecord
+ */
+public class DescribeTypeCache
+{
+ include "../core/Version.as";
+
+ //--------------------------------------------------------------------------
+ //
+ // Class initialization
+ //
+ //--------------------------------------------------------------------------
+
+ registerCacheHandler("bindabilityInfo", bindabilityInfoHandler);
+
+ //--------------------------------------------------------------------------
+ //
+ // Class variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ private static var typeCache:Object = {};
+
+ /**
+ * @private
+ */
+ private static var cacheHandlers:Object = {};
+
+ //--------------------------------------------------------------------------
+ //
+ // Class methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Calls <code>flash.utils.describeType()</code> for the first time and caches
+ * the return value so that subsequent calls return faster.
+ *
+ * @param o Can be either a string describing a fully qualified class name or any
+ * ActionScript value, including all available ActionScript types, object instances,
+ * primitive types (such as <code>uint</code>), and class objects.
+ *
+ * @return Returns the cached record.
+ *
+ * @see flash.utils#describeType()
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static function describeType(o:*):DescribeTypeCacheRecord
+ {
+ var className:String;
+ var cacheKey:String;
+
+ if (o is String)
+ cacheKey = className = o;
+ else
+ cacheKey = className = getQualifiedClassName(o);
+
+ //Need separate entries for describeType(Foo) and describeType(myFoo)
+ if (o is Class)
+ cacheKey += "$";
+
+ if (cacheKey in typeCache)
+ {
+ return typeCache[cacheKey];
+ }
+ else
+ {
+ if (o is String)
+ {
+ try
+ {
+ o = getDefinitionByName(o);
+ }
+ catch (error:ReferenceError)
+ {
+ // The o parameter doesn't refer to an ActionScript
+ // definition, it's just a string value.
+ }
+ }
+ var typeDescription:XML = flash.utils.describeType(o);
+ var record:DescribeTypeCacheRecord = new DescribeTypeCacheRecord();
+ record.typeDescription = typeDescription;
+ record.typeName = className;
+ typeCache[cacheKey] = record;
+
+ return record;
+ }
+ }
+
+ /**
+ * registerCacheHandler lets you add function handler for specific strings.
+ * These functions get called when the user refers to these values on a
+ * instance of <code>DescribeTypeCacheRecord</code>.
+ *
+ * @param valueName String that specifies the value for which the handler must be set.
+ * @param handler Function that should be called when user references valueName.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static function registerCacheHandler(valueName:String, handler:Function):void
+ {
+ cacheHandlers[valueName] = handler;
+ }
+
+ /**
+ * @private
+ */
+ internal static function extractValue(valueName:String, record:DescribeTypeCacheRecord):*
+ {
+ if (valueName in cacheHandlers)
+ return cacheHandlers[valueName](record);
+
+ return undefined;
+ }
+
+ /**
+ * @private
+ */
+ private static function bindabilityInfoHandler(record:DescribeTypeCacheRecord):*
+ {
+ return new BindabilityInfo(record.typeDescription);
+ }
+}
+
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1f6418c4/frameworks/projects/MX/src/main/flex/mx/utils/DescribeTypeCacheRecord.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/utils/DescribeTypeCacheRecord.as b/frameworks/projects/MX/src/main/flex/mx/utils/DescribeTypeCacheRecord.as
new file mode 100644
index 0000000..ea17f6c
--- /dev/null
+++ b/frameworks/projects/MX/src/main/flex/mx/utils/DescribeTypeCacheRecord.as
@@ -0,0 +1,129 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 mx.utils
+{
+
+import flash.utils.Proxy;
+import flash.utils.flash_proxy;
+
+use namespace flash_proxy;
+
+[ExcludeClass]
+
+/**
+ * @private
+ * This class represents a single cache entry, this gets created
+ * as part of the <code>describeType</code> method call on the
+ * <code>DescribeTypeCache</code> class.
+ */
+
+public dynamic class DescribeTypeCacheRecord extends Proxy
+{
+ //--------------------------------------------------------------------------
+ //
+ // Class variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ private var cache:Object = {};
+
+ //--------------------------------------------------------------------------
+ //
+ // Class properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // typeDescription
+ //----------------------------------
+
+ /**
+ * @private
+ */
+ public var typeDescription:XML;
+
+ //----------------------------------
+ // typeName
+ //----------------------------------
+
+ /**
+ * @private
+ */
+ public var typeName:String;
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ public function DescribeTypeCacheRecord()
+ {
+ super();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Overridden methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ override flash_proxy function getProperty(name:*):*
+ {
+ var result:* = cache[name];
+
+ if (result === undefined)
+ {
+ result = DescribeTypeCache.extractValue(name, this);
+ cache[name] = result;
+ }
+
+ return result;
+ }
+
+ /**
+ * @private
+ */
+ override flash_proxy function hasProperty(name:*):Boolean
+ {
+ if (name in cache)
+ return true;
+
+ var value:* = DescribeTypeCache.extractValue(name, this);
+
+ if (value === undefined)
+ return false;
+
+ cache[name] = value;
+
+ return true;
+ }
+}
+
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1f6418c4/frameworks/projects/MX/src/main/flex/mx/utils/GraphicsUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/utils/GraphicsUtil.as b/frameworks/projects/MX/src/main/flex/mx/utils/GraphicsUtil.as
new file mode 100644
index 0000000..fd7e58d
--- /dev/null
+++ b/frameworks/projects/MX/src/main/flex/mx/utils/GraphicsUtil.as
@@ -0,0 +1,298 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 mx.utils
+{
+
+import flash.display.Graphics;
+
+/**
+ * The Graphics class is an all-static class with utility methods
+ * related to the Graphics class.
+ * You do not create instances of GraphicsUtil;
+ * instead you simply call methods such as the
+ * <code>GraphicsUtil.drawRoundRectComplex()</code> method.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+public class GraphicsUtil
+{
+ include "../core/Version.as";
+
+ //--------------------------------------------------------------------------
+ //
+ // Class methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Draws a rounded rectangle using the size of a radius to draw the rounded corners.
+ * You must set the line style, fill, or both
+ * on the Graphics object before
+ * you call the <code>drawRoundRectComplex()</code> method
+ * by calling the <code>linestyle()</code>,
+ * <code>lineGradientStyle()</code>, <code>beginFill()</code>,
+ * <code>beginGradientFill()</code>, or
+ * <code>beginBitmapFill()</code> method.
+ *
+ * @param graphics The Graphics object that draws the rounded rectangle.
+ *
+ * @param x The horizontal position relative to the
+ * registration point of the parent display object, in pixels.
+ *
+ * @param y The vertical position relative to the
+ * registration point of the parent display object, in pixels.
+ *
+ * @param width The width of the round rectangle, in pixels.
+ *
+ * @param height The height of the round rectangle, in pixels.
+ *
+ * @param topLeftRadius The radius of the upper-left corner, in pixels.
+ *
+ * @param topRightRadius The radius of the upper-right corner, in pixels.
+ *
+ * @param bottomLeftRadius The radius of the bottom-left corner, in pixels.
+ *
+ * @param bottomRightRadius The radius of the bottom-right corner, in pixels.
+ *
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static function drawRoundRectComplex(graphics:Graphics, x:Number, y:Number,
+ width:Number, height:Number,
+ topLeftRadius:Number, topRightRadius:Number,
+ bottomLeftRadius:Number, bottomRightRadius:Number):void
+ {
+ var xw:Number = x + width;
+ var yh:Number = y + height;
+
+ // Make sure none of the radius values are greater than w/h.
+ // These are all inlined to avoid function calling overhead
+ var minSize:Number = width < height ? width * 2 : height * 2;
+ topLeftRadius = topLeftRadius < minSize ? topLeftRadius : minSize;
+ topRightRadius = topRightRadius < minSize ? topRightRadius : minSize;
+ bottomLeftRadius = bottomLeftRadius < minSize ? bottomLeftRadius : minSize;
+ bottomRightRadius = bottomRightRadius < minSize ? bottomRightRadius : minSize;
+
+ // Math.sin and Math,tan values for optimal performance.
+ // Math.rad = Math.PI / 180 = 0.0174532925199433
+ // r * Math.sin(45 * Math.rad) = (r * 0.707106781186547);
+ // r * Math.tan(22.5 * Math.rad) = (r * 0.414213562373095);
+ //
+ // We can save further cycles by precalculating
+ // 1.0 - 0.707106781186547 = 0.292893218813453 and
+ // 1.0 - 0.414213562373095 = 0.585786437626905
+
+ // bottom-right corner
+ var a:Number = bottomRightRadius * 0.292893218813453; // radius - anchor pt;
+ var s:Number = bottomRightRadius * 0.585786437626905; // radius - control pt;
+ graphics.moveTo(xw, yh - bottomRightRadius);
+ graphics.curveTo(xw, yh - s, xw - a, yh - a);
+ graphics.curveTo(xw - s, yh, xw - bottomRightRadius, yh);
+
+ // bottom-left corner
+ a = bottomLeftRadius * 0.292893218813453;
+ s = bottomLeftRadius * 0.585786437626905;
+ graphics.lineTo(x + bottomLeftRadius, yh);
+ graphics.curveTo(x + s, yh, x + a, yh - a);
+ graphics.curveTo(x, yh - s, x, yh - bottomLeftRadius);
+
+ // top-left corner
+ a = topLeftRadius * 0.292893218813453;
+ s = topLeftRadius * 0.585786437626905;
+ graphics.lineTo(x, y + topLeftRadius);
+ graphics.curveTo(x, y + s, x + a, y + a);
+ graphics.curveTo(x + s, y, x + topLeftRadius, y);
+
+ // top-right corner
+ a = topRightRadius * 0.292893218813453;
+ s = topRightRadius * 0.585786437626905;
+ graphics.lineTo(xw - topRightRadius, y);
+ graphics.curveTo(xw - s, y, xw - a, y + a);
+ graphics.curveTo(xw, y + s, xw, y + topRightRadius);
+ graphics.lineTo(xw, yh - bottomRightRadius);
+ }
+
+ /**
+ * Draws a rounded rectangle using the size of individual x and y radii to
+ * draw the rounded corners.
+ * You must set the line style, fill, or both
+ * on the Graphics object before
+ * you call the <code>drawRoundRectComplex2()</code> method
+ * by calling the <code>linestyle()</code>,
+ * <code>lineGradientStyle()</code>, <code>beginFill()</code>,
+ * <code>beginGradientFill()</code>, or
+ * <code>beginBitmapFill()</code> method.
+ *
+ * @param graphics The Graphics object that draws the rounded rectangle.
+ *
+ * @param x The horizontal position relative to the
+ * registration point of the parent display object, in pixels.
+ *
+ * @param y The vertical position relative to the
+ * registration point of the parent display object, in pixels.
+ *
+ * @param width The width of the round rectangle, in pixels.
+ *
+ * @param height The height of the round rectangle, in pixels.
+ *
+ * @param radiusX The default radiusX to use, if corner-specific values are not specified.
+ * This value must be specified.
+ *
+ * @param radiusY The default radiusY to use, if corner-specific values are not specified.
+ * If 0, the value of radiusX is used.
+ *
+ * @param topLeftRadiusX The x radius of the upper-left corner, in pixels. If NaN,
+ * the value of radiusX is used.
+ *
+ * @param topLeftRadiusY The y radius of the upper-left corner, in pixels. If NaN,
+ * the value of topLeftRadiusX is used.
+ *
+ * @param topRightRadiusX The x radius of the upper-right corner, in pixels. If NaN,
+ * the value of radiusX is used.
+ *
+ * @param topRightRadiusY The y radius of the upper-right corner, in pixels. If NaN,
+ * the value of topRightRadiusX is used.
+ *
+ * @param bottomLeftRadiusX The x radius of the bottom-left corner, in pixels. If NaN,
+ * the value of radiusX is used.
+ *
+ * @param bottomLeftRadiusY The y radius of the bottom-left corner, in pixels. If NaN,
+ * the value of bottomLeftRadiusX is used.
+ *
+ * @param bottomRightRadiusX The x radius of the bottom-right corner, in pixels. If NaN,
+ * the value of radiusX is used.
+ *
+ * @param bottomRightRadiusY The y radius of the bottom-right corner, in pixels. If NaN,
+ * the value of bottomRightRadiusX is used.
+ *
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Flex 4
+ */
+ public static function drawRoundRectComplex2(graphics:Graphics, x:Number, y:Number,
+ width:Number, height:Number,
+ radiusX:Number, radiusY:Number,
+ topLeftRadiusX:Number, topLeftRadiusY:Number,
+ topRightRadiusX:Number, topRightRadiusY:Number,
+ bottomLeftRadiusX:Number, bottomLeftRadiusY:Number,
+ bottomRightRadiusX:Number, bottomRightRadiusY:Number):void
+ {
+ var xw:Number = x + width;
+ var yh:Number = y + height;
+ var maxXRadius:Number = width / 2;
+ var maxYRadius:Number = height / 2;
+
+ // Rules for determining radius for each corner:
+ // - If explicit nnnRadiusX value is set, use it. Otherwise use radiusX.
+ // - If explicit nnnRadiusY value is set, use it. Otherwise use corresponding nnnRadiusX.
+ if (radiusY == 0)
+ radiusY = radiusX;
+ if (isNaN(topLeftRadiusX))
+ topLeftRadiusX = radiusX;
+ if (isNaN(topLeftRadiusY))
+ topLeftRadiusY = topLeftRadiusX;
+ if (isNaN(topRightRadiusX))
+ topRightRadiusX = radiusX;
+ if (isNaN(topRightRadiusY))
+ topRightRadiusY = topRightRadiusX;
+ if (isNaN(bottomLeftRadiusX))
+ bottomLeftRadiusX = radiusX;
+ if (isNaN(bottomLeftRadiusY))
+ bottomLeftRadiusY = bottomLeftRadiusX;
+ if (isNaN(bottomRightRadiusX))
+ bottomRightRadiusX = radiusX;
+ if (isNaN(bottomRightRadiusY))
+ bottomRightRadiusY = bottomRightRadiusX;
+
+ // Pin radius values to half of the width/height
+ if (topLeftRadiusX > maxXRadius)
+ topLeftRadiusX = maxXRadius;
+ if (topLeftRadiusY > maxYRadius)
+ topLeftRadiusY = maxYRadius;
+ if (topRightRadiusX > maxXRadius)
+ topRightRadiusX = maxXRadius;
+ if (topRightRadiusY > maxYRadius)
+ topRightRadiusY = maxYRadius;
+ if (bottomLeftRadiusX > maxXRadius)
+ bottomLeftRadiusX = maxXRadius;
+ if (bottomLeftRadiusY > maxYRadius)
+ bottomLeftRadiusY = maxYRadius;
+ if (bottomRightRadiusX > maxXRadius)
+ bottomRightRadiusX = maxXRadius;
+ if (bottomRightRadiusY > maxYRadius)
+ bottomRightRadiusY = maxYRadius;
+
+ // Math.sin and Math,tan values for optimal performance.
+ // Math.rad = Math.PI / 180 = 0.0174532925199433
+ // r * Math.sin(45 * Math.rad) = (r * 0.707106781186547);
+ // r * Math.tan(22.5 * Math.rad) = (r * 0.414213562373095);
+ //
+ // We can save further cycles by precalculating
+ // 1.0 - 0.707106781186547 = 0.292893218813453 and
+ // 1.0 - 0.414213562373095 = 0.585786437626905
+
+ // bottom-right corner
+ var aX:Number = bottomRightRadiusX * 0.292893218813453; // radius - anchor pt;
+ var aY:Number = bottomRightRadiusY * 0.292893218813453; // radius - anchor pt;
+ var sX:Number = bottomRightRadiusX * 0.585786437626905; // radius - control pt;
+ var sY:Number = bottomRightRadiusY * 0.585786437626905; // radius - control pt;
+ graphics.moveTo(xw, yh - bottomRightRadiusY);
+ graphics.curveTo(xw, yh - sY, xw - aX, yh - aY);
+ graphics.curveTo(xw - sX, yh, xw - bottomRightRadiusX, yh);
+
+ // bottom-left corner
+ aX = bottomLeftRadiusX * 0.292893218813453;
+ aY = bottomLeftRadiusY * 0.292893218813453;
+ sX = bottomLeftRadiusX * 0.585786437626905;
+ sY = bottomLeftRadiusY * 0.585786437626905;
+ graphics.lineTo(x + bottomLeftRadiusX, yh);
+ graphics.curveTo(x + sX, yh, x + aX, yh - aY);
+ graphics.curveTo(x, yh - sY, x, yh - bottomLeftRadiusY);
+
+ // top-left corner
+ aX = topLeftRadiusX * 0.292893218813453;
+ aY = topLeftRadiusY * 0.292893218813453;
+ sX = topLeftRadiusX * 0.585786437626905;
+ sY = topLeftRadiusY * 0.585786437626905;
+ graphics.lineTo(x, y + topLeftRadiusY);
+ graphics.curveTo(x, y + sY, x + aX, y + aY);
+ graphics.curveTo(x + sX, y, x + topLeftRadiusX, y);
+
+ // top-right corner
+ aX = topRightRadiusX * 0.292893218813453;
+ aY = topRightRadiusY * 0.292893218813453;
+ sX = topRightRadiusX * 0.585786437626905;
+ sY = topRightRadiusY * 0.585786437626905;
+ graphics.lineTo(xw - topRightRadiusX, y);
+ graphics.curveTo(xw - sX, y, xw - aX, y + aY);
+ graphics.curveTo(xw, y + sY, xw, y + topRightRadiusY);
+ graphics.lineTo(xw, yh - bottomRightRadiusY);
+ }
+}
+
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1f6418c4/frameworks/projects/MX/src/main/flex/mx/utils/IXMLNotifiable.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/utils/IXMLNotifiable.as b/frameworks/projects/MX/src/main/flex/mx/utils/IXMLNotifiable.as
new file mode 100644
index 0000000..0ca48bc
--- /dev/null
+++ b/frameworks/projects/MX/src/main/flex/mx/utils/IXMLNotifiable.as
@@ -0,0 +1,43 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 mx.utils
+{
+
+/**
+ * The IXMLNotifiable interface.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+public interface IXMLNotifiable
+{
+ /**
+ * @private
+ */
+ function xmlNotification(currentTarget:Object,
+ type:String,
+ target:Object,
+ value:Object,
+ detail:Object):void;
+}
+
+}
\ No newline at end of file