Clover icon

Coverage Report

  1. Project Clover database Thu Nov 7 2024 17:01:39 GMT
  2. Package jalview.appletgui

File OverviewCanvas.java

 

Coverage histogram

../../img/srcFileCovDistChart0.png
0% of files have more coverage

Code metrics

12
38
7
1
173
108
13
0.34
5.43
7
1.86

Classes

Class Line # Actions
OverviewCanvas 34 38 13
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.appletgui;
22   
23    import jalview.renderer.OverviewRenderer;
24    import jalview.renderer.OverviewResColourFinder;
25    import jalview.viewmodel.OverviewDimensions;
26   
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;
33   
 
34    public class OverviewCanvas extends Component
35    {
36    // This is set true if the alignment view changes whilst
37    // the overview is being calculated
38    private volatile boolean restart = false;
39   
40    private volatile boolean updaterunning = false;
41   
42    private OverviewDimensions od;
43   
44    private OverviewRenderer or = null;
45   
46    private Image miniMe;
47   
48    private Image offscreen;
49   
50    private AlignViewport av;
51   
52    private jalview.renderer.seqfeatures.FeatureRenderer fr;
53   
54    private Frame nullFrame;
55   
 
56  0 toggle public OverviewCanvas(OverviewDimensions overviewDims,
57    AlignViewport alignvp)
58    {
59  0 od = overviewDims;
60  0 av = alignvp;
61   
62  0 nullFrame = new Frame();
63  0 nullFrame.addNotify();
64   
65  0 fr = new jalview.renderer.seqfeatures.FeatureRenderer(av);
66    }
67   
68    /**
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)
71    *
72    * @param overviewDims
73    */
 
74  0 toggle public void resetOviewDims(OverviewDimensions overviewDims)
75    {
76  0 od = overviewDims;
77    }
78   
79    /**
80    * Signals to drawing code that the associated alignment viewport has changed
81    * and a redraw will be required
82    */
 
83  0 toggle public boolean restartDraw()
84    {
85  0 synchronized (this)
86    {
87  0 if (updaterunning)
88    {
89  0 restart = true;
90  0 if (or != null)
91    {
92  0 or.setRedraw(true);
93    }
94    }
95    else
96    {
97  0 updaterunning = true;
98    }
99  0 return restart;
100    }
101    }
102   
 
103  0 toggle public void draw(boolean showSequenceFeatures, boolean showAnnotation,
104    FeatureRenderer transferRenderer)
105    {
106  0 miniMe = null;
107   
108  0 if (showSequenceFeatures)
109    {
110  0 fr.transferSettings(transferRenderer);
111    }
112   
113  0 setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
114   
115  0 or = new OverviewRenderer(fr, od, av.getAlignment(),
116    av.getResidueShading(), new OverviewResColourFinder());
117  0 miniMe = nullFrame.createImage(od.getWidth(), od.getHeight());
118  0 offscreen = nullFrame.createImage(od.getWidth(), od.getHeight());
119   
120  0 miniMe = or.draw(od.getRows(av.getAlignment()),
121    od.getColumns(av.getAlignment()));
122   
123  0 Graphics mg = miniMe.getGraphics();
124   
125    // checks for conservation annotation to make sure overview works for DNA
126    // too
127  0 if (showAnnotation)
128    {
129  0 mg.translate(0, od.getSequencesHeight());
130  0 or.drawGraph(mg, av.getAlignmentConservationAnnotation(),
131    od.getGraphHeight(), od.getColumns(av.getAlignment()));
132  0 mg.translate(0, -od.getSequencesHeight());
133    }
134   
135  0 if (restart)
136    {
137  0 restart = false;
138  0 draw(showSequenceFeatures, showAnnotation, transferRenderer);
139    }
140    else
141    {
142  0 updaterunning = false;
143    }
144    }
145   
 
146  0 toggle @Override
147    public void update(Graphics g)
148    {
149  0 paint(g);
150    }
151   
 
152  0 toggle @Override
153    public void paint(Graphics g)
154    {
155  0 Graphics og = offscreen.getGraphics();
156  0 if (miniMe != null)
157    {
158  0 og.drawImage(miniMe, 0, 0, this);
159  0 og.setColor(Color.red);
160  0 od.drawBox(og);
161  0 g.drawImage(offscreen, 0, 0, this);
162    }
163    }
164   
165    /**
166    * Nulls references to protect against potential memory leaks
167    */
 
168  0 toggle void dispose()
169    {
170  0 od = null;
171    }
172   
173    }