From: amwaterhouse Date: Wed, 15 Dec 2004 17:19:15 +0000 (+0000) Subject: If selection altered, update RubberbandGroup X-Git-Tag: Release_2_0~812 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f65ab8b9feb5f7f36084e254a1a3cb080cd8811b;p=jalview.git If selection altered, update RubberbandGroup --- diff --git a/src/jalview/gui/Selection.java b/src/jalview/gui/Selection.java index 6f73f5d..0ac9389 100755 --- a/src/jalview/gui/Selection.java +++ b/src/jalview/gui/Selection.java @@ -4,18 +4,29 @@ import jalview.datamodel.*; import java.util.*; -public class Selection { +public class Selection +{ + Vector selected = new Vector(); + AlignViewport av; - public void addElement(DrawableSequence seq) { - addElement((SequenceI)seq); + public Selection(AlignViewport av) + { + this.av = av; } + public void addElement(SequenceI seq) { selected.addElement(seq); - } + SequenceGroup sg = av.getRubberbandGroup(); + if(sg==null) + { + sg = new SequenceGroup(); + sg.setEndRes(av.alignment.getWidth()-1); + av.setRubberbandGroup(sg); + } + + sg.addSequence(seq); - public void removeElement(DrawableSequence seq) { - removeElement((SequenceI)seq); } public void clear() { @@ -23,16 +34,18 @@ public class Selection { } public void removeElement(SequenceI seq) { - if (selected.contains(seq)) { + if (selected.contains(seq)) selected.removeElement(seq); - } else { + else System.err.println("WARNING: Tried to remove SequenceI NOT in Selection"); - } - } - public boolean contains(DrawableSequence seq) { - return contains((SequenceI)seq); + SequenceGroup sg = av.getRubberbandGroup(); + if (sg != null) + sg.deleteSequence(seq); + + } + public boolean contains(SequenceI seq) { return selected.contains(seq); }