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.renderer;
23 import static org.testng.Assert.assertEquals;
25 import jalview.datamodel.Alignment;
26 import jalview.datamodel.AlignmentI;
27 import jalview.datamodel.Sequence;
28 import jalview.datamodel.SequenceFeature;
29 import jalview.datamodel.SequenceI;
30 import jalview.gui.AlignViewport;
31 import jalview.renderer.seqfeatures.FeatureRenderer;
32 import jalview.schemes.FeatureColour;
33 import jalview.schemes.ZappoColourScheme;
34 import jalview.viewmodel.AlignmentViewport;
35 import jalview.viewmodel.OverviewDimensions;
36 import jalview.viewmodel.OverviewDimensionsShowHidden;
37 import jalview.viewmodel.ViewportRanges;
39 import java.awt.Color;
41 import org.testng.annotations.Test;
42 public class OverviewRendererTest
46 public void testGetColumnColourFromSequence()
48 OverviewResColourFinder cf = new OverviewResColourFinder(false,
49 Color.PINK, Color.green); // gapColour, hiddenColour
50 Sequence seq1 = new Sequence("seq1", "PQ-RL-");
51 Sequence seq2 = new Sequence("seq2", "FVE");
52 AlignmentI al = new Alignment(new SequenceI[] { seq1, seq2 });
53 AlignmentViewport av = new AlignViewport(al);
54 OverviewDimensions od = new OverviewDimensionsShowHidden(new ViewportRanges(al), false);
55 ResidueShaderI rs = new ResidueShader(new ZappoColourScheme());
56 FeatureRenderer fr = new FeatureRenderer(av);
57 OverviewRenderer or = new OverviewRenderer(fr, od, al, rs, cf);
59 // P is magenta (see ResidueProperties.zappo)
60 assertEquals(or.getColumnColourFromSequence(null, seq1, 0), Color.magenta.getRGB());
62 assertEquals(or.getColumnColourFromSequence(null, seq1, 1),
63 Color.green.getRGB());
64 // gap is pink (specified in OverviewResColourFinder constructor above)
65 assertEquals(or.getColumnColourFromSequence(null, seq1, 2),
68 assertEquals(or.getColumnColourFromSequence(null, seq2, 0),
69 Color.orange.getRGB());
71 assertEquals(or.getColumnColourFromSequence(null, seq2, 2),
73 // past end of sequence colour as gap (JAL-2929)
74 assertEquals(or.getColumnColourFromSequence(null, seq2, 3),
78 * now add a feature on seq1
80 seq1.addSequenceFeature(
81 new SequenceFeature("Pfam", "desc", 1, 4, null));
82 fr.findAllFeatures(true);
83 av.setShowSequenceFeatures(true);
84 fr.setColour("Pfam", new FeatureColour(Color.yellow));
85 assertEquals(or.getColumnColourFromSequence(null, seq1, 0),
86 Color.yellow.getRGB());
88 // don't show sequence features
89 av.setShowSequenceFeatures(false);
90 assertEquals(or.getColumnColourFromSequence(null, seq1, 0),
91 Color.magenta.getRGB());