X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=c61fe342f6f41058aaffefd0611901049e08ad99;hb=refs%2Fheads%2Ffeatures%2Fr2_11_2_alphafold%2FJAL-2349_JAL-3855;hp=e6ac07e93d6baf8ca9962e977ecb59f0076ca153;hpb=d7f65ab5aed90618588864660d3e45bd18367a2b;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index e6ac07e..c61fe34 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -20,6 +20,17 @@ */ package jalview.gui; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; + +import javax.swing.JInternalFrame; + import jalview.analysis.AlignmentUtils; import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.api.AlignViewportI; @@ -29,11 +40,13 @@ import jalview.api.FeatureSettingsModelI; import jalview.api.FeaturesDisplayedI; import jalview.api.ViewStyleI; import jalview.bin.Cache; +import jalview.bin.Console; import jalview.commands.CommandI; import jalview.datamodel.AlignedCodonFrame; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.ColumnSelection; +import jalview.datamodel.ContactMatrixI; import jalview.datamodel.HiddenColumns; import jalview.datamodel.SearchResults; import jalview.datamodel.SearchResultsI; @@ -52,18 +65,6 @@ import jalview.util.MessageManager; import jalview.viewmodel.AlignmentViewport; import jalview.ws.params.AutoCalcSetting; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; - -import javax.swing.JInternalFrame; - /** * DOCUMENT ME! * @@ -124,14 +125,14 @@ public class AlignViewport extends AlignmentViewport sequenceSetID = seqsetid; viewId = viewid; // TODO remove these once 2.4.VAMSAS release finished - if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null) + if (seqsetid != null) { - Cache.log.debug( + Console.debug( "Setting viewport's sequence set id : " + sequenceSetID); } - if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null) + if (viewId != null) { - Cache.log.debug("Setting viewport's view id : " + viewId); + Console.debug("Setting viewport's view id : " + viewId); } init(); @@ -186,14 +187,14 @@ public class AlignViewport extends AlignmentViewport sequenceSetID = seqsetid; viewId = viewid; // TODO remove these once 2.4.VAMSAS release finished - if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null) + if (seqsetid != null) { - Cache.log.debug( + Console.debug( "Setting viewport's sequence set id : " + sequenceSetID); } - if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null) + if (viewId != null) { - Cache.log.debug("Setting viewport's view id : " + viewId); + Console.debug("Setting viewport's view id : " + viewId); } if (hiddenColumns != null) @@ -291,8 +292,8 @@ public class AlignViewport extends AlignmentViewport schemeName = Cache.getDefault(Preferences.DEFAULT_COLOUR, ResidueColourScheme.NONE); } - ColourSchemeI colourScheme = ColourSchemeProperty - .getColourScheme(this, alignment, schemeName); + ColourSchemeI colourScheme = ColourSchemeProperty.getColourScheme(this, + alignment, schemeName); residueShading = new ResidueShader(colourScheme); if (colourScheme instanceof UserColourScheme) @@ -446,31 +447,6 @@ public class AlignViewport extends AlignmentViewport } /** - * returns the visible column regions of the alignment - * - * @param selectedRegionOnly - * true to just return the contigs intersecting with the selected - * area - * @return - */ - public Iterator getViewAsVisibleContigs(boolean selectedRegionOnly) - { - int start = 0; - int end = 0; - if (selectedRegionOnly && selectionGroup != null) - { - start = selectionGroup.getStartRes(); - end = selectionGroup.getEndRes() + 1; - } - else - { - end = alignment.getWidth(); - } - return (alignment.getHiddenColumns().getVisContigsIterator(start, end, - false)); - } - - /** * get hash of undo and redo list for the alignment * * @return long[] { historyList.hashCode, redoList.hashCode }; @@ -620,7 +596,7 @@ public class AlignViewport extends AlignmentViewport // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass()) if (needsUpdate) { - Cache.log.debug("trigger update for " + calcId); + Console.debug("trigger update for " + calcId); } } @@ -710,16 +686,20 @@ public class AlignViewport extends AlignmentViewport { if (AlignmentUtils.isMappable(toAdd, getAlignment())) { - if (openLinkedAlignment(toAdd, title)) - { - return; - } + openLinkedAlignment(toAdd, title); + return; } } + addDataToAlignment(toAdd); + } - /* - * No mappings, or offer declined - add sequences to this alignment - */ + /** + * adds sequences to this alignment + * + * @param toAdd + */ + void addDataToAlignment(AlignmentI toAdd) + { // TODO: JAL-407 regardless of above - identical sequences (based on ID and // provenance) should share the same dataset sequence @@ -740,8 +720,11 @@ public class AlignViewport extends AlignmentViewport al.addSequence(seq); } } - - ranges.setEndSeq(getAlignment().getHeight()); + for (ContactMatrixI cm : toAdd.getContactMaps()) + { + al.addContactList(cm); + } + ranges.setEndSeq(getAlignment().getHeight() - 1); // BH 2019.04.18 firePropertyChange("alignment", null, getAlignment().getSequences()); } @@ -754,30 +737,58 @@ public class AlignViewport extends AlignmentViewport * @param al * @param title */ - protected boolean openLinkedAlignment(AlignmentI al, String title) + protected void openLinkedAlignment(AlignmentI al, String title) { String[] options = new String[] { MessageManager.getString("action.no"), MessageManager.getString("label.split_window"), MessageManager.getString("label.new_window"), }; final String question = JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.open_split_window?")); - int response = JvOptionPane.showOptionDialog(Desktop.desktop, question, + final AlignViewport us = this; + + /* + * options No, Split Window, New Window correspond to + * dialog responses 0, 1, 2 (even though JOptionPane shows them + * in reverse order) + */ + JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop) + .setResponseHandler(0, new Runnable() + { + @Override + public void run() + { + addDataToAlignment(al); + } + }).setResponseHandler(1, new Runnable() + { + @Override + public void run() + { + us.openLinkedAlignmentAs(al, title, true); + } + }).setResponseHandler(2, new Runnable() + { + @Override + public void run() + { + us.openLinkedAlignmentAs(al, title, false); + } + }); + dialog.showDialog(question, MessageManager.getString("label.open_split_window"), JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null, options, options[0]); + } - if (response != 1 && response != 2) - { - return false; - } - final boolean openSplitPane = (response == 1); - final boolean openInNewWindow = (response == 2); - + protected void openLinkedAlignmentAs(AlignmentI al, String title, + boolean newWindowOrSplitPane) + { /* * Identify protein and dna alignments. Make a copy of this one if opening * in a new split pane. */ - AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment()) + AlignmentI thisAlignment = newWindowOrSplitPane + ? new Alignment(getAlignment()) : getAlignment(); AlignmentI protein = al.isNucleotide() ? thisAlignment : al; final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment; @@ -809,7 +820,7 @@ public class AlignViewport extends AlignmentViewport // alignFrame.setFileName(file, format); // } - if (openInNewWindow) + if (!newWindowOrSplitPane) { Desktop.addInternalFrame(newAlignFrame, title, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); @@ -817,19 +828,16 @@ public class AlignViewport extends AlignmentViewport try { - newAlignFrame.setMaximum( - jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", false)); + newAlignFrame.setMaximum(Cache.getDefault("SHOW_FULLSCREEN", false)); } catch (java.beans.PropertyVetoException ex) { } - if (openSplitPane) + if (newWindowOrSplitPane) { al.alignAs(thisAlignment); protein = openSplitFrame(newAlignFrame, thisAlignment); } - - return true; } /** @@ -986,10 +994,10 @@ public class AlignViewport extends AlignmentViewport } /** - * Applies the supplied feature settings descriptor to currently known features. - * This supports an 'initial configuration' of feature colouring based on a - * preset or user favourite. This may then be modified in the usual way using - * the Feature Settings dialogue. + * Applies the supplied feature settings descriptor to currently known + * features. This supports an 'initial configuration' of feature colouring + * based on a preset or user favourite. This may then be modified in the usual + * way using the Feature Settings dialogue. * * @param featureSettings */ @@ -1002,8 +1010,8 @@ public class AlignViewport extends AlignmentViewport /** * when mergeOnly is set, then group and feature visibility or feature colours * are not modified for features and groups already known to the feature - * renderer. Feature ordering is always adjusted, and transparency is always set - * regardless. + * renderer. Feature ordering is always adjusted, and transparency is always + * set regardless. * * @param featureSettings * @param mergeOnly @@ -1015,12 +1023,13 @@ public class AlignViewport extends AlignmentViewport { return; } - + FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas .getFeatureRenderer(); List origRenderOrder = new ArrayList<>(); List origGroups = new ArrayList<>(); - // preserve original render order - allows differentiation between user configured colours and autogenerated ones + // preserve original render order - allows differentiation between user + // configured colours and autogenerated ones origRenderOrder.addAll(fr.getRenderOrder()); origGroups.addAll(fr.getFeatureGroups()); @@ -1052,7 +1061,8 @@ public class AlignViewport extends AlignmentViewport && origColour.getColour().equals( ColorUtils.createColourFromName(type))))) { - // if we are merging, only update if there wasn't already a colour defined for + // if we are merging, only update if there wasn't already a colour + // defined for // this type if (preferredColour != null) { @@ -1076,7 +1086,8 @@ public class AlignViewport extends AlignmentViewport { if (!mergeOnly || !origGroups.contains(group)) { - // when merging, display groups only if the aren't already marked as not visible + // when merging, display groups only if the aren't already marked as not + // visible fr.setGroupVisibility(group, featureSettings.isGroupDisplayed(group)); }