Return-Path: X-Original-To: apmail-flex-commits-archive@www.apache.org Delivered-To: apmail-flex-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5093011406 for ; Fri, 25 Apr 2014 23:14:38 +0000 (UTC) Received: (qmail 24653 invoked by uid 500); 25 Apr 2014 23:14:37 -0000 Delivered-To: apmail-flex-commits-archive@flex.apache.org Received: (qmail 24580 invoked by uid 500); 25 Apr 2014 23:14:36 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 24567 invoked by uid 99); 25 Apr 2014 23:14:36 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Apr 2014 23:14:36 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 574959528C4; Fri, 25 Apr 2014 23:14:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aharui@apache.org To: commits@flex.apache.org Date: Fri, 25 Apr 2014 23:14:37 -0000 Message-Id: In-Reply-To: <9957105c95404ac89d635f728bf08ff9@git.apache.org> References: <9957105c95404ac89d635f728bf08ff9@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] git commit: [flex-utilities] [refs/heads/develop] - MobileTrader demo app donated by Adobe Systems Inc. MobileTrader demo app donated by Adobe Systems Inc. Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/b2f1e508 Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/b2f1e508 Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/b2f1e508 Branch: refs/heads/develop Commit: b2f1e508ac9d293ded855aebd12859cb7391e707 Parents: 3dc107b Author: Alex Harui Authored: Fri Apr 25 16:14:16 2014 -0700 Committer: Alex Harui Committed: Fri Apr 25 16:14:16 2014 -0700 ---------------------------------------------------------------------- MobileTrader/src/MobileTrader-app.xml | 276 +++++++++++++++++++ MobileTrader/src/MobileTrader.mxml | 63 +++++ MobileTrader/src/assets/Stocks.png | Bin 0 -> 56262 bytes MobileTrader/src/assets/alarm_on_48.png | Bin 0 -> 495 bytes MobileTrader/src/assets/arrow_left.png | Bin 0 -> 52561 bytes MobileTrader/src/assets/arrow_left_24.png | Bin 0 -> 47785 bytes MobileTrader/src/assets/back.png | Bin 0 -> 64121 bytes MobileTrader/src/assets/background.png | Bin 0 -> 49376 bytes MobileTrader/src/assets/chart_icon.png | Bin 0 -> 52491 bytes MobileTrader/src/assets/chart_line_48.png | Bin 0 -> 687 bytes MobileTrader/src/assets/down.png | Bin 0 -> 51486 bytes MobileTrader/src/assets/logo.png | Bin 0 -> 55223 bytes MobileTrader/src/assets/man_48.png | Bin 0 -> 586 bytes MobileTrader/src/assets/money_48.png | Bin 0 -> 676 bytes MobileTrader/src/assets/phone.png | Bin 0 -> 55463 bytes MobileTrader/src/assets/splash-trader.jpg | Bin 0 -> 339335 bytes MobileTrader/src/assets/splash.jpg | Bin 0 -> 52136 bytes MobileTrader/src/assets/up.png | Bin 0 -> 51531 bytes MobileTrader/src/blackberry-tablet.xml | 22 ++ MobileTrader/src/charts/AxisArrayList.as | 80 ++++++ MobileTrader/src/charts/BarChart.mxml | 95 +++++++ .../src/charts/CollaborativePortfolioChart.mxml | 89 ++++++ MobileTrader/src/charts/PortfolioChart.mxml | 174 ++++++++++++ MobileTrader/src/charts/RealTimeChart.mxml | 125 +++++++++ MobileTrader/src/charts/SummaryChart.mxml | 125 +++++++++ MobileTrader/src/components/AssetsSummary.mxml | 173 ++++++++++++ MobileTrader/src/controller/Feed.as | 143 ++++++++++ MobileTrader/src/model/Stock.as | 48 ++++ .../src/renderers/AssetSummaryRenderer.mxml | 47 ++++ MobileTrader/src/renderers/StockRenderer.as | 134 +++++++++ MobileTrader/src/skins/ActionBarSkin.mxml | 67 +++++ .../src/skins/ListHeaderButtonSkin.mxml | 186 +++++++++++++ .../skins/ListHeaderButtonSkinRightAlign.mxml | 186 +++++++++++++ MobileTrader/src/styles.css | 43 +++ MobileTrader/src/views/AdvisorView.mxml | 109 ++++++++ MobileTrader/src/views/AlertsView.mxml | 72 +++++ MobileTrader/src/views/AssetsView.mxml | 86 ++++++ .../src/views/MobileTraderHomeView.mxml | 25 ++ MobileTrader/src/views/SettingsView.mxml | 67 +++++ MobileTrader/src/views/StockView.mxml | 125 +++++++++ MobileTrader/src/views/WatchListView.mxml | 82 ++++++ 41 files changed, 2642 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/MobileTrader-app.xml ---------------------------------------------------------------------- diff --git a/MobileTrader/src/MobileTrader-app.xml b/MobileTrader/src/MobileTrader-app.xml new file mode 100644 index 0000000..853ee7d --- /dev/null +++ b/MobileTrader/src/MobileTrader-app.xml @@ -0,0 +1,276 @@ + + + + + + + + MobileTrader + + + MobileTrader + + + MobileTrader + + + 0.0.0 + + + + + + + + + + + + + + + + + + [This value will be overwritten by Flash Builder in the output app.xml] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + false + true + none + + + + + + + + + + + + + + + + + + + assets/Stocks.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + UIDeviceFamily + + 1 + 2 + + ]]> + high + + http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/MobileTrader.mxml ---------------------------------------------------------------------- diff --git a/MobileTrader/src/MobileTrader.mxml b/MobileTrader/src/MobileTrader.mxml new file mode 100644 index 0000000..c357e98 --- /dev/null +++ b/MobileTrader/src/MobileTrader.mxml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/assets/Stocks.png ---------------------------------------------------------------------- diff --git a/MobileTrader/src/assets/Stocks.png b/MobileTrader/src/assets/Stocks.png new file mode 100755 index 0000000..1ce9269 Binary files /dev/null and b/MobileTrader/src/assets/Stocks.png differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/assets/alarm_on_48.png ---------------------------------------------------------------------- diff --git a/MobileTrader/src/assets/alarm_on_48.png b/MobileTrader/src/assets/alarm_on_48.png new file mode 100755 index 0000000..afc2d2f Binary files /dev/null and b/MobileTrader/src/assets/alarm_on_48.png differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/assets/arrow_left.png ---------------------------------------------------------------------- diff --git a/MobileTrader/src/assets/arrow_left.png b/MobileTrader/src/assets/arrow_left.png new file mode 100755 index 0000000..94c96a2 Binary files /dev/null and b/MobileTrader/src/assets/arrow_left.png differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/assets/arrow_left_24.png ---------------------------------------------------------------------- diff --git a/MobileTrader/src/assets/arrow_left_24.png b/MobileTrader/src/assets/arrow_left_24.png new file mode 100755 index 0000000..a3019ba Binary files /dev/null and b/MobileTrader/src/assets/arrow_left_24.png differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/assets/back.png ---------------------------------------------------------------------- diff --git a/MobileTrader/src/assets/back.png b/MobileTrader/src/assets/back.png new file mode 100755 index 0000000..300d227 Binary files /dev/null and b/MobileTrader/src/assets/back.png differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/assets/background.png ---------------------------------------------------------------------- diff --git a/MobileTrader/src/assets/background.png b/MobileTrader/src/assets/background.png new file mode 100755 index 0000000..87bbd59 Binary files /dev/null and b/MobileTrader/src/assets/background.png differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/assets/chart_icon.png ---------------------------------------------------------------------- diff --git a/MobileTrader/src/assets/chart_icon.png b/MobileTrader/src/assets/chart_icon.png new file mode 100755 index 0000000..536a2ef Binary files /dev/null and b/MobileTrader/src/assets/chart_icon.png differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/assets/chart_line_48.png ---------------------------------------------------------------------- diff --git a/MobileTrader/src/assets/chart_line_48.png b/MobileTrader/src/assets/chart_line_48.png new file mode 100755 index 0000000..eb5ee0d Binary files /dev/null and b/MobileTrader/src/assets/chart_line_48.png differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/assets/down.png ---------------------------------------------------------------------- diff --git a/MobileTrader/src/assets/down.png b/MobileTrader/src/assets/down.png new file mode 100755 index 0000000..6f075e4 Binary files /dev/null and b/MobileTrader/src/assets/down.png differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/assets/logo.png ---------------------------------------------------------------------- diff --git a/MobileTrader/src/assets/logo.png b/MobileTrader/src/assets/logo.png new file mode 100755 index 0000000..0fb0f21 Binary files /dev/null and b/MobileTrader/src/assets/logo.png differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/assets/man_48.png ---------------------------------------------------------------------- diff --git a/MobileTrader/src/assets/man_48.png b/MobileTrader/src/assets/man_48.png new file mode 100755 index 0000000..931b2a3 Binary files /dev/null and b/MobileTrader/src/assets/man_48.png differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/assets/money_48.png ---------------------------------------------------------------------- diff --git a/MobileTrader/src/assets/money_48.png b/MobileTrader/src/assets/money_48.png new file mode 100755 index 0000000..2d84fae Binary files /dev/null and b/MobileTrader/src/assets/money_48.png differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/assets/phone.png ---------------------------------------------------------------------- diff --git a/MobileTrader/src/assets/phone.png b/MobileTrader/src/assets/phone.png new file mode 100755 index 0000000..ca02011 Binary files /dev/null and b/MobileTrader/src/assets/phone.png differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/assets/splash-trader.jpg ---------------------------------------------------------------------- diff --git a/MobileTrader/src/assets/splash-trader.jpg b/MobileTrader/src/assets/splash-trader.jpg new file mode 100755 index 0000000..1d09861 Binary files /dev/null and b/MobileTrader/src/assets/splash-trader.jpg differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/assets/splash.jpg ---------------------------------------------------------------------- diff --git a/MobileTrader/src/assets/splash.jpg b/MobileTrader/src/assets/splash.jpg new file mode 100644 index 0000000..4141133 Binary files /dev/null and b/MobileTrader/src/assets/splash.jpg differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/assets/up.png ---------------------------------------------------------------------- diff --git a/MobileTrader/src/assets/up.png b/MobileTrader/src/assets/up.png new file mode 100755 index 0000000..8e47373 Binary files /dev/null and b/MobileTrader/src/assets/up.png differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/blackberry-tablet.xml ---------------------------------------------------------------------- diff --git a/MobileTrader/src/blackberry-tablet.xml b/MobileTrader/src/blackberry-tablet.xml new file mode 100644 index 0000000..7dd226b --- /dev/null +++ b/MobileTrader/src/blackberry-tablet.xml @@ -0,0 +1,22 @@ + + + + + http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/charts/AxisArrayList.as ---------------------------------------------------------------------- diff --git a/MobileTrader/src/charts/AxisArrayList.as b/MobileTrader/src/charts/AxisArrayList.as new file mode 100644 index 0000000..03d86b5 --- /dev/null +++ b/MobileTrader/src/charts/AxisArrayList.as @@ -0,0 +1,80 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 charts +{ + import mx.collections.ArrayList; + + public class AxisArrayList extends ArrayList + { + private var _max:Number = 100; + public function get max():Number + { + return _max; + } + public function set max(value:Number):void + { + _max = value; + update(); + } + + private var _min:Number = 0; + public function get min():Number + { + return _min; + } + public function set min(value:Number):void + { + _min = value; + update(); + } + + private var _step:Number = 10; + public function get step():Number + { + return _step; + } + public function set step(value:Number):void + { + _step = value; + update(); + } + + private function update():void + { + var arr:Array = []; + var i:Number; + if (step > 0) + { + for (i = min; i <= max; i += step) + { + arr.push(i); + } + } + else + { + for (i = max; i >= min; i += step) + { + arr.push(i); + } + } + source = arr; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/charts/BarChart.mxml ---------------------------------------------------------------------- diff --git a/MobileTrader/src/charts/BarChart.mxml b/MobileTrader/src/charts/BarChart.mxml new file mode 100644 index 0000000..3ba016d --- /dev/null +++ b/MobileTrader/src/charts/BarChart.mxml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/charts/CollaborativePortfolioChart.mxml ---------------------------------------------------------------------- diff --git a/MobileTrader/src/charts/CollaborativePortfolioChart.mxml b/MobileTrader/src/charts/CollaborativePortfolioChart.mxml new file mode 100644 index 0000000..ff44c3c --- /dev/null +++ b/MobileTrader/src/charts/CollaborativePortfolioChart.mxml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/charts/PortfolioChart.mxml ---------------------------------------------------------------------- diff --git a/MobileTrader/src/charts/PortfolioChart.mxml b/MobileTrader/src/charts/PortfolioChart.mxml new file mode 100644 index 0000000..c69502a --- /dev/null +++ b/MobileTrader/src/charts/PortfolioChart.mxml @@ -0,0 +1,174 @@ + + + + + + + max) max = data[i]; + } + redraw(); + } + + public function get data():Array + { + return _data; + } + + protected function completeHandler():void + { + data = [ + 80236, 85639, 82364, 72369, 69523, 85632, 86352, 82562, 87523, 89658, 96853, 106256, + 112045, 100258, 112584, 86352, 86523, 108532, 110253, 120145, 116325, 114856, 110256, 111857, + 112852, 115632, 128632, 121741, 92365, 95638, 132800, 128963, 125698, 112587, 121856, 126874, + 131569, 97563, 98563, 100235, 110523, 119536, 121532, 117563, 125963, 139523, 131856, 138972, + 125639, 103698, 130856, 147523, 110263, 125698, 145962, 138653, 131568, 111258, 125693, 161984 + ]; + + Multitouch.inputMode = MultitouchInputMode.GESTURE; + rect.addEventListener(TransformGestureEvent.GESTURE_ZOOM, function(e:TransformGestureEvent):void{zoom(e.scaleX)}); + + } + + protected function zoom(scaleX:Number):void + { + var w:Number = path.width * scaleX; + if (scaleX>1) + path.width = w > width*5 ? width*5 : w; + else + { + path.width = w < width ? width : w; + if (path.x + path.width < width) path.x = width - path.width; + } + } + + protected function redraw():void + { + if (!data) return; + + var pathData:String = "M 0 " + height; + + var xPos:Number; + var yPos:Number; + for (var i:int=0; i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/charts/RealTimeChart.mxml ---------------------------------------------------------------------- diff --git a/MobileTrader/src/charts/RealTimeChart.mxml b/MobileTrader/src/charts/RealTimeChart.mxml new file mode 100644 index 0000000..b063bbf --- /dev/null +++ b/MobileTrader/src/charts/RealTimeChart.mxml @@ -0,0 +1,125 @@ + + + + + + + maxValue) maxValue = history[i].last; + } + + var pathData:String = ""; + + var length:int = history.length; + + for (i=0; i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/charts/SummaryChart.mxml ---------------------------------------------------------------------- diff --git a/MobileTrader/src/charts/SummaryChart.mxml b/MobileTrader/src/charts/SummaryChart.mxml new file mode 100644 index 0000000..a944c7c --- /dev/null +++ b/MobileTrader/src/charts/SummaryChart.mxml @@ -0,0 +1,125 @@ + + + + + + + max) max = data[i]; + } + redraw(); + } + + public function redraw():void + { + if (!data) return; + + var pathData:String=""; + + var xPos:Number; + var yPos:Number; + for (var i:int=0; i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/components/AssetsSummary.mxml ---------------------------------------------------------------------- diff --git a/MobileTrader/src/components/AssetsSummary.mxml b/MobileTrader/src/components/AssetsSummary.mxml new file mode 100644 index 0000000..01c7bb9 --- /dev/null +++ b/MobileTrader/src/components/AssetsSummary.mxml @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/controller/Feed.as ---------------------------------------------------------------------- diff --git a/MobileTrader/src/controller/Feed.as b/MobileTrader/src/controller/Feed.as new file mode 100644 index 0000000..41b56eb --- /dev/null +++ b/MobileTrader/src/controller/Feed.as @@ -0,0 +1,143 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// +/** + * Christophe Coenraets, http://coenraets.org + */ +package controller +{ + import flash.events.TimerEvent; + import flash.utils.Dictionary; + import flash.utils.Timer; + import model.Stock; + import mx.collections.ArrayCollection; + + public class Feed + { + protected var index:int = 0; + + protected var updateOrder:Array = [6,4,1,7,0,3,2,5]; // used to simulated randomness of updates + + protected var timer:Timer; + + protected var stockMap:Dictionary; + + [Bindable] + public var stockList:ArrayCollection; + + public function Feed() + { + stockMap = new Dictionary(); + stockList = new ArrayCollection(); + + stockList.addItem(new Stock("XOM", 81.39)); + stockList.addItem(new Stock("WMT", 51.47)); + stockList.addItem(new Stock("CVX", 102.93)); + stockList.addItem(new Stock("AIG", 36.01)); + stockList.addItem(new Stock("IBM", 155.49)); + stockList.addItem(new Stock("SAP", 57.53)); + stockList.addItem(new Stock("MOT", 41.50)); + stockList.addItem(new Stock("MCD", 73)); + + var stockCount:int = stockList.length; + + for (var k:int = 0; k < stockCount; k++) + { + var s:Stock = stockList.getItemAt(k) as Stock; + s.open = s.last; + s.high = s.last; + s.low = s.last; + s.change = 0; + stockMap[s.symbol] = s; + } + + // Simulate history for the last 2 minutes + for (var i:int=0; i < 120 ; i++) + { + for (var j:int=0 ; j= stockList.length) index = 0; + simulateChange(stockList.getItemAt(updateOrder[index]) as Stock, true); + index++; + } + + protected function simulateChange(stock:Stock, removeFirst:Boolean = true):void + { + var maxChange:Number = stock.open * 0.005; + var change:Number = maxChange - Math.random() * maxChange * 2; + + change = change == 0 ? 0.01 : change; + + var newValue:Number = stock.last + change; + + if (newValue > stock.open * 1.15 || newValue < stock.open * 0.85) + { + change = -change; + newValue = stock.last + change; + } + + stock.change = change; + stock.last = newValue; + + if (stock.last > stock.high) + { + stock.high = stock.last; + } + else if (stock.last < stock.low || stock.low == 0) + { + stock.low = stock.last; + } + + if (!stock.history) + { + stock.history = new ArrayCollection(); + } + if (removeFirst) + { + stock.history.removeItemAt(0); + } + stock.history.addItem({high: stock.high, low: stock.low, open: stock.open, last: stock.last}); + } + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/model/Stock.as ---------------------------------------------------------------------- diff --git a/MobileTrader/src/model/Stock.as b/MobileTrader/src/model/Stock.as new file mode 100644 index 0000000..832eacf --- /dev/null +++ b/MobileTrader/src/model/Stock.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. +// +//////////////////////////////////////////////////////////////////////////////// +/** + * Christophe Coenraets, http://coenraets.org + */ +package model +{ + import mx.collections.ArrayCollection; + + [Bindable] + public class Stock + { + public var symbol:String; + public var name:String; + public var low:Number; + public var high:Number; + public var open:Number; + public var last:Number; + public var change:Number = 0; + public var date:Date; + + public var history:ArrayCollection; + + public function Stock(symbol:String, last:Number) + { + this.symbol = symbol; + this.last = last; + } + + } + +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/renderers/AssetSummaryRenderer.mxml ---------------------------------------------------------------------- diff --git a/MobileTrader/src/renderers/AssetSummaryRenderer.mxml b/MobileTrader/src/renderers/AssetSummaryRenderer.mxml new file mode 100644 index 0000000..e28772b --- /dev/null +++ b/MobileTrader/src/renderers/AssetSummaryRenderer.mxml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/renderers/StockRenderer.as ---------------------------------------------------------------------- diff --git a/MobileTrader/src/renderers/StockRenderer.as b/MobileTrader/src/renderers/StockRenderer.as new file mode 100644 index 0000000..16981c6 --- /dev/null +++ b/MobileTrader/src/renderers/StockRenderer.as @@ -0,0 +1,134 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// +/** + * Christophe Coenraets, http://coenraets.org + */ +package renderers +{ + import flashx.textLayout.formats.VerticalAlign; + + import mx.formatters.NumberFormatter; + import mx.graphics.SolidColor; + import mx.states.SetStyle; + + import spark.components.Group; + import spark.components.HGroup; + import spark.components.Image; + import spark.components.Label; + import spark.components.LabelItemRenderer; + import spark.primitives.Rect; + + public class StockRenderer extends LabelItemRenderer + { + public var hGroup:HGroup; + public var symbolLabel:Label; + public var openLabel:Label; + public var lastLabel:Label; + public var highLabel:Label; + public var lowLabel:Label; + public var chartIcon:Image; + + [Embed("assets/chart_icon.png")] + private var chartIconClass:Class; + + protected var nf:NumberFormatter = new NumberFormatter(); + + public function StockRenderer() + { + super(); + nf.precision = 2; + } + + override public function set data(value:Object):void + { + super.data = value; + if (!value) return; + symbolLabel.text = value.symbol; + openLabel.text = nf.format(value.open); + lastLabel.text = nf.format(value.last); + if (value.change < 0) + lastLabel.setStyle("color", 0xFF0000); + else + lastLabel.setStyle("color", 0x006600); + highLabel.text = nf.format(value.high); + lowLabel.text = nf.format(value.low); + } + + override protected function createChildren():void { + if (!hGroup) + { + hGroup = new HGroup(); + hGroup.paddingLeft = 10; + hGroup.paddingRight = 10; + hGroup.verticalAlign = "middle"; + addChild(hGroup); + } + + if (!symbolLabel) { + symbolLabel = new Label(); + symbolLabel.percentWidth = 100; + hGroup.addElement(symbolLabel); + } + if (!openLabel) { + openLabel = new Label(); + openLabel.percentWidth = 100; + openLabel.setStyle("textAlign", "right"); + hGroup.addElement(openLabel); + } + if (!lastLabel) { + lastLabel = new Label(); + lastLabel.percentWidth = 100; + lastLabel.setStyle("textAlign", "right"); + hGroup.addElement(lastLabel); + } + if (!highLabel) { + highLabel = new Label(); + highLabel.percentWidth = 100; + highLabel.setStyle("textAlign", "right"); + hGroup.addElement(highLabel); + } + if (!lowLabel) { + lowLabel = new Label(); + lowLabel.percentWidth = 100; + lowLabel.setStyle("textAlign", "right"); + hGroup.addElement(lowLabel); + } + if (!chartIcon) { + chartIcon = new Image(); + chartIcon.source = chartIconClass; + hGroup.addElement(chartIcon); + } + + + } + + // Override layoutContents() to lay out the HGroup container. + override protected function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void + { + // Make sure our width/height is in the min/max for the label + var childWidth:Number = unscaledWidth - 6; + childWidth = Math.max(hGroup.getMinBoundsWidth(), Math.min(hGroup.getMaxBoundsWidth(), childWidth)); + var childHeight:Number = unscaledHeight - 10; + childHeight = Math.max(hGroup.getMinBoundsHeight(), Math.min(hGroup.getMaxBoundsHeight(), childHeight)); + // Set the label's position and size + hGroup.setLayoutBoundsSize(childWidth, childHeight); + hGroup.setLayoutBoundsPosition(3, 5); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/skins/ActionBarSkin.mxml ---------------------------------------------------------------------- diff --git a/MobileTrader/src/skins/ActionBarSkin.mxml b/MobileTrader/src/skins/ActionBarSkin.mxml new file mode 100644 index 0000000..593ae0c --- /dev/null +++ b/MobileTrader/src/skins/ActionBarSkin.mxml @@ -0,0 +1,67 @@ + + + + + + + [HostComponent("spark.components.ActionBar")] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/skins/ListHeaderButtonSkin.mxml ---------------------------------------------------------------------- diff --git a/MobileTrader/src/skins/ListHeaderButtonSkin.mxml b/MobileTrader/src/skins/ListHeaderButtonSkin.mxml new file mode 100644 index 0000000..8b81dcb --- /dev/null +++ b/MobileTrader/src/skins/ListHeaderButtonSkin.mxml @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/skins/ListHeaderButtonSkinRightAlign.mxml ---------------------------------------------------------------------- diff --git a/MobileTrader/src/skins/ListHeaderButtonSkinRightAlign.mxml b/MobileTrader/src/skins/ListHeaderButtonSkinRightAlign.mxml new file mode 100644 index 0000000..9bf3311 --- /dev/null +++ b/MobileTrader/src/skins/ListHeaderButtonSkinRightAlign.mxml @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b2f1e508/MobileTrader/src/styles.css ---------------------------------------------------------------------- diff --git a/MobileTrader/src/styles.css b/MobileTrader/src/styles.css new file mode 100644 index 0000000..f205870 --- /dev/null +++ b/MobileTrader/src/styles.css @@ -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. + */ +@namespace "library://ns.adobe.com/flex/spark"; + +ActionBar +{ + skinClass: ClassReference("skins.ActionBarSkin"); +} + +TabbedViewNavigatorApplication +{ + backgroundColor: #000000; +} + +View +{ + backgroundColor: #DCDCDC; +} + +List +{ + alternatingItemColors: #F0F0F0,#DCDCDC; + +} + +global +{ + fontSize: 20; +}