X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fappletgui%2FScalePanel.java;h=07e83e764c4953d9e9342057d264d73b1a8f726f;hb=7bc226b58110fa26d9dbd3f0c78095d06909ffc3;hp=9cde175ffe3b8d1c4c495687b885e870f096ea9a;hpb=dd74fc4938723fe5ec48d4e5fdcfbe58ac42a48d;p=jalview.git diff --git a/src/jalview/appletgui/ScalePanel.java b/src/jalview/appletgui/ScalePanel.java index 9cde175..07e83e7 100755 --- a/src/jalview/appletgui/ScalePanel.java +++ b/src/jalview/appletgui/ScalePanel.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -38,7 +38,7 @@ public class ScalePanel int min; //used by mouseDragged to see if user int max; //used by mouseDragged to see if user boolean mouseDragging = false; - int [] reveal; + int[] reveal; public ScalePanel(AlignViewport av, AlignmentPanel ap) { @@ -57,13 +57,17 @@ public class ScalePanel final int res; if (av.hasHiddenColumns) + { res = av.getColumnSelection().adjustForHiddenColumns(x); + } else + { res = x; + } min = res; max = res; - if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) + if ( (evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) { PopupMenu pop = new PopupMenu(); @@ -78,7 +82,9 @@ public class ScalePanel reveal = null; ap.repaint(); if (ap.overviewPanel != null) + { ap.overviewPanel.updateOverviewImage(); + } } }); pop.add(item); @@ -94,7 +100,9 @@ public class ScalePanel reveal = null; ap.repaint(); if (ap.overviewPanel != null) + { ap.overviewPanel.updateOverviewImage(); + } } }); pop.add(item); @@ -113,11 +121,15 @@ public class ScalePanel if (av.getSelectionGroup() != null && av.getSelectionGroup().getSize() == av.alignment.getHeight()) + { av.setSelectionGroup(null); + } ap.repaint(); if (ap.overviewPanel != null) + { ap.overviewPanel.updateOverviewImage(); + } } }); pop.add(item); @@ -143,13 +155,13 @@ public class ScalePanel sg.setEndRes(res); av.setSelectionGroup(sg); - if(evt.isShiftDown()) + if (evt.isShiftDown()) { int min = Math.min(av.getColumnSelection().getMin(), res); int max = Math.max(av.getColumnSelection().getMax(), res); - for (int i = min; i av.alignment.getWidth()) + if (res > av.alignment.getWidth()) { - res = av.alignment.getWidth()-1; + res = av.alignment.getWidth() - 1; } - if(av.hasHiddenColumns) + if (av.hasHiddenColumns) + { res = av.getColumnSelection().adjustForHiddenColumns(res); + } if (!stretchingGroup) { - ap.repaint(); + ap.repaint(); - return; + return; } SequenceGroup sg = av.getSelectionGroup(); if (res > sg.getStartRes()) { - sg.setEndRes(res); + sg.setEndRes(res); } else if (res < sg.getStartRes()) { - sg.setStartRes(res); + sg.setStartRes(res); } stretchingGroup = false; @@ -201,10 +215,14 @@ public class ScalePanel int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); if (res < 0) + { res = 0; + } if (av.hasHiddenColumns) + { res = av.getColumnSelection().adjustForHiddenColumns(res); + } if (res > av.alignment.getWidth()) { @@ -257,17 +275,20 @@ public class ScalePanel } } - public void mouseEntered(MouseEvent evt) { if (mouseDragging) + { ap.seqPanel.scrollCanvas(null); + } } public void mouseExited(MouseEvent evt) { if (mouseDragging) + { ap.seqPanel.scrollCanvas(evt); + } } public void mouseClicked(MouseEvent evt) @@ -278,7 +299,9 @@ public class ScalePanel public void mouseMoved(MouseEvent evt) { if (!av.hasHiddenColumns) + { return; + } int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); @@ -316,7 +339,6 @@ public class ScalePanel { gg.setFont(av.getFont()); - //Fill in the background gg.setColor(Color.white); gg.fillRect(0, 0, width, height); @@ -328,16 +350,17 @@ public class ScalePanel for (int i = 0; i < cs.size(); i++) { - int sel = cs.columnAt(i); - if(av.hasHiddenColumns) - sel = av.getColumnSelection().findColumnPosition(sel); - + int sel = cs.columnAt(i); + if (av.hasHiddenColumns) + { + sel = av.getColumnSelection().findColumnPosition(sel); + } - if ((sel >= startx) && (sel <= endx)) - { - gg.fillRect((sel - startx) * av.charWidth, 0, av.charWidth, - getSize().height); - } + if ( (sel >= startx) && (sel <= endx)) + { + gg.fillRect( (sel - startx) * av.charWidth, 0, av.charWidth, + getSize().height); + } } // Draw the scale numbers @@ -348,47 +371,48 @@ public class ScalePanel FontMetrics fm = gg.getFontMetrics(av.getFont()); int y = av.charHeight - fm.getDescent(); - if ((scalestartx % 10) == 0) + if ( (scalestartx % 10) == 0) { - scalestartx += 5; + scalestartx += 5; } String string; - int maxX=0; + int maxX = 0; for (int i = scalestartx; i < endx; i += 5) { - if ((i % 10) == 0) + if ( (i % 10) == 0) + { + string = String.valueOf(av.getColumnSelection().adjustForHiddenColumns( + i)); + if ( (i - startx - 1) * av.charWidth > maxX) { - string = String.valueOf(av.getColumnSelection().adjustForHiddenColumns(i)); - if ( (i - startx - 1) * av.charWidth > maxX) - { - gg.drawString(string, - (i - startx - 1) * av.charWidth, y); - maxX = (i - startx + 1) * av.charWidth + fm.stringWidth(string); - } + gg.drawString(string, + (i - startx - 1) * av.charWidth, y); + maxX = (i - startx + 1) * av.charWidth + fm.stringWidth(string); + } - gg.drawLine( (int) ( ( (i - startx - 1) * av.charWidth) + - (av.charWidth / 2)), y + 2, - (int) ( ( (i - startx - 1) * av.charWidth) + - (av.charWidth / 2)), - y + (fm.getDescent() * 2)); + gg.drawLine( (int) ( ( (i - startx - 1) * av.charWidth) + + (av.charWidth / 2)), y + 2, + (int) ( ( (i - startx - 1) * av.charWidth) + + (av.charWidth / 2)), + y + (fm.getDescent() * 2)); - } - else - { - gg.drawLine((int) (((i - startx - 1) * av.charWidth) + - (av.charWidth / 2)), y + fm.getDescent(), - (int) (((i - startx - 1) * av.charWidth) + - (av.charWidth / 2)), y + (fm.getDescent() * 2)); - } + } + else + { + gg.drawLine( (int) ( ( (i - startx - 1) * av.charWidth) + + (av.charWidth / 2)), y + fm.getDescent(), + (int) ( ( (i - startx - 1) * av.charWidth) + + (av.charWidth / 2)), y + (fm.getDescent() * 2)); + } } if (av.hasHiddenColumns) { gg.setColor(Color.blue); int res; - if(av.getShowHiddenMarkers()) + if (av.getShowHiddenMarkers()) { for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); i++) @@ -397,8 +421,10 @@ public class ScalePanel res = av.getColumnSelection().findHiddenRegionPosition(i) - startx; - if(res < 0 || res > endx-scalestartx) + if (res < 0 || res > endx - scalestartx) + { continue; + } gg.fillPolygon(new int[] {res * av.charWidth - av.charHeight / 4,