X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=e146754bdb7c3a2fa0d50f90bdab25564c6983db;hb=09eebd8c6997a33049084e307078717cc1a693a6;hp=4f5b7d04ec17d18ee171ca8dc2de561fb1728ea1;hpb=2afaba8da802954edbedf5c0748412d965763a2c;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 4f5b7d0..e146754 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -57,6 +57,7 @@ import jalview.datamodel.Annotation; import jalview.datamodel.ColumnSelection; import jalview.datamodel.ContactListI; import jalview.datamodel.ContactRange; +import jalview.datamodel.GraphLine; import jalview.datamodel.HiddenColumns; import jalview.datamodel.SequenceI; import jalview.gui.JalviewColourChooser.ColourChooserListener; @@ -150,6 +151,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, private MouseWheelListener[] _mwl; + private boolean notJustOne; + /** * Creates a new AnnotationPanel object. * @@ -596,6 +599,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, } else { + GraphLine thr = aa[graphStretch].getThreshold(); int currentX = getColumnForXPos(evt.getX()); ContactListI forCurrentX = av.getContactList(aa[graphStretch], currentX); @@ -608,11 +612,48 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, int fr, to; fr = Math.min(cXci.cStart, cXci.cEnd); to = Math.max(cXci.cStart, cXci.cEnd); - for (int c = fr; c <= to; c++) + // select corresponding range in segment under mouse { - av.getColumnSelection().addElement(c); + for (int c = fr; c <= to; c++) + { + av.getColumnSelection().addElement(c); + } + av.getColumnSelection().addElement(currentX); + } + // and also select everything lower than the max range adjacent + // (kind of works) + { + int c = fr - 1; + ContactRange cr = forCurrentX.getRangeFor(fr, to); + double cval; + while (c > 0) + { + cval = forCurrentX.getContactAt(c); + if (// cr.getMin() <= cval && + cval <= cr.getMax()) + { + av.getColumnSelection().addElement(c--); + } + else + { + break; + } + } + c = to; + while (c < forCurrentX.getContactHeight()) + { + cval = forCurrentX.getContactAt(c); + if (// cr.getMin() <= cval && + cval <= cr.getMax()) + { + av.getColumnSelection().addElement(c++); + } + else + { + break; + } + } } - av.getColumnSelection().addElement(currentX); } } } @@ -776,6 +817,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, * mostly vertical drag */ dragMode = DragMode.Resize; + notJustOne = evt.isShiftDown(); /* * but could also be a matrix drag @@ -816,7 +858,20 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, AlignmentAnnotation graphAnnotation = av.getAlignment() .getAlignmentAnnotation()[graphStretch]; int newHeight = Math.max(0, graphAnnotation.graphHeight + deltaY); - graphAnnotation.graphHeight = newHeight; + if (notJustOne) + { + for (AlignmentAnnotation similar : av.getAlignment() + .findAnnotations(null, graphAnnotation.getCalcId(), + graphAnnotation.label)) + { + similar.graphHeight = newHeight; + } + + } + else + { + graphAnnotation.graphHeight = newHeight; + } adjustPanelHeight(); ap.paintAlignment(false, false); } @@ -889,29 +944,47 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, ContactGeometry lastXcgeom = new ContactGeometry(forFromX, cma.graphHeight); ContactGeometry.contactInterval lastXci = lastXcgeom - .mapFor(rowIndex[1], rowIndex[1] + deltaY); + .mapFor(rowIndex[1], rowIndex[1] - deltaY); + ContactGeometry cXcgeom = new ContactGeometry(forToX, cma.graphHeight); ContactGeometry.contactInterval cXci = cXcgeom.mapFor(rowIndex[1], - rowIndex[1] + deltaY); + 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 + ")"); + System.err.println("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++) { - av.getColumnSelection().addElement(c); + if (cma.sequenceRef != null) + { + int col = cma.sequenceRef.findIndex(c); + av.getColumnSelection().addElement(col); + } + else + { + 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); + if (cma.sequenceRef != null) + { + int col = cma.sequenceRef.findIndex(c); + av.getColumnSelection().addElement(col); + } + else + { + av.getColumnSelection().addElement(c); + } } fr = Math.min(lastX, currentX); to = Math.max(lastX, currentX); @@ -1001,15 +1074,14 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, static int[] getRowIndexAndOffset(int yPos, AlignmentAnnotation[] aa) { int[] res = new int[2]; + res[0] = -1; + res[1] = 0; if (aa == null) { - res[0] = -1; - res[1] = 0; return res; } int row = -1; int height = 0, lheight = 0; - for (int i = 0; i < aa.length; i++) { if (aa[i].visible) @@ -1080,14 +1152,16 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (clist != null) { ContactGeometry cgeom = new ContactGeometry(clist, ann.graphHeight); - ContactGeometry.contactInterval ci = cgeom.mapFor(rowAndOffset, - rowAndOffset); + ContactGeometry.contactInterval ci = cgeom.mapFor(rowAndOffset); ContactRange cr = clist.getRangeFor(ci.cStart, ci.cEnd); - tooltip = "Contact from " + ci.cStart + " to " + ci.cEnd - + "
Mean:" + cr.getMean(); - - // ap.getStructureSelectionManager().mouseOverSequence(ann.sequenceRef, - // new int[] {column, ci.cStart,ci.cEnd}, -1, null) + tooltip = "Contact from " + clist.getPosition() + ", [" + ci.cStart + + " - " + ci.cEnd + "]" + "
Mean:" + cr.getMean(); + int col = ann.sequenceRef.findPosition(column); + ap.getStructureSelectionManager() + .highlightPositionsOn(ann.sequenceRef, new int[][] + { new int[] { col, col }, + new int[] + { ci.cStart, ci.cEnd } }, null); } } return tooltip; @@ -1249,24 +1323,37 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (image == null || imgWidth != image.getWidth(this) || image.getHeight(this) != getHeight()) { - try - { - image = new BufferedImage(imgWidth, - ap.getAnnotationPanel().getHeight(), - BufferedImage.TYPE_INT_RGB); - } catch (OutOfMemoryError oom) + boolean tried = false; + image = null; + while (image == null && !tried) { try { - System.gc(); - } catch (Exception x) + image = new BufferedImage(imgWidth, + ap.getAnnotationPanel().getHeight(), + BufferedImage.TYPE_INT_RGB); + tried = true; + } catch (IllegalArgumentException exc) + { + System.err.println( + "Serious issue with viewport geometry imgWidth requested was " + + imgWidth); + return; + } catch (OutOfMemoryError oom) { + try + { + System.gc(); + } catch (Exception x) + { + } + ; + new OOMWarning( + "Couldn't allocate memory to redraw screen. Please restart Jalview", + oom); + return; } - ; - new OOMWarning( - "Couldn't allocate memory to redraw screen. Please restart Jalview", - oom); - return; + } gg = (Graphics2D) image.getGraphics();