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/>.
18 package jalview.schemes;
21 import java.awt.event.*;
23 import jalview.api.AlignViewportI;
24 import jalview.api.AlignmentViewPanel;
25 import jalview.datamodel.*;
26 import jalview.schemes.*;
29 * Helps generate the colors for RNA secondary structure. Future: add option to
30 * change colors based on covariation.
32 * @author Lauren Michelle Lui
35 public class RNAHelicesColourChooser
40 AlignmentViewPanel ap;
44 Hashtable oldgroupColours;
46 jalview.datamodel.AlignmentAnnotation currentAnnotation;
48 boolean adjusting = false;
50 public RNAHelicesColourChooser(AlignViewportI av, final AlignmentViewPanel ap)
52 oldcs = av.getGlobalColourScheme();
53 if (av.getAlignment().getGroups() != null)
55 oldgroupColours = new Hashtable();
56 Vector allGroups = ap.getAlignment().getGroups();
58 for (int g = 0; g < allGroups.size(); g++)
60 sg = (SequenceGroup) allGroups.get(g);
63 oldgroupColours.put(sg, sg.cs);
70 if (oldcs instanceof RNAHelicesColour)
72 RNAHelicesColour rhc = (RNAHelicesColour) oldcs;
77 Vector list = new Vector();
79 for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
81 String label = av.getAlignment().getAlignmentAnnotation()[i].label;
82 if (!list.contains(label))
83 list.addElement(label);
85 list.addElement(label + "_" + (index++));
96 // Check if combobox is still adjusting
102 currentAnnotation = av.getAlignment().getAlignmentAnnotation()[0];// annotations.getSelectedIndex()];
104 RNAHelicesColour rhc = null;
106 rhc = new RNAHelicesColour(currentAnnotation);
108 av.setGlobalColourScheme(rhc);
110 if (av.getAlignment().getGroups() != null)
112 Vector allGroups = ap.getAlignment().getGroups();
114 for (int g = 0; g < allGroups.size(); g++)
116 sg = (SequenceGroup) allGroups.get(g);
123 sg.cs = new RNAHelicesColour(currentAnnotation);
128 ap.paintAlignment(false);
133 av.setGlobalColourScheme(oldcs);
134 if (av.getAlignment().getGroups() != null)
136 Vector allGroups = ap.getAlignment().getGroups();
138 for (int g = 0; g < allGroups.size(); g++)
140 sg = (SequenceGroup) allGroups.get(g);
141 sg.cs = (ColourSchemeI) oldgroupColours.get(sg);
146 public void annotations_actionPerformed(ActionEvent e)