Example usage for org.jfree.chart.event ChartChangeEvent getSource

List of usage examples for org.jfree.chart.event ChartChangeEvent getSource

Introduction

In this page you can find the example usage for org.jfree.chart.event ChartChangeEvent getSource.

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

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

/**
 *
 * @param cce/*from  w  w w. j  av a 2s  . c om*/
 */
@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();
                }
            }
        }
    }
}