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.renderer.OverviewRenderer;
24 import jalview.renderer.OverviewResColourFinder;
25 import jalview.viewmodel.OverviewDimensions;
27 import java.awt.Color;
28 import java.awt.Component;
29 import java.awt.Dimension;
30 import java.awt.Frame;
31 import java.awt.Graphics;
32 import java.awt.Image;
34 public class OverviewCanvas extends Component
36 // This is set true if the alignment view changes whilst
37 // the overview is being calculated
38 private volatile boolean restart = false;
40 private volatile boolean updaterunning = false;
42 private OverviewDimensions od;
44 private OverviewRenderer or = null;
48 private Image offscreen;
50 private AlignViewport av;
52 private jalview.renderer.seqfeatures.FeatureRenderer fr;
54 private Frame nullFrame;
56 public OverviewCanvas(OverviewDimensions overviewDims,
57 AlignViewport alignvp)
62 nullFrame = new Frame();
63 nullFrame.addNotify();
65 fr = new jalview.renderer.seqfeatures.FeatureRenderer(av);
69 * Update the overview dimensions object used by the canvas (e.g. if we change
70 * from showing hidden columns to hiding them or vice versa)
74 public void resetOviewDims(OverviewDimensions overviewDims)
80 * Signals to drawing code that the associated alignment viewport has changed
81 * and a redraw will be required
83 public boolean restartDraw()
103 public void draw(boolean showSequenceFeatures, boolean showAnnotation,
104 FeatureRenderer transferRenderer)
108 if (showSequenceFeatures)
110 fr.transferSettings(transferRenderer);
113 setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
115 or = new OverviewRenderer(fr, od, av.getAlignment(),
116 av.getResidueShading(), new OverviewResColourFinder());
117 miniMe = nullFrame.createImage(od.getWidth(), od.getHeight());
118 offscreen = nullFrame.createImage(od.getWidth(), od.getHeight());
120 miniMe = or.draw(od.getRows(av.getAlignment()),
121 od.getColumns(av.getAlignment()));
123 Graphics mg = miniMe.getGraphics();
125 // checks for conservation annotation to make sure overview works for DNA
129 mg.translate(0, od.getSequencesHeight());
130 or.drawGraph(mg, av.getAlignmentConservationAnnotation(),
131 od.getGraphHeight(), od.getColumns(av.getAlignment()));
132 mg.translate(0, -od.getSequencesHeight());
138 draw(showSequenceFeatures, showAnnotation, transferRenderer);
142 updaterunning = false;
147 public void update(Graphics g)
153 public void paint(Graphics g)
155 Graphics og = offscreen.getGraphics();
158 og.drawImage(miniMe, 0, 0, this);
159 og.setColor(Color.red);
161 g.drawImage(offscreen, 0, 0, this);