2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import java.awt.Color;
24 import java.awt.Graphics;
25 import java.awt.Image;
26 import java.awt.event.MouseEvent;
27 import java.awt.event.MouseListener;
28 import java.awt.event.MouseMotionListener;
30 import javax.swing.JPanel;
38 public class IdwidthAdjuster extends JPanel implements MouseListener,
41 boolean active = false;
50 * Creates a new IdwidthAdjuster object.
55 public IdwidthAdjuster(AlignmentPanel ap)
59 java.net.URL url = getClass().getResource("/images/idwidth.gif");
63 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
66 addMouseListener(this);
67 addMouseMotionListener(this);
76 public void mousePressed(MouseEvent evt)
87 public void mouseReleased(MouseEvent evt)
99 public void mouseEntered(MouseEvent evt)
111 public void mouseExited(MouseEvent evt)
123 public void mouseDragged(MouseEvent evt)
127 int curwidth = ap.getAlignViewport().getIdWidth();
128 int dif = evt.getX() - oldX;
130 if (((curwidth + dif) > 20) || (dif > 0))
132 ap.getAlignViewport().setIdWidth(curwidth + dif);
134 ap.paintAlignment(true);
146 public void mouseMoved(MouseEvent evt)
156 public void mouseClicked(MouseEvent evt)
166 public void paintComponent(Graphics g)
168 g.setColor(Color.white);
169 g.fillRect(0, 0, getWidth(), getHeight());
175 g.drawImage(image, getWidth() - 20, 2, this);