2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, 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,
51 final AlignmentViewPanel ap)
53 oldcs = av.getGlobalColourScheme();
54 if (av.getAlignment().getGroups() != null)
56 oldgroupColours = new Hashtable();
57 for (SequenceGroup sg : ap.getAlignment().getGroups())
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.getAlignment().getAlignmentAnnotation().length; i++)
79 String label = av.getAlignment().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.getAlignment().getAlignmentAnnotation()[0];// annotations.getSelectedIndex()];
102 RNAHelicesColour rhc = null;
104 rhc = new RNAHelicesColour(currentAnnotation);
106 av.setGlobalColourScheme(rhc);
108 if (av.getAlignment().getGroups() != null)
110 for (SequenceGroup sg : ap.getAlignment().getGroups())
117 sg.cs = new RNAHelicesColour(currentAnnotation);
122 ap.paintAlignment(false);
127 av.setGlobalColourScheme(oldcs);
128 if (av.getAlignment().getGroups() != null)
130 for (SequenceGroup sg : ap.getAlignment().getGroups())
132 sg.cs = (ColourSchemeI) oldgroupColours.get(sg);
137 public void annotations_actionPerformed(ActionEvent e)