X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FTreeCanvas.java;h=55ce44a23ed71c3babeaee2d70c39d2d777ba1cf;hb=0c90355de2854b4ba6f30c1c162f9cb0c712351a;hp=bb028bf79a5f790ea2bb22c33663fe0af8135ab8;hpb=279c6495df1a0de231600a2d283098c7411c4730;p=jalview.git diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index bb028bf..55ce44a 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -143,9 +143,43 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, scrollPane = scroller; addMouseListener(this); addMouseMotionListener(this); + ToolTipManager.sharedInstance().registerComponent(this); } + public void clearSelectedLeaves() + { + Vector leaves = tp.getTree() + .findLeaves(tp.getTree().getTopNode()); + if (tp.isColumnWise()) + { + markColumnsFor(getAssociatedPanels(), leaves, Color.white, true); + } + else + { + for (AlignmentPanel ap : getAssociatedPanels()) + { + SequenceGroup selected = ap.av.getSelectionGroup(); + if (selected != null) + { + { + for (int i = 0; i < leaves.size(); i++) + { + SequenceI seq = (SequenceI) leaves.elementAt(i).element(); + if (selected.contains(seq)) + { + selected.addOrRemove(seq, false); + } + } + selected.recalcConservation(); + } + } + ap.av.sendSelection(); + } + } + PaintRefresher.Refresh(tp, av.getSequenceSetId()); + repaint(); + } /** * DOCUMENT ME! * @@ -830,7 +864,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Vector leaves = tree.findLeaves(highlightNode); if (tp.isColumnWise()) { - markColumnsFor(getAssociatedPanels(), leaves, Color.red); + markColumnsFor(getAssociatedPanels(), leaves, Color.red,false); } else { @@ -1109,16 +1143,42 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, } ColumnSelection cs = av.getColumnSelection(); HiddenColumns hc = av.getAlignment().getHiddenColumns(); - int offp = (rseq != null) ? rseq.findIndex(rseq.getStart() + colm) - : colm; + AlignmentAnnotation aa = tp.getAssocAnnotation(); + int offp=-1; + if (aa != null) + { + ContactMatrixI cm = av.getContactMatrix(aa); + // generally, we assume cm has 1:1 mapping to annotation row - probably wrong + // but.. if + if (cm instanceof MappableContactMatrixI) + { + int[] pos; + // use the mappable's mapping - always the case for PAE Matrices so good + // for 2.11.3 + MappableContactMatrixI mcm = (MappableContactMatrixI) cm; + pos = mcm.getMappedPositionsFor(rseq, colm + 1); + // finally, look up the position of the column + if (pos != null) + { + offp = rseq.findIndex(pos[0]); + } + } else { + offp = colm; + } + } + if (offp<=0) + { + return false; + } + offp-=2; if (!av.hasHiddenColumns()) { - return cs.contains(offp - 1); + return cs.contains(offp); } - if (hc.isVisible(offp - 1)) + if (hc.isVisible(offp)) { - return cs.contains(offp - 1); + return cs.contains(offp); // return cs.contains(hc.absoluteToVisibleColumn(offp)); } return false; @@ -1151,7 +1211,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, } private void markColumnsFor(AlignmentPanel[] aps, Vector l, - Color col) + Color col, boolean clearSelected) { SequenceI rseq = tp.assocAnnotation.sequenceRef; if (av == null || av.getAlignment() == null) @@ -1191,25 +1251,26 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, continue; } // TODO: handle ranges... - offp = seqpos[0]; + offp = seqpos[0]-1; } else { offp = (rseq != null) ? rseq.findIndex(rseq.getStart() + colm) : colm; } - if (!av.hasHiddenColumns() || hc.isVisible(offp - 1)) + if (!av.hasHiddenColumns() || hc.isVisible(offp)) { - if (cs.contains(offp - 1)) + if (clearSelected || cs.contains(offp)) { - cs.removeElement(offp - 1); + cs.removeElement(offp); } else { - cs.addElement(offp - 1); + cs.addElement(offp); } } } + PaintRefresher.Refresh(tp, av.getSequenceSetId()); } public void createSeqGroupFor(AlignmentPanel[] aps, Vector l,