2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
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
100 RNAHelicesColour rhc = null;
102 rhc = new RNAHelicesColour(av.getAlignment());
104 av.setGlobalColourScheme(rhc);
106 if (av.getAlignment().getGroups() != null)
108 for (SequenceGroup sg : ap.getAlignment().getGroups())
115 sg.cs = new RNAHelicesColour(sg);
120 ap.paintAlignment(false);
125 av.setGlobalColourScheme(oldcs);
126 if (av.getAlignment().getGroups() != null)
128 for (SequenceGroup sg : ap.getAlignment().getGroups())
130 sg.cs = (ColourSchemeI) oldgroupColours.get(sg);
135 public void annotations_actionPerformed(ActionEvent e)