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.event.MouseAdapter;
28 import java.awt.event.MouseEvent;
30 import javax.swing.JPanel;
38 @SuppressWarnings("serial")
39 public class IdwidthAdjuster extends JPanel
45 * Creates a new IdwidthAdjuster object above the id panel that can be dragged
46 * to change the panel's width
49 * The associated AlignmentPanel
52 public IdwidthAdjuster(AlignmentPanel ap)
54 // BH 2019.07.01 no need for overridden paintComponent, especially as it was
55 // overriding paint(g) so
56 // allowing strange component painting in its place.
58 setBackground(Color.white);
61 setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
63 // BH 2019.07.01 MouseAdapter is cleaner - no need for fields active or ap
65 MouseAdapter ma = (new MouseAdapter()
68 public void mousePressed(MouseEvent evt)
74 public void mouseDragged(MouseEvent evt)
76 AlignViewportI viewport = ap.getAlignViewport();
77 int curwidth = viewport.getIdWidth();
78 int dif = evt.getX() - oldX;
79 int newWidth = curwidth + dif;
80 if ((newWidth > 20) || (dif > 0))
82 viewport.setIdWidth(newWidth);
83 ap.paintAlignment(true, false);
89 public void mouseReleased(MouseEvent evt)
92 // If in a SplitFrame with co-scaled alignments, set the other's id
95 AlignViewportI viewport = ap.getAlignViewport();
96 if (viewport.getCodingComplement() != null
97 && viewport.isScaleProteinAsCdna())
99 viewport.getCodingComplement().setIdWidth(viewport.getIdWidth());
100 SplitFrame sf = (SplitFrame) ap.alignFrame
101 .getSplitViewContainer();
108 addMouseListener(ma);
109 addMouseMotionListener(ma);