Search in sources :

Example 1 with NetworkColorDialog

use of edu.ucsf.rbvi.clusterMaker2.internal.ui.NetworkColorDialog in project clusterMaker2 by RBVI.

the class DendroView method getButtonBox.

private JPanel getButtonBox() {
    // Get our border
    JPanel buttonBox = new JPanel();
    buttonBox.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    // Now add our buttons
    // The Settings button will bring up the Pixel Settings dialog
    {
        JButton settingsButton = createButton("Settings...");
        settingsButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent actionEvent) {
                ColorExtractor ce = null;
                try {
                    ce = ((DoubleArrayDrawer) arrayDrawer).getColorExtractor();
                } catch (Exception e) {
                }
                PixelSettingsSelector pssSelector = new PixelSettingsSelector(globalXmap, globalYmap, getZoomXmap(), getZoomYmap(), ce, colorPresets);
                JDialog popup = new ModelessSettingsDialog(viewFrame, "Pixel Settings", pssSelector);
                popup.addWindowListener(PropertyConfig.getStoreOnWindowClose(getDataModel().getDocumentConfig()));
                popup.pack();
                popup.setVisible(true);
            }
        });
        buttonBox.add(settingsButton);
    }
    // The Save Data button brings up a file dialog and saves the .CDT, .GTR, and .ATR files
    {
        JButton saveButton = createButton("Save Data...");
        saveButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent actionEvent) {
                JFileChooser chooser = new JFileChooser();
                int returnVal = chooser.showSaveDialog(viewFrame);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    // Save the data
                    // Get the name of the file
                    String filePath = chooser.getSelectedFile().getAbsolutePath();
                    if (filePath.length() == 0)
                        return;
                    DataModelWriter writer = new DataModelWriter(dataModel);
                    if (dataModel.aidFound())
                        writer.writeAtr(filePath + ".atr");
                    if (dataModel.gidFound())
                        writer.writeGtr(filePath + ".gtr");
                    writer.writeCdt(filePath + ".cdt");
                }
            }
        });
        buttonBox.add(saveButton);
    }
    // The Export Graphics button brings up a new dialog that allows the user
    // to produce images for publication
    {
        JButton exportButton = createButton("Export Graphics...");
        exportButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent actionevent) {
                GraphicsExportPanel graphicsExport = new GraphicsExportPanel(myView);
                graphicsExport.setGeneFont(textview.getFont());
                graphicsExport.setArrayFont(arraynameview.getFont());
                JDialog popup = new CancelableSettingsDialog(viewFrame, "Export Graphics", graphicsExport);
                popup.addWindowListener(PropertyConfig.getStoreOnWindowClose(getDataModel().getDocumentConfig()));
                popup.pack();
                popup.setVisible(true);
            }
        });
        buttonBox.add(exportButton);
    }
    if (dataModel.aidFound()) {
        JButton flipButton = createButton("Flip Tree Nodes");
        flipButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent actionEvent) {
                flipSelectedATRNode();
            }
        });
        buttonBox.add(flipButton);
    }
    // Map the visual properties onto the network
    if (dataModel instanceof TreeViewModel) {
        final ClusterManager clusterManager = ((TreeViewModel) dataModel).getClusterManager();
        JButton vizMapButton = createButton("Map Colors Onto Network...");
        vizMapButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // Get the colors from the view
                ColorExtractor ce = null;
                try {
                    ce = ((DoubleArrayDrawer) arrayDrawer).getColorExtractor();
                } catch (Exception e) {
                    // this shouldn't happen at this point!
                    ce = new ColorExtractor();
                    ce.setDefaultColorSet(colorPresets.getDefaultColorSet());
                }
                List<String> attributes = new ArrayList();
                if (dataModel.isSymmetrical()) {
                } else {
                    // Get the node attributes
                    int[] selections = arraySelection.getSelectedIndexes();
                    HeaderInfo arrayInfo = dataModel.getArrayHeaderInfo();
                    if (selections.length >= 1) {
                        for (int i = 0; i < selections.length; i++) {
                            attributes.add(arrayInfo.getHeader(selections[i])[0]);
                        }
                    } else {
                        // Nothing selected, add them all
                        int count = arrayInfo.getNumHeaders();
                        for (int i = 0; i < count; i++) {
                            attributes.add(arrayInfo.getHeader(i)[0]);
                        }
                    }
                }
                // Bring up the dialog
                NetworkColorDialog ncd = new NetworkColorDialog(null, ce, attributes, viewFrame, clusterManager, dataModel.getDataMatrix().getMinValue(), dataModel.getDataMatrix().getMaxValue(), dataModel.isSymmetrical());
            }
        });
        buttonBox.add(vizMapButton);
    }
    // The Close button exits clusterViz
    {
        JButton closeButton = createButton("Close");
        closeButton.addActionListener(new ActionListener() {

            // called when close button hit
            public void actionPerformed(ActionEvent evt) {
                viewFrame.closeWindow();
            }
        });
        // 
        buttonBox.add(closeButton);
    }
    return buttonBox;
}
Also used : ArrayList(java.util.ArrayList) LoadException(edu.ucsf.rbvi.clusterMaker2.internal.treeview.LoadException) ModelessSettingsDialog(edu.ucsf.rbvi.clusterMaker2.internal.treeview.ModelessSettingsDialog) DataModelWriter(edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.DataModelWriter) HeaderInfo(edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo) NetworkColorDialog(edu.ucsf.rbvi.clusterMaker2.internal.ui.NetworkColorDialog) ArrayList(java.util.ArrayList) List(java.util.List) TreeViewModel(edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.TreeViewModel) ClusterManager(edu.ucsf.rbvi.clusterMaker2.internal.api.ClusterManager)

Aggregations

ClusterManager (edu.ucsf.rbvi.clusterMaker2.internal.api.ClusterManager)1 HeaderInfo (edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo)1 LoadException (edu.ucsf.rbvi.clusterMaker2.internal.treeview.LoadException)1 ModelessSettingsDialog (edu.ucsf.rbvi.clusterMaker2.internal.treeview.ModelessSettingsDialog)1 DataModelWriter (edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.DataModelWriter)1 TreeViewModel (edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.TreeViewModel)1 NetworkColorDialog (edu.ucsf.rbvi.clusterMaker2.internal.ui.NetworkColorDialog)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1