Example usage for org.jfree.data.xy XYSeries fireSeriesChanged

List of usage examples for org.jfree.data.xy XYSeries fireSeriesChanged

Introduction

In this page you can find the example usage for org.jfree.data.xy XYSeries fireSeriesChanged.

Prototype

public void fireSeriesChanged() 

Source Link

Document

General method for signalling to registered listeners that the series has been changed.

Usage

From source file:com.bdb.weather.display.preferences.ColorPreferencePanel.java

private void createSeriesData() {
    for (int i = 0; i < dataset.getSeriesCount(); i++) {
        XYSeries series = dataset.getSeries(i);
        series.clear();/*from w  ww. j  ava  2  s .co m*/
        for (int j = 0; j < 360; j++) {
            series.add(j / 360.0, Math.sin(Math.toRadians(j + (i * (360.0 / dataset.getSeriesCount())))),
                    false);
        }
        series.fireSeriesChanged();
    }
}

From source file:com.anrisoftware.prefdialog.miscswing.multichart.freechart.FreechartXYChart.java

private void updateInsertData(int row0, int row1, int offset) {
    ChartModel model = this.model;
    XYSeriesCollection series = getCategory();
    for (int col = 0; col < series.getSeriesCount(); col++) {
        XYSeries xyseries = series.getSeries(col);
        for (int row = row0; row <= row1; row++) {
            xyseries.add(row, model.getValueAt(row, col), false);
        }// www .ja v a  2  s . c  o  m
        xyseries.fireSeriesChanged();
    }
}

From source file:P251.graphPanel.java

/**
   Adds data to the plot.  Checks that x,y are the same length
   and then adds them to the named series pairwise.
 *///from w w  w  . j a  va2 s .  co m
public void addData(double[] x, double[] y, String name) {

    XYSeries tmp_series;

    try {
        tmp_series = dataset.getSeries(name);
    } catch (org.jfree.data.UnknownKeyException e) {
        tmp_series = new XYSeries(name);
        dataset.addSeries(tmp_series);
    }

    System.out.println("spot 1");

    if (x.length != y.length) {
        System.out.println("sizes don't match");
        return;

    }
    for (int j = 0; j < x.length; ++j) {
        tmp_series.add(x[j], y[j], false);
    }
    tmp_series.fireSeriesChanged();

}

From source file:com.vgi.mafscaling.Rescale.java

private boolean setXYSeries(XYSeries series, ArrayList<Double> xarr, ArrayList<Double> yarr) {
    if (xarr.size() == 0 || xarr.size() != yarr.size())
        return false;
    series.clear();//from ww  w .ja v  a 2  s.co  m
    for (int i = 0; i < xarr.size(); ++i)
        series.add(xarr.get(i), yarr.get(i), false);
    series.fireSeriesChanged();
    return true;
}

From source file:P251.graphPanel.java

/**
   Bins and adds to the data series named name. if a data series
   with that name already exists,  if no
   series with name exists a new data series is created.
   Binning  is useful if/*  ww w.  j a  v a  2  s .c om*/
   there are many redundant points in the data.   
   The data is
   binned between [bottom,top). Data out side of this range are
   discarded.   Plots points at the center of bins that non-zero
   counts.
           
   @param data the x-coordinate data to be binned
   @param y the y coordinate of all of the data
   @param name name of the data series
   @param bottom the minimum value of the data to be binned, any
   data less than bottom is discarded
   @param top the maximum value of the data to be binned, any value
   equal to or greater than this value will be discarded
   @param binCount the number of bins to use, more bins gives finer resolution
        
   @see #addDataBinning(double x, double [] data, String name,double bottom, double top,int binCount)
        
           
 */
public void addDataBinning(double[] data, double y, String name, double bottom, double top, int binCount) {
    XYSeries tmp_series;

    try {
        tmp_series = dataset.getSeries(name);
    } catch (org.jfree.data.UnknownKeyException e) {
        tmp_series = new XYSeries(name);
        dataset.addSeries(tmp_series);
    }

    // add a catch here to deal with if the name is wrong

    // make histogram of values

    int hist[] = new int[binCount];
    for (double x : data) {
        // watch the logic here, protecting bounds
        if (x >= bottom && x < top) {
            ++hist[(int) Math.floor(binCount * x)];
        }
    }

    // pick out non-zero entries,add those entries to series
    for (int j = 0; j < binCount; ++j) {
        if (hist[j] > 0) {
            tmp_series.add(((double) j) / binCount + (top - bottom) / (2 * binCount), y, false);
        }
    }
    tmp_series.fireSeriesChanged();

}

From source file:P251.graphPanel.java

/**
   Bins and adds to the data series named name. if a data series
   with that name already exists,  if no
   series with name exists a new data series is created.
   Binning  is useful if/*from   w  ww.java2 s .c o m*/
   there are many redundant points in the data.   
   The data is
   binned between [bottom,top). Data out side of this range are
   discarded.   Plots points at the center of bins that non-zero
   counts.
        
   @param x the x coordinate of all of the data
   @param data the x-coordinate data to be binned
   @param name name of the data series
   @param bottom the minimum value of the data to be binned, any
   data less than bottom is discarded
   @param top the maximum value of the data to be binned, any value
   equal to or greater than this value will be discarded
   @param binCount the number of bins to use, more bins gives finer resolution
        
   @see #addDataBinning( double [] data, double y, String name,double bottom, double top,int binCount)
 */
