use of net.sf.mzmine.util.dialogs.AxesSetupDialog in project mzmine2 by mzmine.
the class ScatterPlotChart method actionPerformed.
public void actionPerformed(ActionEvent event) {
super.actionPerformed(event);
String command = event.getActionCommand();
if (command.equals("SETUP_AXES")) {
AxesSetupDialog dialog = new AxesSetupDialog(window, plot);
dialog.setVisible(true);
return;
}
if (command.equals("TIC")) {
double valueX = plot.getDomainCrosshairValue();
double valueY = plot.getRangeCrosshairValue();
PeakListRow selectedRow = mainDataSet.getRow(valueX, valueY);
if (selectedRow == null) {
MZmineCore.getDesktop().displayErrorMessage(window, "No peak is selected");
return;
}
Feature[] peaks = selectedRow.getPeaks();
Range<Double> rtRange = peakList.getRowsRTRange();
Range<Double> mzRange = PeakUtils.findMZRange(peaks);
// Label best peak with preferred identity.
final Feature bestPeak = selectedRow.getBestPeak();
final PeakIdentity peakIdentity = selectedRow.getPreferredPeakIdentity();
final Map<Feature, String> labelMap = new HashMap<Feature, String>(1);
if (bestPeak != null && peakIdentity != null) {
labelMap.put(bestPeak, peakIdentity.getName());
}
ScanSelection scanSelection = new ScanSelection(rtRange, 1);
TICVisualizerModule.showNewTICVisualizerWindow(peakList.getRawDataFiles(), peaks, labelMap, scanSelection, TICPlotType.BASEPEAK, mzRange);
}
if ("SAVE_EMF".equals(command)) {
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("EMF Image", "EMF");
chooser.setFileFilter(filter);
int returnVal = chooser.showSaveDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
String file = chooser.getSelectedFile().getPath();
if (!file.toLowerCase().endsWith(".emf"))
file += ".emf";
int width = (int) this.getSize().getWidth();
int height = (int) this.getSize().getHeight();
// Save image
SaveImage SI = new SaveImage(getChart(), file, width, height, FileType.EMF);
new Thread(SI).start();
}
}
if ("SAVE_EPS".equals(command)) {
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("EPS Image", "EPS");
chooser.setFileFilter(filter);
int returnVal = chooser.showSaveDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
String file = chooser.getSelectedFile().getPath();
if (!file.toLowerCase().endsWith(".eps"))
file += ".eps";
int width = (int) this.getSize().getWidth();
int height = (int) this.getSize().getHeight();
// Save image
SaveImage SI = new SaveImage(getChart(), file, width, height, FileType.EPS);
new Thread(SI).start();
}
}
}
use of net.sf.mzmine.util.dialogs.AxesSetupDialog in project mzmine2 by mzmine.
the class MsMsVisualizerWindow method actionPerformed.
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent event) {
String command = event.getActionCommand();
if (command.equals("SHOW_SPECTRUM")) {
CursorPosition pos = getCursorPosition();
if (pos != null) {
SpectraVisualizerModule.showNewSpectrumWindow(pos.getDataFile(), pos.getScanNumber());
}
}
if (command.equals("SETUP_AXES")) {
AxesSetupDialog dialog = new AxesSetupDialog(this, IDAPlot.getXYPlot());
dialog.setVisible(true);
}
if (command.equals("SHOW_DATA_POINTS")) {
IDAPlot.switchDataPointsVisible();
}
if (command.equals("SWITCH_TOOLTIPS")) {
if (tooltipMode) {
IDAPlot.showPeaksTooltips(false);
toolBar.setTooltipButton(false);
tooltipMode = false;
} else {
IDAPlot.showPeaksTooltips(true);
toolBar.setTooltipButton(true);
tooltipMode = true;
}
}
if (command.equals("FIND_SPECTRA")) {
// Parameters
final DoubleParameter inputMZ = new DoubleParameter("Ion m/z", "m/z value of ion to search for.");
final MZToleranceParameter inputMZTolerance = new MZToleranceParameter();
final DoubleParameter inputIntensity = new DoubleParameter("Min. ion intensity", "Only ions with intensities above this value will be searched for.");
final BooleanParameter inputNL = new BooleanParameter("Neutral Loss", "If selected, the ion to be searched for will be a neutral loss ion.\nIn this case, only ions above the min. intensity will be examined.", false);
final ComboParameter<Colors> inputColors = new ComboParameter<Colors>("Color", "The color which the data points will be marked with.", Colors.values());
Parameter<?>[] parameters = new Parameter<?>[5];
parameters[0] = inputMZ;
parameters[1] = inputMZTolerance;
parameters[2] = inputIntensity;
parameters[3] = inputNL;
parameters[4] = inputColors;
final ParameterSet parametersSearch = new SimpleParameterSet(parameters);
ExitCode exitCode = parametersSearch.showSetupDialog(this, true);
if (exitCode != ExitCode.OK)
return;
double searchMZ = parametersSearch.getParameter(inputMZ).getValue();
MZTolerance searchMZTolerance = parametersSearch.getParameter(inputMZTolerance).getValue();
double minIntensity = parametersSearch.getParameter(inputIntensity).getValue();
boolean neutralLoss = parametersSearch.getParameter(inputNL).getValue();
Color highligtColor = Color.red;
;
if (parametersSearch.getParameter(inputColors).getValue().equals(Colors.green)) {
highligtColor = Color.green;
}
if (parametersSearch.getParameter(inputColors).getValue().equals(Colors.blue)) {
highligtColor = Color.blue;
}
// Find and highlight spectra with specific ion
dataset.highlightSpectra(searchMZ, searchMZTolerance, minIntensity, neutralLoss, highligtColor);
// Add legend entry
LegendItemCollection chartLegend = IDAPlot.getXYPlot().getLegendItems();
chartLegend.add(new LegendItem("Ion: " + searchMZ, "", "MS/MS spectra which contain the " + searchMZ + " ion\nTolerance: " + searchMZTolerance.toString() + "\nMin intensity: " + minIntensity, "", new Ellipse2D.Double(0, 0, 7, 7), highligtColor));
IDAPlot.getXYPlot().setFixedLegendItems(chartLegend);
}
}
use of net.sf.mzmine.util.dialogs.AxesSetupDialog in project mzmine2 by mzmine.
the class TICPlot method actionPerformed.
@Override
public void actionPerformed(final ActionEvent event) {
super.actionPerformed(event);
final String command = event.getActionCommand();
if ("SHOW_DATA_POINTS".equals(command)) {
switchDataPointsVisible();
}
if ("SHOW_ANNOTATIONS".equals(command)) {
switchItemLabelsVisible();
}
if ("SETUP_AXES".equals(command)) {
JFrame parent = null;
if (visualizer instanceof JFrame)
parent = (JFrame) visualizer;
new AxesSetupDialog(parent, getXYPlot()).setVisible(true);
}
if ("ZOOM_IN".equals(command)) {
getXYPlot().getDomainAxis().resizeRange(1.0 / ZOOM_FACTOR);
getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
}
// Set tick size to auto when zooming
String[] zoomList = new String[] { "ZOOM_IN_BOTH", "ZOOM_IN_DOMAIN", "ZOOM_IN_RANGE", "ZOOM_OUT_BOTH", "ZOOM_DOMAIN_BOTH", "ZOOM_RANGE_BOTH", "ZOOM_RESET_BOTH", "ZOOM_RESET_DOMAIN", "ZOOM_RESET_RANGE" };
if (Arrays.asList(zoomList).contains(command)) {
getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
getXYPlot().getRangeAxis().setAutoTickUnitSelection(true);
}
if ("ZOOM_OUT".equals(command)) {
getXYPlot().getDomainAxis().resizeRange(ZOOM_FACTOR);
getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
// if (getXYPlot().getDomainAxis().getRange().contains(0.0000001)) {
// getXYPlot().getDomainAxis().setAutoRange(true);
// getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
// }
}
if ("ZOOM_AUTO".equals(command)) {
getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
getXYPlot().getRangeAxis().setAutoTickUnitSelection(true);
restoreAutoDomainBounds();
restoreAutoRangeBounds();
}
if ("SET_SAME_RANGE".equals(command)) {
// Get current axes range.
final NumberAxis xAxis = (NumberAxis) getXYPlot().getDomainAxis();
final NumberAxis yAxis = (NumberAxis) getXYPlot().getRangeAxis();
final double xMin = xAxis.getRange().getLowerBound();
final double xMax = xAxis.getRange().getUpperBound();
final double xTick = xAxis.getTickUnit().getSize();
final double yMin = yAxis.getRange().getLowerBound();
final double yMax = yAxis.getRange().getUpperBound();
final double yTick = yAxis.getTickUnit().getSize();
// Set the range of these frames
for (final Window frame : JFrame.getWindows()) {
if (frame instanceof TICVisualizerWindow) {
final TICVisualizerWindow ticFrame = (TICVisualizerWindow) frame;
ticFrame.setAxesRange(xMin, xMax, xTick, yMin, yMax, yTick);
}
}
}
if ("SHOW_SPECTRUM".equals(command)) {
visualizer.actionPerformed(event);
}
if ("SHOW_LEGEND".equals(command)) {
// Toggle legend visibility.
final LegendTitle legend = getChart().getLegend();
legend.setVisible(!legend.isVisible());
}
if ("GRAY_BACKGROUND".equals(command)) {
// Toggle background color
final Paint color = getChart().getPlot().getBackgroundPaint();
Color bgColor, liColor;
if (color.equals(Color.lightGray)) {
bgColor = Color.white;
liColor = Color.lightGray;
} else {
bgColor = Color.lightGray;
liColor = Color.white;
}
getChart().getPlot().setBackgroundPaint(bgColor);
getChart().getXYPlot().setDomainGridlinePaint(liColor);
getChart().getXYPlot().setRangeGridlinePaint(liColor);
}
if ("SAVE_EMF".equals(command)) {
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("EMF Image", "EMF");
chooser.setFileFilter(filter);
int returnVal = chooser.showSaveDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
String file = chooser.getSelectedFile().getPath();
if (!file.toLowerCase().endsWith(".emf"))
file += ".emf";
int width = (int) this.getSize().getWidth();
int height = (int) this.getSize().getHeight();
// Save image
SaveImage SI = new SaveImage(getChart(), file, width, height, FileType.EMF);
new Thread(SI).start();
}
}
if ("SAVE_EPS".equals(command)) {
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("EPS Image", "EPS");
chooser.setFileFilter(filter);
int returnVal = chooser.showSaveDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
String file = chooser.getSelectedFile().getPath();
if (!file.toLowerCase().endsWith(".eps"))
file += ".eps";
int width = (int) this.getSize().getWidth();
int height = (int) this.getSize().getHeight();
// Save image
SaveImage SI = new SaveImage(getChart(), file, width, height, FileType.EPS);
new Thread(SI).start();
}
}
}
Aggregations