Added graphics-optimized versions of itemRenderers to use SVG more efficiently.
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/047b3a37 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/047b3a37 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/047b3a37 Branch: refs/heads/develop Commit: 047b3a372055168763668de3b2bca48f361c86f3 Parents: ecd88a1 Author: Peter Ent <[email protected]> Authored: Fri Oct 24 15:38:42 2014 -0400 Committer: Peter Ent <[email protected]> Committed: Fri Oct 24 15:38:42 2014 -0400 ---------------------------------------------------------------------- .../as/projects/FlexJSJX/basic-manifest.xml | 5 + .../as/projects/FlexJSJX/src/FlexJSJXClasses.as | 5 + .../optimized/SVGBoxItemRenderer.as | 207 ++++++++++++++ .../optimized/SVGChartDataGroup.as | 157 +++++++++++ .../optimized/SVGLineSegmentItemRenderer.as | 201 +++++++++++++ .../optimized/SVGWedgeItemRenderer.as | 281 +++++++++++++++++++ .../src/org/apache/flex/core/IContentView.js | 103 +++++++ 7 files changed, 959 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/047b3a37/frameworks/as/projects/FlexJSJX/basic-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/basic-manifest.xml b/frameworks/as/projects/FlexJSJX/basic-manifest.xml index f35189b..bab814f 100644 --- a/frameworks/as/projects/FlexJSJX/basic-manifest.xml +++ b/frameworks/as/projects/FlexJSJX/basic-manifest.xml @@ -52,6 +52,11 @@ <component id="LineChartLinearVsLinearLayout" class="org.apache.flex.charts.beads.layouts.LineChartLinearVsLinearLayout" /> <component id="VerticalColumnLayout" class="org.apache.flex.html.beads.layouts.VerticalColumnLayout" /> + <component id="SVGChartDataGroup" class="org.apache.flex.charts.supportClasses.optimized.SVGChartDataGroup"/> + <component id="SVGBoxItemRenderer" class="org.apache.flex.charts.supportClasses.optimized.SVGBoxItemRenderer"/> + <component id="SVGWedgeItemRenderer" class="org.apache.flex.charts.supportClasses.optimized.SVGWedgeItemRenderer"/> + <component id="SVGLineSegmentItemRenderer" class="org.apache.flex.charts.supportClasses.optimized.SVGLineSegmentItemRenderer"/> + <component id="Fade" class="org.apache.flex.effects.Fade"/> <component id="Move" class="org.apache.flex.effects.Move"/> <component id="Resize" class="org.apache.flex.effects.Resize"/> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/047b3a37/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as b/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as index 19a1fcb..2c8c944 100644 --- a/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as +++ b/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as @@ -27,6 +27,7 @@ package */ internal class FlexJSJXClasses { + import org.apache.flex.charts.beads.ChartItemRendererFactory; ChartItemRendererFactory; import org.apache.flex.charts.beads.DataItemRendererFactoryForSeriesData; DataItemRendererFactoryForSeriesData; import org.apache.flex.charts.beads.HorizontalCategoryAxisBead; HorizontalCategoryAxisBead; @@ -46,6 +47,10 @@ internal class FlexJSJXClasses import org.apache.flex.charts.supportClasses.BoxItemRenderer; BoxItemRenderer; import org.apache.flex.charts.supportClasses.LineSegmentItemRenderer; LineSegmentItemRenderer; import org.apache.flex.charts.supportClasses.WedgeItemRenderer; WedgeItemRenderer; + import org.apache.flex.charts.supportClasses.optimized.SVGChartDataGroup; SVGChartDataGroup; + import org.apache.flex.charts.supportClasses.optimized.SVGBoxItemRenderer; SVGBoxItemRenderer; + import org.apache.flex.charts.supportClasses.optimized.SVGWedgeItemRenderer; SVGWedgeItemRenderer; + import org.apache.flex.charts.supportClasses.optimized.SVGLineSegmentItemRenderer; SVGLineSegmentItemRenderer; import org.apache.flex.effects.Tween; Tween; import org.apache.flex.effects.Move; Move; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/047b3a37/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/supportClasses/optimized/SVGBoxItemRenderer.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/supportClasses/optimized/SVGBoxItemRenderer.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/supportClasses/optimized/SVGBoxItemRenderer.as new file mode 100644 index 0000000..a85b554 --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/supportClasses/optimized/SVGBoxItemRenderer.as @@ -0,0 +1,207 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.charts.supportClasses.optimized +{ + import org.apache.flex.charts.core.IChartItemRenderer; + import org.apache.flex.charts.core.IChartSeries; + import org.apache.flex.core.graphics.GraphicsContainer; + import org.apache.flex.core.graphics.IFill; + import org.apache.flex.core.graphics.IStroke; + import org.apache.flex.core.graphics.SolidColor; + import org.apache.flex.core.graphics.SolidColorStroke; + import org.apache.flex.html.supportClasses.DataItemRenderer; + + /** + * The SVGBoxItemRenderer draws its graphics directly into a SVGChartDataGroup + * (GraphicsContainer). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class SVGBoxItemRenderer extends DataItemRenderer implements IChartItemRenderer + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function SVGBoxItemRenderer() + { + super(); + } + + private var _series:IChartSeries; + + /** + * The series to which this itemRenderer instance belongs. Or, the series + * being presented. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get series():IChartSeries + { + return _series; + } + public function set series(value:IChartSeries):void + { + _series = value; + } + + private var _yField:String = "y"; + + /** + * The name of the field containing the value for the Y axis. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get yField():String + { + return _yField; + } + public function set yField(value:String):void + { + _yField = value; + } + + private var _xField:String = "x"; + + /** + * The name of the field containing the value for the X axis. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get xField():String + { + return _xField; + } + public function set xField(value:String):void + { + _xField = value; + } + + private var _fill:IFill; + + /** + * The color used to fill the interior of the box. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get fill():IFill + { + return _fill; + } + public function set fill(value:IFill):void + { + _fill = value; + } + + private var _stroke:IStroke; + + /** + * The outline of the box. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get stroke():IStroke + { + return _stroke; + } + public function set stroke(value:IStroke):void + { + _stroke = value; + } + + /** + * @copy org.apache.flex.supportClasses.UIItemRendererBase#data + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set data(value:Object):void + { + super.data = value; + drawBar(); + } + + /** + * @copy org.apache.flex.core.UIBase#width + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set width(value:Number):void + { + super.width = value; + drawBar(); + } + + /** + * @copy org.apache.flex.core.UIBase#height + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set height(value:Number):void + { + super.height = value; + drawBar(); + } + + /** + * @private + */ + protected function drawBar():void + { + if ((this.width > 0) && (this.height > 0)) + { + var hsdg:SVGChartDataGroup = this.itemRendererParent as SVGChartDataGroup; + + hsdg.fill = fill; + hsdg.stroke = stroke; + hsdg.drawRect(this.x, this.y, this.width, this.height); + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/047b3a37/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/supportClasses/optimized/SVGChartDataGroup.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/supportClasses/optimized/SVGChartDataGroup.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/supportClasses/optimized/SVGChartDataGroup.as new file mode 100644 index 0000000..c1a48d1 --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/supportClasses/optimized/SVGChartDataGroup.as @@ -0,0 +1,157 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.charts.supportClasses.optimized +{ + import org.apache.flex.charts.core.IChartDataGroup; + import org.apache.flex.charts.core.IChartItemRenderer; + import org.apache.flex.charts.core.IChartSeries; + import org.apache.flex.core.IContentView; + import org.apache.flex.core.IItemRenderer; + import org.apache.flex.core.IItemRendererParent; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.graphics.GraphicsContainer; + import org.apache.flex.events.Event; + + /** + * The SVGChartDataGroup serves as the drawing canvas for SVG itemRenderers. Rather than having + * individual itemRenderer objects in the display list, this class provides a canvas where the + * itemRenderers can draw directly using the flex.core.graphics package. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class SVGChartDataGroup extends GraphicsContainer implements IItemRendererParent, IContentView, IChartDataGroup + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function SVGChartDataGroup() + { + super(); + + _children = new Array(); + + addEventListener("widthChanged", resizeContainer); + addEventListener("heightChanged", resizeContainer); + } + + private var _children:Array; + + /** + * @copy org.apache.flex.core.IItemRendererParent#getItemRendererForIndex() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function getItemRendererForIndex(index:int):IItemRenderer + { + if (index < 0 || index >= _children.length) return null; + return _children[index] as IItemRenderer; + } + + /** + * Returns the itemRenderer that matches both the series and child index. A null return is + * valid since some charts have optional itemRenderers for their series. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function getItemRendererForSeriesAtIndex(series:IChartSeries, index:int):IChartItemRenderer + { + var n:int = _children.length; + for(var i:int=0; i < n; i++) + { + var child:IChartItemRenderer = _children[i] as IChartItemRenderer; + if (child && child.series == series) { + if (index == 0) return child; + --index; + } + } + + return null; + } + + /** + * @copy org.apache.flex.core.IItemRendererParent#removeAllElements() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function removeAllElements():void + { + _children = new Array(); + } + + /** + * Overrides the addElement function to set the element into an internal + * list. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function addElement(value:Object):void + { + _children.push(value); + + var base:UIBase = value as UIBase; + base.addedToParent(); + } + + /** + * Overrides the addElementAt function to set the element into an internal + * list. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function addElementAt(value:Object, index:int):void + { + if (index >= _children.length) _children.push(value); + else _children.splice(index, 0, value); + + var base:UIBase = value as UIBase; + base.addedToParent(); + } + + /** + * @private + */ + private function resizeContainer(event:Event) : void + { + // might need to do something with this + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/047b3a37/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/supportClasses/optimized/SVGLineSegmentItemRenderer.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/supportClasses/optimized/SVGLineSegmentItemRenderer.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/supportClasses/optimized/SVGLineSegmentItemRenderer.as new file mode 100644 index 0000000..7f030d2 --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/supportClasses/optimized/SVGLineSegmentItemRenderer.as @@ -0,0 +1,201 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.charts.supportClasses.optimized +{ + import org.apache.flex.charts.core.IChartSeries; + import org.apache.flex.core.graphics.GraphicsContainer; + import org.apache.flex.core.graphics.IStroke; + import org.apache.flex.core.graphics.Path; + import org.apache.flex.core.graphics.SolidColorStroke; + import org.apache.flex.html.supportClasses.DataItemRenderer; + import org.apache.flex.charts.supportClasses.ILineSegmentItemRenderer; + + /** + * The SVGLineSegmentItemRenderer draws its graphics directly into a SVGChartDataGroup (a + * GraphicsContainer). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class SVGLineSegmentItemRenderer extends DataItemRenderer implements ILineSegmentItemRenderer + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function SVGLineSegmentItemRenderer() + { + super(); + } + + private var _series:IChartSeries; + + /** + * The series to which this itemRenderer instance belongs. Or, the series + * being presented. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get series():IChartSeries + { + return _series; + } + public function set series(value:IChartSeries):void + { + _series = value; + } + + private var _points:Array; + + /** + * The points of the vertices. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get points():Array + { + return _points; + } + public function set points(value:Array):void + { + _points = value; + drawLine(); + } + + private var _stroke:IStroke; + + public function get stroke():IStroke + { + return _stroke; + } + public function set stroke(value:IStroke):void + { + _stroke = value; + drawLine(); + } + + /** + * @copy org.apache.flex.supportClasses.UIItemRendererBase#data + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set data(value:Object):void + { + super.data = value; + } + + /** + * The name of the field containing the value for the Y axis. This is not implemented by this class. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get yField():String + { + return null; + } + public function set yField(value:String):void + { + } + + /** + * The name of the field containing the value for the X axis. This is not implemented by this class. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get xField():String + { + return null; + } + public function set xField(value:String):void + { + } + + private var _fillColor:uint; + + /** + * The color used to fill the interior of the box. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get fillColor():uint + { + return _fillColor; + } + public function set fillColor(value:uint):void + { + _fillColor = value; + } + + /** + * @private + */ + protected function drawLine():void + { + if (points != null) + { + var graphicsContainer:GraphicsContainer = this.itemRendererParent as GraphicsContainer; + + if (stroke == null) { + var solidColorStroke:SolidColorStroke = new SolidColorStroke(); + solidColorStroke.color = 0x000088; + solidColorStroke.weight = 1; + solidColorStroke.alpha = 1; + _stroke = solidColorStroke; + } + + graphicsContainer.stroke = stroke; + graphicsContainer.fill = null; + + var pathString:String = ""; + + for (var i:int=0; i < points.length; i++) { + var point:Object = points[i]; + if (i == 0) pathString += "M "+point.x+" "+point.y+" "; + else pathString += "L "+point.x+" "+point.y+" "; + } + + graphicsContainer.drawPath(pathString); + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/047b3a37/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/supportClasses/optimized/SVGWedgeItemRenderer.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/supportClasses/optimized/SVGWedgeItemRenderer.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/supportClasses/optimized/SVGWedgeItemRenderer.as new file mode 100644 index 0000000..1fc58a6 --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/supportClasses/optimized/SVGWedgeItemRenderer.as @@ -0,0 +1,281 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.charts.supportClasses.optimized +{ + import org.apache.flex.charts.core.IChartSeries; + import org.apache.flex.core.graphics.GraphicsContainer; + import org.apache.flex.core.graphics.IFill; + import org.apache.flex.core.graphics.IStroke; + import org.apache.flex.core.graphics.Path; + import org.apache.flex.html.supportClasses.DataItemRenderer; + import org.apache.flex.charts.supportClasses.IWedgeItemRenderer; + + /** + * The SVGWedgeItemRenderer draws its graphics directly into a SVGChartDataGroup + * (a GraphicsContainer). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class SVGWedgeItemRenderer extends DataItemRenderer implements IWedgeItemRenderer + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function SVGWedgeItemRenderer() + { + super(); + } + + private var _series:IChartSeries; + + /** + * The series to which this itemRenderer instance belongs. Or, the series + * being presented. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get series():IChartSeries + { + return _series; + } + public function set series(value:IChartSeries):void + { + _series = value; + } + + private var _centerX:Number; + + /** + * The X coordinate of the center of the pie. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get centerX():Number + { + return _centerX; + } + public function set centerX(value:Number):void + { + _centerX = value; + drawWedgeInternal(); + } + + private var _centerY:Number; + + /** + * The Y coordinate of the center of the pie. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get centerY():Number + { + return _centerY; + } + public function set centerY(value:Number):void + { + _centerY = value; + drawWedgeInternal(); + } + + private var _startAngle:Number; + + /** + * The starting angle (radians) of the wedge. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get startAngle():Number + { + return _startAngle; + } + public function set startAngle(value:Number):void + { + _startAngle = value; + drawWedgeInternal(); + } + + private var _arc:Number; + + /** + * The sweep (radians) of the wedge, relative to the startAngle. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get arc():Number + { + return _arc; + } + public function set arc(value:Number):void + { + _arc = value; + drawWedgeInternal(); + } + + private var _radius:Number; + + /** + * The radius of the pie. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get radius():Number + { + return _radius; + } + public function set radius(value:Number):void + { + _radius = value; + drawWedgeInternal(); + } + + private var _fill:IFill; + + /** + * The color used to fill the interior of the box. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get fill():IFill + { + return _fill; + } + public function set fill(value:IFill):void + { + _fill = value; + } + + private var _stroke:IStroke; + + /** + * The outline of the box. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get stroke():IStroke + { + return _stroke; + } + public function set stroke(value:IStroke):void + { + _stroke = value; + } + + /** + * @private + */ + private function drawWedgeInternal():void + { + if ( !isNaN(centerX) && !isNaN(centerY) && !isNaN(startAngle) && !isNaN(arc) && !isNaN(radius) ) { + drawWedge(centerX, centerY, startAngle, arc, radius, radius, false); + } + } + + /** + * @private + * + * Draw a wedge of a circle + * @param graphics the graphics object to draw into + * @param x the x center of the circle + * @param y the y center of the circle + * @param startAngle start angle (radians) + * @param arc sweep angle (radians) + * @param radius radius of the circle + * @param yRadius vertical radius (or radius if none given) + * @param continueFlag if true, uses a moveTo call to start drawing at the start point of the circle; else continues drawing using only lineTo and curveTo + * + */ + public function drawWedge(x:Number, y:Number, + startAngle:Number, arc:Number, + radius:Number, yRadius:Number = NaN, + continueFlag:Boolean = false):void + { + var graphicsContainer:GraphicsContainer = this.itemRendererParent as GraphicsContainer; + + var x1:Number = x + radius * Math.cos(startAngle); + var y1:Number = y + radius * Math.sin(startAngle); + var x2:Number = x + radius * Math.cos(startAngle + arc); + var y2:Number = y + radius * Math.sin(startAngle + arc); + + var pathString:String = 'M' + x + ' ' + y + ' L' + x1 + ' ' + y1 + ' A' + radius + ' ' + radius + + ' 0 0 1 ' + x2 + ' ' + y2 + ' z'; + + graphicsContainer.fill = fill; + graphicsContainer.stroke = stroke; + graphicsContainer.drawPath(pathString); + } + + /* + * Ignored by WedgeItemRenderer + */ + + /** + * @private + */ + public function get xField():String + { + return null; + } + public function set xField(value:String):void + { + } + + /** + * @private + */ + public function get yField():String + { + return null; + } + public function set yField(value:String):void + { + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/047b3a37/frameworks/js/FlexJS/src/org/apache/flex/core/IContentView.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/IContentView.js b/frameworks/js/FlexJS/src/org/apache/flex/core/IContentView.js new file mode 100644 index 0000000..d326978 --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/flex/core/IContentView.js @@ -0,0 +1,103 @@ +/** + * 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. + */ + +/** + * org.apache.flex.core.IContentView + * + * @fileoverview + * + * @suppress {checkTypes} + */ + +goog.provide('org.apache.flex.core.IContentView'); + + + +/** + * @interface + */ +org.apache.flex.core.IContentView = function() { +}; + + +/** + * @return {number} x position. + */ +org.apache.flex.core.IContentView.prototype.get_x = function() {}; + + +/** + * @param {number} value x position. + */ +org.apache.flex.core.IContentView.prototype.set_x = function(value) {}; + + +/** + * @return {number} y position. + */ +org.apache.flex.core.IContentView.prototype.get_y = function() {}; + + +/** + * @param {number} value y position. + */ +org.apache.flex.core.IContentView.prototype.set_y = function(value) {}; + + +/** + * @return {number} Component width. + */ +org.apache.flex.core.IContentView.prototype.get_width = function() {}; + + +/** + * @param {number} value Component width. + */ +org.apache.flex.core.IContentView.prototype.set_width = function(value) {}; + + +/** + * @return {number} Component height. + */ +org.apache.flex.core.IContentView.prototype.get_height = function() {}; + + +/** + * @param {number} value Component height. + */ +org.apache.flex.core.IContentView.prototype.set_height = function(value) {}; + + +/** + * Adds a new element to component. + * @param {Object} value The child element being added. + */ +org.apache.flex.core.IContentView.prototype.addElement = function(value) {}; + + +/** + * Removes all of the component's children. + * @return {void} + */ +org.apache.flex.core.IContentView.prototype.removeAllElements = function() {}; + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +org.apache.flex.core.IContentView.prototype.FLEXJS_CLASS_INFO = { + names: [{ name: 'IContentView', qName: 'org.apache.flex.core.IContentView'}] +};
