From 5cac379811d10d829b134021f034e56bf9678fbc Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 16 Oct 2018 16:37:13 +0100 Subject: [PATCH] =?utf8?q?JAL-3127=20use=20AlignViewportI.addGroup()=20to=20?= =?utf8?q?add=20group=20and=20propagate=20to=20complement=20view.=20also=20u?= =?utf8?q?pdates=20sequence=20ID=20colours=20from=20group=E2=80=99s=20idColo?= =?utf8?q?ur=20attribute?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/api/AlignViewportI.java | 8 +++++ src/jalview/gui/TreeCanvas.java | 41 +++----------------------- src/jalview/viewmodel/AlignmentViewport.java | 36 ++++++++++++++++++++++ 3 files changed, 48 insertions(+), 37 deletions(-) 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); + } + } } -- 1.7.10.2