public void addDataBinning(double x, double[] data, String name, double bottom, double top, int binCount) {
    XYSeries tmp_series;

    try {
        tmp_series = dataset.getSeries(name);
    } catch (org.jfree.data.UnknownKeyException e) {
        tmp_series = new XYSeries(name);
        dataset.addSeries(tmp_series);
    }

    // add a catch here to deal with if the name is wrong

    // make histogram of values

    int hist[] = new int[binCount];
    for (double val : data) {
        // watch the logic here, protecting bounds
        if (val >= bottom && val < top) {
            ++hist[(int) Math.floor(binCount * val)];
        }
    }

    // pick out non-zero entries,add those entries to series
    for (int j = 0; j < binCount; ++j) {
        if (hist[j] > 0) {
            tmp_series.add(x, ((double) j) / binCount + (top - bottom) / (2 * binCount), false);
        }
    }
    tmp_series.fireSeriesChanged();

}

From source file:com.vgi.mafscaling.LogView.java

private void updateChart() {
    if (logDataTable.getColumnCount() != dataset.getSeriesCount())
        return;//from  www.java  2 s .c  om
    Column col;
    String colName;
    String val;
    XYSeries series;
    int seriesIdx = 0;
    for (int i = 0; i < logDataTable.getColumnCount(); ++i) {
        int colIdx = logDataTable.getCurrentIndexForOriginalColumn(i);
        col = logDataTable.getColumn(colIdx);
        colName = col.getHeaderValue().toString();
        series = dataset.getSeries(seriesIdx++);
        if (!series.getDescription().equals(colName)) {
            JOptionPane.showMessageDialog(null,
                    "Invalid series found for the column index " + colIdx + ": series name "
                            + series.getDescription() + " doesn't match column name " + colName,
                    "Invalid value", JOptionPane.ERROR_MESSAGE);
            return;
        }
        series.clear();
        for (int j = 0; j < logDataTable.getRowCount(); ++j) {
            try {
                val = (String) logDataTable.getValueAt(j, colIdx);
                series.add(j, Double.valueOf(val), false);
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null,
                        "Invalid numeric value in column " + colName + ", row " + (j + 1), "Invalid value",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }
        }
        series.fireSeriesChanged();
    }
    chartPanel.repaint();
}

From source file:com.vgi.mafscaling.LogView.java

private void loadLogFile() {
    fileChooser.setMultiSelectionEnabled(false);
    if (JFileChooser.APPROVE_OPTION != fileChooser.showOpenDialog(this))
        return;//from   ww  w .ja v a 2  s  . c om
    // close log player
    if (logPlayWindow != null)
        disposeLogView();
    // process log file
    File file = fileChooser.getSelectedFile();
    Properties prop = new Properties();
    prop.put("delimiter", ",");
    prop.put("firstRowHasColumnNames", "true");
    setCursor(new Cursor(Cursor.WAIT_CURSOR));
    logDataTable.filter(null);
    filterText.setText("");
    try {
        for (int i = 0; i < logDataTable.getColumnCount(); ++i)
            logDataTable.getTableHeader().removeMouseListener(
                    ((CheckboxHeaderRenderer) logDataTable.getColumn(i).getHeaderRenderer())
                            .getMouseListener());
        logDataTable.refresh(file.toURI().toURL(), prop);
        Column col;
        String colName;
        String lcColName;
        String val;
        CheckboxHeaderRenderer renderer;
        Component comp;
        XYSeries series;
        xAxisColumn.removeAllItems();
        yAxisColumn.removeAllItems();
        plotsColumn.removeAllItems();
        xAxisColumn.addItem("");
        yAxisColumn.addItem("");
        plotsColumn.setText("");
        plot3d.removeAllPlots();
        rpmDataset.removeAllSeries();
        dataset.removeAllSeries();
        xyMarker.clearLabels(true);
        rpmCol = -1;
        displCount = 0;
        selectionCombo.removeAllItems();
        listModel.removeAllElements();
        JTableHeader tableHeader = logDataTable.getTableHeader();
        for (int i = 0; i < logDataTable.getColumnCount(); ++i) {
            col = logDataTable.getColumn(i);
            renderer = new CheckboxHeaderRenderer(i + 1, tableHeader);
            col.setHeaderRenderer(renderer);
            colName = col.getHeaderValue().toString();
            xAxisColumn.addItem(colName);
            yAxisColumn.addItem(colName);
            plotsColumn.addItem(colName);
            comp = renderer.getTableCellRendererComponent(logDataTable.getTable(), colName, false, false, 0, 0);
            col.setPreferredWidth(comp.getPreferredSize().width + 4);
            series = new XYSeries(colName);
            series.setDescription(colName);
            lcColName = colName.toLowerCase();
            dataset.addSeries(series);
            plotRenderer.setSeriesShapesVisible(i, false);
            plotRenderer.setSeriesVisible(i, false);
            selectionCombo.addItem(colName);
            listModel.addElement(new JLabel(colName, renderer.getCheckIcon(), JLabel.LEFT));
            if (rpmDataset.getSeriesCount() == 0
                    && (lcColName.matches(".*rpm.*") || lcColName.matches(".*eng.*speed.*"))) {
                rpmDataset.addSeries(series);
                rpmPlotRenderer.setSeriesShapesVisible(0, false);
                rpmPlotRenderer.setSeriesVisible(0, false);
                rpmCol = i;
            }
            for (int j = 0; j < logDataTable.getRowCount(); ++j) {
                try {
                    val = (String) logDataTable.getValueAt(j, i);
                    series.add(j, Double.valueOf(val), false);
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null,
                            "Invalid numeric value in column " + colName + ", row " + (j + 1), "Invalid value",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }
            series.fireSeriesChanged();
        }
        if (logDataTable.getControlPanel().getComponentCount() > 7)
            logDataTable.getControlPanel().remove(7);
        logDataTable.getControlPanel().add(new JLabel("   [" + file.getName() + "]"));
        initColors();
    } catch (Exception ex) {
        ex.printStackTrace();
        logger.error(ex);
    } finally {
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }
}