Example usage for org.jfree.chart.event ChartChangeEventType NEW_DATASET

List of usage examples for org.jfree.chart.event ChartChangeEventType NEW_DATASET

Introduction

In this page you can find the example usage for org.jfree.chart.event ChartChangeEventType NEW_DATASET.

Prototype

ChartChangeEventType NEW_DATASET

To view the source code for org.jfree.chart.event ChartChangeEventType NEW_DATASET.

Click Source Link

Document

NEW_DATASET.

Usage

From source file:net.sf.maltcms.chromaui.charts.format.ScaledNumberFormatter.java

/**
 *
 * @param cce/*w  w w.  jav  a  2 s . 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();
                }
            }
        }
    }
}