2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2006 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.*;
33 public class IdwidthAdjuster extends JPanel implements MouseListener,
36 boolean active = false;
42 * Creates a new IdwidthAdjuster object.
44 * @param ap DOCUMENT ME!
46 public IdwidthAdjuster(AlignmentPanel ap)
50 java.net.URL url = getClass().getResource("/images/idwidth.gif");
54 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
57 addMouseListener(this);
58 addMouseMotionListener(this);
64 * @param evt DOCUMENT ME!
66 public void mousePressed(MouseEvent evt)
74 * @param evt DOCUMENT ME!
76 public void mouseReleased(MouseEvent evt)
85 * @param evt DOCUMENT ME!
87 public void mouseEntered(MouseEvent evt)
96 * @param evt DOCUMENT ME!
98 public void mouseExited(MouseEvent evt)
107 * @param evt DOCUMENT ME!
109 public void mouseDragged(MouseEvent evt)
113 Dimension d = ap.idPanel.idCanvas.getPreferredSize();
114 int dif = evt.getX() - oldX;
116 if (((d.width + dif) > 20) || (dif > 0))
118 ap.idPanel.idCanvas.setPreferredSize(new Dimension(d.width + dif,
129 * @param evt DOCUMENT ME!
131 public void mouseMoved(MouseEvent evt)
138 * @param evt DOCUMENT ME!
140 public void mouseClicked(MouseEvent evt)
147 * @param g DOCUMENT ME!
149 public void paintComponent(Graphics g)
151 g.setColor(Color.white);
152 g.fillRect(0, 0, getWidth(), getHeight());
158 g.drawImage(image, getWidth() - 20, 2, this);