X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FChimeraViewFrame.java;h=ba360af3117fc953555dc98f06d739adc08e63ad;hb=d6ab1d005a0adbdf4997842893796cbef56b0f53;hp=67eddcac4a21b8c0a0e25564c74374e12d70011b;hpb=20bb45279db7745e7d0062c1084f97644c60db19;p=jalview.git diff --git a/src/jalview/gui/ChimeraViewFrame.java b/src/jalview/gui/ChimeraViewFrame.java index 67eddca..ba360af 100644 --- a/src/jalview/gui/ChimeraViewFrame.java +++ b/src/jalview/gui/ChimeraViewFrame.java @@ -20,6 +20,7 @@ */ package jalview.gui; +import jalview.api.FeatureRenderer; import jalview.bin.Cache; import jalview.datamodel.AlignmentI; import jalview.datamodel.PDBEntry; @@ -76,6 +77,10 @@ public class ChimeraViewFrame extends StructureViewerBase private Random random = new Random(); + private int myWidth = 500; + + private int myHeight = 150; + /** * Initialise menu options. */ @@ -86,8 +91,8 @@ public class ChimeraViewFrame extends StructureViewerBase viewerActionMenu.setText(MessageManager.getString("label.chimera")); - viewerColour.setText(MessageManager - .getString("label.colour_with_chimera")); + viewerColour + .setText(MessageManager.getString("label.colour_with_chimera")); viewerColour.setToolTipText(MessageManager .getString("label.let_chimera_manage_structure_colours")); @@ -95,35 +100,41 @@ public class ChimeraViewFrame extends StructureViewerBase savemenu.setVisible(false); // not yet implemented viewMenu.add(fitToWindow); - JMenuItem writeFeatures = new JMenuItem( - MessageManager.getString("label.create_chimera_attributes")); - writeFeatures.setToolTipText(MessageManager - .getString("label.create_chimera_attributes_tip")); - writeFeatures.addActionListener(new ActionListener() + /* + * exchange of Jalview features and Chimera attributes is for now + * an optionally enabled experimental feature + */ + if (Desktop.instance.showExperimental()) { - @Override - public void actionPerformed(ActionEvent e) + JMenuItem writeFeatures = new JMenuItem( + MessageManager.getString("label.create_chimera_attributes")); + writeFeatures.setToolTipText(MessageManager + .getString("label.create_chimera_attributes_tip")); + writeFeatures.addActionListener(new ActionListener() { - sendFeaturesToChimera(); - } - }); - viewerActionMenu.add(writeFeatures); - - final JMenu fetchAttributes = new JMenu( - MessageManager.getString("label.fetch_chimera_attributes")); - fetchAttributes.setToolTipText(MessageManager - .getString("label.fetch_chimera_attributes_tip")); - fetchAttributes.addMouseListener(new MouseAdapter() - { - - @Override - public void mouseEntered(MouseEvent e) + @Override + public void actionPerformed(ActionEvent e) + { + sendFeaturesToChimera(); + } + }); + viewerActionMenu.add(writeFeatures); + + final JMenu fetchAttributes = new JMenu( + MessageManager.getString("label.fetch_chimera_attributes")); + fetchAttributes.setToolTipText(MessageManager + .getString("label.fetch_chimera_attributes_tip")); + fetchAttributes.addMouseListener(new MouseAdapter() { - buildAttributesMenu(fetchAttributes); - } - }); - viewerActionMenu.add(fetchAttributes); + @Override + public void mouseEntered(MouseEvent e) + { + buildAttributesMenu(fetchAttributes); + } + }); + viewerActionMenu.add(fetchAttributes); + } } /** @@ -185,7 +196,9 @@ public class ChimeraViewFrame extends StructureViewerBase */ protected void sendFeaturesToChimera() { - jmb.sendFeaturesToViewer(getAlignmentPanel()); + int count = jmb.sendFeaturesToViewer(getAlignmentPanel()); + statusBar.setText( + MessageManager.formatMessage("label.attributes_set", count)); } /** @@ -225,7 +238,8 @@ public class ChimeraViewFrame extends StructureViewerBase * a new viewer */ openNewChimera(ap, new PDBEntry[] { pdbentry }, - new SequenceI[][] { seq }); + new SequenceI[][] + { seq }); } /** @@ -254,7 +268,7 @@ public class ChimeraViewFrame extends StructureViewerBase useAlignmentPanelForSuperposition(ap); } jmb.setColourBySequence(true); - setSize(400, 400); // probably should be a configurable/dynamic default here + setSize(myWidth, myHeight); initMenus(); addingStructures = false; @@ -264,7 +278,8 @@ public class ChimeraViewFrame extends StructureViewerBase this.addInternalFrameListener(new InternalFrameAdapter() { @Override - public void internalFrameClosing(InternalFrameEvent internalFrameEvent) + public void internalFrameClosing( + InternalFrameEvent internalFrameEvent) { closeViewer(false); } @@ -385,9 +400,8 @@ public class ChimeraViewFrame extends StructureViewerBase boolean opened = jmb.openSession(chimeraSessionFile); if (!opened) { - System.err - .println("An error occurred opening Chimera session file " - + chimeraSessionFile); + System.err.println("An error occurred opening Chimera session file " + + chimeraSessionFile); } } @@ -430,10 +444,9 @@ public class ChimeraViewFrame extends StructureViewerBase { if (!closeChimera) { - String prompt = MessageManager.formatMessage( - "label.confirm_close_chimera", - new Object[] { jmb.getViewerTitle(getViewerName(), - false) }); + String prompt = MessageManager + .formatMessage("label.confirm_close_chimera", new Object[] + { jmb.getViewerTitle(getViewerName(), false) }); prompt = JvSwingUtils.wrapTooltip(true, prompt); int confirm = JvOptionPane.showConfirmDialog(this, prompt, MessageManager.getString("label.close_viewer"), @@ -477,7 +490,7 @@ public class ChimeraViewFrame extends StructureViewerBase StructureFile pdb = null; try { - String[] curfiles = jmb.getPdbFile(); // files currently in viewer + String[] curfiles = jmb.getStructureFiles(); // files currently in viewer // TODO: replace with reference fetching/transfer code (validate PDBentry // as a DBRef?) for (int pi = 0; pi < jmb.getPdbCount(); pi++) @@ -529,15 +542,16 @@ public class ChimeraViewFrame extends StructureViewerBase } catch (Exception ex) { ex.printStackTrace(); - errormsgs.append("When retrieving pdbfiles for '" - + thePdbEntry.getId() + "'"); + errormsgs.append( + "When retrieving pdbfiles for '" + thePdbEntry.getId() + "'"); } if (errormsgs.length() > 0) { - JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager - .formatMessage("label.pdb_entries_couldnt_be_retrieved", - new Object[] { errormsgs.toString() }), + JvOptionPane.showInternalMessageDialog(Desktop.desktop, + MessageManager.formatMessage( + "label.pdb_entries_couldnt_be_retrieved", new Object[] + { errormsgs.toString() }), MessageManager.getString("label.couldnt_load_file"), JvOptionPane.ERROR_MESSAGE); } @@ -594,8 +608,9 @@ public class ChimeraViewFrame extends StructureViewerBase oomerror); } catch (Exception ex) { - Cache.log.error("Couldn't open " + pe.getFile() - + " in Chimera viewer!", ex); + Cache.log.error( + "Couldn't open " + pe.getFile() + " in Chimera viewer!", + ex); } finally { Cache.log.debug("File locations are " + files); @@ -607,6 +622,16 @@ public class ChimeraViewFrame extends StructureViewerBase jmb.setFinishedInit(true); jmb.setLoadingFromArchive(false); + /* + * ensure that any newly discovered features (e.g. RESNUM) + * are added to any open feature settings dialog + */ + FeatureRenderer fr = getBinding().getFeatureRenderer(null); + if (fr != null) + { + fr.featuresAdded(); + } + // refresh the sequence colours for the new structure(s) for (AlignmentPanel ap : _colourwith) { @@ -644,12 +669,13 @@ public class ChimeraViewFrame extends StructureViewerBase { for (int i = 0; i < pdb.getChains().size(); i++) { - String chid = new String(pdb.getId() + ":" - + pdb.getChains().elementAt(i).id); + String chid = new String( + pdb.getId() + ":" + pdb.getChains().elementAt(i).id); jmb.getChainNames().add(chid); jmb.getChainFile().put(chid, file); } } + private String fetchPdbFile(PDBEntry processingEntry) throws Exception { // FIXME: this is duplicated code with Jmol frame ? @@ -664,7 +690,8 @@ public class ChimeraViewFrame extends StructureViewerBase * Write 'fetching PDB' progress on AlignFrame as we are not yet visible */ String msg = MessageManager.formatMessage("status.fetching_pdb", - new Object[] { pdbid }); + new Object[] + { pdbid }); getAlignmentPanel().alignFrame.setProgressBar(msg, handle); // long hdl = startProgressBar(MessageManager.formatMessage( // "status.fetching_pdb", new Object[] @@ -732,17 +759,15 @@ public class ChimeraViewFrame extends StructureViewerBase @Override public void eps_actionPerformed(ActionEvent e) { - throw new Error( - MessageManager - .getString("error.eps_generation_not_implemented")); + throw new Error(MessageManager + .getString("error.eps_generation_not_implemented")); } @Override public void png_actionPerformed(ActionEvent e) { - throw new Error( - MessageManager - .getString("error.png_generation_not_implemented")); + throw new Error(MessageManager + .getString("error.png_generation_not_implemented")); } @Override @@ -852,19 +877,18 @@ public class ChimeraViewFrame extends StructureViewerBase } /** - * Override superclass method to make the 'Chimera' menu always visible, but - * 'Superpose with...' only enabled if there is more than one structure shown + * Sends commands to align structures according to associated alignment(s). + * + * @return */ @Override - public void updateTitleAndMenus() + protected String alignStructs_withAllAlignPanels() { - super.updateTitleAndMenus(); - viewerActionMenu.setVisible(true); - viewSelectionMenu.setEnabled(false); - if (getBinding().getPdbFile().length > 1 - && getBinding().getSequence().length > 1) + String reply = super.alignStructs_withAllAlignPanels(); + if (reply != null) { - viewSelectionMenu.setEnabled(true); + statusBar.setText("Superposition failed: " + reply); } + return reply; } }