/*
- * 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.4.0.b2)
+ * Copyright (C) 2009 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
import jalview.datamodel.*;
-public class ScalePanel
- extends Panel implements MouseMotionListener, MouseListener
+public class ScalePanel extends Panel implements MouseMotionListener,
+ MouseListener
{
protected int offy = 4;
+
public int width;
protected AlignViewport av;
+
AlignmentPanel ap;
boolean stretchingGroup = false;
- int min; //used by mouseDragged to see if user
- int max; //used by mouseDragged to see if user
+
+ int min; // used by mouseDragged to see if user
+
+ int max; // used by mouseDragged to see if user
+
boolean mouseDragging = false;
+
int[] reveal;
public ScalePanel(AlignViewport av, AlignmentPanel ap)
min = res;
max = res;
- if ( (evt.getModifiers() & InputEvent.BUTTON3_MASK)
- == InputEvent.BUTTON3_MASK)
+ if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
{
PopupMenu pop = new PopupMenu();
if (reveal != null)
{
av.hideColumns(res, res);
if (av.getSelectionGroup() != null
- &&
- av.getSelectionGroup().getSize() == av.alignment.getHeight())
+ && av.getSelectionGroup().getSize() == av.alignment
+ .getHeight())
{
av.setSelectionGroup(null);
}
pop.show(this, evt.getX(), evt.getY());
}
}
- else // LEFT MOUSE TO SELECT
+ else
+ // LEFT MOUSE TO SELECT
{
if (!evt.isControlDown() && !evt.isShiftDown())
{
{
col = av.getColumnSelection().adjustForHiddenColumns(i);
- if ( (col < sg.getStartRes()) || (col > sg.getEndRes()))
+ if ((col < sg.getStartRes()) || (col > sg.getEndRes()))
{
av.getColumnSelection().removeElement(col);
}
reveal = null;
for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); i++)
{
- int[] region = (int[]) av.getColumnSelection().getHiddenColumns().
- elementAt(i);
+ int[] region = (int[]) av.getColumnSelection().getHiddenColumns()
+ .elementAt(i);
if (res + 1 == region[0] || res - 1 == region[1])
{
reveal = region;
public void paint(Graphics g)
{
drawScale(g, av.getStartRes(), av.getEndRes(), getSize().width,
- getSize().height);
+ getSize().height);
}
-// scalewidth will normally be screenwidth,
+ // scalewidth will normally be screenwidth,
public void drawScale(Graphics gg, int startx, int endx, int width,
- int height)
+ int height)
{
gg.setFont(av.getFont());
- //Fill in the background
+ // Fill in the background
gg.setColor(Color.white);
gg.fillRect(0, 0, width, height);
gg.setColor(Color.black);
- //Fill the selected columns
+ // Fill the selected columns
ColumnSelection cs = av.getColumnSelection();
gg.setColor(new Color(220, 0, 0));
sel = av.getColumnSelection().findColumnPosition(sel);
}
- if ( (sel >= startx) && (sel <= endx))
+ if ((sel >= startx) && (sel <= endx))
{
- gg.fillRect( (sel - startx) * av.charWidth, 0, av.charWidth,
- getSize().height);
+ gg.fillRect((sel - startx) * av.charWidth, 0, av.charWidth,
+ getSize().height);
}
}
FontMetrics fm = gg.getFontMetrics(av.getFont());
int y = av.charHeight - fm.getDescent();
- if ( (scalestartx % 10) == 0)
+ if ((scalestartx % 10) == 0)
{
scalestartx += 5;
}
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);
+ 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));
+ 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));
}
}
int res;
if (av.getShowHiddenMarkers())
{
- for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size();
- i++)
+ for (int i = 0; i < av.getColumnSelection().getHiddenColumns()
+ .size(); i++)
{
- res = av.getColumnSelection().findHiddenRegionPosition(i) -
- startx;
+ res = av.getColumnSelection().findHiddenRegionPosition(i)
+ - startx;
if (res < 0 || res > endx - scalestartx)
{
}
gg.fillPolygon(new int[]
- {res * av.charWidth - av.charHeight / 4,
- res * av.charWidth + av.charHeight / 4,
- res * av.charWidth},
- new int[]
- {
- y - av.charHeight / 2, y - av.charHeight / 2,
- y + 8
- }, 3);
+ { res * av.charWidth - av.charHeight / 4,
+ res * av.charWidth + av.charHeight / 4, res * av.charWidth },
+ new int[]
+ { y - av.charHeight / 2, y - av.charHeight / 2, y + 8 },
+ 3);
}
}