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.
21 package jalview.appletgui;
23 import java.awt.Cursor;
24 import java.awt.Dimension;
25 import java.awt.Panel;
26 import java.awt.event.MouseEvent;
27 import java.awt.event.MouseListener;
28 import java.awt.event.MouseMotionListener;
30 public class IdwidthAdjuster extends Panel
31 implements MouseListener, MouseMotionListener
33 boolean active = false;
39 public IdwidthAdjuster(AlignmentPanel ap)
44 addMouseListener(this);
45 addMouseMotionListener(this);
49 public void mousePressed(MouseEvent evt)
55 public void mouseReleased(MouseEvent evt)
61 * If in a SplitFrame with co-scaled alignments, set the other's id width to
62 * match; note applet does not (yet) store this in ViewStyle
65 * Code disabled for now as it doesn't work, don't know why; idCanvas width
66 * keeps resetting to a previous value (actually two alternating values!)
68 // final AlignViewportI viewport = ap.getAlignViewport();
69 // if (viewport.getCodingComplement() != null
70 // && viewport.isScaleProteinAsCdna())
72 // Dimension d = ap.idPanel.idCanvas.getSize();
73 // SplitFrame sf = ap.alignFrame.getSplitFrame();
74 // final AlignmentPanel otherPanel =
75 // sf.getComplement(ap.alignFrame).alignPanel;
76 // otherPanel.setIdWidth(d.width, d.height);
77 // otherPanel.repaint();
82 public void mouseEntered(MouseEvent evt)
85 setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
91 public void mouseExited(MouseEvent evt)
94 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
99 public void mouseDragged(MouseEvent evt)
102 Dimension d = ap.idPanel.idCanvas.getSize();
103 int dif = evt.getX() - oldX;
105 final int newWidth = d.width + dif;
106 if (newWidth > 20 || dif > 0)
108 ap.setIdWidth(newWidth, d.height);
109 this.setSize(newWidth, getSize().height);
115 public void mouseMoved(MouseEvent evt)
120 public void mouseClicked(MouseEvent evt)