X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fjbgui%2FGStructureViewer.java;h=485d755aa345edb336470882001f84fc8c5e96ed;hb=0dedd282914b05258e76292aaba17045f40e446f;hp=cee8b932819c749a47d7d9278def6b68337671bf;hpb=20bb45279db7745e7d0062c1084f97644c60db19;p=jalview.git diff --git a/src/jalview/jbgui/GStructureViewer.java b/src/jalview/jbgui/GStructureViewer.java index cee8b93..485d755 100644 --- a/src/jalview/jbgui/GStructureViewer.java +++ b/src/jalview/jbgui/GStructureViewer.java @@ -20,15 +20,14 @@ */ package jalview.jbgui; -import jalview.api.structures.JalviewStructureDisplayI; -import jalview.gui.ColourMenuHelper.ColourChangeListener; -import jalview.util.MessageManager; - import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; +import javax.swing.JCheckBoxMenuItem; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JMenu; @@ -37,8 +36,14 @@ import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JRadioButtonMenuItem; -public abstract class GStructureViewer extends JInternalFrame implements - JalviewStructureDisplayI, ColourChangeListener +import jalview.api.structures.JalviewStructureDisplayI; +import jalview.gui.ColourMenuHelper.ColourChangeListener; +import jalview.util.ImageMaker.TYPE; +import jalview.util.MessageManager; + +@SuppressWarnings("serial") +public abstract class GStructureViewer extends JInternalFrame + implements JalviewStructureDisplayI, ColourChangeListener { // private AAStructureBindingModel bindingModel; @@ -54,6 +59,10 @@ public abstract class GStructureViewer extends JInternalFrame implements protected JMenuItem alignStructs; + protected JCheckBoxMenuItem showAlignmentOnly; + + protected JCheckBoxMenuItem hideHiddenRegions; + protected JMenuItem fitToWindow; protected JRadioButtonMenuItem seqColour; @@ -86,6 +95,9 @@ public abstract class GStructureViewer extends JInternalFrame implements private void jbInit() throws Exception { + + setName("jalview-structureviewer"); + JMenuBar menuBar = new JMenuBar(); this.setJMenuBar(menuBar); @@ -93,7 +105,8 @@ public abstract class GStructureViewer extends JInternalFrame implements fileMenu.setText(MessageManager.getString("action.file")); savemenu = new JMenu(); - savemenu.setActionCommand(MessageManager.getString("action.save_image")); + savemenu.setActionCommand( + MessageManager.getString("action.save_image")); savemenu.setText(MessageManager.getString("action.save_as")); JMenuItem pdbFile = new JMenuItem(); @@ -103,7 +116,7 @@ public abstract class GStructureViewer extends JInternalFrame implements @Override public void actionPerformed(ActionEvent actionEvent) { - pdbFile_actionPerformed(actionEvent); + pdbFile_actionPerformed(); } }); @@ -114,7 +127,7 @@ public abstract class GStructureViewer extends JInternalFrame implements @Override public void actionPerformed(ActionEvent actionEvent) { - png_actionPerformed(actionEvent); + makePDBImage(TYPE.PNG); } }); @@ -125,7 +138,7 @@ public abstract class GStructureViewer extends JInternalFrame implements @Override public void actionPerformed(ActionEvent actionEvent) { - eps_actionPerformed(actionEvent); + makePDBImage(TYPE.EPS); } }); @@ -136,7 +149,7 @@ public abstract class GStructureViewer extends JInternalFrame implements @Override public void actionPerformed(ActionEvent actionEvent) { - viewMapping_actionPerformed(actionEvent); + viewMapping_actionPerformed(); } }); @@ -153,31 +166,30 @@ public abstract class GStructureViewer extends JInternalFrame implements @Override public void actionPerformed(ActionEvent actionEvent) { - fitToWindow_actionPerformed(); + getBinding().focusView(); } }); JMenu helpMenu = new JMenu(); helpMenu.setText(MessageManager.getString("action.help")); helpItem = new JMenuItem(); - helpItem.setText(MessageManager.getString("label.jmol_help")); helpItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { - showHelp_actionPerformed(actionEvent); + showHelp_actionPerformed(); } }); alignStructs = new JMenuItem(); - alignStructs - .setText(MessageManager.getString("label.align_structures")); + alignStructs.setText( + MessageManager.getString("label.superpose_structures")); alignStructs.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { - alignStructs_actionPerformed(actionEvent); + alignStructsWithAllAlignPanels(); } }); @@ -209,62 +221,79 @@ public abstract class GStructureViewer extends JInternalFrame implements protected void fitToWindow_actionPerformed() { + getBinding().focusView(); } protected void highlightSelection_actionPerformed() { } - protected void viewerColour_actionPerformed(ActionEvent actionEvent) + protected void viewerColour_actionPerformed() { } - protected void alignStructs_actionPerformed(ActionEvent actionEvent) - { - } + protected abstract String alignStructsWithAllAlignPanels(); - public void pdbFile_actionPerformed(ActionEvent actionEvent) + public void pdbFile_actionPerformed() { } - public void png_actionPerformed(ActionEvent actionEvent) + public void makePDBImage(TYPE imageType) { } - public void eps_actionPerformed(ActionEvent actionEvent) + public void viewMapping_actionPerformed() { } - public void viewMapping_actionPerformed(ActionEvent actionEvent) + public void seqColour_actionPerformed() { } - public void seqColour_actionPerformed(ActionEvent actionEvent) + public void chainColour_actionPerformed() { } - public void chainColour_actionPerformed(ActionEvent actionEvent) + public void chargeColour_actionPerformed() { } - public void chargeColour_actionPerformed(ActionEvent actionEvent) + public void background_actionPerformed() { } - public void background_actionPerformed(ActionEvent actionEvent) + public void showHelp_actionPerformed() { } - public void showHelp_actionPerformed(ActionEvent actionEvent) + /** + * Saves the unselected entries in the 'View Chain' menu into a list. Entries + * are formatted as "pdbid:chainid". Unselected chains should be hidden in the + * structure display. + */ + protected void setChainsToHide() { - + List chains = new ArrayList<>(); + for (int i = 0; i < chainMenu.getItemCount(); i++) + { + JMenuItem menuItem = chainMenu.getItem(i); + if (menuItem instanceof JCheckBoxMenuItem) + { + JCheckBoxMenuItem item = (JCheckBoxMenuItem) menuItem; + if (!item.isSelected()) + { + chains.add(item.getText().split(" ")[0]); + } + } + } + getBinding().setChainsToHide(chains); } }