use of net.sf.mzmine.util.SaveImage in project mzmine2 by mzmine.
the class SpectraPlot method actionPerformed.
@Override
public void actionPerformed(final ActionEvent event) {
super.actionPerformed(event);
final String command = event.getActionCommand();
if ("SHOW_REMOVED_TITLES".equals(command)) {
for (int i = 0; i < getChart().getSubtitleCount(); i++) {
getChart().getSubtitle(i).setVisible(true);
}
getChart().getTitle().setVisible(true);
}
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.SaveImage in project mzmine2 by mzmine.
the class ProductIonFilterPlot method actionPerformed.
@Override
public void actionPerformed(final ActionEvent event) {
super.actionPerformed(event);
final String command = event.getActionCommand();
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.SaveImage 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.SaveImage in project mzmine2 by mzmine.
the class MsMsPlot method actionPerformed.
@Override
public void actionPerformed(final ActionEvent event) {
super.actionPerformed(event);
final String command = event.getActionCommand();
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.SaveImage 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