Example usage for org.jfree.data.general DatasetChangeEvent DatasetChangeEvent

List of usage examples for org.jfree.data.general DatasetChangeEvent DatasetChangeEvent

Introduction

In this page you can find the example usage for org.jfree.data.general DatasetChangeEvent DatasetChangeEvent.

Prototype

public DatasetChangeEvent(Object source, Dataset dataset) 

Source Link

Document

Constructs a new event.

Usage

From source file:net.sourceforge.jabm.view.BarChart.java

public void compute(ReportVariablesChangedEvent event) {
    computeVariableNames();/*  w w  w  .  j a va2s  .  co m*/
    final Dataset eventOriginator = this;
    try {
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                for (DatasetChangeListener listener : listeners) {
                    listener.datasetChanged(new DatasetChangeEvent(eventOriginator, eventOriginator));
                }
            }
        });
    } catch (InterruptedException e) {
        logger.warn(e);
        Thread.currentThread().interrupt();
    } catch (InvocationTargetException e) {
        logger.warn(e);
    }
}

From source file:net.sourceforge.jabm.view.TimeSeriesChart.java

/**
 * When this report is computed it notifies its listeners (typically
 * the JFreeChart swing component) that its data set has changed.
 *//*from   ww w . j av  a  2 s  .co  m*/
public void compute(ReportVariablesChangedEvent event) {
    final Dataset eventOriginator = this;
    for (DatasetChangeListener listener : listeners) {
        listener.datasetChanged(new DatasetChangeEvent(eventOriginator, eventOriginator));
    }
}

From source file:org.jfree.data.statistics.SimpleHistogramDataset.java

/**
 * Sets the flag that controls whether or not the bin count is divided by
 * the bin size in the {@link #getYValue(int, int)} method, and sends a
 * {@link DatasetChangeEvent} to all registered listeners.
 *
 * @param adjust  the flag./* w  w w . ja v a2s  .co m*/
 *
 * @see #getAdjustForBinSize()
 */
public void setAdjustForBinSize(boolean adjust) {
    this.adjustForBinSize = adjust;
    notifyListeners(new DatasetChangeEvent(this, this));
}

From source file:org.cds06.speleograph.GraphPanel.java

/**
 * Method called when a Series has changed in the application.
 *
 * @param event information about the event.
 *///w  ww .j  av  a  2  s  .com
@Override
public void datasetChanged(DatasetChangeEvent event) {
    for (int i = 0, max = plot.getDatasetCount(); i < max; i++) {
        plot.setDataset(i, null);
        plot.setRangeAxis(i, null);
        plot.setRenderer(i, null);
    }
    final ArrayList<NumberAxis> shownAxis = new ArrayList<>(series.size());
    for (final Series set : series) {
        if (set == null)
            continue;
        NumberAxis rangeAxis = set.getAxis();
        if (set.isShow()) {
            int id = series.indexOf(set);
            plot.setDataset(id, set);
            plot.setRenderer(id, set.getRenderer(), false);
            int index = shownAxis.indexOf(rangeAxis);
            if (index == -1) {
                shownAxis.add(rangeAxis);
                index = shownAxis.indexOf(rangeAxis);
                plot.setRangeAxis(index, rangeAxis, false);
                plot.setRangeAxisLocation(index, AxisLocation.BOTTOM_OR_LEFT);
            }
            plot.mapDatasetToRangeAxis(id, index);
            plot.getRenderer().setSeriesItemLabelsVisible(0, true, true);
            plot.datasetChanged(new DatasetChangeEvent(this, set));
        }
    }
    if (shownAxis.size() == 0) {
        setupEmptyChart();
    } else {
        plot.setDomainAxis(dateAxis);

    }
}

From source file:net.sourceforge.processdash.ui.lib.chart.DiscPlot.java

/**
 * Sets the dataset and sends a {@link DatasetChangeEvent} to 'this'.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 * /*w w  w  .j a va 2 s.c  o  m*/
 * @see #getDataset()
 */
