Search in sources :

Example 1 with OrderedReplicateSetSelector

use of uk.ac.babraham.SeqMonk.Dialogs.OrderedReplicateSetSelector in project SeqMonk by s-andrews.

the class PCAScatterPlotDialog method actionPerformed.

/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand().equals("close")) {
        setVisible(false);
        dispose();
    } else if (ae.getActionCommand().equals("sublists")) {
        // Select a set of sublists from the current probe list to highlight
        // in the plot
        OrderedReplicateSetSelector selector = new OrderedReplicateSetSelector(this, SeqMonkApplication.getInstance().dataCollection().getAllReplicateSets(), highlightedSets);
        // It's modal so by the time we get here the selection has been made
        highlightedSets = selector.getOrderedSets();
        // try to highlight anything.
        if (highlightedSets != null && highlightedSets.length == 0) {
            highlightedSets = null;
        }
        selector.dispose();
        actionPerformed(new ActionEvent(this, 1, "plot"));
    } else if (ae.getActionCommand().equals("plot")) {
        int xIndex = xStores.getSelectedIndex();
        int yIndex = yStores.getSelectedIndex();
        getContentPane().remove(scatterPlotPanel);
        scatterPlotPanel = new PCAScatterPlotPanel(data, xIndex, yIndex, highlightedSets, showLabelsBox.isSelected(), dotSizeSlider.getValue());
        getContentPane().add(scatterPlotPanel, BorderLayout.CENTER);
        validate();
    } else if (ae.getActionCommand().equals("save_image")) {
        ImageSaver.saveImage(scatterPlotPanel);
    } else if (ae.getActionCommand().equals("export")) {
        JFileChooser chooser = new JFileChooser(SeqMonkPreferences.getInstance().getSaveLocation());
        chooser.setMultiSelectionEnabled(false);
        chooser.setFileFilter(new TxtFileFilter());
        int result = chooser.showSaveDialog(this);
        if (result == JFileChooser.CANCEL_OPTION)
            return;
        File file = chooser.getSelectedFile();
        SeqMonkPreferences.getInstance().setLastUsedSaveLocation(file);
        if (file.isDirectory())
            return;
        if (!file.getPath().toLowerCase().endsWith(".txt")) {
            file = new File(file.getPath() + ".txt");
        }
        // Check if we're stepping on anyone's toes...
        if (file.exists()) {
            int answer = JOptionPane.showOptionDialog(this, file.getName() + " exists.  Do you want to overwrite the existing file?", "Overwrite file?", 0, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Overwrite and Save", "Cancel" }, "Overwrite and Save");
            if (answer > 0) {
                return;
            }
        }
        try {
            data.writeExportData(file);
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
    } else {
        throw new IllegalArgumentException("Unknown command " + ae.getActionCommand());
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) ActionEvent(java.awt.event.ActionEvent) TxtFileFilter(uk.ac.babraham.SeqMonk.Utilities.FileFilters.TxtFileFilter) IOException(java.io.IOException) File(java.io.File) OrderedReplicateSetSelector(uk.ac.babraham.SeqMonk.Dialogs.OrderedReplicateSetSelector)

Aggregations

ActionEvent (java.awt.event.ActionEvent)1 File (java.io.File)1 IOException (java.io.IOException)1 JFileChooser (javax.swing.JFileChooser)1 OrderedReplicateSetSelector (uk.ac.babraham.SeqMonk.Dialogs.OrderedReplicateSetSelector)1 TxtFileFilter (uk.ac.babraham.SeqMonk.Utilities.FileFilters.TxtFileFilter)1