X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FScalePanel.java;h=b35fa6c9497b27cf7efd303a415443c40a86d1b4;hb=cbd8cafe5f1d302cf490d34a96f8231659afd402;hp=5419d2722bafee2c15d6df8beb2d4456647b976d;hpb=559b96a91b710f3f2e116790c9cf7e3aa6c76766;p=jalview.git diff --git a/src/jalview/appletgui/ScalePanel.java b/src/jalview/appletgui/ScalePanel.java index 5419d27..b35fa6c 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) 2005 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(); @@ -76,9 +80,11 @@ public class ScalePanel { av.showColumn(reveal[0]); reveal = null; - ap.repaint(); + ap.paintAlignment(true); if (ap.overviewPanel != null) + { ap.overviewPanel.updateOverviewImage(); + } } }); pop.add(item); @@ -92,13 +98,16 @@ public class ScalePanel { av.showAllHiddenColumns(); reveal = null; - ap.repaint(); + ap.paintAlignment(true); if (ap.overviewPanel != null) + { ap.overviewPanel.updateOverviewImage(); + } } }); pop.add(item); } + this.add(pop); pop.show(this, evt.getX(), evt.getY()); } else if (av.getColumnSelection().contains(res)) @@ -109,12 +118,22 @@ public class ScalePanel public void actionPerformed(ActionEvent e) { av.hideColumns(res, res); - ap.repaint(); + if (av.getSelectionGroup() != null + && + av.getSelectionGroup().getSize() == av.alignment.getHeight()) + { + av.setSelectionGroup(null); + } + + ap.paintAlignment(true); if (ap.overviewPanel != null) + { ap.overviewPanel.updateOverviewImage(); + } } }); pop.add(item); + this.add(pop); pop.show(this, evt.getX(), evt.getY()); } } @@ -136,20 +155,20 @@ 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.paintAlignment(true); - 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; - ap.repaint(); + ap.paintAlignment(true); } public void mouseDragged(MouseEvent evt) @@ -194,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()) { @@ -246,21 +271,24 @@ public class ScalePanel } } - ap.repaint(); + ap.paintAlignment(true); } } - 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) @@ -271,7 +299,9 @@ public class ScalePanel public void mouseMoved(MouseEvent evt) { if (!av.hasHiddenColumns) + { return; + } int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); @@ -309,7 +339,6 @@ public class ScalePanel { gg.setFont(av.getFont()); - //Fill in the background gg.setColor(Color.white); gg.fillRect(0, 0, width, height); @@ -321,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 @@ -341,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++) @@ -390,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,