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.Color;
24 import java.awt.Dimension;
25 import java.awt.Graphics;
26 import java.awt.Image;
27 import java.awt.Panel;
28 import java.awt.event.MouseEvent;
29 import java.awt.event.MouseListener;
30 import java.awt.event.MouseMotionListener;
32 public class IdwidthAdjuster extends Panel implements MouseListener,
35 boolean active = false;
43 public IdwidthAdjuster(AlignmentPanel ap)
47 java.net.URL url = getClass().getResource("/images/idwidth.gif");
50 image = java.awt.Toolkit.getDefaultToolkit().getImage(url);
53 addMouseListener(this);
54 addMouseMotionListener(this);
57 public void mousePressed(MouseEvent evt)
62 public void mouseReleased(MouseEvent evt)
68 * If in a SplitFrame with co-scaled alignments, set the other's id width to
69 * match; note applet does not (yet) store this in ViewStyle
72 * Code disabled for now as it doesn't work, don't know why; idCanvas width
73 * keeps resetting to a previous value (actually two alternating values!)
75 // final AlignViewportI viewport = ap.getAlignViewport();
76 // if (viewport.getCodingComplement() != null
77 // && viewport.isScaleProteinAsCdna())
79 // Dimension d = ap.idPanel.idCanvas.getSize();
80 // SplitFrame sf = ap.alignFrame.getSplitFrame();
81 // final AlignmentPanel otherPanel =
82 // sf.getComplement(ap.alignFrame).alignPanel;
83 // otherPanel.setIdWidth(d.width, d.height);
84 // otherPanel.repaint();
88 public void mouseEntered(MouseEvent evt)
94 public void mouseExited(MouseEvent evt)
100 public void mouseDragged(MouseEvent evt)
103 Dimension d = ap.idPanel.idCanvas.getSize();
104 int dif = evt.getX() - oldX;
106 final int newWidth = d.width + dif;
107 if (newWidth > 20 || dif > 0)
109 ap.setIdWidth(newWidth, d.height);
110 this.setSize(newWidth, getSize().height);
115 public void mouseMoved(MouseEvent evt)
119 public void mouseClicked(MouseEvent evt)
123 public void paint(Graphics g)
125 g.setColor(Color.white);
126 g.fillRect(0, 0, getSize().width, getSize().height);
131 g.drawImage(image, getSize().width - 20, 2, this);