Search in sources :

Example 1 with ScanDataSet

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet in project mzmine2 by mzmine.

the class ScanFilterSetupDialog method loadPreview.

/**
 * This function set all the information into the plot chart
 *
 * @param scanNumber
 */
protected void loadPreview(SpectraPlot spectrumPlot, Scan previewScan) {
    Scan newScan = rawDataFilter.filterScan(previewScan, filterParameters);
    ScanDataSet spectraDataSet = new ScanDataSet("Filtered scan", newScan);
    ScanDataSet spectraOriginalDataSet = new ScanDataSet("Original scan", previewScan);
    spectrumPlot.removeAllDataSets();
    spectrumPlot.addDataSet(spectraOriginalDataSet, SpectraVisualizerWindow.scanColor, true);
    spectrumPlot.addDataSet(spectraDataSet, Color.green, true);
    // if the scan is centroided, switch to centroid mode
    spectrumPlot.setPlotMode(previewScan.getSpectrumType());
}
Also used : ScanDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet) Scan(net.sf.mzmine.datamodel.Scan)

Example 2 with ScanDataSet

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet in project mzmine2 by mzmine.

the class DPPResultsLabelGenerator method generateLabel.

/**
 * @see org.jfree.chart.labels.XYItemLabelGenerator#generateLabel(org.jfree.data.xy.XYDataset,
 *      int, int)
 */
public String generateLabel(XYDataset dataset, int series, int item) {
    // X and Y values of current data point
    double originalX = dataset.getX(series, item).doubleValue();
    double originalY = dataset.getY(series, item).doubleValue();
    // Calculate data size of 1 screen pixel
    double xLength = (double) plot.getXYPlot().getDomainAxis().getRange().getLength();
    double pixelX = xLength / plot.getWidth();
    // Size of data set
    int itemCount = dataset.getItemCount(series);
    // Search for data points higher than this one in the interval
    // from limitLeft to limitRight
    double limitLeft = originalX - ((POINTS_RESERVE_X / 2) * pixelX);
    double limitRight = originalX + ((POINTS_RESERVE_X / 2) * pixelX);
    // Iterate data points to the left and right
    for (int i = 1; (item - i > 0) || (item + i < itemCount); i++) {
        // If we get out of the limit we can stop searching
        if ((item - i > 0) && (dataset.getXValue(series, item - i) < limitLeft) && ((item + i >= itemCount) || (dataset.getXValue(series, item + i) > limitRight)))
            break;
        if ((item + i < itemCount) && (dataset.getXValue(series, item + i) > limitRight) && ((item - i <= 0) || (dataset.getXValue(series, item - i) < limitLeft)))
            break;
        // If we find higher data point, bail out
        if ((item - i > 0) && (originalY <= dataset.getYValue(series, item - i)))
            return null;
        if ((item + i < itemCount) && (originalY <= dataset.getYValue(series, item + i)))
            return null;
    }
    // Create label
    String label = null;
    if (dataset instanceof ScanDataSet) {
        label = ((ScanDataSet) dataset).getAnnotation(item);
    } else if (dataset instanceof DPPResultsDataSet) {
        DataPoint[] dps = ((DPPResultsDataSet) dataset).getDataPoints();
        if (dps[item] instanceof ProcessedDataPoint) {
            ProcessedDataPoint p = (ProcessedDataPoint) dps[item];
            label = createLabel(p);
        }
    }
    if (label == null || label.equals("")) {
        double mzValue = dataset.getXValue(series, item);
        label = mzFormat.format(mzValue);
    }
    return label;
}
Also used : ScanDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet) ProcessedDataPoint(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint) ProcessedDataPoint(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 3 with ScanDataSet

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet in project mzmine2 by mzmine.

the class ShoulderPeaksFilterSetupDialog method loadPreview.

/**
 * This function set all the information into the plot chart
 *
 * @param scanNumber
 */
protected void loadPreview(SpectraPlot spectrumPlot, Scan previewScan) {
    // Remove previous data sets
    spectrumPlot.removeAllDataSets();
    // Add scan data set
    ScanDataSet scanDataSet = new ScanDataSet(previewScan);
    spectrumPlot.addDataSet(scanDataSet, SpectraVisualizerWindow.scanColor, false);
    // If the scan is centroided, switch to centroid mode
    spectrumPlot.setPlotMode(previewScan.getSpectrumType());
    // If the parameters are not complete, exit
    ArrayList<String> errors = new ArrayList<String>();
    boolean paramsOK = parameters.checkParameterValues(errors);
    if (!paramsOK)
        return;
    // Get mass list
    String massListName = parameters.getParameter(ShoulderPeaksFilterParameters.massList).getValue();
    MassList massList = previewScan.getMassList(massListName);
    if (massList == null)
        return;
    // Perform filtering
    DataPoint[] mzValues = massList.getDataPoints();
    DataPoint[] remainingMzValues = ShoulderPeaksFilter.filterMassValues(mzValues, parameters);
    Vector<DataPoint> removedPeaks = new Vector<DataPoint>();
    removedPeaks.addAll(Arrays.asList(mzValues));
    removedPeaks.removeAll(Arrays.asList(remainingMzValues));
    DataPoint[] removedMzValues = removedPeaks.toArray(new DataPoint[0]);
    // Add mass list data sets
    DataPointsDataSet removedPeaksDataSet = new DataPointsDataSet("Removed peaks", removedMzValues);
    DataPointsDataSet remainingPeaksDataSet = new DataPointsDataSet("Remaining peaks", remainingMzValues);
    spectrumPlot.addDataSet(removedPeaksDataSet, removedPeaksColor, false);
    spectrumPlot.addDataSet(remainingPeaksDataSet, SpectraVisualizerWindow.peaksColor, false);
}
Also used : ScanDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet) DataPoint(net.sf.mzmine.datamodel.DataPoint) ArrayList(java.util.ArrayList) Vector(java.util.Vector) MassList(net.sf.mzmine.datamodel.MassList) DataPointsDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.DataPointsDataSet)

