X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FTreeCanvas.java;h=f6b842dd960a50c6621ce4e665096887b09a6032;hb=beb2fee66dde629e3bbb7febb38d0116e1a64df2;hp=3a055ae44cab8ac696fc7c2c9c006214195521dc;hpb=4b7d3640209c4434d569c746672cf9eed4250ace;p=jalview.git diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index 3a055ae..f6b842d 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -54,6 +54,7 @@ import jalview.analysis.Conservation; import jalview.analysis.TreeModel; import jalview.api.AlignViewportI; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.Annotation; import jalview.datamodel.BinaryNode; import jalview.datamodel.ColumnSelection; import jalview.datamodel.ContactMatrixI; @@ -67,6 +68,7 @@ import jalview.schemes.ColourSchemeI; import jalview.structure.SelectionSource; import jalview.util.Format; import jalview.util.MessageManager; +import jalview.ws.datamodel.MappableContactMatrixI; /** * DOCUMENT ME! @@ -1035,6 +1037,41 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, cm.setColorForGroup(gp, colors.get(gp)); } } + // stash colors in linked annotation row. + // doesn't work yet. TESTS! + int sstart = aa.sequenceRef != null ? aa.sequenceRef.getStart() - 1 + : 0; + Annotation ae; + Color gpcol = null; + int[] seqpos = null; + for (BitSet gp : colors.keySet()) + { + gpcol = colors.get(gp); + for (int p = gp.nextSetBit(0); p >= 0 + && p < Integer.MAX_VALUE; p = gp.nextSetBit(p + 1)) + { + if (cm instanceof MappableContactMatrixI) + { + MappableContactMatrixI mcm = (MappableContactMatrixI) cm; + seqpos = mcm.getMappedPositionsFor(aa.sequenceRef, p); + if (seqpos == null) + { + // no mapping for this column. + continue; + } + // TODO: handle ranges... + ae = aa.getAnnotationForPosition(seqpos[0]); + } + else + { + ae = aa.getAnnotationForPosition(p + sstart); + } + if (ae != null) + { + ae.colour = gpcol.brighter().darker(); + } + } + } } } @@ -1071,7 +1108,6 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, return false; } ColumnSelection cs = av.getColumnSelection(); - HiddenColumns hc = av.getAlignment().getHiddenColumns(); int offp = (rseq != null) ? rseq.findIndex(rseq.getStart() + colm) : colm; @@ -1087,7 +1123,6 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, } return false; } - private BitSet createColumnGroupFor(Vector l, Color col) { BitSet gp = new BitSet(); @@ -1136,22 +1171,39 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, { continue; } + // TODO - sort indices for faster lookup ColumnSelection cs = av.getColumnSelection(); HiddenColumns hc = av.getAlignment().getHiddenColumns(); + ContactMatrixI cm = av.getContactMatrix(tp.assocAnnotation); + MappableContactMatrixI mcm = null; + int offp; + if (cm instanceof MappableContactMatrixI) + { + mcm = (MappableContactMatrixI) cm; + int[] seqpos = mcm.getMappedPositionsFor( + tp.assocAnnotation.sequenceRef, colm); + if (seqpos == null) + { + // no mapping for this column. + continue; + } + // TODO: handle ranges... + offp = seqpos[0]; + } + else { - int offp = (rseq != null) ? rseq.findIndex(rseq.getStart() + colm) + offp = (rseq != null) ? rseq.findIndex(rseq.getStart() + colm) : colm; - - if (!av.hasHiddenColumns() || hc.isVisible(offp - 1)) + } + if (!av.hasHiddenColumns() || hc.isVisible(offp - 1)) + { + if (cs.contains(offp - 1)) { - if (cs.contains(offp - 1)) - { - cs.removeElement(offp - 1); - } - else - { - cs.addElement(offp - 1); - } + cs.removeElement(offp - 1); + } + else + { + cs.addElement(offp - 1); } } }