2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3 * Copyright (C) 2014 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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.schemes;
22 import java.awt.event.*;
24 import jalview.api.AlignViewportI;
25 import jalview.api.AlignmentViewPanel;
26 import jalview.datamodel.*;
27 import jalview.schemes.*;
30 * Helps generate the colors for RNA secondary structure. Future: add option to
31 * change colors based on covariation.
33 * @author Lauren Michelle Lui
36 public class RNAHelicesColourChooser
41 AlignmentViewPanel ap;
45 Hashtable oldgroupColours;
47 jalview.datamodel.AlignmentAnnotation currentAnnotation;
49 boolean adjusting = false;
51 public RNAHelicesColourChooser(AlignViewportI av,
52 final AlignmentViewPanel ap)
54 oldcs = av.getGlobalColourScheme();
55 if (av.getAlignment().getGroups() != null)
57 oldgroupColours = new Hashtable();
58 for (SequenceGroup sg : ap.getAlignment().getGroups())
62 oldgroupColours.put(sg, sg.cs);
69 if (oldcs instanceof RNAHelicesColour)
71 RNAHelicesColour rhc = (RNAHelicesColour) oldcs;
76 Vector list = new Vector();
78 for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
80 String label = av.getAlignment().getAlignmentAnnotation()[i].label;
81 if (!list.contains(label))
82 list.addElement(label);
84 list.addElement(label + "_" + (index++));
95 // Check if combobox is still adjusting
101 // This loop will find the first rna structure annotation by which to colour
103 AlignmentAnnotation[] annotations = av.getAlignment().getAlignmentAnnotation();
104 for (int i = 0; i < annotations.length; i++) {
106 // is this a sensible way of determining type of annotation?
107 if (annotations[i].getRNAStruc() != null) {
108 currentAnnotation = annotations[i];
112 if (currentAnnotation == null)
114 System.err.println("Jalview is about to try and colour by RNAHelices even"
115 + " though there are no RNA secondary structure annotations present!");
116 currentAnnotation = av.getAlignment().getAlignmentAnnotation()[0];// annotations.getSelectedIndex()];
119 RNAHelicesColour rhc = null;
121 rhc = new RNAHelicesColour(currentAnnotation);
123 av.setGlobalColourScheme(rhc);
125 if (av.getAlignment().getGroups() != null)
127 for (SequenceGroup sg : ap.getAlignment().getGroups())
134 sg.cs = new RNAHelicesColour(currentAnnotation);
139 ap.paintAlignment(false);
144 av.setGlobalColourScheme(oldcs);
145 if (av.getAlignment().getGroups() != null)
147 for (SequenceGroup sg : ap.getAlignment().getGroups())
149 sg.cs = (ColourSchemeI) oldgroupColours.get(sg);
154 public void annotations_actionPerformed(ActionEvent e)