+
+ try
+ {
+ if (dragMode == DragMode.Resize)
+ {
+ /*
+ * resize graph annotation if mouse was dragged up or down
+ */
+ int deltaY = mouseDragLastY - evt.getY();
+ if (deltaY != 0)
+ {
+ AlignmentAnnotation graphAnnotation = av.getAlignment()
+ .getAlignmentAnnotation()[graphStretch];
+ int newHeight = Math.max(0, graphAnnotation.graphHeight + deltaY);
+ graphAnnotation.graphHeight = newHeight;
+ adjustPanelHeight();
+ ap.paintAlignment(false, false);
+ }
+ }
+ else if (dragMode == DragMode.MatrixSelect)
+ {
+ /*
+ * TODO draw a rubber band for range
+ */
+ mouseDragLastX = x;
+ mouseDragLastY = y;
+ ap.paintAlignment(false, false);
+ }
+ else
+ {
+ /*
+ * for mouse drag left or right, delegate to
+ * ScalePanel to adjust the column selection
+ */
+ ap.getScalePanel().mouseDragged(evt);
+ }
+ } finally
+ {
+ mouseDragLastX = x;
+ mouseDragLastY = y;
+ }
+ }
+
+ public void matrixSelectRange(MouseEvent evt)
+ {
+ /*
+ * get geometry of drag
+ */
+ int fromY = Math.min(firstDragY, evt.getY());
+ int toY = Math.max(firstDragY, evt.getY());
+ int deltaY = toY - fromY;
+
+ int[] rowIndex = getRowIndexAndOffset(fromY,
+ av.getAlignment().getAlignmentAnnotation());
+ int[] toRowIndex = getRowIndexAndOffset(toY,
+ av.getAlignment().getAlignmentAnnotation());
+
+ if (rowIndex == null || toRowIndex == null)
+ {
+ System.out.println("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");
+ }
+
+ // rectangular selection on matrix style annotation
+ AlignmentAnnotation cma = av.getAlignment()
+ .getAlignmentAnnotation()[rowIndex[0]];
+
+ int fromXp = Math.min(firstDragX, evt.getX());
+ int toXp = Math.max(firstDragX, evt.getX());
+ int lastX = getColumnForXPos(fromXp);
+ int currentX = getColumnForXPos(toXp);
+ ContactListI forLastX = av.getContactList(cma, lastX);
+ ContactListI forCurrentX = av.getContactList(cma, currentX);
+ if (forLastX != null && forCurrentX != null)
+ {
+ ContactGeometry lastXcgeom = new ContactGeometry(forLastX,
+ cma.graphHeight);
+ ContactGeometry.contactInterval lastXci = lastXcgeom.mapFor(
+ rowIndex[1],
+ rowIndex[1] + ((fromY == firstDragY) ? -deltaY : deltaY));
+ ContactGeometry cXcgeom = new ContactGeometry(forCurrentX,
+ cma.graphHeight);
+ ContactGeometry.contactInterval cXci = cXcgeom.mapFor(rowIndex[1],
+ rowIndex[1] + deltaY);
+ // mark rectangular region formed by drag
+ System.err.println("Matrix Selection from last(" + lastXci.cStart
+ + "," + lastXci.cEnd + ") to cur(" + 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++)
+ {
+ av.getColumnSelection().addElement(c);
+ }
+ 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++)
+ {
+ av.getColumnSelection().addElement(c);
+ }
+ fr = Math.min(lastX, currentX);
+ to = Math.max(lastX, currentX);
+
+ System.err.println("Marking " + fr + " to " + to);
+ for (int c = fr; c <= to; c++)
+ {
+ av.getColumnSelection().addElement(c);
+ }
+ }
+