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;
32 import jalview.api.AlignViewportI;
40 public class IdwidthAdjuster extends JPanel implements MouseListener,
43 boolean active = false;
52 * Creates a new IdwidthAdjuster object.
57 public IdwidthAdjuster(AlignmentPanel ap)
61 java.net.URL url = getClass().getResource("/images/idwidth.gif");
65 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
68 addMouseListener(this);
69 addMouseMotionListener(this);
78 public void mousePressed(MouseEvent evt)
89 public void mouseReleased(MouseEvent evt)
95 * If in a SplitFrame with co-scaled alignments, set the other's id width to
98 final AlignViewportI viewport = ap.getAlignViewport();
99 if (viewport.getCodingComplement() != null
100 && viewport.isScaleProteinAsCdna())
102 viewport.getCodingComplement().setIdWidth(viewport.getIdWidth());
103 SplitFrame sf = (SplitFrame) ap.alignFrame.getSplitViewContainer();
115 public void mouseEntered(MouseEvent evt)
127 public void mouseExited(MouseEvent evt)
139 public void mouseDragged(MouseEvent evt)
143 final AlignViewportI viewport = ap.getAlignViewport();
144 int curwidth = viewport.getIdWidth();
145 int dif = evt.getX() - oldX;
147 final int newWidth = curwidth + dif;
148 if ((newWidth > 20) || (dif > 0))
150 viewport.setIdWidth(newWidth);
152 ap.paintAlignment(true);
164 public void mouseMoved(MouseEvent evt)
174 public void mouseClicked(MouseEvent evt)
184 public void paintComponent(Graphics g)
186 g.setColor(Color.white);
187 g.fillRect(0, 0, getWidth(), getHeight());
193 g.drawImage(image, getWidth() - 20, 2, this);