X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignFrame.java;h=22879792d64e091143e90188d55e45b9d69d5a56;hb=cf78dc7e8c37a03da8e7e396fec7e7ec54666847;hp=e36944f1f87916cec1aecbcb4ec8fac064c46d89;hpb=c73c8c28e34bdcac21e89aa89b69e85dad9e0189;p=jalview.git diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index e36944f..2287979 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -49,7 +49,11 @@ import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.io.AnnotationFile; import jalview.io.AppletFormatAdapter; +import jalview.io.DataSourceType; import jalview.io.FeaturesFile; +import jalview.io.FileFormat; +import jalview.io.FileFormatI; +import jalview.io.FileFormats; import jalview.io.TCoffeeScoreFile; import jalview.schemes.Blosum62ColourScheme; import jalview.schemes.BuriedColourScheme; @@ -102,7 +106,6 @@ import java.net.URLEncoder; import java.util.Arrays; import java.util.Deque; import java.util.HashMap; -import java.util.Hashtable; import java.util.List; import java.util.Map; import java.util.StringTokenizer; @@ -346,7 +349,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, * is protocol for accessing data referred to by file */ - public boolean parseFeaturesFile(String file, String type) + public boolean parseFeaturesFile(String file, DataSourceType type) { return parseFeaturesFile(file, type, true); } @@ -356,14 +359,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, * * @param file * file URL, content, or other resolvable path - * @param type + * @param sourceType * is protocol for accessing data referred to by file * @param autoenabledisplay * when true, display features flag will be automatically enabled if * features are loaded * @return true if data parsed as a features file */ - public boolean parseFeaturesFile(String file, String type, + public boolean parseFeaturesFile(String file, DataSourceType sourceType, boolean autoenabledisplay) { boolean featuresFile = false; @@ -373,7 +376,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, .getFeatureRenderer().getFeatureColours(); boolean relaxedIdMatching = viewport.applet.getDefaultParameter( "relaxedidmatch", false); - featuresFile = new FeaturesFile(file, type).parse( + featuresFile = new FeaturesFile(file, sourceType).parse( viewport.getAlignment(), colours, true, relaxedIdMatching); } catch (Exception ex) { @@ -926,11 +929,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, if (alignPanel.getAlignment().getAlignmentAnnotation() != null) { for (AlignmentAnnotation aa : alignPanel.getAlignment() - .getAlignmentAnnotation()) - { - boolean visible = (aa.sequenceRef == null ? showForAlignment - : showForSequences); - aa.visible = visible; + .getAlignmentAnnotation()) + { + boolean visible = (aa.sequenceRef == null ? showForAlignment + : showForSequences); + aa.visible = visible; } } alignPanel.validateAnnotationDimensions(true); @@ -1357,13 +1360,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this); Frame frame = new Frame(); frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage( + JalviewLite.addFrame(frame, MessageManager.formatMessage( "label.alignment_output_command", new Object[] { e.getActionCommand() }), 600, 500); - FeatureRenderer fr = this.alignPanel.cloneFeatureRenderer(); + FileFormatI fileFormat = FileFormats.getInstance().forName( + e.getActionCommand()); cap.setText(new AppletFormatAdapter(alignPanel).formatSequences( - e.getActionCommand(), viewport.getAlignment(), + fileFormat, viewport.getAlignment(), viewport.getShowJVSuffix())); } @@ -1415,9 +1419,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, FeaturesFile formatter = new FeaturesFile(); if (format.equalsIgnoreCase("Jalview")) { - features = formatter.printJalviewFormat(viewport - .getAlignment().getSequencesArray(), - getDisplayedFeatureCols()); + features = formatter.printJalviewFormat(viewport.getAlignment() + .getSequencesArray(), getDisplayedFeatureCols()); } else { @@ -1480,10 +1483,13 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, url.append(appendProtocol(viewport.applet.getParameter("annotations"))); } - if (viewport.applet.getParameter("jnetfile") != null) + if (viewport.applet.getParameter("jnetfile") != null + || viewport.applet.getParameter("jpredfile") != null) { url.append("&annotations="); - url.append(appendProtocol(viewport.applet.getParameter("jnetfile"))); + url.append(appendProtocol(viewport.applet.getParameter("jnetfile") != null ? viewport.applet + .getParameter("jnetfile") : viewport.applet + .getParameter("jpredfile"))); } if (viewport.applet.getParameter("defaultColour") != null) @@ -2672,26 +2678,43 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, protected void conservationMenuItem_actionPerformed() { - viewport.setConservationSelected(conservationMenuItem.getState()); + boolean selected = conservationMenuItem.getState(); + modifyConservation.setEnabled(selected); + viewport.setConservationSelected(selected); - viewport.setAbovePIDThreshold(false); - abovePIDThreshold.setState(false); + // viewport.setAbovePIDThreshold(false); + // abovePIDThreshold.setState(false); changeColour(viewport.getGlobalColourScheme()); - modifyConservation_actionPerformed(); + if (selected) + { + modifyConservation_actionPerformed(); + } + else + { + SliderPanel.hideConservationSlider(); + } } public void abovePIDThreshold_actionPerformed() { - viewport.setAbovePIDThreshold(abovePIDThreshold.getState()); - - conservationMenuItem.setState(false); - viewport.setConservationSelected(false); + boolean selected = abovePIDThreshold.getState(); + modifyPID.setEnabled(selected); + viewport.setAbovePIDThreshold(selected); + // conservationMenuItem.setState(false); + // viewport.setConservationSelected(false); changeColour(viewport.getGlobalColourScheme()); - modifyPID_actionPerformed(); + if (selected) + { + modifyPID_actionPerformed(); + } + else + { + SliderPanel.hidePIDSlider(); + } } public void sortPairwiseMenuItem_actionPerformed() @@ -3236,11 +3259,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, inputText.addActionListener(this); Menu outputTextboxMenu = new Menu( MessageManager.getString("label.out_to_textbox")); - for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) + for (String ff : FileFormats.getInstance().getWritableFormats(true)) { - - MenuItem item = new MenuItem( - jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]); + MenuItem item = new MenuItem(ff); item.addActionListener(new java.awt.event.ActionListener() { @@ -3515,9 +3536,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, nucleotideColour.addActionListener(this); modifyPID.setLabel(MessageManager .getString("label.modify_identity_threshold")); + modifyPID.setEnabled(abovePIDThreshold.getState()); modifyPID.addActionListener(this); modifyConservation.setLabel(MessageManager .getString("label.modify_conservation_threshold")); + modifyConservation.setEnabled(conservationMenuItem.getState()); modifyConservation.addActionListener(this); annotationColour.setLabel(MessageManager .getString("action.by_annotation")); @@ -4018,19 +4041,15 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } // resolve data source // TODO: this code should be a refactored to an io package - String protocol = AppletFormatAdapter.resolveProtocol(pdbFile, "PDB"); + DataSourceType protocol = AppletFormatAdapter.resolveProtocol( + pdbFile, FileFormat.PDB); if (protocol == null) { return false; } if (needtoadd) { - // make a note of the access mode and add - if (pdbentry.getProperty() == null) - { - pdbentry.setProperty(new Hashtable()); - } - pdbentry.getProperty().put("protocol", protocol); + pdbentry.setProperty("protocol", protocol); toaddpdb.addPDBId(pdbentry); alignPanel.getStructureSelectionManager() .registerPDBEntry(pdbentry); @@ -4067,7 +4086,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } public void newStructureView(JalviewLite applet, PDBEntry pdb, - SequenceI[] seqs, String[] chains, String protocol) + SequenceI[] seqs, String[] chains, DataSourceType protocol) { // Scrub any null sequences from the array Object[] sqch = cleanSeqChainArrays(seqs, chains); @@ -4078,10 +4097,16 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, System.err .println("JalviewLite.AlignFrame:newStructureView: No sequence to bind structure to."); } - if (protocol == null || protocol.trim().length() == 0 - || protocol.equals("null")) + if (protocol == null) { - protocol = (String) pdb.getProperty().get("protocol"); + String sourceType = (String) pdb.getProperty("protocol"); + try + { + protocol = DataSourceType.valueOf(sourceType); + } catch (IllegalArgumentException e) + { + // ignore + } if (protocol == null) { System.err.println("Couldn't work out protocol to open structure: " @@ -4104,12 +4129,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { // can only do alignments with Jmol // find the last jmol window assigned to this alignment - jalview.appletgui.AppletJmol ajm = null, tajm; - Vector jmols = applet - .getAppletWindow(jalview.appletgui.AppletJmol.class); + AppletJmol ajm = null, tajm; + Vector jmols = applet.getAppletWindow(AppletJmol.class); for (int i = 0, iSize = jmols.size(); i < iSize; i++) { - tajm = (jalview.appletgui.AppletJmol) jmols.elementAt(i); + tajm = (AppletJmol) jmols.elementAt(i); if (tajm.ap.alignFrame == this) { ajm = tajm; @@ -4128,7 +4152,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, // otherwise, create a new window if (applet.jmolAvailable) { - new jalview.appletgui.AppletJmol(pdb, seqs, chains, alignPanel, + new AppletJmol(pdb, seqs, chains, alignPanel, protocol); applet.lastFrameX += 40; applet.lastFrameY += 40;