List of usage examples for org.jfree.data.general SeriesChangeEvent getSource
public Object getSource()
From source file:org.trade.ui.chart.CandlestickChart.java
/** * Method seriesChanged./*from w w w .j a v a 2 s . c om*/ * * @param event * SeriesChangeEvent * @see org.jfree.data.general.SeriesChangeListener#seriesChanged(SeriesChangeEvent) */ public void seriesChanged(SeriesChangeEvent event) { Object series = event.getSource(); if (series instanceof CandleSeries) { CandleSeries candleSeries = (CandleSeries) series; if (!candleSeries.isEmpty()) { CombinedDomainXYPlot combinedXYplot = (CombinedDomainXYPlot) this.chart.getPlot(); @SuppressWarnings("unchecked") List<XYPlot> subplots = combinedXYplot.getSubplots(); XYPlot xyplot = subplots.get(0); CandleItem candleItem = (CandleItem) candleSeries.getDataItem(candleSeries.getItemCount() - 1); String msg = "Time: " + dateFormat.format(candleItem.getLastUpdateDate()) + " Open: " + new Money(candleItem.getOpen()) + " High: " + new Money(candleItem.getHigh()) + " Low: " + new Money(candleItem.getLow()) + " Close: " + new Money(candleItem.getClose()) + " Vwap: " + new Money(candleItem.getVwap()); titleLegend2.setText(msg); valueMarker.setValue(candleItem.getClose()); double x = TradingCalendar .getSpecificTime(candleSeries.getStartTime(), candleItem.getPeriod().getStart()).getTime(); String annotationText = "(" + dateFormat.format(candleItem.getLastUpdateDate()) + ", " + new Money(candleItem.getClose()) + ")"; if (null == closePriceLine) { closePriceLine = new XYTextAnnotation(annotationText, x, candleItem.getY()); closePriceLine.setTextAnchor(TextAnchor.BOTTOM_RIGHT); xyplot.addAnnotation(closePriceLine); xyplot.addRangeMarker(valueMarker); } else { closePriceLine.setText(annotationText); closePriceLine.setX(x); closePriceLine.setY(candleItem.getY()); } this.chart.fireChartChanged(); } } }