2424
2525import org .biojava .nbio .structure .align .gui .jmol .AbstractAlignmentJmol ;
2626import org .biojava .nbio .structure .align .model .AFPChain ;
27+ import org .biojava .nbio .structure .align .multiple .MultipleAlignment ;
2728import org .biojava .nbio .structure .align .util .UserConfiguration ;
2829import org .biojava .nbio .structure .align .webstart .WebStartMain ;
2930
3738/**
3839 * Create the menus for structure alignment GUI windows (JFrames).
3940 * <p>
40- * Examples: Text Frames, Alignment Panels, Jmol Panels, etc .
41+ * Examples: Text Frames, Alignment Panels, Jmol Panels.
4142 *
4243 * @author Andreas Prlic
4344 * @author Aleix Lafita
45+ * @author Spencer Bliven
4446 * @since 1.7
4547 *
4648 */
@@ -63,20 +65,26 @@ public class MenuCreator {
6365 public static final String DOT_PLOT = "Show Dot Plot" ;
6466 public static final String PAIRWISE_ALIGN = "New Pairwise Alignment" ;
6567 public static final String MULTIPLE_ALIGN = "New Multiple Alignment" ;
66- protected static final int keyMask = Toolkit .getDefaultToolkit ().getMenuShortcutKeyMask ();
68+ protected static final int keyMask =
69+ Toolkit .getDefaultToolkit ().getMenuShortcutKeyMask ();
6770
6871 /**
69- * Provide a JMenuBar that can be added to a JFrame containing a JmolPanel.<p>
72+ * Provide a JMenuBar that can be added to a JFrame containing
73+ * a JmolPanel. The alignment has to be either an AFPChain or a
74+ * MultipleAlignment: set the other parameter to null.<p>
7075 * Menus included:
7176 * <ul><li>File: open, save, export, import, exit.
7277 * <li>Align: new pairwise alignment, new multiple alignment.
73- * <li>View: aligment panel, aligned pairs, text format, FatCat format, distance matrices, dot plot.
78+ * <li>View: aligment panel, aligned pairs, text format,
79+ * FatCat format, distance matrices, dot plot.
7480 * <li>Help
7581 * </ul>
7682 *
7783 * @return a JMenuBar
7884 */
79- public static JMenuBar initJmolMenu (JFrame frame , AbstractAlignmentJmol parent , AFPChain afpChain ){
85+ public static JMenuBar initJmolMenu (JFrame frame ,
86+ AbstractAlignmentJmol parent , AFPChain afpChain ,
87+ MultipleAlignment msa ) {
8088
8189 JMenuBar menu = new JMenuBar ();
8290
@@ -87,11 +95,11 @@ public static JMenuBar initJmolMenu(JFrame frame, AbstractAlignmentJmol parent,
8795 //Load
8896 if (parent != null ){
8997 JMenuItem loadF = getLoadMenuItem ();
90- loadF .addActionListener (new MyAlignmentLoadListener (parent ));
98+ loadF .addActionListener (new MyAlignmentLoadListener ());
9199 file .add (loadF );
92100 }
93101 //Save
94- JMenuItem saveF = getSaveAlignmentMenuItem (afpChain ); //TODO generalize saving afpChain and MultipleAlignment
102+ JMenuItem saveF = getSaveAlignmentMenuItem (afpChain , msa );
95103 file .add (saveF );
96104 //Open PDB
97105 JMenuItem openPDB = getShowPDBMenuItem ();
@@ -143,10 +151,10 @@ public static JMenuBar initJmolMenu(JFrame frame, AbstractAlignmentJmol parent,
143151
144152 if ( parent != null ){
145153 //Alignment Panel
146- JMenuItem aligpI = MenuCreator .getIcon (parent ,ALIGNMENT_PANEL );
147- aligpI .setMnemonic (KeyEvent .VK_M );
148- aligpI .setAccelerator (KeyStroke .getKeyStroke (KeyEvent .VK_M , keyMask ));
149- view .add (aligpI );
154+ JMenuItem apI = MenuCreator .getIcon (parent ,ALIGNMENT_PANEL );
155+ apI .setMnemonic (KeyEvent .VK_M );
156+ apI .setAccelerator (KeyStroke .getKeyStroke (KeyEvent .VK_M , keyMask ));
157+ view .add (apI );
150158 //Text Format
151159 JMenuItem textI = MenuCreator .getIcon (parent ,TEXT_ONLY );
152160 textI .setMnemonic (KeyEvent .VK_T );
@@ -268,15 +276,20 @@ public static JMenuItem getLoadMenuItem() {
268276
269277
270278 /**
271- * Create the menu for the Alignment Panel representation of Structural Alignments.
279+ * Create the menu for the Alignment Panel representation of
280+ * Structural Alignments. The alignment can be in AFPChain format
281+ * or in the MultipleAlignment format.
282+ *
272283 * @param frame
273284 * @param actionListener
274285 * @param afpChain
286+ * @param MultipleAlignment
275287 * @return a JMenuBar
276288 */
277- public static JMenuBar getAlignmentPanelMenu (JFrame frame , ActionListener actionListener ,AFPChain afpChain ){
278-
279-
289+ public static JMenuBar getAlignmentPanelMenu (JFrame frame ,
290+ ActionListener actionListener , AFPChain afpChain ,
291+ MultipleAlignment msa ){
292+
280293 JMenuBar menu = new JMenuBar ();
281294
282295 JMenu file = new JMenu ("File" );
@@ -287,14 +300,14 @@ public static JMenuBar getAlignmentPanelMenu(JFrame frame, ActionListener action
287300
288301 JMenuItem saveF = null ;
289302
290- if (saveicon != null )
303+ if (saveicon != null )
291304 saveF = new JMenuItem ("Save text display" , saveicon );
292305 else
293306 saveF = new JMenuItem ("Save text display" );
294307
295308 saveF .setMnemonic (KeyEvent .VK_S );
296- MySaveFileListener listener = new MySaveFileListener (afpChain );
297- listener .setFatCatOutput (true );
309+ MySaveFileListener listener = new MySaveFileListener (afpChain , msa );
310+ listener .setTextOutput (true );
298311 saveF .addActionListener (listener );
299312 file .add (saveF );
300313
@@ -365,9 +378,12 @@ public static JMenuBar getAlignmentPanelMenu(JFrame frame, ActionListener action
365378 * @param frame
366379 * @param actionListener
367380 * @param afpChain
381+ * @param msa
368382 * @return a JMenuBar
369383 */
370- public static JMenuBar getAlignmentTextMenu (JFrame frame , ActionListener actionListener , AFPChain afpChain ){
384+ public static JMenuBar getAlignmentTextMenu (JFrame frame ,
385+ ActionListener actionListener , AFPChain afpChain ,
386+ MultipleAlignment msa ){
371387
372388 JMenuBar menu = new JMenuBar ();
373389
@@ -385,8 +401,9 @@ public static JMenuBar getAlignmentTextMenu(JFrame frame, ActionListener actionL
385401 saveF = new JMenuItem ("Save text display" );
386402
387403 saveF .setMnemonic (KeyEvent .VK_S );
388- MySaveFileListener listener = new MySaveFileListener (afpChain ); //TODO save MultipleAlignment not implemented
389- listener .setFatCatOutput (true );
404+ MySaveFileListener listener =
405+ new MySaveFileListener (afpChain , msa );
406+ listener .setTextOutput (true );
390407 saveF .addActionListener (listener );
391408 file .add (saveF );
392409 file .addSeparator ();
@@ -476,7 +493,9 @@ public static JMenuItem getExportPDBMenuItem(AbstractAlignmentJmol parent) {
476493 return exportI ;
477494 }
478495
479- public static JMenuItem getSaveAlignmentMenuItem (AFPChain afpChain ) {
496+ public static JMenuItem getSaveAlignmentMenuItem (AFPChain afpChain ,
497+ MultipleAlignment msa ){
498+
480499 ImageIcon saveicon = createImageIcon ("/icons/filesave.png" );
481500 JMenuItem saveF = null ;
482501
@@ -487,7 +506,7 @@ public static JMenuItem getSaveAlignmentMenuItem(AFPChain afpChain) {
487506
488507 saveF .setMnemonic (KeyEvent .VK_S );
489508 saveF .setAccelerator (KeyStroke .getKeyStroke (KeyEvent .VK_S , keyMask ));
490- saveF .addActionListener (new MySaveFileListener (afpChain ));
509+ saveF .addActionListener (new MySaveFileListener (afpChain , msa ));
491510
492511 return saveF ;
493512 }
@@ -725,9 +744,7 @@ public void actionPerformed(ActionEvent e) {
725744
726745 /**
727746 * Creates a frame to display a DotPlotPanel.
728- *
729747 * Used by the 'View>Show Dot Plot' menu item
730- * @author Spencer Bliven
731748 *
732749 */
733750 public static class DotPlotListener implements ActionListener {
@@ -737,7 +754,8 @@ public DotPlotListener(AFPChain afpChain) {
737754 }
738755 @ Override
739756 public void actionPerformed (ActionEvent e ) {
740- String title = String .format ("%s vs. %s" , afpChain .getName1 (),afpChain .getName2 ());
757+ String title = String .format ("%s vs. %s" ,
758+ afpChain .getName1 (),afpChain .getName2 ());
741759
742760 // Create window
743761 JFrame frame = new JFrame (title );
@@ -760,12 +778,11 @@ public void windowClosing(WindowEvent e){
760778
761779 public static JMenuBar initAlignmentGUIMenu (JFrame frame ) {
762780
763-
764781 JMenu file = new JMenu ("File" );
765782 file .getAccessibleContext ().setAccessibleDescription ("File Menu" );
766783
767784 JMenuItem loadF = MenuCreator .getLoadMenuItem ();
768- loadF .addActionListener (new MyAlignmentLoadListener (null ));
785+ loadF .addActionListener (new MyAlignmentLoadListener ());
769786 file .add (loadF );
770787
771788 JMenuItem openPDB = MenuCreator .getShowPDBMenuItem ();
0 commit comments