2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 import java.awt.event.*;
31 public class IdwidthAdjuster
32 extends JPanel implements MouseListener,
35 boolean active = false;
41 * Creates a new IdwidthAdjuster object.
43 * @param ap DOCUMENT ME!
45 public IdwidthAdjuster(AlignmentPanel ap)
49 java.net.URL url = getClass().getResource("/images/idwidth.gif");
53 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
56 addMouseListener(this);
57 addMouseMotionListener(this);
63 * @param evt DOCUMENT ME!
65 public void mousePressed(MouseEvent evt)
73 * @param evt DOCUMENT ME!
75 public void mouseReleased(MouseEvent evt)
84 * @param evt DOCUMENT ME!
86 public void mouseEntered(MouseEvent evt)
95 * @param evt DOCUMENT ME!
97 public void mouseExited(MouseEvent evt)
106 * @param evt DOCUMENT ME!
108 public void mouseDragged(MouseEvent evt)
112 Dimension d = ap.idPanel.idCanvas.getPreferredSize();
113 int dif = evt.getX() - oldX;
115 if ( ( (d.width + dif) > 20) || (dif > 0))
117 ap.idPanel.idCanvas.setPreferredSize(new Dimension(d.width + dif,
119 ap.paintAlignment(true);
128 * @param evt DOCUMENT ME!
130 public void mouseMoved(MouseEvent evt)
137 * @param evt DOCUMENT ME!
139 public void mouseClicked(MouseEvent evt)
146 * @param g DOCUMENT ME!
148 public void paintComponent(Graphics g)
150 g.setColor(Color.white);
151 g.fillRect(0, 0, getWidth(), getHeight());
157 g.drawImage(image, getWidth() - 20, 2, this);