add bar chart classes from examples/BarChartExample for cross-compilation

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

Branch: refs/heads/develop
Commit: 51147642f752bb6a731471b1317a30887aca1c01
Parents: b3c9c9f
Author: Alex Harui <aha...@apache.org>
Authored: Wed Jan 22 23:11:08 2014 -0800
Committer: Alex Harui <aha...@apache.org>
Committed: Wed Jan 22 23:11:08 2014 -0800

----------------------------------------------------------------------
 .../apache/flex/html/staticControls/BarChart.as |  46 ++++++++
 .../html/staticControls/beads/BarChartView.as   |  45 +++++++
 .../html/staticControls/beads/BoxGridView.as    |  48 ++++++++
 .../beads/ChartItemRendererFactory.as           | 100 ++++++++++++++++
 .../flex/html/staticControls/beads/IChart.as    |  26 ++++
 .../html/staticControls/beads/IChartAxis.as     |  25 ++++
 .../staticControls/beads/IChartItemRenderer.as  |  39 ++++++
 .../html/staticControls/beads/IChartSeries.as   |  37 ++++++
 .../flex/html/staticControls/beads/XAxisBead.as | 107 +++++++++++++++++
 .../beads/layout/BarChartLayout.as              | 118 +++++++++++++++++++
 .../supportClasses/BarChartSeries.as            |  70 +++++++++++
 .../supportClasses/BoxItemRenderer.as           | 116 ++++++++++++++++++
 12 files changed, 777 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/51147642/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/BarChart.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/BarChart.as
 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/BarChart.as
