+
+ /**
+ * modify current selection according to a received message.
+ */
+ public void selection(SequenceGroup seqsel, ColumnSelection colsel,
+ SelectionSource source)
+ {
+ // TODO: fix this hack - source of messages is align viewport, but SeqPanel
+ // handles selection messages...
+ // TODO: extend config options to allow user to control if selections may be
+ // shared between viewports.
+ if (av == source
+ || !av.followSelection
+ || (source instanceof AlignViewport && ((AlignViewport) source)
+ .getSequenceSetId().equals(av.getSequenceSetId())))
+ {
+ return;
+ }
+ // do we want to thread this ? (contention with seqsel and colsel locks, I
+ // suspect)
+ boolean repaint = false;
+ if (av.selectionGroup == null || !av.isSelectionGroupChanged())
+ {
+ SequenceGroup sgroup = null;
+ if (seqsel != null)
+ {
+ if (av.alignment == null)
+ {
+ jalview.bin.Cache.log.warn("alignviewport av SeqSetId="
+ + av.getSequenceSetId() + " ViewId=" + av.getViewId()
+ + " 's alignment is NULL! returning immediatly.");
+ return;
+ }
+ sgroup = seqsel.intersect(av.alignment,
+ (av.hasHiddenRows) ? av.hiddenRepSequences : null);
+ }
+ if (sgroup != null && sgroup.getSize() > 0)
+ {
+ av.setSelectionGroup(sgroup);
+ }
+ else
+ {
+ av.setSelectionGroup(null);
+ }
+ repaint = av.isSelectionGroupChanged();
+ }
+ if (av.colSel == null || !av.isColSelChanged())
+ {
+ // the current selection is unset or from a previous message
+ // so import the new colsel.
+ if (colsel == null || colsel.size() == 0)
+ {
+ if (av.colSel != null)
+ {
+ av.colSel.clear();
+ }
+ }
+ else
+ {
+ if (av.colSel == null)
+ {
+ av.colSel = new ColumnSelection(colsel);
+ }
+ else
+ {
+ av.colSel.setElementsFrom(colsel);
+ }
+ }
+ repaint |= av.isColSelChanged();
+ }
+ if (av.hasHiddenColumns
+ && (av.colSel == null || av.colSel.getHiddenColumns() == null))
+ {
+ System.err.println("Bad things");
+ }
+ if (repaint)
+ {
+ // probably finessing with multiple redraws here
+ PaintRefresher.Refresh(this, av.getSequenceSetId());
+ // ap.paintAlignment(false);
+ }
+ }