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

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

Introduction

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

Prototype

public void setDescription(String description) 

Source Link

Document

Sets the description of the series and sends a PropertyChangeEvent to all registered listeners.

Usage

From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV2.EICPlot.java

void updateData(@Nonnull List<BetterPeak> peaks, @Nonnull List<BetterComponent> modelPeaks) {
    xyDataset.removeAllSeries();/*from   w w  w . j av  a  2 s.co  m*/
    toolTips.clear();

    int seriesID = 0;
    for (BetterPeak peak : peaks) {
        XYSeries series = new XYSeries(seriesID++);
        series.setDescription(PeakType.SIMPLE.name());

        for (int i = 0; i < peak.chromatogram.length; ++i)
            series.add(peak.chromatogram.getRetTime(i), peak.chromatogram.getIntensity(i));

        xyDataset.addSeries(series);
        toolTips.add(String.format("M/z: %.2f\nIntensity: %.0f", peak.getMZ(), peak.getIntensity()));
    }

    for (BetterPeak peak : modelPeaks) {
        XYSeries series = new XYSeries((seriesID++));
        series.setDescription(PeakType.MODEL.name());

        for (int i = 0; i < peak.chromatogram.length; ++i)
            series.add(peak.chromatogram.getRetTime(i), peak.chromatogram.getIntensity(i));

        xyDataset.addSeries(series);
        toolTips.add(
                String.format("Model peak\nM/z: %.2f\nIntensity: %.0f", peak.getMZ(), peak.getIntensity()));
    }
}

From source file:org.spantus.exp.segment.draw.AbstractGraphGenerator.java

protected XYSeries newSeries(String name, XYSeriesCollection collection) {
    XYSeries series = new XYSeries(name);
    series.setDescription(name);
    collection.addSeries(series);//  w  w  w.  j a  v a 2s  . c  o m
    return series;
}

From source file:org.gwaspi.reports.GenericReportGenerator.java

public static XYDataset getSampleHetzygDataset(SampleQAHetzygPlotZoom sampleQAHetzygPlotZoom,
        OperationKey operationKey) throws IOException {

    XYDataset resultXYDataset;/*from w ww. j  a  va 2s. co m*/

    QASamplesOperationDataSet qaSamplesOpDS = (QASamplesOperationDataSet) OperationManager
            .generateOperationDataSet(operationKey);

    OperationMetadata rdOPMetadata = getOperationService().getOperationMetadata(operationKey);

    Map<Integer, SampleKey> samples = qaSamplesOpDS.getSamplesKeysSource().getIndicesMap();
    List<Double> hetzyRatios = (List) qaSamplesOpDS.getHetzyRatios(-1, -1);
    List<Double> missingRatios = (List) qaSamplesOpDS.getMissingRatios(-1, -1);

    //<editor-fold defaultstate="expanded" desc="BUILD XYDataset">
    XYSeries dataSeries = new XYSeries("");

    int count = 0;
    Map<String, SampleKey> samplesLabeler = new LinkedHashMap<String, SampleKey>();
    for (SampleKey tmpSampleKey : samples.values()) {
        double tmpHetzyVal = hetzyRatios.get(count);
        double tmpMissratVal = missingRatios.get(count);
        if (Double.isNaN(tmpHetzyVal) || Double.isInfinite(tmpHetzyVal)) {
            tmpHetzyVal = 0;
        }
        if (Double.isNaN(tmpMissratVal) || Double.isInfinite(tmpMissratVal)) {
            tmpMissratVal = 0;
        }

        dataSeries.add(tmpHetzyVal, tmpMissratVal);
        samplesLabeler.put(count + "_" + tmpMissratVal + "_" + tmpHetzyVal, tmpSampleKey);
        count++;
    }
    sampleQAHetzygPlotZoom.setLabelerMap(samplesLabeler);

    dataSeries.setDescription(rdOPMetadata.getDescription());

    resultXYDataset = new XYSeriesCollection(dataSeries);
    //</editor-fold>

    return resultXYDataset;
}

