[virtualcommons-svn] SF.net SVN: virtualcommons:[159] mentalmodels/trunk/flex/src
Status: Beta
Brought to you by:
alllee
From: <kj...@us...> - 2009-06-12 02:39:13
|
Revision: 159 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=159&view=rev Author: kjonas Date: 2009-06-12 02:39:11 +0000 (Fri, 12 Jun 2009) Log Message: ----------- ForecastComponent.mxml renders on screen All "modes" render properly. No value-checking implemented. Modified Paths: -------------- mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml Modified: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-10 23:47:06 UTC (rev 158) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-12 02:39:11 UTC (rev 159) @@ -1,7 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="customComponents.*"> - <comp:ForecastComponent id="forecastComponent" numColumns="15" numBays="3" style="0"/> + <mx:VBox id="content" minWidth="160"> + <comp:ForecastComponent id="forecastComponent0" numColumns="15" numBays="3" style="0" minimumWidth="{content.minWidth}"/> + <comp:ForecastComponent id="forecastComponent1" numColumns="15" numBays="3" style="1" minimumWidth="{content.minWidth}"/> + <comp:ForecastComponent id="forecastComponent2" numColumns="6" numBays="3" style="2" minimumWidth="{content.minWidth}"/> + <comp:ForecastComponent id="forecastComponent3" numColumns="6" numBays="3" style="3" minimumWidth="{content.minWidth}"/> + </mx:VBox> <mx:Script> <![CDATA[ Modified: mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-06-10 23:47:06 UTC (rev 158) +++ mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-06-12 02:39:11 UTC (rev 159) @@ -1,8 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()"> - <mx:ArrayCollection id="sched"/> - <mx:HBox id="gridContainer"> <mx:VBox id="labels"> </mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-10 23:47:06 UTC (rev 158) +++ mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-12 02:39:11 UTC (rev 159) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> - <mx:VBox id="labels" verticalGap="2"/> + <mx:VBox id="labels" verticalGap="5" minWidth="{minimumWidth}" horizontalAlign="right"/> <mx:Script> <![CDATA[ @@ -14,20 +14,49 @@ [Bindable] public var dataProvider:ArrayCollection = new ArrayCollection(); [Bindable] public var numBays:int = 3; [Bindable] public var numColumns:int = 15; + [Bindable] public var minimumWidth:int = 30; [Bindable] public var style:int = 0; // 0:PeopleEntry, 1:PeopleViewing, 2:FishEntry, 3:Calculated public function init():void { + createGrid(); + fillGridColumns(); + fillGridFields(); + setGridHeight(); + addChild(dataGrid); + } + + private function addLabel(text:String="", html:Boolean=false):void + { + var newLabel:Label = new Label(); + if(text != "" && !html) + { + newLabel.text = text; + } + else if(html) + { + newLabel.htmlText = text; + } + labels.addChild(newLabel); + } + + private function addField():void + { + dataProvider.addItem(new Object()); + } + + private function createGrid():void + { dataGrid = new DataGrid; dataGrid.id = "dataGrid"; dataGrid.editable = true; dataGrid.enabled = true; - dataGrid.dataProvider = dataProvider; - - dataGrid.initialize(); - + } + + private function fillGridColumns():void + { var newColumnArray:Array = new Array(numColumns); - for(var columnNumber:int=0; columnNumber<newColumnArray.length; columnNumber++) + for(var columnNumber:int = 0; columnNumber < numColumns; columnNumber++) { var newDataGridColumn:DataGridColumn = new DataGridColumn(); newDataGridColumn.draggable = false; @@ -44,36 +73,76 @@ } dataGrid.columns = newColumnArray; + dataGrid.editable = ((style == 0) || (style == 2)); // 0:PeopleEntry, 2:FishEntry + } + + private function fillGridFields():void + { var bayNumber:int = 0; if(style==0 || style==1) // 0:PeopleEntry, 1:PeopleViewing { - addLabel(); + if(style==0) + { + addLabel(" <b>Predict</b>:",true); + } + else + { + addLabel(" <b>You Predicted</b>:",true); + } + addLabel("# People in Harbor:"); + addField(); + for(bayNumber=0; bayNumber<numBays; bayNumber++) { addLabel("# People in Bay " + (bayNumber+1) + ":"); + addField(); } } else if(style==2) { - addLabel(); + addLabel(" <b>Predict:</b>",true); + for(bayNumber=0; bayNumber<numBays; bayNumber++) { - addLabel("# Fish in Bay " + (bayNumber+1) + ":"); + addLabel("# Fish in Bay " + (bayNumber+1) + "(AM):"); + addField(); } } - - //end init() + else if(style==3) + { + addLabel(" <b>We calculate that:</b>",true); + + addLabel("You will be in location #:"); + addField(); + addLabel("You will get USD:"); + addField(); + addLabel("Others will get USD:"); + addField(); + for(bayNumber=0; bayNumber<numBays; bayNumber++) + { + addLabel("# Fish in Bay " + (bayNumber+1) + "(PM):"); + addField(); + } + } + dataGrid.dataProvider = dataProvider; } - public function addLabel(text:String=""):void + private function setGridHeight():void { - var newLabel:Label = new Label(); - if(text != "") + switch(style) { - newLabel.text = text; + case(0): + case(1): // 0:PeopleEntry, 1:PeopleViewing + dataGrid.height = (23)*(numBays+2)-1; + break; + case(2): // 2:FishEntry + dataGrid.height = (23)*(numBays+1); + break; + case(3): // 3:Calculated + dataGrid.height = (23)*(numBays+4)-3; + break; } - labels.addChild(newLabel); } ]]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |