use of net.sf.mzmine.modules.visualization.tic.TICPlot in project mzmine2 by mzmine.
the class PeakResolverSetupDialog method addDialogComponents.
/**
* This function add all the additional components for this dialog over the original
* ParameterSetupDialog.
*/
@Override
protected void addDialogComponents() {
super.addDialogComponents();
final PeakList[] peakLists = MZmineCore.getProjectManager().getCurrentProject().getPeakLists();
// Elements of panel.
preview = new JCheckBox("Show preview");
preview.addActionListener(this);
preview.setHorizontalAlignment(SwingConstants.CENTER);
preview.setEnabled(peakLists.length > 0);
// Preview panel.
final JPanel previewPanel = new JPanel(new BorderLayout());
previewPanel.add(new JSeparator(), BorderLayout.NORTH);
previewPanel.add(preview, BorderLayout.CENTER);
previewPanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);
// Feature list combo-box.
comboPeakList = new JComboBox<PeakList>();
comboPeakList.setFont(COMBO_FONT);
for (final PeakList peakList : peakLists) {
if (peakList.getNumberOfRawDataFiles() == 1) {
comboPeakList.addItem(peakList);
}
}
comboPeakList.addActionListener(this);
// Peaks combo box.
comboPeak = new JComboBox<PeakListRow>();
comboPeak.setFont(COMBO_FONT);
comboPeak.setRenderer(new PeakPreviewComboRenderer());
comboPeak.setPreferredSize(new Dimension(PREFERRED_PEAK_COMBO_WIDTH, comboPeak.getPreferredSize().height));
pnlLabelsFields = GUIUtils.makeTablePanel(2, 2, new JComponent[] { new JLabel("Feature list"), comboPeakList, new JLabel("Chromatogram"), comboPeak });
// Put all together.
pnlVisible = new JPanel(new BorderLayout());
pnlVisible.add(previewPanel, BorderLayout.NORTH);
// TIC plot.
ticPlot = new TICPlot(this);
ticPlot.setMinimumSize(MINIMUM_TIC_DIMENSIONS);
// Tool bar.
final TICToolBar toolBar = new TICToolBar(ticPlot);
toolBar.getComponentAtIndex(0).setVisible(false);
// Panel for XYPlot.
pnlPlotXY = new JPanel(new BorderLayout());
pnlPlotXY.setBackground(Color.white);
pnlPlotXY.add(ticPlot, BorderLayout.CENTER);
pnlPlotXY.add(toolBar, BorderLayout.EAST);
GUIUtils.addMarginAndBorder(pnlPlotXY, 10);
mainPanel.add(pnlVisible, 0, getNumberOfParameters() + 3, 2, 1, 0, 0, GridBagConstraints.HORIZONTAL);
// Layout and position.
updateBounds();
}
use of net.sf.mzmine.modules.visualization.tic.TICPlot in project mzmine2 by mzmine.
the class MultiSpectraVisualizerWindow method addSpectra.
private JPanel addSpectra(int scan) {
JPanel panel = new JPanel(new BorderLayout());
// Split pane for eic plot (top) and spectrum (bottom)
JSplitPane bottomPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
// Create EIC plot
// labels for TIC visualizer
Map<Feature, String> labelsMap = new HashMap<Feature, String>(0);
Feature peak = row.getPeak(activeRaw);
// scan selection
ScanSelection scanSelection = new ScanSelection(activeRaw.getDataRTRange(1), 1);
// mz range
Range<Double> mzRange = null;
mzRange = peak.getRawDataPointsMZRange();
// optimize output by extending the range
double upper = mzRange.upperEndpoint();
double lower = mzRange.lowerEndpoint();
double fiveppm = (upper * 5E-6);
mzRange = Range.closed(lower - fiveppm, upper + fiveppm);
// labels
labelsMap.put(peak, peak.toString());
// get EIC window
TICVisualizerWindow window = new // raw
TICVisualizerWindow(// raw
new RawDataFile[] { activeRaw }, // plot type
TICPlotType.BASEPEAK, // scan selection
scanSelection, // mz range
mzRange, // selected features
new Feature[] { peak }, // labels
labelsMap);
// get EIC Plot
TICPlot ticPlot = window.getTICPlot();
ticPlot.setPreferredSize(new Dimension(600, 200));
ticPlot.getChart().getLegend().setVisible(false);
// add a retention time Marker to the EIC
ValueMarker marker = new ValueMarker(activeRaw.getScan(scan).getRetentionTime());
marker.setPaint(Color.RED);
marker.setStroke(new BasicStroke(3.0f));
XYPlot plot = (XYPlot) ticPlot.getChart().getPlot();
plot.addDomainMarker(marker);
bottomPane.add(ticPlot);
bottomPane.setResizeWeight(0.5);
bottomPane.setEnabled(true);
bottomPane.setDividerSize(5);
bottomPane.setDividerLocation(200);
JSplitPane spectrumPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
// get MS/MS spectra window
SpectraVisualizerWindow spectraWindow = new SpectraVisualizerWindow(activeRaw);
spectraWindow.loadRawData(activeRaw.getScan(scan));
// get MS/MS spectra plot
SpectraPlot spectrumPlot = spectraWindow.getSpectrumPlot();
spectrumPlot.getChart().getLegend().setVisible(false);
spectrumPlot.setPreferredSize(new Dimension(600, 400));
spectrumPane.add(spectrumPlot);
spectrumPane.add(spectraWindow.getToolBar());
spectrumPane.setResizeWeight(1);
spectrumPane.setEnabled(false);
spectrumPane.setDividerSize(0);
bottomPane.add(spectrumPane);
panel.add(bottomPane);
panel.setBorder(BorderFactory.createLineBorder(Color.black));
return panel;
}
use of net.sf.mzmine.modules.visualization.tic.TICPlot in project mzmine2 by mzmine.
the class KovatsIndexExtractionDialog method updateChart.
private void updateChart() {
updateParameterSetFromComponents();
if (selectedDataFile == null)
return;
try {
// old charts axes ranges
org.jfree.data.Range domainZoom = chart == null ? null : chart.getChart().getXYPlot().getDomainAxis().getRange();
org.jfree.data.Range rangeZoom = chart == null ? null : chart.getChart().getXYPlot().getRangeAxis().getRange();
Range<Double> rangeMZ = parameterSet.getParameter(KovatsIndexExtractionParameters.mzRange).getValue();
Range<Double> rangeRT = parameterSet.getParameter(KovatsIndexExtractionParameters.rtRange).getValue();
if (rangeMZ == null) {
// set range to specific alkane fragment
rangeMZ = Range.closed(56.6, 57.5);
((MZRangeComponent) getComponentForParameter(KovatsIndexExtractionParameters.mzRange)).setValue(rangeMZ);
}
if (rangeRT == null) {
rangeRT = selectedDataFile[0].getDataRTRange();
((RTRangeComponent) getComponentForParameter(KovatsIndexExtractionParameters.rtRange)).setValue(rangeRT);
}
// create dataset
TICSumDataSet data = new TICSumDataSet(selectedDataFile, rangeRT, rangeMZ, null, TICPlotType.BASEPEAK);
chart = new TICPlot(this);
chart.addTICDataset(data);
if (domainZoom != null)
chart.getChart().getXYPlot().getDomainAxis().setRange(domainZoom);
if (rangeZoom != null)
chart.getChart().getXYPlot().getRangeAxis().setRange(rangeZoom);
// add control for markers
chart.getGestureAdapter().addGestureHandler(new ChartGestureDragDiffHandler(Entity.PLOT, Button.BUTTON1, new Key[] { Key.NONE }, e -> handleMarkerDrag(e)));
chart.getGestureAdapter().addGestureHandler(new ChartGestureHandler(new ChartGesture(Entity.PLOT, Event.RELEASED), e -> {
if (chart != null)
chart.setMouseZoomable(true);
if (currentlyDraggedMarker != null) {
// set value of current marker
logger.info("Marker dragging ended at " + currentlyDraggedMarker.getValue());
int index = markers.indexOf(currentlyDraggedMarker);
double value = e.getCoordinates().getX();
setValue(index, value);
//
currentlyDraggedMarker = null;
}
}));
kovatsValuesChanged();
pnChart.removeAll();
pnChart.add(chart, BorderLayout.CENTER);
revalidate();
repaint();
} catch (Exception e) {
logger.log(Level.WARNING, "Peak picking parameters incorrect");
}
}
use of net.sf.mzmine.modules.visualization.tic.TICPlot in project mzmine2 by mzmine.
the class XICManualPickerDialog method addDialogComponents.
@Override
protected void addDialogComponents() {
super.addDialogComponents();
Color l = new Color(50, 255, 50, 150), u = new Color(255, 50, 50, 150);
Stroke stroke = new BasicStroke(1.0f);
// make new panel, put tic into the middle of a border layout.
remove(this.mainPanel);
rtRangeComp = new DoubleRangeComponent(MZmineCore.getConfiguration().getRTFormat());
mzRangeComp = new DoubleRangeComponent(MZmineCore.getConfiguration().getMZFormat());
applyMassRange = new JButton("Set");
applyMassRange.addActionListener(a -> setMassRange());
addListenertoRTComp(rtRangeComp);
JLabel rtLabel = new JLabel("Retention time range");
JLabel mzLabel = new JLabel("m/z range");
mainPanel.add(rtLabel, 0, getNumberOfParameters() + 1);
mainPanel.add(rtRangeComp, 1, getNumberOfParameters() + 1);
mainPanel.add(mzLabel, 0, getNumberOfParameters() + 2);
mainPanel.add(mzRangeComp, 1, getNumberOfParameters() + 2);
mainPanel.add(applyMassRange, 2, getNumberOfParameters() + 2);
BorderLayout borderLayout = new BorderLayout();
Panel pnlNewMain = new Panel(borderLayout);
// put another border layout for south of the new main panel, so we can place controls and
// integration specific stuff there
Panel pnlControlsAndParameters = new Panel(new BorderLayout());
pnlControlsAndParameters.add(this.mainPanel, BorderLayout.CENTER);
pnlNewMain.add(pnlControlsAndParameters, BorderLayout.SOUTH);
// now make another panel to put the integration specific stuff, like the buttons and the
// current area
Panel pnlIntegration = new Panel(new FlowLayout());
setLower = GUIUtils.addButton(pnlIntegration, null, icoLower, this, "SETLOWER", "Set the lower integration boundary.");
setUpper = GUIUtils.addButton(pnlIntegration, null, icoUpper, this, "SETUPPER", "Set the upper integration boundary.");
GUIUtils.addSeparator(pnlIntegration);
pnlIntegration.add(new Label("Area: "));
txtArea = new JTextField(10);
txtArea.setEditable(false);
pnlIntegration.add(txtArea);
pnlControlsAndParameters.add(pnlIntegration, BorderLayout.NORTH);
ticPlot = new TICPlot(this);
ticPlot.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
ticPlot.setMinimumSize(new Dimension(400, 200));
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
ticPlot.setPreferredSize(new Dimension((int) (screenSize.getWidth() / 1.3d), (int) (screenSize.getHeight() / 1.8d)));
pnlNewMain.add(ticPlot, BorderLayout.CENTER);
// add a mouse listener to place the boundaries
getTicPlot().addChartMouseListener(new ChartMouseListener() {
// https://stackoverflow.com/questions/1512112/jfreechart-get-mouse-coordinates
// draw a marker at the current position
@Override
public void chartMouseMoved(ChartMouseEvent event) {
Point2D p = ticPlot.translateScreenToJava2D(event.getTrigger().getPoint());
Rectangle2D plotArea = ticPlot.getScreenDataArea();
XYPlot plot = ticPlot.getXYPlot();
double rtValue = plot.getDomainAxis().java2DToValue(p.getX(), plotArea, plot.getDomainAxisEdge());
Color clr = (nextBorder == NextBorder.LOWER) ? l : u;
addMarkers();
plot.addDomainMarker(new ValueMarker(rtValue, clr, stroke));
}
@Override
public void chartMouseClicked(ChartMouseEvent event) {
Point2D p = ticPlot.translateScreenToJava2D(event.getTrigger().getPoint());
Rectangle2D plotArea = ticPlot.getScreenDataArea();
XYPlot plot = ticPlot.getXYPlot();
double rtValue = plot.getDomainAxis().java2DToValue(p.getX(), plotArea, plot.getDomainAxisEdge());
inputSource = InputSource.GRAPH;
setRTBoundary(rtValue);
inputSource = InputSource.OTHER;
}
});
add(pnlNewMain);
pack();
}
use of net.sf.mzmine.modules.visualization.tic.TICPlot in project mzmine2 by mzmine.
the class ShapeModelerSetupDialog method addComponents.
/**
* This function add all the additional components for this dialog over the original
* ParameterSetupDialog.
*/
private void addComponents() {
PeakList[] peakLists = MZmineCore.getProjectManager().getCurrentProject().getPeakLists();
// Elements of pnlpreview
JPanel pnlpreview = new JPanel(new BorderLayout());
preview = new JCheckBox(" Show preview of peak building ");
preview.addActionListener(this);
preview.setHorizontalAlignment(SwingConstants.CENTER);
preview.setEnabled(peakLists.length > 0);
pnlpreview.add(new JSeparator(), BorderLayout.NORTH);
pnlpreview.add(preview, BorderLayout.CENTER);
pnlpreview.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);
JComponent[] tableComponents = new JComponent[4];
tableComponents[0] = new JLabel("Feature list");
comboPeakList = new JComboBox<PeakList>();
for (PeakList peakList : peakLists) {
comboPeakList.addItem(peakList);
}
comboPeakList.setFont(comboFont);
comboPeakList.addActionListener(this);
tableComponents[1] = comboPeakList;
comboPeak = new JComboBox<PeakListRow>();
comboPeak.setFont(comboFont);
comboPeak.setRenderer(new PeakPreviewComboRenderer());
tableComponents[2] = new JLabel("Peak");
tableComponents[3] = comboPeak;
pnlLabelsFields = GUIUtils.makeTablePanel(2, 2, tableComponents);
// Put all together
pnlVisible = new JPanel(new BorderLayout());
pnlVisible.add(pnlpreview, BorderLayout.NORTH);
// Panel for XYPlot
pnlPlotXY = new JPanel(new BorderLayout());
GUIUtils.addMarginAndBorder(pnlPlotXY, 10);
pnlPlotXY.setBackground(Color.white);
ticPlot = new TICPlot((ActionListener) this);
pnlPlotXY.add(ticPlot, BorderLayout.CENTER);
toolBar = new TICToolBar(ticPlot);
toolBar.getComponentAtIndex(0).setVisible(false);
pnlPlotXY.add(toolBar, BorderLayout.EAST);
mainPanel.add(pnlVisible, 0, getNumberOfParameters() + 3, 3, 1, 0, 0);
updateMinimumSize();
pack();
setLocationRelativeTo(MZmineCore.getDesktop().getMainWindow());
}
Aggregations