X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignFrame.java;h=ed04a0a16ec87ede2da555d004c8ac791837d12d;hb=f4766a7bbcfae845fc95923b01fa14ff83d589ff;hp=a14da77d76681e4e951a8fcfd40f26ee9c87f934;hpb=2a9991ef1eb02d97e9c8ed1644f292117ae6f600;p=jalview.git diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index a14da77..ed04a0a 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -22,9 +22,13 @@ package jalview.appletgui; import jalview.analysis.AlignmentSorter; import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; +import jalview.analysis.TreeBuilder; +import jalview.analysis.scoremodels.PIDModel; +import jalview.analysis.scoremodels.ScoreModels; import jalview.api.AlignViewControllerGuiI; import jalview.api.AlignViewControllerI; import jalview.api.AlignViewportI; +import jalview.api.FeatureColourI; import jalview.api.FeatureRenderer; import jalview.api.FeatureSettingsControllerI; import jalview.api.SequenceStructureBinding; @@ -42,13 +46,18 @@ import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentOrder; import jalview.datamodel.ColumnSelection; +import jalview.datamodel.HiddenColumns; import jalview.datamodel.PDBEntry; import jalview.datamodel.Sequence; 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; @@ -59,8 +68,7 @@ import jalview.schemes.HydrophobicColourScheme; import jalview.schemes.NucleotideColourScheme; import jalview.schemes.PIDColourScheme; import jalview.schemes.PurinePyrimidineColourScheme; -import jalview.schemes.RNAHelicesColourChooser; -import jalview.schemes.RNAInteractionColourScheme; +import jalview.schemes.RNAHelicesColour; import jalview.schemes.StrandColourScheme; import jalview.schemes.TCoffeeColourScheme; import jalview.schemes.TaylorColourScheme; @@ -71,11 +79,13 @@ import jalview.structures.models.AAStructureBindingModel; import jalview.util.MappingUtils; import jalview.util.MessageManager; import jalview.viewmodel.AlignmentViewport; +import jalview.viewmodel.ViewportRanges; import java.awt.BorderLayout; import java.awt.Canvas; import java.awt.CheckboxMenuItem; import java.awt.Color; +import java.awt.FlowLayout; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Frame; @@ -84,6 +94,7 @@ import java.awt.Label; import java.awt.Menu; import java.awt.MenuBar; import java.awt.MenuItem; +import java.awt.Panel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.FocusEvent; @@ -100,12 +111,13 @@ 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; import java.util.Vector; +import org.jmol.viewer.Viewer; + public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemListener, KeyListener, AlignViewControllerGuiI { @@ -138,8 +150,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, * @param title * @param embedded */ - public AlignFrame(AlignmentI al, JalviewLite applet, - String title, boolean embedded) + public AlignFrame(AlignmentI al, JalviewLite applet, String title, + boolean embedded) { this(al, applet, title, embedded, true); } @@ -154,22 +166,22 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, * @param embedded * @param addToDisplay */ - public AlignFrame(AlignmentI al, JalviewLite applet, - String title, boolean embedded, boolean addToDisplay) + public AlignFrame(AlignmentI al, JalviewLite applet, String title, + boolean embedded, boolean addToDisplay) { this(al, null, null, applet, title, embedded, addToDisplay); } public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs, - ColumnSelection columnSelection, JalviewLite applet, - String title, boolean embedded) + HiddenColumns hidden, JalviewLite applet, String title, + boolean embedded) { - this(al, hiddenSeqs, columnSelection, applet, title, embedded, true); + this(al, hiddenSeqs, hidden, applet, title, embedded, true); } public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs, - ColumnSelection columnSelection, JalviewLite applet, - String title, boolean embedded, boolean addToDisplay) + HiddenColumns hidden, JalviewLite applet, String title, + boolean embedded, boolean addToDisplay) { if (applet != null) { @@ -210,12 +222,12 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, if (hiddenSeqs != null && hiddenSeqs.length > 0) { viewport.hideSequence(hiddenSeqs); - viewport.setHasHiddenRows(true); } - if (columnSelection != null) + if (hidden != null) { - viewport.setColumnSelection(columnSelection); + viewport.getAlignment().setHiddenColumns(hidden); } + viewport.setScaleAboveWrapped(scaleAbove.getState()); alignPanel = new AlignmentPanel(this, viewport); avc = new jalview.controller.AlignViewController(this, viewport, @@ -232,8 +244,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, normSequenceLogo.setState(viewport.isNormaliseSequenceLogo()); applyToAllGroups.setState(viewport.getColourAppliesToAllGroups()); annotationPanelMenuItem.setState(viewport.isShowAnnotation()); - showAlignmentAnnotations.setState(viewport.isShowAnnotation()); - showSequenceAnnotations.setState(viewport.isShowAnnotation()); + showAlignmentAnnotations.setEnabled(annotationPanelMenuItem.getState()); + showSequenceAnnotations.setEnabled(annotationPanelMenuItem.getState()); + showAlignmentAnnotations.setState(true); + showSequenceAnnotations.setState(false); seqLimits.setState(viewport.getShowJVSuffix()); @@ -275,6 +289,16 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } if (viewport.getAlignment().isNucleotide()) { + conservationMenuItem.setEnabled(false); + clustalColour.setEnabled(false); + BLOSUM62Colour.setEnabled(false); + zappoColour.setEnabled(false); + taylorColour.setEnabled(false); + hydrophobicityColour.setEnabled(false); + helixColour.setEnabled(false); + strandColour.setEnabled(false); + turnColour.setEnabled(false); + buriedColour.setEnabled(false); viewport.updateStrucConsensus(alignPanel); if (viewport.getAlignment().hasRNAStructure()) { @@ -289,6 +313,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { RNAHelixColour.setEnabled(false); purinePyrimidineColour.setEnabled(false); + nucleotideColour.setEnabled(false); } // Some JVMS send keyevents to Top frame or lowest panel, // Havent worked out why yet. So add to both this frame and seqCanvas for @@ -302,6 +327,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, alignPanel.annotationSpaceFillerHolder.addKeyListener(this); alignPanel.alabels.addKeyListener(this); + setAnnotationsVisibility(); + if (addToDisplay) { addToDisplay(embedded); @@ -338,7 +365,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); } @@ -348,28 +375,25 @@ 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) { - // TODO: test if importing a features file onto an alignment which already - // has features with links overwrites the original links. - - Hashtable featureLinks = new Hashtable(); boolean featuresFile = false; try { - featuresFile = new jalview.io.FeaturesFile(file, type) - .parse(viewport.getAlignment(), alignPanel.seqPanel.seqCanvas - .getFeatureRenderer().getFeatureColours(), featureLinks, - true, viewport.applet.getDefaultParameter( - "relaxedidmatch", false)); + Map colours = alignPanel.seqPanel.seqCanvas + .getFeatureRenderer().getFeatureColours(); + boolean relaxedIdMatching = viewport.applet + .getDefaultParameter("relaxedidmatch", false); + featuresFile = new FeaturesFile(file, sourceType).parse( + viewport.getAlignment(), colours, true, relaxedIdMatching); } catch (Exception ex) { ex.printStackTrace(); @@ -377,10 +401,6 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, if (featuresFile) { - if (featureLinks.size() > 0) - { - alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureLinks = featureLinks; - } if (autoenabledisplay) { viewport.setShowSequenceFeatures(true); @@ -405,10 +425,13 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, @Override public void keyPressed(KeyEvent evt) { + ViewportRanges ranges = viewport.getRanges(); + if (viewport.cursorMode - && ((evt.getKeyCode() >= KeyEvent.VK_0 && evt.getKeyCode() <= KeyEvent.VK_9) || (evt - .getKeyCode() >= KeyEvent.VK_NUMPAD0 && evt - .getKeyCode() <= KeyEvent.VK_NUMPAD9)) + && ((evt.getKeyCode() >= KeyEvent.VK_0 + && evt.getKeyCode() <= KeyEvent.VK_9) + || (evt.getKeyCode() >= KeyEvent.VK_NUMPAD0 + && evt.getKeyCode() <= KeyEvent.VK_NUMPAD9)) && Character.isDigit(evt.getKeyChar())) { alignPanel.seqPanel.numberPressed(evt.getKeyChar()); @@ -551,13 +574,13 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, case KeyEvent.VK_F2: viewport.cursorMode = !viewport.cursorMode; - statusBar.setText(MessageManager.formatMessage( - "label.keyboard_editing_mode", new String[] + statusBar.setText(MessageManager + .formatMessage("label.keyboard_editing_mode", new String[] { (viewport.cursorMode ? "on" : "off") })); if (viewport.cursorMode) { - alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes; - alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq; + alignPanel.seqPanel.seqCanvas.cursorX = ranges.getStartRes(); + alignPanel.seqPanel.seqCanvas.cursorY = ranges.getStartSeq(); } break; @@ -577,27 +600,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } case KeyEvent.VK_PAGE_UP: - if (viewport.getWrapAlignment()) - { - alignPanel.scrollUp(true); - } - else - { - alignPanel.setScrollValues(viewport.startRes, viewport.startSeq - - viewport.endSeq + viewport.startSeq); - } + ranges.pageUp(); break; case KeyEvent.VK_PAGE_DOWN: - if (viewport.getWrapAlignment()) - { - alignPanel.scrollUp(false); - } - else - { - alignPanel.setScrollValues(viewport.startRes, viewport.startSeq - + viewport.endSeq - viewport.startSeq); - } + ranges.pageDown(); break; case KeyEvent.VK_Z: @@ -702,11 +709,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, // Hide everything by the current selection - this is a hack - we do the // invert and then hide // first check that there will be visible columns after the invert. - if ((viewport.getColumnSelection() != null - && viewport.getColumnSelection().getSelected() != null && viewport - .getColumnSelection().getSelected().size() > 0) - || (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg - .getEndRes())) + if (viewport.hasSelectedColumns() || (sg != null && sg.getSize() > 0 + && sg.getStartRes() <= sg.getEndRes())) { // now invert the sequence set, if required - empty selection implies // that no hiding is required. @@ -732,8 +736,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, hide = true; viewport.hideAllSelectedSeqs(); } - else if (!(toggleCols && viewport.getColumnSelection().getSelected() - .size() > 0)) + else if (!(toggleCols && viewport.hasSelectedColumns())) { viewport.showAllHiddenSeqs(); } @@ -741,7 +744,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, if (toggleCols) { - if (viewport.getColumnSelection().getSelected().size() > 0) + if (viewport.hasSelectedColumns()) { viewport.hideSelectedColumns(); if (!toggleSeqs) @@ -753,6 +756,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { viewport.showAllHiddenColumns(); } + viewport.sendSelection(); } } @@ -812,8 +816,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } else if (source == annotationPanelMenuItem) { - viewport.setShowAnnotation(annotationPanelMenuItem.getState()); - alignPanel.setAnnotationVisible(annotationPanelMenuItem.getState()); + boolean showAnnotations = annotationPanelMenuItem.getState(); + showAlignmentAnnotations.setEnabled(showAnnotations); + showSequenceAnnotations.setEnabled(showAnnotations); + viewport.setShowAnnotation(showAnnotations); + alignPanel.setAnnotationVisible(showAnnotations); } else if (source == sequenceFeatures) { @@ -832,16 +839,18 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { boolean newState = sortAnnBySequence.getState(); sortAnnByLabel.setState(false); - setAnnotationSortOrder(newState ? SequenceAnnotationOrder.SEQUENCE_AND_LABEL - : SequenceAnnotationOrder.NONE); + setAnnotationSortOrder( + newState ? SequenceAnnotationOrder.SEQUENCE_AND_LABEL + : SequenceAnnotationOrder.NONE); setViewportAnnotationOrder(); } else if (source == sortAnnByLabel) { boolean newState = sortAnnByLabel.getState(); sortAnnBySequence.setState(false); - setAnnotationSortOrder(newState ? SequenceAnnotationOrder.LABEL_AND_SEQUENCE - : SequenceAnnotationOrder.NONE); + setAnnotationSortOrder( + newState ? SequenceAnnotationOrder.LABEL_AND_SEQUENCE + : SequenceAnnotationOrder.NONE); setViewportAnnotationOrder(); } else if (source == showAutoFirst) @@ -913,7 +922,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, /** * Set the visibility state of sequence-related and/or alignment-related - * annotations depending on checkbox selections. Repaint after calling. + * annotations depending on checkbox selections, and repaint. * * @param visible */ @@ -921,14 +930,19 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { boolean showForAlignment = showAlignmentAnnotations.getState(); boolean showForSequences = showSequenceAnnotations.getState(); - for (AlignmentAnnotation aa : alignPanel.getAlignment() - .getAlignmentAnnotation()) + if (alignPanel.getAlignment().getAlignmentAnnotation() != null) { - boolean visible = (aa.sequenceRef == null ? showForAlignment - : showForSequences); + for (AlignmentAnnotation aa : alignPanel.getAlignment() + .getAlignmentAnnotation()) + { + boolean visible = (aa.sequenceRef == null ? showForAlignment + : showForSequences); aa.visible = visible; + } } - alignPanel.validateAnnotationDimensions(false); + alignPanel.validateAnnotationDimensions(true); + validate(); + repaint(); } private void setAnnotationSortOrder(SequenceAnnotationOrder order) @@ -967,6 +981,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, @Override public void actionPerformed(ActionEvent evt) { + viewport.applet.currentAlignFrame = this; + Object source = evt.getSource(); if (source == inputText) @@ -1045,6 +1061,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { delete_actionPerformed(); } + else if (source == createGroup) + { + createGroup_actionPerformed(); + } + else if (source == unGroup) + { + unGroup_actionPerformed(); + } else if (source == grpsFromSelection) { makeGrpsFromSelection_actionPerformed(); @@ -1064,11 +1088,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, else if (source == invertSequenceMenuItem) { invertSequenceMenuItem_actionPerformed(); + // uncomment to slave sequence selections in split frame + // viewport.sendSelection(); } else if (source == invertColSel) { viewport.invertColumnSelection(); alignPanel.paintAlignment(true); + viewport.sendSelection(); } else if (source == remove2LeftMenuItem) { @@ -1102,27 +1129,34 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { viewport.showAllHiddenColumns(); alignPanel.paintAlignment(true); + viewport.sendSelection(); } else if (source == showSeqs) { viewport.showAllHiddenSeqs(); alignPanel.paintAlignment(true); + // uncomment if we want to slave sequence selections in split frame + // viewport.sendSelection(); } else if (source == hideColumns) { viewport.hideSelectedColumns(); alignPanel.paintAlignment(true); + viewport.sendSelection(); } else if (source == hideSequences && viewport.getSelectionGroup() != null) { viewport.hideAllSelectedSeqs(); alignPanel.paintAlignment(true); + // uncomment if we want to slave sequence selections in split frame + // viewport.sendSelection(); } else if (source == hideAllButSelection) { toggleHiddenRegions(false, false); alignPanel.paintAlignment(true); + viewport.sendSelection(); } else if (source == hideAllSelection) { @@ -1131,12 +1165,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, viewport.hideAllSelectedSeqs(); viewport.hideSelectedColumns(); alignPanel.paintAlignment(true); + viewport.sendSelection(); } else if (source == showAllHidden) { viewport.showAllHiddenColumns(); viewport.showAllHiddenSeqs(); alignPanel.paintAlignment(true); + viewport.sendSelection(); } else if (source == showGroupConsensus) { @@ -1174,8 +1210,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, cap.setText(contents.toString()); Frame frame = new Frame(); frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage( - "label.alignment_properties", new String[] + jalview.bin.JalviewLite.addFrame(frame, MessageManager + .formatMessage("label.alignment_properties", new String[] { getTitle() }), 400, 250); } else if (source == overviewMenuItem) @@ -1227,13 +1263,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { changeColour(new PurinePyrimidineColourScheme()); } - else if (source == RNAInteractionColour) - { - changeColour(new RNAInteractionColourScheme()); - } + // else if (source == RNAInteractionColour) + // { + // changeColour(new RNAInteractionColourScheme()); + // } else if (source == RNAHelixColour) { - new RNAHelicesColourChooser(viewport, alignPanel); + changeColour(new RNAHelicesColour(viewport.getAlignment())); + // new RNAHelicesColourChooser(viewport, alignPanel); } else if (source == modifyPID) { @@ -1336,16 +1373,15 @@ 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( - "label.alignment_output_command", new Object[] + JalviewLite.addFrame(frame, MessageManager + .formatMessage("label.alignment_output_command", new Object[] { e.getActionCommand() }), 600, 500); - FeatureRenderer fr = this.alignPanel.cloneFeatureRenderer(); - viewport.setFeatureRenderer(fr); - viewport.setIncludeHiddenRegion(false); - cap.setText(new AppletFormatAdapter(viewport).formatSequences( - e.getActionCommand(), viewport.getAlignment(), - viewport.getShowJVSuffix())); + FileFormatI fileFormat = FileFormats.getInstance() + .forName(e.getActionCommand()); + cap.setText( + new AppletFormatAdapter(alignPanel).formatSequences(fileFormat, + viewport.getAlignment(), viewport.getShowJVSuffix())); } public void loadAnnotations() @@ -1379,13 +1415,24 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, return annotation; } - private Map getDisplayedFeatureCols() + private Map getDisplayedFeatureCols() { if (alignPanel.getFeatureRenderer() != null - && viewport.getFeaturesDisplayed()!= null) + && viewport.getFeaturesDisplayed() != null) { return alignPanel.getFeatureRenderer().getDisplayedFeatureCols(); - + + } + return null; + } + + private List getDisplayedFeatureGroups() + { + if (alignPanel.getFeatureRenderer() != null + && viewport.getFeaturesDisplayed() != null) + { + return alignPanel.getFeatureRenderer().getDisplayedFeatureGroups(); + } return null; } @@ -1393,16 +1440,18 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, public String outputFeatures(boolean displayTextbox, String format) { String features; + FeaturesFile formatter = new FeaturesFile(); if (format.equalsIgnoreCase("Jalview")) { - features = new FeaturesFile().printJalviewFormat(viewport - .getAlignment().getSequencesArray(), - getDisplayedFeatureCols()); + features = formatter.printJalviewFormat(viewport.getAlignment() + .getSequencesArray(), getDisplayedFeatureCols(), + getDisplayedFeatureGroups(), true); } else { - features = new FeaturesFile().printGFFFormat(viewport.getAlignment() - .getSequencesArray(), getDisplayedFeatureCols()); + features = formatter.printGffFormat(viewport.getAlignment() + .getSequencesArray(), getDisplayedFeatureCols(), + getDisplayedFeatureGroups(), true); } if (displayTextbox) @@ -1445,8 +1494,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, : "?"; url.append(firstSep); - url.append("open=" - + appendProtocol(viewport.applet.getParameter("file"))); + url.append( + "open=" + appendProtocol(viewport.applet.getParameter("file"))); if (viewport.applet.getParameter("features") != null) { @@ -1457,27 +1506,30 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, if (viewport.applet.getParameter("annotations") != null) { url.append("&annotations="); - url.append(appendProtocol(viewport.applet.getParameter("annotations"))); + 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) { - url.append("&colour=" - + removeWhiteSpace(viewport.applet - .getParameter("defaultColour"))); + url.append("&colour=" + removeWhiteSpace( + viewport.applet.getParameter("defaultColour"))); } if (viewport.applet.getParameter("userDefinedColour") != null) { - url.append("&colour=" - + removeWhiteSpace(viewport.applet - .getParameter("userDefinedColour"))); + url.append("&colour=" + removeWhiteSpace( + viewport.applet.getParameter("userDefinedColour"))); } if (viewport.applet.getParameter("tree") != null) { @@ -1567,8 +1619,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { undoMenuItem.setEnabled(true); CommandI command = viewport.getHistoryList().peek(); - undoMenuItem.setLabel(MessageManager.formatMessage( - "label.undo_command", new Object[] + undoMenuItem.setLabel(MessageManager + .formatMessage("label.undo_command", new Object[] { command.getDescription() })); } else @@ -1582,8 +1634,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, redoMenuItem.setEnabled(true); CommandI command = viewport.getRedoList().peek(); - redoMenuItem.setLabel(MessageManager.formatMessage( - "label.redo_command", new Object[] + redoMenuItem.setLabel(MessageManager + .formatMessage("label.redo_command", new Object[] { command.getDescription() })); } else @@ -1636,8 +1688,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, // viewport.getColumnSelection().getHiddenColumns() // != null; updateEditMenuBar(); - originalSource.firePropertyChange("alignment", null, originalSource - .getAlignment().getSequences()); + originalSource.firePropertyChange("alignment", null, + originalSource.getAlignment().getSequences()); } /** @@ -1669,8 +1721,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, // != null; updateEditMenuBar(); - originalSource.firePropertyChange("alignment", null, originalSource - .getAlignment().getSequences()); + originalSource.firePropertyChange("alignment", null, + originalSource.getAlignment().getSequences()); } AlignmentViewport getOriginatingSource(CommandI command) @@ -1684,8 +1736,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { EditCommand editCommand = (EditCommand) command; al = editCommand.getAlignment(); - Vector comps = (Vector) PaintRefresher.components.get(viewport - .getSequenceSetId()); + Vector comps = PaintRefresher.components + .get(viewport.getSequenceSetId()); for (int i = 0; i < comps.size(); i++) { if (comps.elementAt(i) instanceof AlignmentPanel) @@ -1741,26 +1793,24 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, viewport, complement); complement.getAlignment().moveSelectedSequencesByOne(mappedSelection, up ? null : complement.getHiddenRepSequences(), up); - // TODO need to trigger a repaint of the complementary panel - how? - // would prefer to handle in SplitFrame but it is not overriding key - // listener chiz + getSplitFrame().getComplement(this).alignPanel.paintAlignment(true); } } synchronized void slideSequences(boolean right, int size) { - List sg = new Vector(); + List sg = new Vector<>(); if (viewport.cursorMode) { - sg.add(viewport.getAlignment().getSequenceAt( - alignPanel.seqPanel.seqCanvas.cursorY)); + sg.add(viewport.getAlignment() + .getSequenceAt(alignPanel.seqPanel.seqCanvas.cursorY)); } else if (viewport.getSelectionGroup() != null && viewport.getSelectionGroup().getSize() != viewport .getAlignment().getHeight()) { - sg = viewport.getSelectionGroup().getSequences( - viewport.getHiddenRepSequences()); + sg = viewport.getSelectionGroup() + .getSequences(viewport.getHiddenRepSequences()); } if (sg.size() < 1) @@ -1780,8 +1830,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, SequenceI[] seqs1 = sg.toArray(new SequenceI[sg.size()]); - SequenceI[] seqs2 = invertGroup.toArray(new SequenceI[invertGroup - .size()]); + SequenceI[] seqs2 = invertGroup + .toArray(new SequenceI[invertGroup.size()]); for (int i = 0; i < invertGroup.size(); i++) { seqs2[i] = invertGroup.elementAt(i); @@ -1790,13 +1840,13 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, SlideSequencesCommand ssc; if (right) { - ssc = new SlideSequencesCommand("Slide Sequences", seqs2, seqs1, - size, viewport.getGapCharacter()); + ssc = new SlideSequencesCommand("Slide Sequences", seqs2, seqs1, size, + viewport.getGapCharacter()); } else { - ssc = new SlideSequencesCommand("Slide Sequences", seqs1, seqs2, - size, viewport.getGapCharacter()); + ssc = new SlideSequencesCommand("Slide Sequences", seqs1, seqs2, size, + viewport.getGapCharacter()); } int groupAdjustment = 0; @@ -1836,9 +1886,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, if (historyList != null && historyList.size() > 0 && historyList.peek() instanceof SlideSequencesCommand) { - appendHistoryItem = ssc - .appendSlideCommand((SlideSequencesCommand) historyList - .peek()); + appendHistoryItem = ssc.appendSlideCommand( + (SlideSequencesCommand) historyList.peek()); } if (!appendHistoryItem) @@ -1851,7 +1900,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, static StringBuffer copiedSequences; - static Vector copiedHiddenColumns; + static Vector copiedHiddenColumns; protected void copy_actionPerformed() { @@ -1862,7 +1911,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, SequenceGroup sg = viewport.getSelectionGroup(); copiedSequences = new StringBuffer(); - Map orderedSeqs = new HashMap(); + Map orderedSeqs = new HashMap<>(); for (int i = 0; i < sg.getSize(); i++) { SequenceI seq = sg.getSequenceAt(i); @@ -1875,12 +1924,13 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, if (viewport.hasHiddenColumns() && viewport.getSelectionGroup() != null) { - copiedHiddenColumns = new Vector(); + copiedHiddenColumns = new Vector<>(viewport.getAlignment() + .getHiddenColumns().getHiddenColumnsCopy()); int hiddenOffset = viewport.getSelectionGroup().getStartRes(); - for (int[] region : viewport.getColumnSelection().getHiddenColumns()) + for (int[] region : copiedHiddenColumns) { - copiedHiddenColumns.addElement(new int[] - { region[0] - hiddenOffset, region[1] - hiddenOffset }); + region[0] = region[0] - hiddenOffset; + region[1] = region[1] - hiddenOffset; } } else @@ -1928,14 +1978,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, endRes += seq.getStart() - 1; } - copiedSequences.append(seq.getName() - + "\t" - + startRes - + "\t" - + endRes - + "\t" - + seq.getSequenceAsString(sg.getStartRes(), - sg.getEndRes() + 1) + "\n"); + copiedSequences.append(seq.getName() + "\t" + startRes + "\t" + endRes + + "\t" + seq.getSequenceAsString(sg.getStartRes(), + sg.getEndRes() + 1) + + "\n"); } } @@ -1977,14 +2023,18 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, if (newAlignment) { - String newtitle = MessageManager.getString("label.copied_sequences"); - if (getTitle().startsWith(MessageManager.getString("label.copied_sequences"))) + String newtitle = MessageManager + .getString("label.copied_sequences"); + if (getTitle().startsWith( + MessageManager.getString("label.copied_sequences"))) { newtitle = getTitle(); } else { - newtitle = newtitle.concat(MessageManager.formatMessage("label.from_msname", new String[]{getTitle()})); + newtitle = newtitle.concat(MessageManager + .formatMessage("label.from_msname", new String[] + { getTitle() })); } AlignFrame af = new AlignFrame(new Alignment(newSeqs), viewport.applet, newtitle, false); @@ -1992,7 +2042,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { for (int i = 0; i < copiedHiddenColumns.size(); i++) { - int[] region = (int[]) copiedHiddenColumns.elementAt(i); + int[] region = copiedHiddenColumns.elementAt(i); af.viewport.hideColumns(region[0], region[1]); } } @@ -2024,10 +2074,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, seqs, 0, viewport.getAlignment().getWidth(), viewport.getAlignment())); - viewport.setEndSeq(viewport.getAlignment().getHeight()); + viewport.getRanges().setEndSeq(viewport.getAlignment().getHeight()); viewport.getAlignment().getWidth(); - viewport.firePropertyChange("alignment", null, viewport.getAlignment() - .getSequences()); + viewport.firePropertyChange("alignment", null, + viewport.getAlignment().getSequences()); } @@ -2054,9 +2104,32 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, seqs.addElement(seq); } - // If the cut affects all sequences, remove highlighted columns + /* + * If the cut affects all sequences, warn, remove highlighted columns + */ if (sg.getSize() == viewport.getAlignment().getHeight()) { + boolean isEntireAlignWidth = (((sg.getEndRes() - sg.getStartRes()) + + 1) == viewport.getAlignment().getWidth()) ? true : false; + if (isEntireAlignWidth) + { + String title = MessageManager.getString("label.delete_all"); + Panel infoPanel = new Panel(); + infoPanel.setLayout(new FlowLayout()); + infoPanel.add( + new Label(MessageManager.getString("warn.delete_all"))); + + final JVDialog dialog = new JVDialog(this, title, true, 400, 200); + dialog.setMainPanel(infoPanel); + dialog.ok.setLabel(MessageManager.getString("action.ok")); + dialog.cancel.setLabel(MessageManager.getString("action.cancel")); + dialog.setVisible(true); + + if (!dialog.accept) + { + return; + } + } viewport.getColumnSelection().removeElements(sg.getStartRes(), sg.getEndRes() + 1); } @@ -2078,8 +2151,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, viewport.setSelectionGroup(null); viewport.getAlignment().deleteGroup(sg); - viewport.firePropertyChange("alignment", null, viewport.getAlignment() - .getSequences()); + viewport.firePropertyChange("alignment", null, + viewport.getAlignment().getSequences()); if (viewport.getAlignment().getHeight() < 1) { @@ -2187,7 +2260,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } sg.setEndRes(viewport.getAlignment().getWidth() - 1); viewport.setSelectionGroup(sg); - alignPanel.paintAlignment(true); + // JAL-2034 - should delegate to + // alignPanel to decide if overview needs + // updating. + alignPanel.paintAlignment(false); PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId()); viewport.sendSelection(); } @@ -2204,7 +2280,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, viewport.setSelectionGroup(null); alignPanel.idPanel.idCanvas.searchResults = null; alignPanel.seqPanel.seqCanvas.highlightSearchResults(null); - alignPanel.paintAlignment(true); + // JAL-2034 - should delegate to + // alignPanel to decide if overview needs + // updating. + alignPanel.paintAlignment(false); PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId()); viewport.sendSelection(); } @@ -2231,10 +2310,12 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, void trimAlignment(boolean trimLeft) { + AlignmentI al = viewport.getAlignment(); + ViewportRanges ranges = viewport.getRanges(); ColumnSelection colSel = viewport.getColumnSelection(); int column; - if (colSel.size() > 0) + if (!colSel.isEmpty()) { if (trimLeft) { @@ -2248,59 +2329,57 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, SequenceI[] seqs; if (viewport.getSelectionGroup() != null) { - seqs = viewport.getSelectionGroup().getSequencesAsArray( - viewport.getHiddenRepSequences()); + seqs = viewport.getSelectionGroup() + .getSequencesAsArray(viewport.getHiddenRepSequences()); } else { - seqs = viewport.getAlignment().getSequencesArray(); + seqs = al.getSequencesArray(); } TrimRegionCommand trimRegion; if (trimLeft) { - trimRegion = new TrimRegionCommand("Remove Left", - TrimRegionCommand.TRIM_LEFT, seqs, column, - viewport.getAlignment(), viewport.getColumnSelection(), - viewport.getSelectionGroup()); - viewport.setStartRes(0); + trimRegion = new TrimRegionCommand("Remove Left", true, seqs, + column, al); + ranges.setStartRes(0); } else { - trimRegion = new TrimRegionCommand("Remove Right", - TrimRegionCommand.TRIM_RIGHT, seqs, column, - viewport.getAlignment(), viewport.getColumnSelection(), - viewport.getSelectionGroup()); + trimRegion = new TrimRegionCommand("Remove Right", false, seqs, + column, al); } - statusBar.setText(MessageManager.formatMessage( - "label.removed_columns", new String[] + statusBar.setText(MessageManager + .formatMessage("label.removed_columns", new String[] { Integer.valueOf(trimRegion.getSize()).toString() })); addHistoryItem(trimRegion); - for (SequenceGroup sg : viewport.getAlignment().getGroups()) + for (SequenceGroup sg : al.getGroups()) { if ((trimLeft && !sg.adjustForRemoveLeft(column)) || (!trimLeft && !sg.adjustForRemoveRight(column))) { - viewport.getAlignment().deleteGroup(sg); + al.deleteGroup(sg); } } - viewport.firePropertyChange("alignment", null, viewport - .getAlignment().getSequences()); + viewport.firePropertyChange("alignment", null, al.getSequences()); } } public void removeGappedColumnMenuItem_actionPerformed() { - int start = 0, end = viewport.getAlignment().getWidth() - 1; + AlignmentI al = viewport.getAlignment(); + ViewportRanges ranges = viewport.getRanges(); + int start = 0; + int end = ranges.getAbsoluteAlignmentWidth() - 1; SequenceI[] seqs; if (viewport.getSelectionGroup() != null) { - seqs = viewport.getSelectionGroup().getSequencesAsArray( - viewport.getHiddenRepSequences()); + seqs = viewport.getSelectionGroup() + .getSequencesAsArray(viewport.getHiddenRepSequences()); start = viewport.getSelectionGroup().getStartRes(); end = viewport.getSelectionGroup().getEndRes(); } @@ -2315,34 +2394,36 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, addHistoryItem(removeGapCols); - statusBar.setText(MessageManager.formatMessage( - "label.removed_empty_columns", new String[] + statusBar.setText(MessageManager + .formatMessage("label.removed_empty_columns", new String[] { Integer.valueOf(removeGapCols.getSize()).toString() })); // This is to maintain viewport position on first residue // of first sequence - SequenceI seq = viewport.getAlignment().getSequenceAt(0); - int startRes = seq.findPosition(viewport.startRes); + SequenceI seq = al.getSequenceAt(0); + int startRes = seq.findPosition(ranges.getStartRes()); // ShiftList shifts; // viewport.getAlignment().removeGaps(shifts=new ShiftList()); // edit.alColumnChanges=shifts.getInverse(); // if (viewport.hasHiddenColumns) // viewport.getColumnSelection().compensateForEdits(shifts); - viewport.setStartRes(seq.findIndex(startRes) - 1); - viewport.firePropertyChange("alignment", null, viewport.getAlignment() - .getSequences()); + ranges.setStartRes(seq.findIndex(startRes) - 1); + viewport.firePropertyChange("alignment", null, al.getSequences()); } public void removeAllGapsMenuItem_actionPerformed() { - int start = 0, end = viewport.getAlignment().getWidth() - 1; + AlignmentI al = viewport.getAlignment(); + ViewportRanges ranges = viewport.getRanges(); + int start = 0; + int end = ranges.getAbsoluteAlignmentWidth() - 1; SequenceI[] seqs; if (viewport.getSelectionGroup() != null) { - seqs = viewport.getSelectionGroup().getSequencesAsArray( - viewport.getHiddenRepSequences()); + seqs = viewport.getSelectionGroup() + .getSequencesAsArray(viewport.getHiddenRepSequences()); start = viewport.getSelectionGroup().getStartRes(); end = viewport.getSelectionGroup().getEndRes(); } @@ -2353,16 +2434,15 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, // This is to maintain viewport position on first residue // of first sequence - SequenceI seq = viewport.getAlignment().getSequenceAt(0); - int startRes = seq.findPosition(viewport.startRes); + SequenceI seq = al.getSequenceAt(0); + int startRes = seq.findPosition(ranges.getStartRes()); - addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end, - viewport.getAlignment())); + addHistoryItem( + new RemoveGapsCommand("Remove Gaps", seqs, start, end, al)); - viewport.setStartRes(seq.findIndex(startRes) - 1); + ranges.setStartRes(seq.findIndex(startRes) - 1); - viewport.firePropertyChange("alignment", null, viewport.getAlignment() - .getSequences()); + viewport.firePropertyChange("alignment", null, al.getSequences()); } @@ -2392,12 +2472,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, if (viewport.getAlignment().getAlignmentAnnotation() != null) { - for (int i = 0; i < viewport.getAlignment().getAlignmentAnnotation().length; i++) + for (int i = 0; i < viewport.getAlignment() + .getAlignmentAnnotation().length; i++) { - if (!viewport.getAlignment().getAlignmentAnnotation()[i].autoCalculated) + if (!viewport.getAlignment() + .getAlignmentAnnotation()[i].autoCalculated) { - newal.addAnnotation(viewport.getAlignment() - .getAlignmentAnnotation()[i]); + newal.addAnnotation( + viewport.getAlignment().getAlignmentAnnotation()[i]); } } } @@ -2414,8 +2496,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, PaintRefresher.Register(newaf.alignPanel.seqPanel.seqCanvas, newaf.alignPanel.av.getSequenceSetId()); - Vector comps = (Vector) PaintRefresher.components.get(viewport - .getSequenceSetId()); + Vector comps = PaintRefresher.components + .get(viewport.getSequenceSetId()); int viewSize = -1; for (int i = 0; i < comps.size(); i++) { @@ -2499,7 +2581,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, if (alignPanel != null && (fr = alignPanel.getFeatureRenderer()) != null) { - + fr.setGroupVisibility(Arrays.asList(groups), state); alignPanel.seqPanel.seqCanvas.repaint(); if (alignPanel.overviewPanel != null) @@ -2546,11 +2628,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } Frame frame = new Frame(); - OverviewPanel overview = new OverviewPanel(alignPanel); + final OverviewPanel overview = new OverviewPanel(alignPanel); frame.add(overview); // +50 must allow for applet frame window - jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage( - "label.overview_params", new String[] + jalview.bin.JalviewLite.addFrame(frame, MessageManager + .formatMessage("label.overview_params", new String[] { this.getTitle() }), overview.getPreferredSize().width, overview.getPreferredSize().height + 50); @@ -2561,6 +2643,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, @Override public void windowClosing(WindowEvent e) { + overview.dispose(); if (ap != null) { ap.setOverviewPanel(null); @@ -2572,40 +2655,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } + @Override public void changeColour(ColourSchemeI cs) { - int threshold = 0; - - if (cs != null) - { - if (viewport.getAbovePIDThreshold()) - { - viewport.setThreshold(SliderPanel.setPIDSliderSource(alignPanel, - cs, "Background")); - } - - if (viewport.getConservationSelected()) - { - cs.setConservationApplied(true); - viewport.setIncrement(SliderPanel.setConservationSlider(alignPanel, - cs, "Background")); - } - else - { - cs.setConservationApplied(false); - } - } viewport.setGlobalColourScheme(cs); - if (alignPanel.getOverviewPanel() != null) - { - alignPanel.getOverviewPanel().updateOverviewImage(); - } - - jalview.structure.StructureSelectionManager - .getStructureSelectionManager(viewport.applet) - .sequenceColoursChanged(alignPanel); - alignPanel.paintAlignment(true); } @@ -2615,7 +2669,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, && viewport.getGlobalColourScheme() != null) { SliderPanel.setPIDSliderSource(alignPanel, - viewport.getGlobalColourScheme(), "Background"); + viewport.getResidueShading(), alignPanel.getViewName()); SliderPanel.showPIDSlider(); } } @@ -2626,40 +2680,58 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, && viewport.getGlobalColourScheme() != null) { SliderPanel.setConservationSlider(alignPanel, - viewport.getGlobalColourScheme(), "Background"); + viewport.getResidueShading(), alignPanel.getViewName()); SliderPanel.showConservationSlider(); } } protected void conservationMenuItem_actionPerformed() { - viewport.setConservationSelected(conservationMenuItem.getState()); - - viewport.setAbovePIDThreshold(false); - abovePIDThreshold.setState(false); + boolean selected = conservationMenuItem.getState(); + modifyConservation.setEnabled(selected); + viewport.setConservationSelected(selected); + viewport.getResidueShading().setConservationApplied(selected); 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); + if (!selected) + { + viewport.getResidueShading().setThreshold(0, + viewport.isIgnoreGapsConsensus()); + } changeColour(viewport.getGlobalColourScheme()); - modifyPID_actionPerformed(); + if (selected) + { + modifyPID_actionPerformed(); + } + else + { + SliderPanel.hidePIDSlider(); + } } public void sortPairwiseMenuItem_actionPerformed() { SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); - AlignmentSorter.sortByPID(viewport.getAlignment(), viewport - .getAlignment().getSequenceAt(0), null); + AlignmentSorter.sortByPID(viewport.getAlignment(), + viewport.getAlignment().getSequenceAt(0)); addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder, viewport.getAlignment())); @@ -2670,8 +2742,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); AlignmentSorter.sortByID(viewport.getAlignment()); - addHistoryItem(new OrderCommand("ID Sort", oldOrder, - viewport.getAlignment())); + addHistoryItem( + new OrderCommand("ID Sort", oldOrder, viewport.getAlignment())); alignPanel.paintAlignment(true); } @@ -2720,7 +2792,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, SequenceI current; int Width = viewport.getAlignment().getWidth(); - for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++) + for (int i = 0; i < viewport.getAlignment().getSequences() + .size(); i++) { current = viewport.getAlignment().getSequenceAt(i); @@ -2733,8 +2806,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } if ((viewport.getSelectionGroup() != null - && viewport.getSelectionGroup().getSize() < 4 && viewport - .getSelectionGroup().getSize() > 0) + && viewport.getSelectionGroup().getSize() < 4 + && viewport.getSelectionGroup().getSize() > 0) || viewport.getAlignment().getHeight() < 4) { return; @@ -2751,25 +2824,31 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, public void averageDistanceTreeMenuItem_actionPerformed() { - NewTreePanel("AV", "PID", "Average distance tree using PID"); + newTreePanel(TreeBuilder.AVERAGE_DISTANCE, new PIDModel().getName(), + "Average distance tree using PID"); } public void neighbourTreeMenuItem_actionPerformed() { - NewTreePanel("NJ", "PID", "Neighbour joining tree using PID"); + newTreePanel(TreeBuilder.NEIGHBOUR_JOINING, new PIDModel().getName(), + "Neighbour joining tree using PID"); } protected void njTreeBlosumMenuItem_actionPerformed() { - NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62"); + newTreePanel(TreeBuilder.NEIGHBOUR_JOINING, + ScoreModels.getInstance().getBlosum62().getName(), + "Neighbour joining tree using BLOSUM62"); } protected void avTreeBlosumMenuItem_actionPerformed() { - NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62"); + newTreePanel(TreeBuilder.AVERAGE_DISTANCE, + ScoreModels.getInstance().getBlosum62().getName(), + "Average distance tree using BLOSUM62"); } - void NewTreePanel(String type, String pwType, String title) + void newTreePanel(String type, String pwType, String title) { // are the sequences aligned? if (!viewport.getAlignment().isAligned(false)) @@ -2777,7 +2856,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, SequenceI current; int Width = viewport.getAlignment().getWidth(); - for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++) + for (int i = 0; i < viewport.getAlignment().getSequences() + .size(); i++) { current = viewport.getAlignment().getSequenceAt(i); @@ -2790,8 +2870,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } - if ((viewport.getSelectionGroup() != null && viewport - .getSelectionGroup().getSize() > 1) + if ((viewport.getSelectionGroup() != null + && viewport.getSelectionGroup().getSize() > 1) || (viewport.getAlignment().getHeight() > 1)) { final TreePanel tp = new TreePanel(alignPanel, type, pwType); @@ -2832,12 +2912,12 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, public void sortByTree(TreePanel treePanel, String title) { SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); - AlignmentSorter - .sortByTree(viewport.getAlignment(), treePanel.getTree()); + AlignmentSorter.sortByTree(viewport.getAlignment(), + treePanel.getTree()); // addHistoryItem(new HistoryItem("Sort", viewport.alignment, // HistoryItem.SORT)); - addHistoryItem(new OrderCommand(MessageManager.formatMessage( - "label.order_by_params", new String[] + addHistoryItem(new OrderCommand(MessageManager + .formatMessage("label.order_by_params", new String[] { title }), oldOrder, viewport.getAlignment())); alignPanel.paintAlignment(true); } @@ -2934,39 +3014,37 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, // TODO: update this text for each release or centrally store it for // lite and application g.setFont(new Font("Helvetica", Font.BOLD, 14)); - g.drawString(MessageManager.formatMessage( - "label.jalviewLite_release", new String[] + g.drawString(MessageManager + .formatMessage("label.jalviewLite_release", new String[] { version }), x, y += fh); g.setFont(new Font("Helvetica", Font.BOLD, 12)); - g.drawString(MessageManager.formatMessage( - "label.jaview_build_date", new String[] + g.drawString(MessageManager.formatMessage("label.jaview_build_date", + new String[] { builddate }), x, y += fh); g.setFont(new Font("Helvetica", Font.PLAIN, 12)); - g.drawString(MessageManager.getString("label.jalview_authors_1"), - x, y += fh * 1.5); + g.drawString(MessageManager.getString("label.jalview_authors_1"), x, + y += fh * 1.5); g.drawString(MessageManager.getString("label.jalview_authors_2"), x + 50, y += fh + 8); - g.drawString( - MessageManager.getString("label.jalview_dev_managers"), x, - y += fh); + g.drawString(MessageManager.getString("label.jalview_dev_managers"), + x, y += fh); g.drawString(MessageManager .getString("label.jalview_distribution_lists"), x, y += fh); g.drawString(MessageManager.getString("label.jalview_please_cite"), x, y += fh + 8); g.drawString( - MessageManager.getString("label.jalview_cite_1_authors"), - x, y += fh); - g.drawString( - MessageManager.getString("label.jalview_cite_1_title"), x, + MessageManager.getString("label.jalview_cite_1_authors"), x, y += fh); + g.drawString(MessageManager.getString("label.jalview_cite_1_title"), + x, y += fh); g.drawString(MessageManager.getString("label.jalview_cite_1_ref"), x, y += fh); } } Frame frame = new Frame(); - frame.add(new AboutPanel(JalviewLite.getVersion(), JalviewLite - .getBuildDate())); + frame.add(new AboutPanel(JalviewLite.getVersion(), + JalviewLite.getBuildDate())); jalview.bin.JalviewLite.addFrame(frame, MessageManager.getString("label.jalview"), 580, 220); @@ -3001,10 +3079,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, MessageManager.getString("label.load_features_annotations")); MenuItem outputFeatures = new MenuItem( - MessageManager.getString("label.export_features").concat("...")); + MessageManager.getString("label.export_features")); MenuItem outputAnnotations = new MenuItem( - MessageManager.getString("label.export_annotations").concat("...")); + MessageManager.getString("label.export_annotations")); MenuItem closeMenuItem = new MenuItem( MessageManager.getString("action.close")); @@ -3070,7 +3148,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, MenuItem purinePyrimidineColour = new MenuItem(); - MenuItem RNAInteractionColour = new MenuItem(); + // MenuItem RNAInteractionColour = new MenuItem(); MenuItem RNAHelixColour = new MenuItem(); @@ -3197,11 +3275,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() { @@ -3241,20 +3317,20 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, pasteNew.addActionListener(this); pasteThis.setLabel(MessageManager.getString("label.to_this_alignment")); pasteThis.addActionListener(this); - remove2LeftMenuItem.setLabel(MessageManager - .getString("action.remove_left")); + remove2LeftMenuItem + .setLabel(MessageManager.getString("action.remove_left")); remove2LeftMenuItem.addActionListener(this); - remove2RightMenuItem.setLabel(MessageManager - .getString("action.remove_right")); + remove2RightMenuItem + .setLabel(MessageManager.getString("action.remove_right")); remove2RightMenuItem.addActionListener(this); - removeGappedColumnMenuItem.setLabel(MessageManager - .getString("action.remove_empty_columns")); + removeGappedColumnMenuItem.setLabel( + MessageManager.getString("action.remove_empty_columns")); removeGappedColumnMenuItem.addActionListener(this); - removeAllGapsMenuItem.setLabel(MessageManager - .getString("action.remove_all_gaps")); + removeAllGapsMenuItem + .setLabel(MessageManager.getString("action.remove_all_gaps")); removeAllGapsMenuItem.addActionListener(this); - removeRedundancyMenuItem.setLabel(MessageManager.getString( - "action.remove_redundancy").concat("...")); + removeRedundancyMenuItem + .setLabel(MessageManager.getString("action.remove_redundancy")); removeRedundancyMenuItem.addActionListener(this); /* @@ -3264,21 +3340,25 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, findMenuItem.addActionListener(this); selectAllSequenceMenuItem.addActionListener(this); deselectAllSequenceMenuItem.addActionListener(this); - invertSequenceMenuItem.setLabel(MessageManager - .getString("action.invert_sequence_selection")); + invertSequenceMenuItem.setLabel( + MessageManager.getString("action.invert_sequence_selection")); invertSequenceMenuItem.addActionListener(this); - invertColSel.setLabel(MessageManager - .getString("action.invert_column_selection")); + invertColSel.setLabel( + MessageManager.getString("action.invert_column_selection")); invertColSel.addActionListener(this); - deleteGroups.setLabel(MessageManager - .getString("action.undefine_groups")); + deleteGroups + .setLabel(MessageManager.getString("action.undefine_groups")); deleteGroups.addActionListener(this); - grpsFromSelection.setLabel(MessageManager - .getString("action.make_groups_selection")); + grpsFromSelection.setLabel( + MessageManager.getString("action.make_groups_selection")); grpsFromSelection.addActionListener(this); createGroup.setLabel(MessageManager.getString("action.create_group")); + createGroup.addActionListener(this); unGroup.setLabel(MessageManager.getString("action.remove_group")); - annotationColumnSelection.setLabel("Select by Annotation"); + unGroup.addActionListener(this); + + annotationColumnSelection.setLabel( + MessageManager.getString("action.select_by_annotation")); annotationColumnSelection.addActionListener(this); /* @@ -3292,14 +3372,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, Menu hideMenu = new Menu(MessageManager.getString("action.hide")); hideColumns .setLabel(MessageManager.getString("label.selected_columns")); - hideSequences.setLabel(MessageManager - .getString("label.selected_sequences")); - hideAllButSelection.setLabel(MessageManager - .getString("label.all_but_selected_region")); - hideAllSelection.setLabel(MessageManager - .getString("label.selected_region")); - showAllHidden.setLabel(MessageManager - .getString("label.all_sequences_columns")); + hideSequences + .setLabel(MessageManager.getString("label.selected_sequences")); + hideAllButSelection.setLabel( + MessageManager.getString("label.all_but_selected_region")); + hideAllSelection + .setLabel(MessageManager.getString("label.selected_region")); + showAllHidden.setLabel( + MessageManager.getString("label.all_sequences_columns")); showColumns.addActionListener(this); showSeqs.addActionListener(this); hideColumns.addActionListener(this); @@ -3307,39 +3387,39 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, hideAllButSelection.addActionListener(this); hideAllSelection.addActionListener(this); showAllHidden.addActionListener(this); - featureSettings.setLabel(MessageManager - .getString("label.feature_settings")); + featureSettings + .setLabel(MessageManager.getString("action.feature_settings")); featureSettings.addActionListener(this); - sequenceFeatures.setLabel(MessageManager - .getString("label.show_sequence_features")); + sequenceFeatures.setLabel( + MessageManager.getString("label.show_sequence_features")); sequenceFeatures.addItemListener(this); sequenceFeatures.setState(false); - followMouseOverFlag.setLabel(MessageManager - .getString("label.automatic_scrolling")); + followMouseOverFlag.setLabel( + MessageManager.getString("label.automatic_scrolling")); followMouseOverFlag.addItemListener(this); alProperties.addActionListener(this); - overviewMenuItem.setLabel(MessageManager - .getString("label.overview_window")); + overviewMenuItem + .setLabel(MessageManager.getString("label.overview_window")); overviewMenuItem.addActionListener(this); /* * Configure Annotations menu items and actions */ - annotationPanelMenuItem.setLabel(MessageManager - .getString("label.show_annotations")); + annotationPanelMenuItem + .setLabel(MessageManager.getString("label.show_annotations")); annotationPanelMenuItem.addItemListener(this); - showGroupConsensus.setLabel(MessageManager - .getString("label.group_consensus")); - showGroupConservation.setLabel(MessageManager - .getString("label.group_conservation")); - showConsensusHistogram.setLabel(MessageManager - .getString("label.show_consensus_histogram")); - showSequenceLogo.setLabel(MessageManager - .getString("label.show_consensus_logo")); - normSequenceLogo.setLabel(MessageManager - .getString("label.norm_consensus_logo")); - applyAutoAnnotationSettings.setLabel(MessageManager - .getString("label.apply_all_groups")); + showGroupConsensus + .setLabel(MessageManager.getString("label.group_consensus")); + showGroupConservation + .setLabel(MessageManager.getString("label.group_conservation")); + showConsensusHistogram.setLabel( + MessageManager.getString("label.show_consensus_histogram")); + showSequenceLogo.setLabel( + MessageManager.getString("label.show_consensus_logo")); + normSequenceLogo.setLabel( + MessageManager.getString("label.norm_consensus_logo")); + applyAutoAnnotationSettings + .setLabel(MessageManager.getString("label.apply_all_groups")); applyAutoAnnotationSettings.setState(true); Menu autoAnnMenu = new Menu( MessageManager.getString("label.autocalculated_annotation")); @@ -3359,8 +3439,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, MessageManager.getString("label.sort_annotations_by_label")); showAutoFirst = new CheckboxMenuItem( MessageManager.getString("label.show_first")); + showAutoFirst.setState(false); // pending applet parameter + setShowAutoCalculatedAbove(showAutoFirst.getState()); showAutoLast = new CheckboxMenuItem( MessageManager.getString("label.show_last")); + showAutoLast.setState(!showAutoFirst.getState()); showAlignmentAnnotations.addItemListener(this); showSequenceAnnotations.addItemListener(this); sortAnnBySequence.addItemListener(this); @@ -3391,130 +3474,139 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, viewTextMenuItem.setLabel(MessageManager.getString("action.text")); viewTextMenuItem.setState(true); viewTextMenuItem.addItemListener(this); - colourTextMenuItem.setLabel(MessageManager - .getString("label.colour_text")); + colourTextMenuItem + .setLabel(MessageManager.getString("label.colour_text")); colourTextMenuItem.addItemListener(this); - displayNonconservedMenuItem.setLabel(MessageManager - .getString("label.show_non_conversed")); + displayNonconservedMenuItem + .setLabel(MessageManager.getString("label.show_non_conserved")); displayNonconservedMenuItem.addItemListener(this); wrapMenuItem.setLabel(MessageManager.getString("action.wrap")); wrapMenuItem.addItemListener(this); - renderGapsMenuItem.setLabel(MessageManager - .getString("action.show_gaps")); + renderGapsMenuItem + .setLabel(MessageManager.getString("action.show_gaps")); renderGapsMenuItem.setState(true); renderGapsMenuItem.addItemListener(this); - centreColumnLabelFlag.setLabel(MessageManager - .getString("label.centre_column_labels")); + centreColumnLabelFlag.setLabel( + MessageManager.getString("label.centre_column_labels")); centreColumnLabelFlag.addItemListener(this); seqLimits.setState(true); - seqLimits.setLabel(MessageManager - .getString("label.show_sequence_limits")); + seqLimits.setLabel( + MessageManager.getString("label.show_sequence_limits")); seqLimits.addItemListener(this); /* * Configure Colour menu items and actions */ - applyToAllGroups.setLabel(MessageManager - .getString("label.apply_colour_to_all_groups")); + applyToAllGroups.setLabel( + MessageManager.getString("label.apply_colour_to_all_groups")); applyToAllGroups.setState(true); applyToAllGroups.addItemListener(this); - clustalColour.setLabel(MessageManager.getString("label.clustalx")); + clustalColour.setLabel( + MessageManager.getString("label.colourScheme_clustal")); clustalColour.addActionListener(this); - zappoColour.setLabel(MessageManager.getString("label.zappo")); + zappoColour + .setLabel(MessageManager.getString("label.colourScheme_zappo")); zappoColour.addActionListener(this); - taylorColour.setLabel(MessageManager.getString("label.taylor")); + taylorColour.setLabel( + MessageManager.getString("label.colourScheme_taylor")); taylorColour.addActionListener(this); - hydrophobicityColour.setLabel(MessageManager - .getString("label.hydrophobicity")); + hydrophobicityColour.setLabel( + MessageManager.getString("label.colourScheme_hydrophobic")); hydrophobicityColour.addActionListener(this); - helixColour - .setLabel(MessageManager.getString("label.helix_propensity")); + helixColour.setLabel(MessageManager + .getString("label.colourScheme_helix_propensity")); helixColour.addActionListener(this); strandColour.setLabel(MessageManager - .getString("label.strand_propensity")); + .getString("label.colourScheme_strand_propensity")); strandColour.addActionListener(this); - turnColour.setLabel(MessageManager.getString("label.turn_propensity")); + turnColour.setLabel( + MessageManager.getString("label.colourScheme_turn_propensity")); turnColour.addActionListener(this); - buriedColour.setLabel(MessageManager.getString("label.buried_index")); + buriedColour.setLabel( + MessageManager.getString("label.colourScheme_buried_index")); buriedColour.addActionListener(this); purinePyrimidineColour.setLabel(MessageManager - .getString("label.purine_pyrimidine")); + .getString("label.colourScheme_purine/pyrimidine")); purinePyrimidineColour.addActionListener(this); - RNAInteractionColour.setLabel(MessageManager - .getString("label.rna_interaction")); - RNAInteractionColour.addActionListener(this); - RNAHelixColour.setLabel(MessageManager - .getString("action.by_rna_helixes")); + // RNAInteractionColour.setLabel(MessageManager + // .getString("label.rna_interaction")); + // RNAInteractionColour.addActionListener(this); + RNAHelixColour.setLabel( + MessageManager.getString("label.colourScheme_rna_helices")); RNAHelixColour.addActionListener(this); - userDefinedColour.setLabel(MessageManager - .getString("action.user_defined")); + userDefinedColour + .setLabel(MessageManager.getString("action.user_defined")); userDefinedColour.addActionListener(this); - PIDColour.setLabel(MessageManager - .getString("label.percentage_identity")); + PIDColour.setLabel( + MessageManager.getString("label.colourScheme_%_identity")); PIDColour.addActionListener(this); - BLOSUM62Colour.setLabel(MessageManager - .getString("label.blosum62_score")); + BLOSUM62Colour.setLabel( + MessageManager.getString("label.colourScheme_blosum62")); BLOSUM62Colour.addActionListener(this); - tcoffeeColour - .setLabel(MessageManager.getString("label.tcoffee_scores")); + tcoffeeColour.setLabel( + MessageManager.getString("label.colourScheme_t-coffee_scores")); // it will be enabled only if a score file is provided tcoffeeColour.setEnabled(false); tcoffeeColour.addActionListener(this); - conservationMenuItem.setLabel(MessageManager - .getString("action.by_conservation")); + conservationMenuItem + .setLabel(MessageManager.getString("action.by_conservation")); conservationMenuItem.addItemListener(this); noColourmenuItem.setLabel(MessageManager.getString("label.none")); noColourmenuItem.addActionListener(this); - abovePIDThreshold.setLabel(MessageManager - .getString("label.above_identity_threshold")); + abovePIDThreshold.setLabel( + MessageManager.getString("label.above_identity_threshold")); abovePIDThreshold.addItemListener(this); - nucleotideColour.setLabel(MessageManager.getString("label.nucleotide")); + nucleotideColour.setLabel( + MessageManager.getString("label.colourScheme_nucleotide")); nucleotideColour.addActionListener(this); - modifyPID.setLabel(MessageManager - .getString("label.modify_identity_thereshold")); + modifyPID.setLabel( + MessageManager.getString("label.modify_identity_threshold")); + modifyPID.setEnabled(abovePIDThreshold.getState()); modifyPID.addActionListener(this); modifyConservation.setLabel(MessageManager - .getString("label.modify_conservation_thereshold")); + .getString("label.modify_conservation_threshold")); + modifyConservation.setEnabled(conservationMenuItem.getState()); modifyConservation.addActionListener(this); - annotationColour.setLabel(MessageManager - .getString("action.by_annotation")); + annotationColour + .setLabel(MessageManager.getString("action.by_annotation")); annotationColour.addActionListener(this); /* * Configure Calculate menu items and actions */ - sortPairwiseMenuItem.setLabel(MessageManager - .getString("action.by_pairwise_id")); + sortPairwiseMenuItem + .setLabel(MessageManager.getString("action.by_pairwise_id")); sortPairwiseMenuItem.addActionListener(this); sortIDMenuItem.setLabel(MessageManager.getString("action.by_id")); sortIDMenuItem.addActionListener(this); - sortLengthMenuItem.setLabel(MessageManager - .getString("action.by_length")); + sortLengthMenuItem + .setLabel(MessageManager.getString("action.by_length")); sortLengthMenuItem.addActionListener(this); sortGroupMenuItem.setLabel(MessageManager.getString("action.by_group")); sortGroupMenuItem.addActionListener(this); - pairwiseAlignmentMenuItem.setLabel(MessageManager - .getString("action.pairwise_alignment")); + pairwiseAlignmentMenuItem.setLabel( + MessageManager.getString("action.pairwise_alignment")); pairwiseAlignmentMenuItem.addActionListener(this); - PCAMenuItem.setLabel(MessageManager - .getString("label.principal_component_analysis")); + PCAMenuItem.setLabel( + MessageManager.getString("label.principal_component_analysis")); PCAMenuItem.addActionListener(this); autoCalculate = new CheckboxMenuItem( - MessageManager.getString("label.autocalculate_consensus"), true); - averageDistanceTreeMenuItem.setLabel(MessageManager - .getString("label.average_distance_identity")); + MessageManager.getString("label.autocalculate_consensus"), + true); + averageDistanceTreeMenuItem.setLabel( + MessageManager.getString("label.average_distance_identity")); averageDistanceTreeMenuItem.addActionListener(this); - neighbourTreeMenuItem.setLabel(MessageManager - .getString("label.neighbour_joining_identity")); + neighbourTreeMenuItem.setLabel( + MessageManager.getString("label.neighbour_joining_identity")); neighbourTreeMenuItem.addActionListener(this); - avDistanceTreeBlosumMenuItem.setLabel(MessageManager - .getString("label.average_distance_bloslum62")); + avDistanceTreeBlosumMenuItem.setLabel( + MessageManager.getString("label.average_distance_blosum62")); avDistanceTreeBlosumMenuItem.addActionListener(this); - njTreeBlosumMenuItem.setLabel(MessageManager - .getString("label.neighbour_blosum62")); + njTreeBlosumMenuItem + .setLabel(MessageManager.getString("label.neighbour_blosum62")); njTreeBlosumMenuItem.addActionListener(this); - sortByTreeMenu.setLabel(MessageManager - .getString("action.by_tree_order")); + sortByTreeMenu + .setLabel(MessageManager.getString("action.by_tree_order")); Menu sortMenu = new Menu(MessageManager.getString("action.sort")); Menu calculateTreeMenu = new Menu( MessageManager.getString("action.calculate_tree")); @@ -3728,6 +3820,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, this.add(statusBar, BorderLayout.SOUTH); } + @Override public void setStatus(String string) { statusBar.setText(string); @@ -3805,8 +3898,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, add(statusBar, BorderLayout.SOUTH); add(alignPanel, BorderLayout.CENTER); // and register with the applet so it can pass external API calls to us - jalview.bin.JalviewLite.addFrame(this, this.getTitle(), - frameWidth, + jalview.bin.JalviewLite.addFrame(this, this.getTitle(), frameWidth, frameHeight); } } @@ -3831,9 +3923,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, theApplet.add(embeddedMenu, BorderLayout.NORTH); theApplet.add(statusBar, BorderLayout.SOUTH); // TODO should size be left to the layout manager? - alignPanel.setSize(theApplet.getSize().width, - theApplet.getSize().height - embeddedMenu.getHeight() - - statusBar.getHeight()); + alignPanel.setSize(theApplet.getSize().width, theApplet.getSize().height + - embeddedMenu.getHeight() - statusBar.getHeight()); theApplet.add(alignPanel, BorderLayout.CENTER); final AlignFrame me = this; theApplet.addFocusListener(new FocusListener() @@ -3873,14 +3964,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, public SequenceStructureBinding addStructureViewInstance( Object jmolviewer, String[] sequenceIds) { - org.jmol.api.JmolViewer viewer = null; + Viewer viewer = null; try { - viewer = (org.jmol.api.JmolViewer) jmolviewer; + viewer = (Viewer) jmolviewer; } catch (ClassCastException ex) { - System.err.println("Unsupported viewer object :" - + jmolviewer.getClass()); + System.err.println( + "Unsupported viewer object :" + jmolviewer.getClass()); } if (viewer == null) { @@ -3922,8 +4013,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, // TODO: search for a jmv that involves viewer if (jmv == null) { // create a new viewer/jalview binding. - jmv = new ExtJmol(viewer, alignPanel, new SequenceI[][] - { seqs }); + jmv = new ExtJmol(viewer, alignPanel, new SequenceI[][] { seqs }); } return jmv; @@ -3949,7 +4039,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, boolean needtoadd = false; if (toaddpdb != null) { - Vector pdbe = toaddpdb.getPDBId(); + Vector pdbe = toaddpdb.getAllPDBEntries(); PDBEntry pdbentry = null; if (pdbe != null && pdbe.size() > 0) { @@ -3976,19 +4066,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); @@ -4006,8 +4092,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { if (seqs[i] != null) { - sequences.addElement(new Object[] - { seqs[i], (chains != null) ? chains[i] : null }); + sequences + .addElement(new Object[] + { seqs[i], (chains != null) ? chains[i] : null }); } } seqs = new SequenceI[sequences.size()]; @@ -4020,13 +4107,12 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, chains[i] = (String) oj[1]; } } - return new Object[] - { seqs, chains }; + return new Object[] { seqs, chains }; } 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); @@ -4034,13 +4120,19 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, chains = (String[]) sqch[1]; if (seqs == null || seqs.length == 0) { - System.err - .println("JalviewLite.AlignFrame:newStructureView: No sequence to bind structure to."); + 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: " @@ -4063,12 +4155,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; @@ -4077,8 +4168,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } if (ajm != null) { - System.err - .println("Incremental adding and aligning structure to existing Jmol view not yet implemented."); + System.err.println( + "Incremental adding and aligning structure to existing Jmol view not yet implemented."); // try and add the pdb structure // ajm.addS ajm = null; @@ -4087,8 +4178,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, // otherwise, create a new window if (applet.jmolAvailable) { - new jalview.appletgui.AppletJmol(pdb, seqs, chains, alignPanel, - protocol); + new AppletJmol(pdb, seqs, chains, alignPanel, protocol); applet.lastFrameX += 40; applet.lastFrameY += 40; } @@ -4115,9 +4205,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, * @param csel * - columns to be selected on the alignment */ - public void select(SequenceGroup sel, ColumnSelection csel) + public void select(SequenceGroup sel, ColumnSelection csel, + HiddenColumns hidden) { - alignPanel.seqPanel.selection(sel, csel, null); + alignPanel.seqPanel.selection(sel, csel, hidden, null); } public void scrollTo(int row, int column) @@ -4170,12 +4261,12 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, */ AlignmentI aln; if ((aln = viewport.getAlignment()) != null - && (aln.getHeight() != file.getHeight() || aln.getWidth() != file - .getWidth())) + && (aln.getHeight() != file.getHeight() + || aln.getWidth() != file.getWidth())) { // TODO: raise a dialog box here rather than bomb out. - System.err - .println("The scores matrix does not match the alignment dimensions"); + System.err.println( + "The scores matrix does not match the alignment dimensions"); } @@ -4209,7 +4300,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, this.splitFrame = sf; } - // may not need this + // may not need this @Override public void setShowSeqFeatures(boolean b) { @@ -4224,6 +4315,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, // setMenusFromViewport(viewport); } + @Override public void refreshFeatureUI(boolean enableIfNecessary) {