Example 4 with ScanDataSet

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet in project mzmine2 by mzmine.

the class SpectraPlot method addDataSet.

// add Dataset with label generator
public synchronized void addDataSet(XYDataset dataSet, Color color, boolean transparency, XYItemLabelGenerator labelGenerator) {
    XYItemRenderer newRenderer;
    if (dataSet instanceof ScanDataSet) {
        ScanDataSet scanDataSet = (ScanDataSet) dataSet;
        Scan scan = scanDataSet.getScan();
        if (scan.getSpectrumType() == MassSpectrumType.CENTROIDED)
            newRenderer = new PeakRenderer(color, transparency);
        else {
            newRenderer = new ContinuousRenderer(color, transparency);
            ((ContinuousRenderer) newRenderer).setDefaultShapesVisible(dataPointsVisible);
        }
        // Add label generator for the dataset
        newRenderer.setDefaultItemLabelGenerator(labelGenerator);
        newRenderer.setDefaultItemLabelsVisible(itemLabelsVisible);
        newRenderer.setDefaultItemLabelPaint(labelsColor);
    } else {
        newRenderer = new PeakRenderer(color, transparency);
        // Add label generator for the dataset
        newRenderer.setDefaultItemLabelGenerator(labelGenerator);
        newRenderer.setDefaultItemLabelsVisible(itemLabelsVisible);
        newRenderer.setDefaultItemLabelPaint(labelsColor);
    }
    plot.setDataset(numOfDataSets, dataSet);
    plot.setRenderer(numOfDataSets, newRenderer);
    numOfDataSets++;
    if (dataSet instanceof ScanDataSet)
        checkAndRunController();
}
Also used : ScanDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet) ContinuousRenderer(net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.ContinuousRenderer) Scan(net.sf.mzmine.datamodel.Scan) PeakRenderer(net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.PeakRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer)

Example 5 with ScanDataSet

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet in project mzmine2 by mzmine.

the class SpectraPlot method setPlotMode.

/**
 * This will set either centroid or continuous renderer to the first data set, assuming that
 * dataset with index 0 contains the raw data.
 */
public void setPlotMode(MassSpectrumType plotMode) {
    this.plotMode = plotMode;
    XYDataset dataSet = plot.getDataset(0);
    if (!(dataSet instanceof ScanDataSet))
        return;
    XYItemRenderer newRenderer;
    if (plotMode == MassSpectrumType.CENTROIDED) {
        newRenderer = new PeakRenderer(SpectraVisualizerWindow.scanColor, false);
    } else {
        newRenderer = new ContinuousRenderer(SpectraVisualizerWindow.scanColor, false);
        ((ContinuousRenderer) newRenderer).setDefaultShapesVisible(dataPointsVisible);
    }
    // Add label generator for the dataset
    SpectraItemLabelGenerator labelGenerator = new SpectraItemLabelGenerator(this);
    newRenderer.setDefaultItemLabelGenerator(labelGenerator);
    newRenderer.setDefaultItemLabelsVisible(itemLabelsVisible);
    newRenderer.setDefaultItemLabelPaint(labelsColor);
    plot.setRenderer(0, newRenderer);
}
Also used : ScanDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet) ContinuousRenderer(net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.ContinuousRenderer) SpectraItemLabelGenerator(net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.SpectraItemLabelGenerator) XYDataset(org.jfree.data.xy.XYDataset) PeakRenderer(net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.PeakRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer)

Aggregations

ScanDataSet (net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet)10 Scan (net.sf.mzmine.datamodel.Scan)5 DataPoint (net.sf.mzmine.datamodel.DataPoint)4 ContinuousRenderer (net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.ContinuousRenderer)3 PeakRenderer (net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.PeakRenderer)3 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)3 ArrayList (java.util.ArrayList)2 DataPointsDataSet (net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.DataPointsDataSet)2 SpectraItemLabelGenerator (net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.SpectraItemLabelGenerator)2 XYDataset (org.jfree.data.xy.XYDataset)2 Color (java.awt.Color)1 NumberFormat (java.text.NumberFormat)1 Vector (java.util.Vector)1 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)1 MassList (net.sf.mzmine.datamodel.MassList)1 DataPointProcessingController (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingController)1 DataPointProcessingManager (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingManager)1 MSLevel (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.MSLevel)1 ProcessedDataPoint (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint)1 IsotopesDataSet (net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.IsotopesDataSet)1