From: gmungoc Date: Thu, 21 Mar 2019 16:28:40 +0000 (+0000) Subject: JAL-1889 better debug logging X-Git-Tag: Release_2_11_0~17^2~35 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=fdf90308b1b24f4063648449c5f316ced24c938b;p=jalview.git JAL-1889 better debug logging --- diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 08c74e8..11ee700 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -257,7 +257,7 @@ public class SeqPanel extends JPanel MousePos findMousePosition(MouseEvent evt) { - return findMousePosition(evt, false); + return findMousePosition(evt, null); } /** @@ -267,7 +267,7 @@ public class SeqPanel extends JPanel * @param evt * @return */ - MousePos findMousePosition(MouseEvent evt, boolean debug) + MousePos findMousePosition(MouseEvent evt, String debug) { int col = findColumn(evt, debug); int seqIndex = -1; @@ -276,11 +276,11 @@ public class SeqPanel extends JPanel int charHeight = av.getCharHeight(); int alignmentHeight = av.getAlignment().getHeight(); - if (debug) + if (debug != null) { System.out.println(String.format( - "charHeight %d alHeight %d canvasWidth %d canvasHeight %d", - charHeight, alignmentHeight, seqCanvas.getWidth(), + "%s: charHeight %d alHeight %d canvasWidth %d canvasHeight %d", + debug, charHeight, alignmentHeight, seqCanvas.getWidth(), seqCanvas.getHeight())); } if (av.getWrapAlignment()) @@ -343,10 +343,10 @@ public class SeqPanel extends JPanel */ int findColumn(MouseEvent evt) { - return findColumn(evt, true); + return findColumn(evt, null); } - int findColumn(MouseEvent evt, boolean debug) + int findColumn(MouseEvent evt, String debug) { int res = 0; int x = evt.getX(); @@ -368,10 +368,10 @@ public class SeqPanel extends JPanel int y = evt.getY(); y = Math.max(0, y - hgap); x -= seqCanvas.getLabelWidthWest(); - if (debug) + if (debug != null) { System.out.println( - String.format("findColumn: x %d labelWest %d charWidth %d ", + String.format("%s: x %d labelWest %d charWidth %d ", debug, x, seqCanvas.getLabelWidthWest(), charWidth)); } if (x < 0) @@ -387,9 +387,9 @@ public class SeqPanel extends JPanel } if (x >= cwidth * charWidth) { - if (debug) + if (debug != null) { - System.out.println("findColumn: cwidth = " + cwidth); + System.out.println(debug + ": cwidth = " + cwidth); } // mouse is over right scale return -1; diff --git a/test/jalview/gui/SeqPanelTest.java b/test/jalview/gui/SeqPanelTest.java index 0d49936..fa0e352 100644 --- a/test/jalview/gui/SeqPanelTest.java +++ b/test/jalview/gui/SeqPanelTest.java @@ -288,7 +288,7 @@ public class SeqPanelTest */ MouseEvent evt = new MouseEvent(testee, Event.MOUSE_MOVE, 0L, 0, x, y, 0, 0, 0, false, 0); - MousePos pos = testee.findMousePosition(evt); + MousePos pos = testee.findMousePosition(evt, "291"); assertEquals(pos.column, 0); assertEquals(pos.seqIndex, -1); // above sequences assertEquals(pos.annotationIndex, -1); @@ -463,7 +463,7 @@ public class SeqPanelTest */ MouseEvent evt = new MouseEvent(testee, Event.MOUSE_MOVE, 0L, 0, x, y, 0, 0, 0, false, 0); - MousePos pos = testee.findMousePosition(evt); + MousePos pos = testee.findMousePosition(evt, "466"); assertEquals(pos.column, 0); assertEquals(pos.seqIndex, -1); // above sequences assertEquals(pos.annotationIndex, -1); @@ -659,7 +659,7 @@ public class SeqPanelTest */ MouseEvent evt = new MouseEvent(testee, Event.MOUSE_MOVE, 0L, 0, x, y, 0, 0, 0, false, 0); - MousePos pos = testee.findMousePosition(evt); + MousePos pos = testee.findMousePosition(evt, "662"); assertEquals(pos.column, 0); assertEquals(pos.seqIndex, -1); // above sequences assertEquals(pos.annotationIndex, -1); @@ -805,7 +805,7 @@ public class SeqPanelTest */ MouseEvent evt = new MouseEvent(testee, Event.MOUSE_MOVE, 0L, 0, x, 0, 0, 0, 0, false, 0); - assertEquals(testee.findColumn(evt), 0); + assertEquals(testee.findColumn(evt, "808"), 0); /* * not quite one charWidth across