X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=2177a269aba985e3e1965f73c8deddb3f6e3b7c9;hb=f3d6a13271e3f34dfb4e40d6a2a7df1d392f8014;hp=eeda585b18439eeef1e846a5efe619cfc361561c;hpb=90dad57dbc2c2cc8c9c77be3e3e2935fc7d7ecdc;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index eeda585..2177a26 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -655,7 +655,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, fr = Math.min(cXci.cStart, cXci.cEnd); to = Math.max(cXci.cStart, cXci.cEnd); - if (evt.isControlDown()) + // double click selects the whole group + if (evt.getClickCount() == 2) { ContactMatrixI matrix = av.getContactMatrix(clicked); @@ -666,6 +667,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, { SequenceI rseq = clicked.sequenceRef; BitSet grp = matrix.getGroupsFor(currentX); + // TODO: cXci needs to be mapped to real groups for (int c = fr; c <= to; c++) { BitSet additionalGrp = matrix.getGroupsFor(c); @@ -696,16 +698,18 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, { // select corresponding range in segment under mouse { - for (int c = fr; c <= to; c++) + int[] rng = forCurrentX.getMappedPositionsFor(fr, to); + if (rng != null) { - av.getColumnSelection().addElement(c); + av.getColumnSelection().addRangeOfElements(rng, true); } av.getColumnSelection().addElement(currentX); } // PAE SPECIFIC // and also select everything lower than the max range adjacent // (kind of works) - if (PAEContactMatrix.PAEMATRIX.equals(clicked.getCalcId())) + if (evt.isControlDown() + && PAEContactMatrix.PAEMATRIX.equals(clicked.getCalcId())) { int c = fr - 1; ContactRange cr = forCurrentX.getRangeFor(fr, to); @@ -723,28 +727,39 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (// cr.getMin() <= cval && cval <= thresh) { - av.getColumnSelection().addElement(c--); - } - else - { - break; + int[] cols = forCurrentX.getMappedPositionsFor(c, c); + if (cols != null) + { + av.getColumnSelection().addRangeOfElements(cols, true); + } + else + { + break; + } } + c--; } - c = to; - while (c < forCurrentX.getContactHeight()) - { - cval = forCurrentX.getContactAt(c); - if (// cr.getMin() <= cval && - cval <= thresh) + c = to; + while (c < forCurrentX.getContactHeight()) { - av.getColumnSelection().addElement(c++); - } - else - { - break; + cval = forCurrentX.getContactAt(c); + if (// cr.getMin() <= cval && + cval <= thresh) + { + int[] cols = forCurrentX.getMappedPositionsFor(c, c); + if (cols != null) + { + av.getColumnSelection().addRangeOfElements(cols, true); + } + } + else + { + break; + } + c++; + } } - } } } ap.paintAlignment(false, false); @@ -1043,38 +1058,56 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, rowIndex[1] - deltaY); // mark rectangular region formed by drag - jalview.bin.Console.trace("Matrix Selection from last(" + fromXc + ",[" - + lastXci.cStart + "," + lastXci.cEnd + "]) to cur(" + toXc - + ",[" + cXci.cStart + "," + cXci.cEnd + "])"); + jalview.bin.Console.trace("Matrix Selection from last(" + fromXc + + ",[" + lastXci.cStart + "," + lastXci.cEnd + "]) to cur(" + + toXc + ",[" + cXci.cStart + "," + cXci.cEnd + "])"); int fr, to; fr = Math.min(lastXci.cStart, lastXci.cEnd); to = Math.max(lastXci.cStart, lastXci.cEnd); - jalview.bin.Console.trace("Marking " + fr + " to " + to); - for (int c = fr; c <= to; c++) + int[] mappedPos = forFromX.getMappedPositionsFor(fr, to); + if (mappedPos != null) { - if (cma.sequenceRef != null) + jalview.bin.Console.trace("Marking " + fr + " to " + to + + " mapping to sequence positions " + mappedPos[0] + " to " + + mappedPos[1]); + for (int pair = 0; pair < mappedPos.length; pair += 2) { - int col = cma.sequenceRef.findIndex(c); - av.getColumnSelection().addElement(col); - } - else - { - av.getColumnSelection().addElement(c); + for (int c = mappedPos[pair]; c <= mappedPos[pair + 1]; c++) +// { +// if (cma.sequenceRef != null) +// { +// int col = cma.sequenceRef.findIndex(cma.sequenceRef.getStart()+c); +// av.getColumnSelection().addElement(col); +// } +// else + { + av.getColumnSelection().addElement(c); + } } } + // and again for most recent corner of drag fr = Math.min(cXci.cStart, cXci.cEnd); to = Math.max(cXci.cStart, cXci.cEnd); - jalview.bin.Console.trace("Marking " + fr + " to " + to); - for (int c = fr; c <= to; c++) + mappedPos = forFromX.getMappedPositionsFor(fr, to); + if (mappedPos != null) { - if (cma.sequenceRef != null) + for (int pair = 0; pair < mappedPos.length; pair += 2) { - int col = cma.sequenceRef.findIndex(c); - av.getColumnSelection().addElement(col); - } - else - { - av.getColumnSelection().addElement(c); + jalview.bin.Console.trace("Marking " + fr + " to " + to + + " mapping to sequence positions " + mappedPos[pair] + " to " + + mappedPos[pair+1]); + for (int c = mappedPos[pair]; c <= mappedPos[pair + 1]; c++) + { +// if (cma.sequenceRef != null) +// { +// int col = cma.sequenceRef.findIndex(cma.sequenceRef.getStart()+c); +// av.getColumnSelection().addElement(col); +// } +// else + { + av.getColumnSelection().addElement(c); + } + } } } fr = Math.min(lastX, currentX); @@ -1247,12 +1280,28 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, ContactRange cr = clist.getRangeFor(ci.cStart, ci.cEnd); tooltip = "Contact from " + clist.getPosition() + ", [" + ci.cStart + " - " + ci.cEnd + "]" + "
Mean:" + cr.getMean(); + int col = ann.sequenceRef.findPosition(column); + int[][] highlightPos; + int[] mappedPos = clist.getMappedPositionsFor(ci.cStart, ci.cEnd); + if (mappedPos != null) + { + highlightPos = new int[1 + mappedPos.length][2]; + highlightPos[0] = new int[] { col, col }; + for (int p = 0, h = 0; p < mappedPos.length; h++, p += 2) + { + highlightPos[h][0] = ann.sequenceRef + .findPosition(mappedPos[p] - 1); + highlightPos[h][1] = ann.sequenceRef + .findPosition(mappedPos[p + 1] - 1); + } + } + else + { + highlightPos = new int[][] { new int[] { col, col } }; + } ap.getStructureSelectionManager() - .highlightPositionsOn(ann.sequenceRef, new int[][] - { new int[] { col, col }, - new int[] - { ci.cStart, ci.cEnd } }, null); + .highlightPositionsOn(ann.sequenceRef, highlightPos, null); } } return tooltip;