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 jalview.viewmodel.OverviewDimensions;
25 import java.awt.BorderLayout;
26 import java.awt.Dimension;
27 import java.awt.Panel;
28 import java.awt.event.ComponentAdapter;
29 import java.awt.event.ComponentEvent;
30 import java.awt.event.MouseEvent;
31 import java.awt.event.MouseListener;
32 import java.awt.event.MouseMotionListener;
34 public class OverviewPanel extends Panel implements Runnable,
35 MouseMotionListener, MouseListener
37 private OverviewDimensions od;
39 private OverviewCanvas oviewCanvas;
41 private AlignViewport av;
43 private AlignmentPanel ap;
45 private boolean updateRunning = false;
47 public OverviewPanel(AlignmentPanel alPanel)
53 od = new OverviewDimensions(av.getRanges(),
54 (av.isShowAnnotation() && av.getSequenceConsensusHash() != null));
56 oviewCanvas = new OverviewCanvas(od, av, ap);
57 setLayout(new BorderLayout());
58 add(oviewCanvas, BorderLayout.CENTER);
60 setSize(new Dimension(od.getWidth(), od.getHeight()));
61 addComponentListener(new ComponentAdapter()
65 public void componentResized(ComponentEvent evt)
67 if ((getWidth() != od.getWidth())
68 || (getHeight() != (od.getHeight())))
70 updateOverviewImage();
75 addMouseMotionListener(this);
77 addMouseListener(this);
79 updateOverviewImage();
84 public void mouseEntered(MouseEvent evt)
89 public void mouseExited(MouseEvent evt)
94 public void mouseClicked(MouseEvent evt)
99 public void mouseMoved(MouseEvent evt)
104 public void mousePressed(MouseEvent evt)
110 public void mouseReleased(MouseEvent evt)
116 public void mouseDragged(MouseEvent evt)
121 private void mouseAction(MouseEvent evt)
123 od.updateViewportFromMouse(evt.getX(), evt.getY(), av.getAlignment()
124 .getHiddenSequences(), av.getColumnSelection(), av
126 ap.setScrollValues(od.getScrollCol(), od.getScrollRow());
127 ap.paintAlignment(false);
131 * Updates the overview image when the related alignment panel is updated
133 public void updateOverviewImage()
135 if ((getSize().width > 0) && (getSize().height > 0))
137 od.setWidth(getSize().width);
138 od.setHeight(getSize().height);
140 setSize(new Dimension(od.getWidth(), od.getHeight()));
144 oviewCanvas.restartDraw();
148 updateRunning = true;
149 Thread thread = new Thread(this);
152 updateRunning = false;
158 oviewCanvas.draw(av.isShowSequenceFeatures(),
159 (av.isShowAnnotation() && av
160 .getAlignmentConservationAnnotation() != null));
165 * Update the overview panel box when the associated alignment panel is
169 public void setBoxPosition()
171 od.setBoxPosition(av.getAlignment()
172 .getHiddenSequences(), av.getColumnSelection(), av.getRanges());