+ } catch (Exception ex)
+ {
+ }
+ }
+ }
+ }
+
+ /**
+ * modify current selection according to a received message.
+ */
+ @Override
+ public void selection(SequenceGroup seqsel, ColumnSelection colsel,
+ HiddenColumns hidden, 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 != null && (av == source || !av.followSelection
+ || (source instanceof AlignViewport
+ && ((AlignmentViewport) source).getSequenceSetId()
+ .equals(av.getSequenceSetId()))))
+ {
+ return;
+ }
+
+ /*
+ * Check for selection in a view of which this one is a dna/protein
+ * complement.
+ */
+ if (selectionFromTranslation(seqsel, colsel, hidden, source))
+ {
+ return;
+ }
+
+ // do we want to thread this ? (contention with seqsel and colsel locks, I
+ // suspect)
+ /*
+ * only copy colsel if there is a real intersection between
+ * sequence selection and this panel's alignment
+ */
+ boolean repaint = false;
+ boolean copycolsel = false;
+ if (av.getSelectionGroup() == null || !av.isSelectionGroupChanged(true))
+ {
+ SequenceGroup sgroup = null;
+ if (seqsel != null && seqsel.getSize() > 0)
+ {
+ if (av.getAlignment() == null)
+ {
+ jalview.bin.Console.outPrintln("Selection message: alignviewport av SeqSetId="
+ + av.getSequenceSetId() + " ViewId=" + av.getViewId()
+ + " 's alignment is NULL! returning immediatly.");
+ return;
+ }
+ sgroup = seqsel.intersect(av.getAlignment(),
+ (av.hasHiddenRows()) ? av.getHiddenRepSequences() : null);
+ if ((sgroup != null && sgroup.getSize() > 0))
+ {
+ copycolsel = true;
+ }
+ }
+ if (sgroup != null && sgroup.getSize() > 0)
+ {
+ av.setSelectionGroup(sgroup);
+ }
+ else
+ {
+ av.setSelectionGroup(null);
+ }
+ repaint = av.isSelectionGroupChanged(true);
+ }
+ if (copycolsel && (av.getColumnSelection() == null
+ || !av.isColSelChanged(true)))
+ {
+ // the current selection is unset or from a previous message
+ // so import the new colsel.
+ if (colsel == null || colsel.isEmpty())
+ {
+ if (av.getColumnSelection() != null)
+ {
+ av.getColumnSelection().clear();
+ }
+ }
+ else
+ {
+ // TODO: shift colSel according to the intersecting sequences
+ if (av.getColumnSelection() == null)
+ {
+ av.setColumnSelection(new ColumnSelection(colsel));
+ }
+ else
+ {
+ av.getColumnSelection().setElementsFrom(colsel,
+ av.getAlignment().getHiddenColumns());