public void setDataset(PieDataset dataset) {
    // if there is an existing dataset, remove the plot from the list of
    // change listeners...
    PieDataset existing = this.dataset;
    if (existing != null) {
        existing.removeChangeListener(this);
    }

    // set the new dataset, and register the chart as a change listener...
    this.dataset = dataset;
    if (dataset != null) {
        setDatasetGroup(dataset.getGroup());
        dataset.addChangeListener(this);
    }

    // tell the item distributor about the change
    if (discDistributor != null) {
        discDistributor.setDataset(dataset);
    }

    // send a dataset change event to self...
    DatasetChangeEvent event = new DatasetChangeEvent(this, dataset);
    datasetChanged(event);
}

From source file:sim.util.media.chart.ChartGenerator.java

/** Key must be 0 or higher.  Will update only if the key passed in is different
from the previously passed in key or if the key is FORCE_KEY.  
If newData is true, then the chart will also be written out to a movie if appropriate. */
public void update(long key, boolean newData) {
    if (key == oldKey && key != FORCE_KEY) // we already did it
        return;/* ww  w  .  j  av a  2  s  .  co m*/
    else {
        oldKey = key;
        update();

        if (newData)
            chart.getPlot().datasetChanged(new DatasetChangeEvent(chart.getPlot(), null));

        // now possibly write to the movie maker
        if (newData && movieMaker != null) {
            // add buffer to the movie maker
            movieMaker.add(getBufferedImage());
        }
    }
}

From source file:edu.gmu.cs.sim.util.media.chart.ChartGenerator.java

/** Key must be 0 or higher.  Will update only if the key passed in is different
 from the previously passed in key or if the key is FORCE_KEY.
 If newData is true, then the chart will also be written out to a movie if appropriate. */
public void update(long key, boolean newData) {
    if (key == oldKey && key != FORCE_KEY) // we already did it
    {//from   w  w w. ja v a2  s .  c o  m
        return;
    } else {
        oldKey = key;
        update();

        if (newData) {
            chart.getPlot().datasetChanged(new DatasetChangeEvent(chart.getPlot(), null));
        }

        // now possibly write to the movie maker
        if (newData && movieMaker != null) {
            // add buffer to the movie maker
            movieMaker.add(getBufferedImage());
        }
    }
}

From source file:ucar.unidata.idv.control.chart.MyTimeSeriesPlot.java

/**
 * ignore changes// ww w  . jav a2  s .  co  m
 *
 * @param b ignore changes_
 */
public void setIgnoreDataSetChanges(boolean b) {
    boolean fireChange = ((b != ignoreDataSetChanges) && !b);
    ignoreDataSetChanges = b;
    if (fireChange) {
        datasetChanged(new DatasetChangeEvent(this, getDataset()));
    }
}

From source file:org.jfree.data.general.AbstractDataset.java

/**
 * Notifies all registered listeners that the dataset has changed, 
 * provided that the <code>notify</code> flag has not been set to 
 * <code>false</code>.//from w  ww .j a va  2s .com
 *
 * @see #addChangeListener(DatasetChangeListener)
 */
protected void fireDatasetChanged() {
    if (this.notify) {
        notifyListeners(new DatasetChangeEvent(this, this));
    }
}

From source file:org.jfree.data.statistics.SimpleHistogramDataset.java

/**
 * Adds an observation to the dataset (by incrementing the item count for
 * the appropriate bin).  A runtime exception is thrown if the value does
 * not fit into any bin./* w ww .  ja va2s. c o m*/
 *
 * @param value  the value.
 * @param notify  send {@link DatasetChangeEvent} to listeners?
 */
public void addObservation(double value, boolean notify) {
    boolean placed = false;
    Iterator iterator = this.bins.iterator();
    while (iterator.hasNext() && !placed) {
        SimpleHistogramBin bin = (SimpleHistogramBin) iterator.next();
        if (bin.accepts(value)) {
            bin.setItemCount(bin.getItemCount() + 1);
            placed = true;
        }
    }
    if (!placed) {
        throw new RuntimeException("No bin.");
    }
    if (notify) {
        notifyListeners(new DatasetChangeEvent(this, this));
    }
}