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.viewmodel.OverviewDimensions;
25 import java.awt.BorderLayout;
26 import java.awt.Dimension;
27 import java.awt.event.ComponentAdapter;
28 import java.awt.event.ComponentEvent;
29 import java.awt.event.MouseAdapter;
30 import java.awt.event.MouseEvent;
31 import java.awt.event.MouseMotionAdapter;
33 import javax.swing.JPanel;
36 * Panel displaying an overview of the full alignment, with an interactive box
37 * representing the viewport onto the alignment.
42 public class OverviewPanel extends JPanel implements Runnable
44 private OverviewDimensions od;
46 private OverviewCanvas oviewCanvas;
48 private AlignViewport av;
50 private AlignmentPanel ap;
53 * Creates a new OverviewPanel object.
56 * The alignment panel which is shown in the overview panel
58 public OverviewPanel(AlignmentPanel alPanel)
63 od = new OverviewDimensions(av.getRanges(),
64 (av.isShowAnnotation() && av
65 .getAlignmentConservationAnnotation() != null));
67 oviewCanvas = new OverviewCanvas(od, av);
68 setLayout(new BorderLayout());
69 add(oviewCanvas, BorderLayout.CENTER);
71 addComponentListener(new ComponentAdapter()
74 public void componentResized(ComponentEvent evt)
76 if ((getWidth() != od.getWidth())
77 || (getHeight() != (od.getHeight())))
79 updateOverviewImage();
84 addMouseMotionListener(new MouseMotionAdapter()
87 public void mouseDragged(MouseEvent evt)
89 if (!av.getWrapAlignment())
91 od.updateViewportFromMouse(evt.getX(), evt.getY(), av
92 .getAlignment().getHiddenSequences(), av
93 .getColumnSelection(), av.getRanges());
94 ap.setScrollValues(od.getScrollCol(), od.getScrollRow());
99 addMouseListener(new MouseAdapter()
102 public void mousePressed(MouseEvent evt)
104 if (!av.getWrapAlignment())
106 od.updateViewportFromMouse(evt.getX(), evt.getY(), av
107 .getAlignment().getHiddenSequences(), av
108 .getColumnSelection(), av.getRanges());
109 ap.setScrollValues(od.getScrollCol(), od.getScrollRow());
114 updateOverviewImage();
118 * Updates the overview image when the related alignment panel is updated
120 public void updateOverviewImage()
122 if ((getWidth() > 0) && (getHeight() > 0))
124 od.setWidth(getWidth());
125 od.setHeight(getHeight());
128 setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
130 if (oviewCanvas.restartDraw())
135 Thread thread = new Thread(this);
144 oviewCanvas.draw(av.isShowSequenceFeatures(),
145 (av.isShowAnnotation() && av
146 .getAlignmentConservationAnnotation() != null), ap
147 .getSeqPanel().seqCanvas.getFeatureRenderer());
152 * Update the overview panel box when the associated alignment panel is
156 public void setBoxPosition()
158 od.setBoxPosition(av.getAlignment()
159 .getHiddenSequences(), av.getColumnSelection(), av.getRanges());