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.OverviewDimensionsWithHidden;
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 OverviewDimensionsWithHidden 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 OverviewDimensionsWithHidden(av.getRanges(),
54 (av.isShowAnnotation() && av.getSequenceConsensusHash() != null));
56 oviewCanvas = new OverviewCanvas(od, av);
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.getAlignment().getHiddenColumns());
125 ap.setScrollValues(od.getScrollCol(), od.getScrollRow());
126 ap.paintAlignment(false);
130 * Updates the overview image when the related alignment panel is updated
132 public void updateOverviewImage()
134 if ((getSize().width > 0) && (getSize().height > 0))
136 od.setWidth(getSize().width);
137 od.setHeight(getSize().height);
139 setSize(new Dimension(od.getWidth(), od.getHeight()));
145 oviewCanvas.restartDraw();
149 updateRunning = true;
151 Thread thread = new Thread(this);
154 updateRunning = false;
160 oviewCanvas.draw(av.isShowSequenceFeatures(),
161 (av.isShowAnnotation() && av
162 .getAlignmentConservationAnnotation() != null), ap);
167 * Update the overview panel box when the associated alignment panel is
171 public void setBoxPosition()
173 od.setBoxPosition(av.getAlignment()
174 .getHiddenSequences(), av
175 .getAlignment().getHiddenColumns());