From: Jim Procter Date: Tue, 16 Oct 2018 15:37:13 +0000 (+0100) Subject: JAL-3127 use AlignViewportI.addGroup() to add group and propagate to complement view... X-Git-Tag: Release_2_11_0~17^2~46^2~15 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5cac379811d10d829b134021f034e56bf9678fbc;p=jalview.git JAL-3127 use AlignViewportI.addGroup() to add group and propagate to complement view. also updates sequence ID colours from group’s idColour attribute --- diff --git a/src/jalview/api/AlignViewportI.java b/src/jalview/api/AlignViewportI.java index 5180e20..389d9cf 100644 --- a/src/jalview/api/AlignViewportI.java +++ b/src/jalview/api/AlignViewportI.java @@ -510,4 +510,12 @@ public interface AlignViewportI extends ViewStyleI */ boolean needToUpdateStructureViews(); + /** + * Adds sequencegroup to the alignment in the view. Also adds a group to the + * complement view if one is defined. + * + * @param sequenceGroup + * - a group defined on sequences in the alignment held by the view + */ + void addSequenceGroup(SequenceGroup sequenceGroup); } diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index dbb7e2b..4658fc9 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -32,7 +32,6 @@ import jalview.schemes.ColourSchemeProperty; import jalview.schemes.UserColourScheme; import jalview.structure.SelectionSource; import jalview.util.Format; -import jalview.util.MappingUtils; import jalview.util.MessageManager; import java.awt.Color; @@ -512,26 +511,10 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, return; } - if ((node.left() == null) && (node.right() == null)) // TODO: internal node - { - node.color = c; + node.color = c; - if (node.element() instanceof SequenceI) - { - AlignmentPanel[] aps = getAssociatedPanels(); - if (aps != null) - { - for (int a = 0; a < aps.length; a++) - { - final SequenceI seq = (SequenceI) node.element(); - aps[a].av.setSequenceColour(seq, c); - } - } - } - } - else + if ((node.left() != null) || (node.right() != null)) // TODO: internal node { - node.color = c; setColor((SequenceNode) node.left(), c); setColor((SequenceNode) node.right(), c); } @@ -1047,26 +1030,10 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, c.verdict(false, aps[a].av.getConsPercGaps()); sg.cs.setConservation(c); } - - aps[a].av.getAlignment().addGroup(new SequenceGroup(sg)); - // TODO can we push all of the below into AlignViewportI? - final AlignViewportI codingComplement = aps[a].av - .getCodingComplement(); - if (codingComplement != null) - { - SequenceGroup mappedGroup = MappingUtils.mapSequenceGroup(sg, av, - codingComplement); - if (mappedGroup.getSequences().size() > 0) - { - codingComplement.getAlignment().addGroup(mappedGroup); - for (SequenceI seq : mappedGroup.getSequences()) - { - codingComplement.setSequenceColour(seq, col.brighter()); - } - } - } // indicate that associated structure views will need an update aps[a].av.setUpdateStructures(true); + // propagate structure view update and sequence group to complement view + aps[a].av.addSequenceGroup(new SequenceGroup(sg)); } } diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index c4923cf..6427b45 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -2982,4 +2982,40 @@ public abstract class AlignmentViewport return update; } + @Override + public void addSequenceGroup(SequenceGroup sequenceGroup) + { + alignment.addGroup(sequenceGroup); + + Color col = sequenceGroup.idColour; + if (col != null) + { + col = col.brighter(); + + for (SequenceI sq : sequenceGroup.getSequences()) + { + setSequenceColour(sq, col); + } + } + + if (codingComplement != null) + { + SequenceGroup mappedGroup = MappingUtils + .mapSequenceGroup(sequenceGroup, this, codingComplement); + if (mappedGroup.getSequences().size() > 0) + { + codingComplement.getAlignment().addGroup(mappedGroup); + + if (col != null) + { + for (SequenceI seq : mappedGroup.getSequences()) + { + codingComplement.setSequenceColour(seq, col); + } + } + } + // propagate the structure view update flag according to our own setting + codingComplement.setUpdateStructures(needToUpdateStructureViews); + } + } }