List of usage examples for org.jfree.chart.event ChartChangeEvent getType
public ChartChangeEventType getType()
From source file:net.sf.maltcms.chromaui.charts.format.ScaledNumberFormatter.java
/** * * @param cce/*from w w w. ja v a 2s .c o m*/ */ @Override public void chartChanged(ChartChangeEvent cce) { ChartChangeEventType ccet = cce.getType(); if (ccet == ChartChangeEventType.DATASET_UPDATED || ccet == ChartChangeEventType.NEW_DATASET) { if (cce.getSource() != (this)) { Plot p = cce.getChart().getPlot(); if (p instanceof XYPlot) { XYPlot xyp = (XYPlot) p; Range axisRange = xyp.getRangeAxis().getRange(); ; if (relativeMode) { int cnt = xyp.getDatasetCount(); Range r = new Range(0, 1); for (int i = 0; i < cnt; i++) { Dataset d = xyp.getDataset(i); if (d != null && d instanceof XYDataset) { XYDataset xyd = (XYDataset) d; Range dr = DatasetUtilities.findRangeBounds(xyd); if (dr != null) { r = new Range(Math.min(r.getLowerBound(), dr.getLowerBound()), Math.max(r.getUpperBound(), dr.getUpperBound())); } } else { throw new NotImplementedException( "No support yet for dataset of type: " + d.getClass()); } } this.dataMin = Math.min(0, r.getLowerBound()); this.dataMax = r.getUpperBound(); cce.getChart().fireChartChanged(); } else { this.min = axisRange.getLowerBound(); this.max = axisRange.getUpperBound(); cce.getChart().fireChartChanged(); } } } } }
From source file:org.yccheok.jstock.gui.charting.InvestmentFlowChartJDialog.java
private void addChangeListener(ChartPanel chartPanel) { chartPanel.getChart().addChangeListener(new ChartChangeListener() { @Override//from w w w . j a v a 2 s . c o m public void chartChanged(ChartChangeEvent event) { if (event.getType() == ChartChangeEventType.GENERAL) { // Sequence is important. We will use invest information box as master. // ROI information box will be adjusted accordingly. investmentFlowLayerUI.updateInvestPoint(); investmentFlowLayerUI.updateROIPoint(); } } }); }
From source file:com.android.ddmuilib.log.event.EventDisplay.java
Control createCompositeChart(final Composite parent, EventLogParser logParser, String title) { mChart = ChartFactory.createTimeSeriesChart(null, null /* timeAxisLabel */, null /* valueAxisLabel */, null, /* dataset. set below */ true /* legend */, false /* tooltips */, false /* urls */); // get the font to make a proper title. We need to convert the swt font, // into an awt font. Font f = parent.getFont();/*from w ww . j a v a2 s. c om*/ FontData[] fData = f.getFontData(); // event though on Mac OS there could be more than one fontData, we'll only use // the first one. FontData firstFontData = fData[0]; java.awt.Font awtFont = SWTUtils.toAwtFont(parent.getDisplay(), firstFontData, true /* ensureSameSize */); mChart.setTitle(new TextTitle(title, awtFont)); final XYPlot xyPlot = mChart.getXYPlot(); xyPlot.setRangeCrosshairVisible(true); xyPlot.setRangeCrosshairLockedOnData(true); xyPlot.setDomainCrosshairVisible(true); xyPlot.setDomainCrosshairLockedOnData(true); mChart.addChangeListener(new ChartChangeListener() { @Override public void chartChanged(ChartChangeEvent event) { ChartChangeEventType type = event.getType(); if (type == ChartChangeEventType.GENERAL) { // because the value we need (rangeCrosshair and domainCrosshair) are // updated on the draw, but the notification happens before the draw, // we process the click in a future runnable! parent.getDisplay().asyncExec(new Runnable() { @Override public void run() { processClick(xyPlot); } }); } } }); mChartComposite = new ChartComposite(parent, SWT.BORDER, mChart, ChartComposite.DEFAULT_WIDTH, ChartComposite.DEFAULT_HEIGHT, ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH, ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT, 3000, // max draw width. We don't want it to zoom, so we put a big number 3000, // max draw height. We don't want it to zoom, so we put a big number true, // off-screen buffer true, // properties true, // save true, // print true, // zoom true); // tooltips mChartComposite.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { mValueTypeDataSetMap.clear(); mDataSetCount = 0; mOccurrenceDataSet = null; mChart = null; mChartComposite = null; mValueDescriptorSeriesMap.clear(); mOcurrenceDescriptorSeriesMap.clear(); } }); return mChartComposite; }
From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java
/** * Returns chart change listener, which will be responsible for handling * zooming event.//w ww . ja va 2s .co m * * @return chart change listener, which will be responsible for handling * zooming event */ private ChartChangeListener getChartChangeListner() { return new ChartChangeListener() { @Override public void chartChanged(ChartChangeEvent event) { // Is weird. This works well for zoom-in. When we add new CCI or // RIS. This event function will be triggered too. However, the // returned draw area will always be the old draw area, unless // you move your move over. // Even I try to capture event.getType() == ChartChangeEventType.NEW_DATASET // also doesn't work. if (event.getType() == ChartChangeEventType.GENERAL) { ChartJDialog.this.chartLayerUI.updateTraceInfos(); // Re-calculating high low value. ChartJDialog.this.updateHighLowJLabels(); } } }; }