List of usage examples for org.jfree.chart.event ChartChangeEventType DATASET_UPDATED
ChartChangeEventType DATASET_UPDATED
To view the source code for org.jfree.chart.event ChartChangeEventType DATASET_UPDATED.
Click Source Link
From source file:net.sf.maltcms.chromaui.charts.format.ScaledNumberFormatter.java
/** * * @param cce/*from w ww . 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.griphyn.vdl.karajan.monitor.monitors.swing.GraphPanel.java
private void createChart() { chart = ChartFactory.createTimeSeriesChart(null, "Time", null, null, false, false, false); cp = new ChartPanel(chart); // avoid stretching fonts and such cp.setMaximumDrawWidth(Integer.MAX_VALUE); cp.setMaximumDrawHeight(Integer.MAX_VALUE); XYPlot plot = chart.getXYPlot();/*w w w . ja v a2 s. c o m*/ plot.setBackgroundPaint(UIManager.getColor("TextField.background")); plot.setDomainCrosshairVisible(true); plot.setDomainCrosshairLockedOnData(false); cp.addChartMouseListener(this); cp.setLayout(new DummyLayoutManager()); cp.add(toolTip = new JToolTip()); toolTip.setVisible(false); cp.addMouseListener(new MouseAdapter() { @Override public void mouseExited(MouseEvent e) { disableToolTip(); } }); chart.addChangeListener(new ChartChangeListener() { @Override public void chartChanged(ChartChangeEvent e) { if (e.getType() == ChartChangeEventType.DATASET_UPDATED) { updateMaxRange(); updateToolTipLocation(); } } }); for (String s : enabled) { addSeries(sampler.getSeries(s)); } JPanel p = new JPanel(); p.setLayout(new BorderLayout()); p.add(cp, BorderLayout.CENTER); legend = new JPanel(); legend.setLayout(new FlowLayout()); rebuildLegend(); this.add(p, BorderLayout.CENTER); this.add(legend, BorderLayout.SOUTH); }
From source file:ucar.unidata.idv.control.chart.MyXYPlot.java
/** * Receives notification of a change to the plot's dataset. * <P>/*ww w. j a v a 2 s.c o m*/ * The axis ranges are updated if necessary. * * @param event information about the event (not used here). */ public void datasetChanged(DatasetChangeEvent event) { configureDomainAxes(); configureRangeAxes(); if (getParent() != null) { getParent().datasetChanged(event); } else { PlotChangeEvent e = new PlotChangeEvent(this); e.setType(ChartChangeEventType.DATASET_UPDATED); notifyListeners(e); } }