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 jalview.api.AlignViewportI;
25 import java.awt.Color;
26 import java.awt.Cursor;
27 import java.awt.Graphics;
28 import java.awt.Image;
29 import java.awt.event.MouseEvent;
30 import java.awt.event.MouseListener;
31 import java.awt.event.MouseMotionListener;
33 import javax.swing.JPanel;
41 public class IdwidthAdjuster extends JPanel
42 implements MouseListener, MouseMotionListener
44 boolean active = false;
53 * Creates a new IdwidthAdjuster object.
58 public IdwidthAdjuster(AlignmentPanel ap)
62 java.net.URL url = getClass().getResource("/images/idwidth.gif");
66 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
69 addMouseListener(this);
70 addMouseMotionListener(this);
80 public void mousePressed(MouseEvent evt)
92 public void mouseReleased(MouseEvent evt)
98 * If in a SplitFrame with co-scaled alignments, set the other's id width to
101 final AlignViewportI viewport = ap.getAlignViewport();
102 if (viewport.getCodingComplement() != null
103 && viewport.isScaleProteinAsCdna())
105 viewport.getCodingComplement().setIdWidth(viewport.getIdWidth());
106 SplitFrame sf = (SplitFrame) ap.alignFrame.getSplitViewContainer();
119 public void mouseEntered(MouseEvent evt)
132 public void mouseExited(MouseEvent evt)
145 public void mouseDragged(MouseEvent evt)
149 final AlignViewportI viewport = ap.getAlignViewport();
150 int curwidth = viewport.getIdWidth();
151 int dif = evt.getX() - oldX;
153 final int newWidth = curwidth + dif;
154 if ((newWidth > 20) || (dif > 0))
156 viewport.setIdWidth(newWidth);
158 ap.paintAlignment(true, false);
171 public void mouseMoved(MouseEvent evt)
182 public void mouseClicked(MouseEvent evt)
193 public void paintComponent(Graphics g)
195 g.setColor(Color.white);
196 g.fillRect(0, 0, getWidth(), getHeight());
202 // g.drawImage(image, getWidth() - 20, 2, this);
203 setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
207 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));