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());
}
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;
}
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);
}
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();
}
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);
}
Aggregations