Search in sources :

Example 6 with BetterPeak

use of dulab.adap.datamodel.BetterPeak in project mzmine2 by mzmine.

the class EICPlot method updateData.

// public void updateData(@Nonnull List <List <NavigableMap <Double, Double>>> clusters,
// @Nonnull List <Double> colors,
// @Nonnull List <List <String>> info,
// @Nonnull List <List<Boolean>> models)
// {
// final float DEFAULT_LINE_WIDTH = 1.0f;
// final float THICK_LINE_WIDTH = 2.0f;
// 
// 
// // for (int i = 0; i < xyDataset.getSeriesCount(); ++i)
// // xyDataset.removeSeries(i);
// xyDataset.removeAllSeries();
// colorDataset.clear();
// toolTips.clear();
// widths.clear();
// 
// int seriesID = 0;
// 
// for (int i = 0; i < clusters.size(); ++i)
// {
// List <NavigableMap <Double, Double>> cluster = clusters.get(i);
// double color = colors.get(i);
// 
// for (int j = 0; j < cluster.size(); ++j)
// {
// XYSeries series = new XYSeries(seriesID++);
// 
// for (Entry <Double, Double> e : cluster.get(j).entrySet())
// series.add(e.getKey(), e.getValue());
// 
// float width = DEFAULT_LINE_WIDTH;
// if (models.get(i).get(j)) width = THICK_LINE_WIDTH;
// 
// xyDataset.addSeries(series);
// colorDataset.add(color);
// toolTips.add(info.get(i).get(j));
// widths.add(width);
// }
// }
// }
void updateData(@Nonnull List<BetterPeak> peaks, @Nonnull List<BetterComponent> modelPeaks) {
    xyDataset.removeAllSeries();
    xyDataset.setNotify(false);
    toolTips.clear();
    // Find retention-time range
    double startRetTime = Double.MAX_VALUE;
    double endRetTime = -Double.MAX_VALUE;
    for (BetterPeak peak : modelPeaks) {
        if (peak.getFirstRetTime() < startRetTime)
            startRetTime = peak.getFirstRetTime();
        if (peak.getLastRetTime() > endRetTime)
            endRetTime = peak.getLastRetTime();
    }
    if (endRetTime < startRetTime)
        return;
    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) {
            double retTime = peak.chromatogram.getRetTime(i);
            if (startRetTime <= retTime && retTime <= endRetTime)
                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()));
    }
    xyDataset.setNotify(true);
}
Also used : BetterPeak(dulab.adap.datamodel.BetterPeak) XYSeries(org.jfree.data.xy.XYSeries) Paint(java.awt.Paint)

Aggregations

BetterPeak (dulab.adap.datamodel.BetterPeak)6 RetTimeClusterer (dulab.adap.workflow.decomposition.RetTimeClusterer)3 Nonnull (javax.annotation.Nonnull)3 BetterComponent (dulab.adap.datamodel.BetterComponent)2 Chromatogram (dulab.adap.datamodel.Chromatogram)2 ComponentSelector (dulab.adap.workflow.decomposition.ComponentSelector)2 PeakList (net.sf.mzmine.datamodel.PeakList)2 XYSeries (org.jfree.data.xy.XYSeries)2 Sets (com.google.common.collect.Sets)1 PeakInfo (dulab.adap.datamodel.PeakInfo)1 java.awt (java.awt)1 Paint (java.awt.Paint)1 ActionEvent (java.awt.event.ActionEvent)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 javax.swing (javax.swing)1 DataPoint (net.sf.mzmine.datamodel.DataPoint)1 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)1