2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
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/>.
21 import java.awt.event.*;
23 import jalview.datamodel.*;
24 import jalview.schemes.*;
27 * Helps generate the colors for RNA secondary structure. Future: add option to
28 * change colors based on covariation.
30 * @author Lauren Michelle Lui
33 public class RNAHelicesColourChooser
42 Hashtable oldgroupColours;
44 jalview.datamodel.AlignmentAnnotation currentAnnotation;
46 boolean adjusting = false;
48 public RNAHelicesColourChooser(AlignViewport av, final AlignmentPanel ap)
50 oldcs = av.getGlobalColourScheme();
51 if (av.alignment.getGroups() != null)
53 oldgroupColours = new Hashtable();
54 Vector allGroups = ap.av.alignment.getGroups();
56 for (int g = 0; g < allGroups.size(); g++)
58 sg = (SequenceGroup) allGroups.get(g);
61 oldgroupColours.put(sg, sg.cs);
68 if (oldcs instanceof RNAHelicesColour)
70 RNAHelicesColour rhc = (RNAHelicesColour) oldcs;
75 Vector list = new Vector();
77 for (int i = 0; i < av.alignment.getAlignmentAnnotation().length; i++)
79 String label = av.alignment.getAlignmentAnnotation()[i].label;
80 if (!list.contains(label))
81 list.addElement(label);
83 list.addElement(label + "_" + (index++));
94 // Check if combobox is still adjusting
100 currentAnnotation = av.alignment.getAlignmentAnnotation()[0];// annotations.getSelectedIndex()];
102 RNAHelicesColour rhc = null;
104 rhc = new RNAHelicesColour(currentAnnotation);
106 av.setGlobalColourScheme(rhc);
108 if (av.alignment.getGroups() != null)
110 Vector allGroups = ap.av.alignment.getGroups();
112 for (int g = 0; g < allGroups.size(); g++)
114 sg = (SequenceGroup) allGroups.get(g);
121 sg.cs = new RNAHelicesColour(currentAnnotation);
126 ap.paintAlignment(false);
131 av.setGlobalColourScheme(oldcs);
132 if (av.alignment.getGroups() != null)
134 Vector allGroups = ap.av.alignment.getGroups();
136 for (int g = 0; g < allGroups.size(); g++)
138 sg = (SequenceGroup) allGroups.get(g);
139 sg.cs = (ColourSchemeI) oldgroupColours.get(sg);
144 public void annotations_actionPerformed(ActionEvent e)