X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FScalePanel.java;h=d2ed1d9d7d8506b98785a1df346de4baf18756cb;hb=153dd62dc91da13ae732600e6ea55ddbe15eab39;hp=4dfb8c8aebb9f2ba071558816932dea3d44501ec;hpb=506d60f0e188723ddc91c26824b41ac7034df3fe;p=jalview.git diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 4dfb8c8..d2ed1d9 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -1,20 +1,19 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) - * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) + * Copyright (C) 2010 J Procter, AM Waterhouse, 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 - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * This file is part of Jalview. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Jalview. If not, see . */ package jalview.gui; @@ -64,7 +63,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener, * DOCUMENT ME! * * @param evt - * DOCUMENT ME! + * DOCUMENT ME! */ public void mousePressed(MouseEvent evt) { @@ -73,10 +72,13 @@ public class ScalePanel extends JPanel implements MouseMotionListener, if (av.hasHiddenColumns) { - res = av.getColumnSelection().adjustForHiddenColumns(x); + x = av.getColumnSelection().adjustForHiddenColumns(x); } - else + + if (x >= av.alignment.getWidth()) { + res = av.alignment.getWidth() - 1; + } else { res = x; } @@ -170,7 +172,6 @@ public class ScalePanel extends JPanel implements MouseMotionListener, iVec = null; sg.setStartRes(res); sg.setEndRes(res); - av.setSelectionGroup(sg); if (evt.isShiftDown()) { @@ -183,17 +184,18 @@ public class ScalePanel extends JPanel implements MouseMotionListener, sg.setStartRes(min); sg.setEndRes(max); } - + av.setSelectionGroup(sg); } ap.paintAlignment(false); + av.sendSelection(); } /** * DOCUMENT ME! * * @param evt - * DOCUMENT ME! + * DOCUMENT ME! */ public void mouseReleased(MouseEvent evt) { @@ -201,14 +203,14 @@ public class ScalePanel extends JPanel implements MouseMotionListener, int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); - if (res > av.alignment.getWidth()) + if (av.hasHiddenColumns) { - res = av.alignment.getWidth() - 1; + res = av.getColumnSelection().adjustForHiddenColumns(res); } - if (av.hasHiddenColumns) + if (res >= av.alignment.getWidth()) { - res = av.getColumnSelection().adjustForHiddenColumns(res); + res = av.alignment.getWidth() - 1; } if (!stretchingGroup) @@ -233,13 +235,14 @@ public class ScalePanel extends JPanel implements MouseMotionListener, } stretchingGroup = false; ap.paintAlignment(false); + av.sendSelection(); } /** * DOCUMENT ME! * * @param evt - * DOCUMENT ME! + * DOCUMENT ME! */ public void mouseDragged(MouseEvent evt) { @@ -256,7 +259,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener, res = av.getColumnSelection().adjustForHiddenColumns(res); } - if (res > av.alignment.getWidth()) + if (res >= av.alignment.getWidth()) { res = av.alignment.getWidth() - 1; } @@ -294,7 +297,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener, int col; for (int i = min; i <= max; i++) { - col = av.getColumnSelection().adjustForHiddenColumns(i); + col = i; // av.getColumnSelection().adjustForHiddenColumns(i); if ((col < sg.getStartRes()) || (col > sg.getEndRes())) { @@ -370,7 +373,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener, * DOCUMENT ME! * * @param g - * DOCUMENT ME! + * DOCUMENT ME! */ public void paintComponent(Graphics g) { @@ -397,23 +400,33 @@ public class ScalePanel extends JPanel implements MouseMotionListener, // Fill the selected columns ColumnSelection cs = av.getColumnSelection(); - gg.setColor(new Color(220, 0, 0)); - - for (int i = 0; i < cs.size(); i++) + int s; + if (cs != null) { - int sel = cs.columnAt(i); - if (av.hasHiddenColumns) - { - sel = av.getColumnSelection().findColumnPosition(sel); - } + gg.setColor(new Color(220, 0, 0)); - if ((sel >= startx) && (sel <= endx)) + for (int i = 0; i < cs.size(); i++) { - gg.fillRect((sel - startx) * av.charWidth, 0, av.charWidth, - getHeight()); + int sel = cs.columnAt(i); + if (av.hasHiddenColumns) + { + if (cs.isVisible(sel)) + { + sel = cs.findColumnPosition(sel); + } + else + { + continue; + } + } + + if ((sel >= startx) && (sel <= endx)) + { + gg.fillRect((sel - startx) * av.charWidth, 0, av.charWidth, + getHeight()); + } } } - // Draw the scale numbers gg.setColor(Color.black);