new file mode 100644
index 0000000..3dca482
--- /dev/null
+++ 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/BarChart.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.html.staticControls
+{
+       import org.apache.flex.core.ISelectionModel;
+       import org.apache.flex.events.Event;
+       import org.apache.flex.html.staticControls.beads.BarChartView;
+       import org.apache.flex.html.staticControls.beads.IChart;
+       import org.apache.flex.html.staticControls.List;
+       import 
org.apache.flex.html.staticControls.supportClasses.NonVirtualDataGroup;
+
+       public class BarChart extends List implements IChart
+       {
+               public function BarChart()
+               {
+                       super();
+               }
+               
+               private var _series:Array;
+               public function get series():Array
+               {
+                       return _series;
+               }
+               public function set series(value:Array):void
+               {
+                       _series = value;
+                       dispatchEvent(new Event("seriesChanged"));
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/51147642/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/BarChartView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/BarChartView.as
 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/BarChartView.as
new file mode 100644
index 0000000..df847aa
--- /dev/null
+++ 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/BarChartView.as
@@ -0,0 +1,45 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.staticControls.beads
+{
+       import org.apache.flex.core.IBeadLayout;
+       import org.apache.flex.core.IParent;
+       import org.apache.flex.core.ISelectionModel;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.core.ValuesManager;
+       import org.apache.flex.html.staticControls.beads.ListView;
+       import 
org.apache.flex.html.staticControls.supportClasses.NonVirtualDataGroup;
+
+       public class BarChartView extends ListView
+       {
+               public function BarChartView()
+               {
+                       super();
+               }
+               
+               private var _strand:IStrand;
+               private var listModel:ISelectionModel;
+               
+               override public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+                       super.strand = value;
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/51147642/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/BoxGridView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/BoxGridView.as
 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/BoxGridView.as
new file mode 100644
index 0000000..e716abb
--- /dev/null
+++ 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/BoxGridView.as
@@ -0,0 +1,48 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.staticControls.beads
+{
+       import org.apache.flex.core.IBeadView;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.core.UIBase;
+       import org.apache.flex.html.staticControls.Label;
+       
+       public class BoxGridView implements IBeadView
+       {
+               public function BoxGridView()
+               {
+               }
+               
+               private var label:Label;
+               
+               private var _strand:IStrand;
+               public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+                       
+                       label = new Label();
+                       label.text = "BoxGrid";
+                       label.x = 0;
+                       label.y = 0;
+                       label.width = 100;
+                       label.height = 25;
+                       UIBase(_strand).addElement(label);
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/51147642/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/ChartItemRendererFactory.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/ChartItemRendererFactory.as
 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/ChartItemRendererFactory.as
new file mode 100644
index 0000000..17526da
--- /dev/null
+++ 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/ChartItemRendererFactory.as
@@ -0,0 +1,100 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.staticControls.beads
+{
+       import org.apache.flex.core.IBead;
+       import org.apache.flex.core.IDataProviderItemRendererMapper;
+       import org.apache.flex.core.IItemRendererClassFactory;
+       import org.apache.flex.core.IItemRendererParent;
+       import org.apache.flex.core.ISelectionModel;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.events.Event;
+       import org.apache.flex.events.IEventDispatcher;
+       import org.apache.flex.html.staticControls.beads.IListView;
+       
+       public class ChartItemRendererFactory implements IBead, 
IDataProviderItemRendererMapper
+       {
+               public function ChartItemRendererFactory()
+               {
+               }
+               
+               private var selectionModel:ISelectionModel;
+               protected var dataGroup:IItemRendererParent;
+               
+               private var _seriesRenderers:Array;
+               public function get seriesRenderers():Array
+               {
+                       return _seriesRenderers;
+               }
+               
+               private var _strand:IStrand;
+               
+               public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+                       selectionModel = value.getBeadByType(ISelectionModel) 
as ISelectionModel;
+                       var listView:IListView = value.getBeadByType(IListView) 
as IListView;
+                       dataGroup = listView.dataGroup;
+//                     selectionModel.addEventListener("dataProviderChanged", 
dataProviderChangeHandler);
+                       
+                       var dp:Array = selectionModel.dataProvider as Array;
+                       if (!dp)
+                               return;
+                       
+                       _seriesRenderers = new Array();
+                       
+                       dataGroup.removeAllElements();
+                       
+                       var series:Array = IChart(_strand).series;
+
+                       for( var j:int=0; j < dp.length; j++)
+                       {
+                               var renderers:Array = new Array();
+                               
+                               for( var i:int=0; i < series.length; i++)
+                               {
+                                       var s:IChartSeries = series[i] as 
IChartSeries;
+                                       var k:IChartItemRenderer = 
s.itemRenderer.newInstance() as IChartItemRenderer;
+                                       k.xField = s.xField;
+                                       k.yField = s.yField;
+                                       k.fillColor = s.fillColor;
+                                       k.data = dp[j];
+                                       k.index = j;
+                                       
+                                       renderers.push(k);
+                                       
+                                       dataGroup.addElement(k);
+                               }
+                               
+                               _seriesRenderers.push(renderers);
+                       }
+                       
+                       IEventDispatcher(_strand).dispatchEvent(new 
Event("itemsCreated"));
+               }
+               
+               public function get 
itemRendererFactory():IItemRendererClassFactory
+               {
+                       return null;
+               }
+               
+               public function set 
itemRendererFactory(value:IItemRendererClassFactory):void
+               {
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/51147642/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IChart.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IChart.as
 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IChart.as
new file mode 100644
index 0000000..ce0a73f
--- /dev/null
+++ 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IChart.as
@@ -0,0 +1,26 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.staticControls.beads
+{
+       public interface IChart
+       {
+               function get series():Array;
+               function set series(value:Array):void;
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/51147642/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IChartAxis.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IChartAxis.as
 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IChartAxis.as
new file mode 100644
index 0000000..079395b
--- /dev/null
+++ 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IChartAxis.as
@@ -0,0 +1,25 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.staticControls.beads
+{
+       public interface IChartAxis
+       {
+               
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/51147642/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IChartItemRenderer.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IChartItemRenderer.as
 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IChartItemRenderer.as
new file mode 100644
index 0000000..61f2bc5
--- /dev/null
+++ 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IChartItemRenderer.as
@@ -0,0 +1,39 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.staticControls.beads
+{
+       import org.apache.flex.core.IItemRenderer;
+       
+       public interface IChartItemRenderer extends IItemRenderer
+       {
+               function get xField():String;
+               function set xField(value:String):void;
+               
+               function get yField():String;
+               function set yField(value:String):void;
+               
+               function get fillColor():uint;
+               function set fillColor(value:uint):void;
+               
+               function set x(value:Number):void;
+               function set y(value:Number):void;
+               function set width(value:Number):void;
+               function set height(value:Number):void;
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/51147642/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IChartSeries.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IChartSeries.as
 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IChartSeries.as
new file mode 100644
index 0000000..b1ec981
--- /dev/null
+++ 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IChartSeries.as
@@ -0,0 +1,37 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.staticControls.beads
+{
+       import org.apache.flex.core.IItemRendererFactory;
+       
+       public interface IChartSeries
+       {
+               function get xField():String;
+               function set xField(value:String):void;
+               
+               function get yField():String;
+               function set yField(value:String):void;
+               
+               function get fillColor():uint;
+               function set fillColor(value:uint):void;
+               
+               function get itemRenderer():IItemRendererFactory;
+               function set itemRenderer(value:IItemRendererFactory):void;
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/51147642/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/XAxisBead.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/XAxisBead.as
 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/XAxisBead.as
new file mode 100644
index 0000000..d2f1308
--- /dev/null
+++ 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/XAxisBead.as
@@ -0,0 +1,107 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.staticControls.beads
+{      
+       import org.apache.flex.core.FilledRectangle;
+       import org.apache.flex.core.IBead;
+       import org.apache.flex.core.IDataProviderItemRendererMapper;
+       import org.apache.flex.core.ISelectionModel;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.core.UIBase;
+       import org.apache.flex.events.Event;
+       import org.apache.flex.events.IEventDispatcher;
+       import org.apache.flex.html.staticControls.Label;
+       import 
org.apache.flex.html.staticControls.beads.models.ArraySelectionModel;
+       
+       public class XAxisBead implements IBead, IChartAxis
+       {
+               public function XAxisBead()
+               {
+               }
+               
+               private var _labelField:String;
+               public function get labelField():String
+               {
+                       return _labelField;
+               }
+               public function set labelField(value:String):void
+               {
+                       _labelField = value;
+               }
+               
+               private var _strand:IStrand;
+               public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+                       
+                       // in order to draw or create the labels, need to know 
when the series has been created.
+                       
IEventDispatcher(_strand).addEventListener("layoutComplete",handleItemsCreated);
+               }
+               
+               private function handleItemsCreated(event:Event):void
+               {
+                       var charter:ChartItemRendererFactory =
+                               
_strand.getBeadByType(IDataProviderItemRendererMapper) as 
ChartItemRendererFactory;
+                       
+                       var model:ArraySelectionModel = 
_strand.getBeadByType(ISelectionModel) as ArraySelectionModel;
+                       var items:Array;
+                       if (model.dataProvider is Array) items = 
model.dataProvider as Array;
+                       else return;
+                       
+                       var renderers:Array = charter.seriesRenderers;
+                       var series:Array = IChart(_strand).series;
+                                       
+                       var xpos:Number = 0;
+                       var useWidth:Number = UIBase(_strand).width / 
renderers.length;
+                       
+                       // draw the horzontal axis
+                       var horzLine:FilledRectangle = new FilledRectangle();
+                       horzLine.fillColor = 0x111111;
+                       horzLine.x = 0;
+                       horzLine.y = UIBase(_strand).height;
+                       horzLine.height = 1;
+                       horzLine.width = UIBase(_strand).width;
+                       UIBase(_strand).addElement(horzLine);
+                       
+                       // place the labels below the axis enough to account 
for the tick marks
+                       var labelY:Number = UIBase(_strand).height + 8;
+                       
+                       for(var i:int=0; i < items.length; i++) {               
                
+                               var label:Label = new Label();
+                               label.text = items[i][labelField];
+                               label.x = xpos;
+                               label.y = labelY;
+                               
+                               UIBase(_strand).addElement(label);
+                               
+                               // add a tick mark, too
+                               var tick:FilledRectangle = new 
FilledRectangle();
+                               tick.fillColor = 0x111111;
+                               tick.x = xpos + useWidth/2;
+                               tick.y = UIBase(_strand).height;
+                               tick.width = 1;
+                               tick.height = 5;
+                               UIBase(_strand).addElement(tick);
+                               
+                               var r:UIBase = UIBase(renderers[i][0]);
+                               xpos += useWidth;
+                       }
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/51147642/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/layout/BarChartLayout.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/layout/BarChartLayout.as
 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/layout/BarChartLayout.as
new file mode 100644
index 0000000..7924cae
--- /dev/null
+++ 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/layout/BarChartLayout.as
@@ -0,0 +1,118 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.staticControls.beads.layout
+{      
+       import org.apache.flex.core.IBeadLayout;
+       import org.apache.flex.core.IDataProviderItemRendererMapper;
+       import org.apache.flex.core.ILayoutParent;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.core.UIBase;
+       import org.apache.flex.events.Event;
+       import org.apache.flex.events.IEventDispatcher;
+       import 
org.apache.flex.html.staticControls.beads.ChartItemRendererFactory;
+       import org.apache.flex.html.staticControls.beads.IChart;
+       import org.apache.flex.html.staticControls.beads.IChartItemRenderer;
+       import 
org.apache.flex.html.staticControls.supportClasses.BarChartSeries;
+       
+       public class BarChartLayout implements IBeadLayout
+       {
+               public function BarChartLayout()
+               {
+               }
+               
+               private var _strand:IStrand;
+               
+               public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+                       
IEventDispatcher(value).addEventListener("widthChanged", changeHandler);
+                       
IEventDispatcher(value).addEventListener("childrenAdded", changeHandler);
+                       
IEventDispatcher(value).addEventListener("itemsCreated", changeHandler);
+               }
+               
+               private var _gap:Number = 20;
+               public function get gap():Number
+               {
+                       return _gap;
+               }
+               public function set gap(value:Number):void
+               {
+                       _gap = value;
+               }
+               
+               private function changeHandler(event:Event):void
+               {
+                       var layoutParent:ILayoutParent = 
_strand.getBeadByType(ILayoutParent) as ILayoutParent;
+                       
+                       var factory:ChartItemRendererFactory = 
_strand.getBeadByType(IDataProviderItemRendererMapper) as 
ChartItemRendererFactory;
+                       var n:int = factory.seriesRenderers.length;
+                       
+                       var xpos:Number = 0;
+                       var useWidth:Number = (UIBase(_strand).width / n) - gap;
+                       var useHeight:Number = UIBase(_strand).height;
+                       
+                       var maxYValue:Number = 0;
+                       var series:Array = IChart(_strand).series;
+                       trace("There are "+series.length+" series in this 
chart");
+                       var seriesMaxes:Array = [];
+                       
+                       for (var s:int = 0; s < series.length; s++)
+                       {
+                               var bcs:BarChartSeries = series[s] as 
BarChartSeries;
+                               seriesMaxes.push({maxValue:0,scaleFactor:0});
+                               
+                               for (var i:int = 0; i < n; i++)
+                               {
+                                       var m:Array = 
factory.seriesRenderers[i] as Array;
+                                       var item:IChartItemRenderer = m[s] as 
IChartItemRenderer;
+                                       var data:Object = item.data;
+                                       var field:String = bcs.yField;
+                                       
+                                       var yValue:Number = Number(data[field]);
+                                       seriesMaxes[s].maxValue = 
Math.max(seriesMaxes[s].maxValue,yValue);
+                               }
+                               
+                               seriesMaxes[s].scaleFactor = 
useHeight/seriesMaxes[s].maxValue;
+                       }
+                       
+                       for (i = 0; i < n; i++)
+                       {
+                               m = factory.seriesRenderers[i] as Array;
+                               for (s=0; s < m.length; s++)
+                               {
+                                       var seriesWidth:Number = 
useWidth/series.length;
+                                       var child:IChartItemRenderer = m[s] as 
IChartItemRenderer;
+                                       data = child.data
+                                       yValue = Number(data[child.yField]);
+                                       
+                                       child.y = useHeight - 
yValue*seriesMaxes[s].scaleFactor;
+                                       child.x = xpos;
+                                       child.width = seriesWidth;
+                                       child.height = 
yValue*seriesMaxes[s].scaleFactor;
+                                       xpos += seriesWidth;
+                               }
+                               
+                               xpos += gap;
+                               
+                       }
+                       
+                       IEventDispatcher(_strand).dispatchEvent(new 
Event("layoutComplete"));
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/51147642/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/supportClasses/BarChartSeries.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/supportClasses/BarChartSeries.as
 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/supportClasses/BarChartSeries.as
new file mode 100644
index 0000000..52d0039
--- /dev/null
+++ 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/supportClasses/BarChartSeries.as
@@ -0,0 +1,70 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.staticControls.supportClasses
+{
+       import org.apache.flex.core.IItemRendererFactory;       
+       import org.apache.flex.html.staticControls.beads.IChartSeries;
+
+       public class BarChartSeries implements IChartSeries
+       {
+               public function BarChartSeries()
+               {
+               }
+               
+               private var _xField:String = "x";
+               public function get xField():String
+               {
+                       return _xField;
+               }
+               public function set xField(value:String):void
+               {
+                       _xField = value;
+               }
+               
+               private var _yField:String;
+               public function get yField():String
+               {
+                       return _yField;
+               }
+               public function set yField(value:String):void
+               {
+                       _yField = value;
+               }
+               
+               private var _fillColor:uint;
+               public function get fillColor():uint
+               {
+                       return _fillColor;
+               }
+               public function set fillColor(value:uint):void
+               {
+                       _fillColor = value;
+               }
+               
+               private var _itemRenderer:IItemRendererFactory;
+               public function get itemRenderer():IItemRendererFactory
+               {
+                       return _itemRenderer;
+               }
+               public function set 
itemRenderer(value:IItemRendererFactory):void
+               {
+                       _itemRenderer = value;
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/51147642/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/supportClasses/BoxItemRenderer.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/supportClasses/BoxItemRenderer.as
 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/supportClasses/BoxItemRenderer.as
new file mode 100644
index 0000000..4615edb
--- /dev/null
+++ 
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/supportClasses/BoxItemRenderer.as
@@ -0,0 +1,116 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.staticControls.supportClasses
+{      
+       import org.apache.flex.core.FilledRectangle;
+       import org.apache.flex.core.IItemRenderer;
+       import org.apache.flex.core.IItemRendererFactory;
+       import org.apache.flex.html.staticControls.beads.IChartItemRenderer;
+       import 
org.apache.flex.html.staticControls.supportClasses.UIItemRendererBase;
+       
+       public class BoxItemRenderer extends UIItemRendererBase implements 
IChartItemRenderer, IItemRendererFactory
+       {
+               public function BoxItemRenderer()
+               {
+                       super();
+               }
+               
+               override public function newInstance():IItemRenderer
+               {
+                       return new BoxItemRenderer();
+               }
+               
+               private var _itemRendererParent:Object;
+               public function get itemRendererParent():Object
+               {
+                       return _itemRendererParent;
+               }
+               public function set itemRendererParent(value:Object):void
+               {
+                       _itemRendererParent = value;
+               }
+               
+               private var filledRect:FilledRectangle;
+               
+               private var _yField:String = "y";
+               public function get yField():String
+               {
+                       return _yField;
+               }
+               public function set yField(value:String):void
+               {
+                       _yField = value;
+               }
+               
+               private var _xField:String = "x";
+               public function get xField():String
+               {
+                       return _xField;
+               }
+               public function set xField(value:String):void
+               {
+                       _xField = value;
+               }
+               
+               private var _fillColor:uint;
+               public function get fillColor():uint
+               {
+                       return _fillColor;
+               }
+               public function set fillColor(value:uint):void
+               {
+                       _fillColor = value;
+               }
+               
+               override public function addedToParent():void
+               {
+                       super.addedToParent();
+               }
+                               
+               override public function set data(value:Object):void
+               {
+                       super.data = value;             
+                       
+                       if (filledRect == null) {
+                               filledRect = new FilledRectangle();
+                               addElement(filledRect);
+                       }       
+               }
+               
+               override public function set width(value:Number):void
+               {
+                       super.width = value;
+                       drawBar();
+               }
+               
+               override public function set height(value:Number):void
+               {
+                       super.height = value;
+                       drawBar();
+               }
+               
+               protected function drawBar():void
+               {
+                       if (filledRect) {
+                               filledRect.fillColor = fillColor;
+                               filledRect.drawRect(0,0,this.width,this.height);
+                       }
+               }
+       }
+}
\ No newline at end of file

Reply via email to