1.1 --- a/modules/lib.charting/src/org/aiotrade/lib/charting/view/ChartView.scala Sun Nov 08 04:27:59 2009 +0800
1.2 +++ b/modules/lib.charting/src/org/aiotrade/lib/charting/view/ChartView.scala Sun Nov 08 05:39:49 2009 +0800
1.3 @@ -78,7 +78,10 @@
1.4 *
1.5 * @author Caoyuan Deng
1.6 */
1.7 -abstract class ChartView(protected var controller: ChartingController, protected var mainSer: TSer, empty: Boolean) extends {
1.8 +abstract class ChartView(protected var controller: ChartingController,
1.9 + protected var mainSer: TSer,
1.10 + empty: Boolean
1.11 +) extends {
1.12 val AXISX_HEIGHT = 12
1.13 val AXISY_WIDTH = 50
1.14 val CONTROL_HEIGHT = 12
1.15 @@ -339,7 +342,7 @@
1.16 }
1.17
1.18 def isPinned: Boolean = {
1.19 - pinned;
1.20 + pinned
1.21 }
1.22
1.23 def setYChartScale(yChartScale: Float) {
1.24 @@ -366,7 +369,7 @@
1.25 datumPane.growYChartScale(increment)
1.26 }
1.27
1.28 - repaint();
1.29 + repaint()
1.30 }
1.31
1.32 def setYChartScaleByCanvasValueRange(canvasValueRange: Double) {
1.33 @@ -384,7 +387,7 @@
1.34 datumPane.scrollChartsVerticallyByPixel(increment)
1.35 }
1.36
1.37 - repaint();
1.38 + repaint()
1.39 }
1.40
1.41 /**
1.42 @@ -510,7 +513,7 @@
1.43
1.44 notifyObserversChanged(classOf[ChartValidityObserver[Any]])
1.45
1.46 - repaint();
1.47 + repaint()
1.48 }
1.49
1.50 def removeOverlappingCharts(ser: TSer) {
1.51 @@ -533,7 +536,7 @@
1.52
1.53 notifyObserversChanged(classOf[ChartValidityObserver[Any]])
1.54
1.55 - repaint();
1.56 + repaint()
1.57 }
1.58
1.59 def computeMaxMin {
1.60 @@ -547,11 +550,13 @@
1.61 /** this method only process FinishedComputing event, if you want more, do it in subclass */
1.62 protected def updateView(evt: SerChangeEvent) {
1.63 if (evt.tpe == SerChangeEvent.Type.FinishedComputing) {
1.64 - if (this.isInstanceOf[WithDrawingPane]) {
1.65 - val drawing = ChartView.this.asInstanceOf[WithDrawingPane].getSelectedDrawing
1.66 + ChartView.this match {
1.67 + case drawPane: WithDrawingPane =>
1.68 + val drawing = drawPane.getSelectedDrawing
1.69 if (drawing != null && drawing.isInDrawing) {
1.70 - return;
1.71 + return
1.72 }
1.73 + case _ =>
1.74 }
1.75
1.76 notifyObserversChanged(classOf[ChartValidityObserver[Any]])
1.77 @@ -594,7 +599,7 @@
1.78 }
1.79
1.80 /** precess event's call back */
1.81 - evt.callBack
1.82 + evt.callBack()
1.83 }
1.84 }
1.85 }
2.1 --- a/modules/lib.charting/src/org/aiotrade/lib/charting/view/ChartViewContainer.scala Sun Nov 08 04:27:59 2009 +0800
2.2 +++ b/modules/lib.charting/src/org/aiotrade/lib/charting/view/ChartViewContainer.scala Sun Nov 08 05:39:49 2009 +0800
2.3 @@ -52,9 +52,9 @@
2.4 */
2.5 abstract class ChartViewContainer extends JPanel {
2.6
2.7 + private val descriptorsWithSlaveView = new HashMap[IndicatorDescriptor, ChartView]
2.8 private var controller: ChartingController = _
2.9 private var masterView: ChartView = _
2.10 - private val descriptorsWithSlaveView = new HashMap[IndicatorDescriptor, ChartView]
2.11 /**
2.12 * each viewContainer can only contains one selectedChart, so we define it here instead of
2.13 * on ChartView or ChartPane;
3.1 --- a/modules/lib.charting/src/org/aiotrade/lib/charting/view/ChartingController.scala Sun Nov 08 04:27:59 2009 +0800
3.2 +++ b/modules/lib.charting/src/org/aiotrade/lib/charting/view/ChartingController.scala Sun Nov 08 05:39:49 2009 +0800
3.3 @@ -76,11 +76,11 @@
3.4
3.5 def setOnCalendarMode(b: Boolean): Unit
3.6
3.7 - def setCursorByRow(referRow: Int, rightRow: Int, updateViews: Boolean): Unit
3.8 + def setCursorByRow(referRow: Int, rightRow: Int, willUpdateViews: Boolean): Unit
3.9
3.10 - def setReferCursorByRow(Row: Int, updateViews: Boolean): Unit
3.11 + def setReferCursorByRow(Row: Int, willUpdateViews: Boolean): Unit
3.12
3.13 - def scrollReferCursor(increment: Int, updateViews: Boolean): Unit
3.14 + def scrollReferCursor(increment: Int, willUpdateViews: Boolean): Unit
3.15
3.16 /** keep refer cursor stay on same x of screen, and scroll charts left or right by bar */
3.17 def scrollChartsHorizontallyByBar(increment: Int): Unit
4.1 --- a/modules/lib.charting/src/org/aiotrade/lib/charting/view/IndicatorChartView.scala Sun Nov 08 04:27:59 2009 +0800
4.2 +++ b/modules/lib.charting/src/org/aiotrade/lib/charting/view/IndicatorChartView.scala Sun Nov 08 05:39:49 2009 +0800
4.3 @@ -51,8 +51,10 @@
4.4 *
4.5 * @author Caoyuan Deng
4.6 */
4.7 -class IndicatorChartView(controller: ChartingController, mainSer: TSer, empty: Boolean)
4.8 -extends ChartView(controller, mainSer, empty) {
4.9 +class IndicatorChartView(controller: ChartingController,
4.10 + mainSer: TSer,
4.11 + empty: Boolean
4.12 +) extends ChartView(controller, mainSer, empty) {
4.13
4.14 def this(controller: ChartingController, mainSer: TSer) = this(controller, mainSer, false)
4.15 def this() = this(null, null, true)
4.16 @@ -172,14 +174,12 @@
4.17 while (i <= getNBars) {
4.18 val time = tb(i)
4.19 val item = mainSer.itemOf(time)
4.20 - if (item != null) {
4.21 - for (v <- mainSer.vars) {
4.22 - if (v.plot != Plot.None) {
4.23 - val value = item.getFloat(v)
4.24 - if (Null.not(value)) {
4.25 - maxValue1 = Math.max(maxValue1, value)
4.26 - minValue1 = Math.min(minValue1, value)
4.27 - }
4.28 + if (mainSer.exists(time)) {
4.29 + for (v <- mainSer.vars if v.plot != Plot.None) {
4.30 + val value = item.getFloat(v)
4.31 + if (Null.not(value)) {
4.32 + maxValue1 = Math.max(maxValue1, value)
4.33 + minValue1 = Math.min(minValue1, value)
4.34 }
4.35 }
4.36 }
5.1 --- a/modules/lib.charting/src/org/aiotrade/lib/charting/view/PopupIndicatorChartView.scala Sun Nov 08 04:27:59 2009 +0800
5.2 +++ b/modules/lib.charting/src/org/aiotrade/lib/charting/view/PopupIndicatorChartView.scala Sun Nov 08 05:39:49 2009 +0800
5.3 @@ -40,8 +40,10 @@
5.4 *
5.5 * @author Caoyuan Deng
5.6 */
5.7 -class PopupIndicatorChartView(controller: ChartingController, mainSer: TSer, empty: Boolean)
5.8 -extends IndicatorChartView(controller, mainSer, empty) {
5.9 +class PopupIndicatorChartView(controller: ChartingController,
5.10 + mainSer: TSer,
5.11 + empty: Boolean
5.12 +) extends IndicatorChartView(controller, mainSer, empty) {
5.13
5.14 def this(controller: ChartingController, mainSer: TSer) = this(controller, mainSer, false)
5.15 def this() = this(null, null, true)
6.1 --- a/modules/lib.chartview/src/org/aiotrade/lib/chartview/AbstractQuoteChartView.scala Sun Nov 08 04:27:59 2009 +0800
6.2 +++ b/modules/lib.chartview/src/org/aiotrade/lib/chartview/AbstractQuoteChartView.scala Sun Nov 08 05:39:49 2009 +0800
6.3 @@ -70,13 +70,15 @@
6.4
6.5 }
6.6
6.7 -abstract class AbstractQuoteChartView(controller: ChartingController, quoteSer: QuoteSer, empty: Boolean)
6.8 -extends ChartView(controller, quoteSer, empty) with WithQuoteChart {
6.9 - import AbstractQuoteChartView._
6.10 -
6.11 - private var quoteChart: QuoteChart = _
6.12 +abstract class AbstractQuoteChartView(controller: ChartingController,
6.13 + quoteSer: QuoteSer,
6.14 + empty: Boolean
6.15 +) extends {
6.16 + private var quoteChart: QuoteChart = _
6.17 protected var maxVolume, minVolume: Float = _
6.18 protected var sec: Sec = _
6.19 +} with ChartView(controller, quoteSer, empty) with WithQuoteChart {
6.20 + import AbstractQuoteChartView._
6.21
6.22 def this(controller: ChartingController, quoteSer: QuoteSer) = this(controller, quoteSer, false)
6.23 def this() = this(null, null, true)
7.1 --- a/modules/lib.chartview/src/org/aiotrade/lib/chartview/AnalysisChartViewContainer.scala Sun Nov 08 04:27:59 2009 +0800
7.2 +++ b/modules/lib.chartview/src/org/aiotrade/lib/chartview/AnalysisChartViewContainer.scala Sun Nov 08 05:39:49 2009 +0800
7.3 @@ -70,23 +70,23 @@
7.4 /** use two list to record the active indicators and their order(index) for later showing */
7.5 val indicatorDescriptorsToBeShowing = new ArrayList[IndicatorDescriptor]
7.6 val indicatorsToBeShowing = new ArrayList[Indicator]
7.7 - for (descriptor <- getController.getContents.lookupDescriptors(classOf[IndicatorDescriptor])) {
7.8 - if (descriptor.active && descriptor.freq.equals(getController.getMasterSer.freq)) {
7.9 - descriptor.serviceInstance(getController.getMasterSer) foreach {indicator =>
7.10 - /**
7.11 - * @NOTICE
7.12 - * As the quoteSer may has been loaded, there may be no more UpdatedEvent
7.13 - * etc. fired, so, computeFrom(0) first.
7.14 - */
7.15 - indicator.computableActor ! ComputeFrom(0) // don't remove me
7.16 + for (descriptor <- getController.getContents.lookupDescriptors(classOf[IndicatorDescriptor])
7.17 + if descriptor.active && descriptor.freq == getController.getMasterSer.freq
7.18 + ) {
7.19 + descriptor.serviceInstance(getController.getMasterSer) foreach {indicator =>
7.20 + /**
7.21 + * @NOTICE
7.22 + * As the quoteSer may has been loaded, there may be no more UpdatedEvent
7.23 + * etc fired, so, computeFrom(0) first.
7.24 + */
7.25 + indicator.computableActor ! ComputeFrom(0) // don't remove me
7.26
7.27 - if (indicator.isOverlapping) {
7.28 - addSlaveView(descriptor, indicator, null)
7.29 - } else {
7.30 - /** To get the extract size of slaveViews to be showing, store them first, then add them later */
7.31 - indicatorDescriptorsToBeShowing += descriptor
7.32 - indicatorsToBeShowing += indicator
7.33 - }
7.34 + if (indicator.isOverlapping) {
7.35 + addSlaveView(descriptor, indicator, null)
7.36 + } else {
7.37 + /** To get the extract size of slaveViews to be showing, store them first, then add them later */
7.38 + indicatorDescriptorsToBeShowing += descriptor
7.39 + indicatorsToBeShowing += indicator
7.40 }
7.41 }
7.42 }
7.43 @@ -98,11 +98,11 @@
7.44 addSlaveView(indicatorDescriptorsToBeShowing(i), indicatorsToBeShowing(i), gbc)
7.45 }
7.46
7.47 - for (descriptor <- getController.getContents.lookupDescriptors(classOf[DrawingDescriptor])) {
7.48 - if (descriptor.freq.equals(getController.getMasterSer.freq)) {
7.49 - descriptor.serviceInstance(getMasterView) foreach {drawing =>
7.50 - getMasterView.asInstanceOf[WithDrawingPane].addDrawing(descriptor, drawing)
7.51 - }
7.52 + for (descriptor <- getController.getContents.lookupDescriptors(classOf[DrawingDescriptor])
7.53 + if descriptor.freq == getController.getMasterSer.freq
7.54 + ) {
7.55 + descriptor.serviceInstance(getMasterView) foreach {drawing =>
7.56 + getMasterView.asInstanceOf[WithDrawingPane].addDrawing(descriptor, drawing)
7.57 }
7.58 }
7.59 }
8.1 --- a/modules/lib.chartview/src/org/aiotrade/lib/chartview/AnalysisQuoteChartView.scala Sun Nov 08 04:27:59 2009 +0800
8.2 +++ b/modules/lib.chartview/src/org/aiotrade/lib/chartview/AnalysisQuoteChartView.scala Sun Nov 08 05:39:49 2009 +0800
8.3 @@ -67,31 +67,34 @@
8.4 quoteChartType = AbstractQuoteChartView.internal_switchAllQuoteChartType(quoteChartType, tpe)
8.5 }
8.6 }
8.7 -class AnalysisQuoteChartView(controller: ChartingController, quoteSer: QuoteSer, empty: Boolean)
8.8 -extends AbstractQuoteChartView(controller, quoteSer, empty) with WithDrawingPane {
8.9 +class AnalysisQuoteChartView(controller: ChartingController,
8.10 + quoteSer: QuoteSer,
8.11 + empty: Boolean
8.12 +) extends {
8.13 + private var compareIndicatorToChart: HashMap[QuoteCompareIndicator, QuoteChart] = _
8.14 + private var withDrawingPaneHelper: WithDrawingPaneHelper = _
8.15 +} with AbstractQuoteChartView(controller, quoteSer, empty) with WithDrawingPane {
8.16 import AnalysisQuoteChartView._
8.17
8.18 - private var compareIndicatorToChart: HashMap[QuoteCompareIndicator, QuoteChart] = _
8.19 -
8.20 - /**
8.21 - * To avoid null withDrawingPaneHelper when getSelectedDrawing called by other
8.22 - * threads (such as dataLoadServer is running and fire a SerChangeEvent
8.23 - * to force a updateView() calling), we should create withDrawingPaneHelper here
8.24 - * (this will makes it be called before the code:
8.25 - * this.mainSer.addSerChangeListener(serChangeListener);
8.26 - * in it's super's constructor: @See:ChartView#ChartView(ChartViewContainer, Ser)
8.27 - */
8.28 - private val withDrawingPaneHelper: WithDrawingPaneHelper = new WithDrawingPaneHelper(this)
8.29 -
8.30 def this(controller: ChartingController, quoteSer: QuoteSer) = this(controller, quoteSer, false)
8.31 def this() = this(null, null, true)
8.32
8.33 override def init(controller: ChartingController, quoteSer: TSer) {
8.34 - super.init(controller, quoteSer)
8.35 -
8.36 quoteChartType = LookFeel().getQuoteChartType
8.37
8.38 compareIndicatorToChart = new HashMap
8.39 +
8.40 + /**
8.41 + * To avoid null withDrawingPaneHelper when getSelectedDrawing called by other
8.42 + * threads (such as dataLoadServer is running and fire a SerChangeEvent
8.43 + * to force a updateView() calling), we should create withDrawingPaneHelper before super.init call
8.44 + * (this will makes it be called before the code:
8.45 + * this.mainSer.addSerChangeListener(serChangeListener)
8.46 + * in it's super's constructor: @See:ChartView#ChartView(ChartViewContainer, Ser)
8.47 + */
8.48 + withDrawingPaneHelper = new WithDrawingPaneHelper(this)
8.49 +
8.50 + super.init(controller, quoteSer)
8.51 }
8.52
8.53 protected def initComponents {
9.1 --- a/modules/lib.chartview/src/org/aiotrade/lib/chartview/RealTimeChartViewContainer.scala Sun Nov 08 04:27:59 2009 +0800
9.2 +++ b/modules/lib.chartview/src/org/aiotrade/lib/chartview/RealTimeChartViewContainer.scala Sun Nov 08 05:39:49 2009 +0800
9.3 @@ -54,7 +54,7 @@
9.4 import RealTimeChartViewContainer._
9.5
9.6 override def init(focusableParent: Component, controller: ChartingController) {
9.7 - super.init(focusableParent, controller);
9.8 + super.init(focusableParent, controller)
9.9
9.10 //getController().setOnCalendarMode(false);
9.11 //getController().growWBar(-2);
10.1 --- a/modules/lib.chartview/src/org/aiotrade/lib/chartview/RealTimeQuoteChartView.scala Sun Nov 08 04:27:59 2009 +0800
10.2 +++ b/modules/lib.chartview/src/org/aiotrade/lib/chartview/RealTimeQuoteChartView.scala Sun Nov 08 05:39:49 2009 +0800
10.3 @@ -63,15 +63,17 @@
10.4
10.5 }
10.6
10.7 -class RealTimeQuoteChartView(controller: ChartingController, quoteSer: QuoteSer, empty: Boolean)
10.8 -extends AbstractQuoteChartView(controller, quoteSer, empty) {
10.9 - import RealTimeQuoteChartView._
10.10 -
10.11 +class RealTimeQuoteChartView(controller: ChartingController,
10.12 + quoteSer: QuoteSer,
10.13 + empty: Boolean
10.14 +) extends {
10.15 private var prevClose = Null.Float
10.16 private var gridValues: Array[Float] = _
10.17 private var tickerSer: QuoteSer = _
10.18 private val cal = Calendar.getInstance
10.19 private var market: Market = _
10.20 +} with AbstractQuoteChartView(controller, quoteSer, empty) {
10.21 + import RealTimeQuoteChartView._
10.22
10.23 def this(controller: ChartingController, quoteSer: QuoteSer) = this(controller, quoteSer, false)
10.24 def this() = this(null, null, true)
10.25 @@ -207,7 +209,7 @@
10.26 var lastOccurredTime = masterSer.lastOccurredTime
10.27
10.28 evt.lastObject match {
10.29 - case null =>
10.30 + case null =>
10.31 case ticker: Ticker =>
10.32 val percentValue = ticker.changeInPercent
10.33 val strValue = ("%+3.2f%% " format percentValue) + ticker(Ticker.LAST_PRICE)