X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=2177a269aba985e3e1965f73c8deddb3f6e3b7c9;hb=cc3341f9d1465b0226d184be4216d022a62e5cee;hp=13c0e5a840f6edb91a43ffb49a9ef81d5cf4ae9e;hpb=a9b20fb4f95f8a4435b09d513959443c266c719c;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 13c0e5a..2177a26 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -621,12 +621,14 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, { int[] rowIndex = getRowIndexAndOffset(evt.getY(), av.getAlignment().getAlignmentAnnotation()); - int yOffset = rowIndex[1]; - if (rowIndex == null) { - System.err.println("IMPLEMENTATION ERROR: matrix click out of range."); + jalview.bin.Console + .error("IMPLEMENTATION ERROR: matrix click out of range."); + return false; } + int yOffset = rowIndex[1]; + AlignmentAnnotation clicked = av.getAlignment() .getAlignmentAnnotation()[rowIndex[0]]; if (clicked.graph != AlignmentAnnotation.CONTACT_MAP) @@ -653,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); @@ -664,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); @@ -694,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); @@ -721,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); @@ -1009,12 +1026,12 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (rowIndex == null || toRowIndex == null) { - System.out.println("Drag out of range. needs to be clipped"); + jalview.bin.Console.trace("Drag out of range. needs to be clipped"); } if (rowIndex[0] != toRowIndex[0]) { - System.out.println("Drag went to another row. needs to be clipped"); + jalview.bin.Console.trace("Drag went to another row. needs to be clipped"); } // rectangular selection on matrix style annotation @@ -1041,44 +1058,62 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, rowIndex[1] - deltaY); // mark rectangular region formed by drag - System.err.println("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); - System.err.println("Marking " + fr + " to " + to); - for (int c = fr; c <= to; c++) + int[] mappedPos = forFromX.getMappedPositionsFor(fr, to); + if (mappedPos != null) { - if (cma.sequenceRef != null) - { - int col = cma.sequenceRef.findIndex(c); - av.getColumnSelection().addElement(col); - } - else + 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) { - 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); - System.err.println("Marking " + fr + " to " + to); - for (int c = fr; c <= to; c++) + mappedPos = forFromX.getMappedPositionsFor(fr, to); + if (mappedPos != null) { - if (cma.sequenceRef != null) - { - int col = cma.sequenceRef.findIndex(c); - av.getColumnSelection().addElement(col); - } - else + for (int pair = 0; pair < mappedPos.length; pair += 2) { - 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); to = Math.max(lastX, currentX); - System.err.println("Marking " + fr + " to " + to); + jalview.bin.Console.trace("Marking " + fr + " to " + to); for (int c = fr; c <= to; c++) { av.getColumnSelection().addElement(c); @@ -1245,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;