From source file:sim.app.sugarscape.util.ResultsGrapher.java

public ResultsGrapher(String resultsfile, String config, String sweep) {
    //System.out.println("starting...");
    output_params_map = new Hashtable(10);
    loadConfigFile(config);/*  www  .ja  v  a 2s  .  c  o  m*/
    this.resultsfile = resultsfile;
    raw = new ArrayList(200);
    ArrayList xp = new ArrayList(10); //number of lines/series
    try {
        File f = new File(resultsfile);
        FileReader fr = new FileReader(f);
        BufferedReader br = new BufferedReader(fr);
        String line = br.readLine();
        String var = null;

        //get the field names
        ArrayList a = new ArrayList(10);
        StringTokenizer st0 = new StringTokenizer(line, ",");
        while (st0.hasMoreTokens()) {
            a.add(st0.nextToken());
        }
        int size = a.size();
        fields = new String[size];

        for (int b = 0; b < size; b++) {
            fields[b] = (String) a.get(b);
            if (fields[b].compareToIgnoreCase(x_axis_fieldname) == 0) {
                x_axis_index = b;
            } else if (fields[b].compareToIgnoreCase(y_axis_fieldname) == 0) {
                y_axis_index = b;
            } else if (fields[b].compareToIgnoreCase(x_param_fieldname) == 0) {
                x_param_index = b;
            } else if (fields[b].compareToIgnoreCase("time") == 0) {
                time_index = b;
            } else if (fields[b].compareToIgnoreCase("run") == 0) {
                run_index = b;
                //System.out.println(run_index + " = run_index");
            } //else if (fields[b].)
        }
        if ((x_axis_index == -1) || (y_axis_index == -1)) {
            System.err.println("Missing an axis variable as specified in " + config);
            System.exit(1);
        }

        int counter = 0;
        float val;
        long time_val;
        int run_val = 0;
        int line_number = -1;
        Double x_axis_val = null;
        Double y_axis_val = null;

        Hashtable h = new Hashtable(100);
        ArrayList params = new ArrayList(100);
        timezero = new DuplicatesHashtable(100, 100);
        nonzero = new DuplicatesHashtable(100, 100);
        while ((line = br.readLine()) != null) {
            line_number++;
            if (line.startsWith("run")) {
                continue;
            }
            //raw.add(line);
            counter = 0;
            time_val = -1;
            run_val = -1;
            StringTokenizer st = new StringTokenizer(line, ",");
            while (st.hasMoreTokens()) {
                var = st.nextToken();
                val = Float.parseFloat(var);
                if (counter == time_index) {
                    time_val = Math.round(Double.parseDouble(var));
                } else if (counter == run_index) {
                    run_val = Math.round(Float.parseFloat(var));
                } else if (counter == y_axis_index) {
                    y_axis_val = Double.valueOf(var);
                } else if (counter == x_axis_index) {
                    x_axis_val = Double.valueOf(var);
                }
                counter++;

            }
            if (time_val != 0) {
                nonzero.put(new Integer(run_val), y_axis_val);
            } else {
                timezero.put(new Integer(run_val), x_axis_val);
            }
            //System.out.println(line);
        }

        System.out.println("Finished loading results file.");
        //System.out.println("x_param_fieldname = " + x_param_fieldname);
        //System.out.println("x_axis_fieldname = " + x_axis_fieldname);
        //System.out.println("y_axis_fieldname = " + y_axis_fieldname);
        loadSweepFile(sweep);
        int sweep_map = -1;
        int sweep_map_xaxis = -1;
        int sweep_map_yaxis = -1;

        for (int d = 0; d < sweep_vars.size(); d++) {
            //System.out.print( ((String)sweep_vars.get(d))+ " ");
            if (((String) sweep_vars.get(d)).compareToIgnoreCase(x_param_fieldname) == 0) {
                sweep_map = d;
            } else if (((String) sweep_vars.get(d)).compareToIgnoreCase(x_axis_fieldname) == 0) {
                sweep_map_xaxis = d;
            } else if (((String) sweep_vars.get(d)).compareToIgnoreCase(y_axis_fieldname) == 0) {
                sweep_map_yaxis = d;
            }
        }

        //Identify the runs for each level of sweep_var
        int[] sweeps = buildSeries(sweep_map);
        int[] uniq_vals = getUniqueIntVals(sweeps);
        int[][] series = new int[uniq_vals.length][sweeps.length / uniq_vals.length];
        //System.out.println("+++"+uniq_vals.length);
        int counter2 = 0;
        for (int d = 0; d < series.length; d++) {
            for (int e = 0; e < sweeps.length / uniq_vals.length; e++) {
                //series[d][e] = ((int[])sweep_vals.get(counter2))[sweep_map_xaxis];
                //System.out.print(series[d][e] + " ");
                //counter2++;
            }
            //System.out.println();
        }
        counter2 = 0;
        ArrayList[] sweep_xprecise = new ArrayList[uniq_vals.length];
        //new ArrayList(sweep_vals.size());
        for (int k = 0; k < series.length; k++) {
            sweep_xprecise[k] = new ArrayList(10);
            for (int g = 0; g < sweeps.length / uniq_vals.length; g++) {
                sweep_xprecise[k].add(sweep_vals.get(counter2));
                counter2++;
            }
        }
        FastQSortAlgorithm fast = new FastQSortAlgorithm();
        DualDoubleArrayFastQSort dual = new DualDoubleArrayFastQSort();

        double[][] sweep_x = new double[series.length][sweeps.length / uniq_vals.length];
        double[][] sweep_y = new double[series.length][sweeps.length / uniq_vals.length];
        for (int j = 0; j < series.length; j++) {
            fast.sort(series[j], sweep_xprecise[j]);

            for (int i = 0; i < sweep_xprecise[j].size(); i++) {

                Integer run = new Integer(((int[]) sweep_xprecise[j].get(i))[run_index]);

                ArrayList run_y = nonzero.get(run);
                ArrayList run_x = timezero.get(run);

                int sz = run_y.size();
                double total_y = 0d;
                double total_x = 0d;
                for (int m = 0; m < sz; m++) {
                    total_y = total_y + ((Double) run_y.get(m)).doubleValue();
                    total_x = total_x + ((Double) run_x.get(m)).doubleValue();
                }
                double y_avg = total_y / sz;
                double x_avg = total_x / sz;

                sweep_y[j][i] = y_avg;
                sweep_x[j][i] = x_avg;
            }
            dual.sort(sweep_x[j], sweep_y[j]);
            //System.out.println();
        }
        //now build the graphical series
        String label = x_param_fieldname + "=";
        XYSeries[] all_xyseries = new XYSeries[series.length];

        for (int n = 0; n < series.length; n++) {
            XYSeries xys = new XYSeries("");
            if (PARAMETERIZED_AVERAGES) {
                xys.setDescription(label + (n + 1));
                //xys.setName(label+(n+1));
            } else {
                xys.setDescription(label + uniq_vals[n]);
                //xys.setName(label+uniq_vals[n]);
            }

            for (int o = 0; o < sweep_x[n].length; o++) {
                xys.add(sweep_x[n][o], sweep_y[n][o]);
                //System.out.println(first_letter+uniq_vals[n] + " " + sweep_x[n][o] + " " + sweep_y[n][o]);
            }
            all_xyseries[n] = xys;
            //System.out.println(xys.getName());
        }
        buildGraphics(all_xyseries);
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:org.gwaspi.reports.GenericReportGenerator.java

public static XYDataset getManhattanZoomByChrAndPos(ManhattanPlotZoom manhattanPlotZoom, OperationKey testOpKey,
        ChromosomeKey chr, MarkerKey markerKey, long requestedPhysPos, long requestedPosWindow) {
    XYDataset resultXYDataset = null;/*from   www.  j a  v a  2s.c o  m*/

    try {
        // ESTIMATE WINDOW SIZE
        Long minPosition;
        Long maxPosition;
        if (markerKey == null) {
            minPosition = requestedPhysPos;
            maxPosition = minPosition + requestedPosWindow;
        } else {
            final Long middlePosition = requestedPhysPos;
            minPosition = Math.round(middlePosition - (double) requestedPosWindow / 2);
            maxPosition = minPosition + requestedPosWindow;
        }

        Map<MarkerKey, Object[]> markerKeyChrPosPVal;

        CommonTestOperationDataSet<? extends TrendTestOperationEntry> testOpDS = (CommonTestOperationDataSet<? extends TrendTestOperationEntry>) OperationManager
                .generateOperationDataSet(testOpKey);
        Iterator<MarkerMetadata> markersMetadatasIt = testOpDS.getMarkersMetadatasSource().iterator();
        Iterator<Double> psIt = testOpDS.getPs(-1, -1).iterator();
        markerKeyChrPosPVal = new LinkedHashMap<MarkerKey, Object[]>(testOpDS.getNumMarkers());
        for (MarkerKey curMarkerKey : testOpDS.getMarkersKeysSource()) {
            Double pValue = psIt.next();
            MarkerMetadata markerMetadata = markersMetadatasIt.next();
            String curChr = markerMetadata.getChr();
            int curPos = markerMetadata.getPos();
            if (!curChr.equals(chr.toString()) || (curPos >= minPosition) || (curPos <= maxPosition)) {
                continue;
            }
            if (pValue.isNaN() || pValue.isInfinite()) { // Ignore invalid P-Values
                pValue = null;
            }
            Object[] data = new Object[] { markerMetadata.getChr(), markerMetadata.getPos(), pValue };
            markerKeyChrPosPVal.put(curMarkerKey, data);
        }

        //<editor-fold defaultstate="expanded" desc="BUILD XYDataset">
        XYSeries dataSeries = new XYSeries("");

        Map<String, MarkerKey> labeler = new LinkedHashMap<String, MarkerKey>();
        for (Map.Entry<MarkerKey, Object[]> entry : markerKeyChrPosPVal.entrySet()) {
            MarkerKey tmpMarker = entry.getKey();
            Object[] data = entry.getValue(); // CHR, POS, PVAL

            int position = (Integer) data[1];
            double pVal = 1;
            if (data[2] != null) {
                pVal = (Double) data[2]; // Is allready free of NaN
            }

            if (pVal < 1 && !Double.isInfinite(pVal)) {
                dataSeries.add(position, pVal);
                labeler.put(chr + "_" + position, tmpMarker);
                //labeler.put(key, "");
            }
        }
        manhattanPlotZoom.setLabelerMap(labeler);

        dataSeries.setDescription("Zoom chr " + chr + " from position " + minPosition + " to " + maxPosition);

        resultXYDataset = new XYSeriesCollection(dataSeries);
        //</editor-fold>
    } catch (IOException ex) {
        log.error(null, ex);
    }

    return resultXYDataset;
}

From source file:org.jfree.data.xy.junit.XYSeriesCollectionTests.java

/**
 * Confirm that cloning works.// w w  w .  j  a va 2s.c om
 */
public void testCloning() {
    XYSeries s1 = new XYSeries("Series");
    s1.add(1.0, 1.1);
    XYSeriesCollection c1 = new XYSeriesCollection();
    c1.addSeries(s1);
    XYSeriesCollection c2 = null;
    try {
        c2 = (XYSeriesCollection) c1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(c1 != c2);
    assertTrue(c1.getClass() == c2.getClass());
    assertTrue(c1.equals(c2));

    // check independence
    s1.setDescription("XYZ");
    assertFalse(c1.equals(c2));
}

From source file:org.jfree.data.xy.XYSeriesCollectionTest.java

/**
 * Confirm that cloning works./*from  w w w.j  a  v  a  2s .c  om*/
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    XYSeries s1 = new XYSeries("Series");
    s1.add(1.0, 1.1);
    XYSeriesCollection c1 = new XYSeriesCollection();
    c1.addSeries(s1);
    XYSeriesCollection c2 = (XYSeriesCollection) c1.clone();
    assertNotSame(c1, c2);
    assertSame(c1.getClass(), c2.getClass());
    assertEquals(c1, c2);

    // check independence
    s1.setDescription("XYZ");
    assertFalse(c1.equals(c2));
}

From source file:org.jfree.data.xy.junit.XYSeriesCollectionTest.java

/**
 * Confirm that cloning works.//from   w ww  .j a  v  a  2  s . co m
 */
public void testCloning() {
    XYSeries s1 = new XYSeries("Series");
    s1.add(1.0, 1.1);
    XYSeriesCollection c1 = new XYSeriesCollection();
    c1.addSeries(s1);
    XYSeriesCollection c2 = null;
    try {
        c2 = (XYSeriesCollection) c1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
        assertTrue(false);
        return;
    }
    assertTrue(c1 != c2);
    assertTrue(c1.getClass() == c2.getClass());
    assertTrue(c1.equals(c2));

    // check independence
    s1.setDescription("XYZ");
    assertFalse(c1.equals(c2));
}

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

private boolean plotCorrectionData() {
    plot3d.removeAllPlots();//from w w  w.j  av  a 2 s  . c o m
    XYSeries series;
    XYPlot plot = chartPanel.getChart().getXYPlot();
    XYSeriesCollection lineDataset = (XYSeriesCollection) plot.getDataset(0);
    DecimalFormat df = new DecimalFormat(".00");
    String val;
    int i = 0;
    int j = 0;
    if (!Utils.isTableEmpty(corrTable)) {
        try {
            for (i = 1; i < corrTable.getColumnCount(); ++i) {
                val = corrTable.getValueAt(0, i).toString();
                series = new XYSeries(df.format(Double.valueOf(val)));
                for (j = 1; j < corrTable.getRowCount(); ++j) {
                    if (corrTable.getValueAt(j, i) != null) {
                        val = corrTable.getValueAt(j, i).toString();
                        if (!val.isEmpty())
                            series.add(Double.valueOf(corrTable.getValueAt(j, 0).toString()),
                                    Double.valueOf(val));
                    }
                }
                if (series.getItemCount() > 0) {
                    corrData.add(series);
                    series.setDescription(series.getKey().toString());
                    lineDataset.addSeries(series);
                }
            }
            plot.getDomainAxis(0).setAutoRange(true);
            plot.getRangeAxis(0).setAutoRange(true);
            plot.getDomainAxis(0).setLabel(xAxisName);
            plot.getRangeAxis(0).setLabel(yAxisName);
            plot.getRenderer(0).setSeriesVisible(0, false);

            double[] x = new double[xAxisArray.size()];
            for (i = 0; i < xAxisArray.size(); ++i)
                x[i] = xAxisArray.get(i);
            double[] y = new double[yAxisArray.size()];
            for (i = 0; i < yAxisArray.size(); ++i)
                y[i] = yAxisArray.get(i);
            double[][] z = Utils.doubleZArray(corrTable, x, y);
            Color[][] colors = Utils.generateTableColorMatrix(corrTable, 1, 1);
            plot3d.addGridPlot("Average Error % Plot", colors, x, y, z);
        } catch (NumberFormatException e) {
            logger.error(e);
            JOptionPane.showMessageDialog(null,
                    "Error parsing number from " + corrTableName + " table, cell(" + i + " : " + j + "): " + e,
                    "Error", JOptionPane.ERROR_MESSAGE);
            return false;
        }
    }
    return true;
}

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

private void loadLogFile() {
    fileChooser.setMultiSelectionEnabled(false);
    if (JFileChooser.APPROVE_OPTION != fileChooser.showOpenDialog(this))
        return;/*from  w w  w . j  a 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));
    }
}