ad6f703ad002ee72d9852ae48a3f1a78b238f192
[jalview.git] / src / jalview / datamodel / SuperGroup.java
1 /*\r
2 * Jalview - A Sequence Alignment Editor and Viewer\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
4 *\r
5 * This program is free software; you can redistribute it and/or\r
6 * modify it under the terms of the GNU General Public License\r
7 * as published by the Free Software Foundation; either version 2\r
8 * of the License, or (at your option) any later version.\r
9 *\r
10 * This program is distributed in the hope that it will be useful,\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 * GNU General Public License for more details.\r
14 *\r
15 * You should have received a copy of the GNU General Public License\r
16 * along with this program; if not, write to the Free Software\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
18 */\r
19 package jalview.datamodel;\r
20 \r
21 import jalview.analysis.*;\r
22 \r
23 import jalview.datamodel.*;\r
24 \r
25 import jalview.schemes.*;\r
26 \r
27 import java.util.*;\r
28 \r
29 \r
30 public class SuperGroup {\r
31     String groupName;\r
32     boolean displayBoxes;\r
33     boolean displayText;\r
34     boolean colourText;\r
35     public ColourSchemeI cs;\r
36     Vector sequenceGroups = new Vector();\r
37 \r
38     public SuperGroup() {\r
39         groupName = "Super group";\r
40         this.displayBoxes = true;\r
41         this.displayText = true;\r
42         this.colourText = false;\r
43         cs = null;\r
44     }\r
45 \r
46     public SuperGroup(String groupName, ColourSchemeI scheme,\r
47         boolean displayBoxes, boolean displayText, boolean colourText) {\r
48         this.groupName = groupName;\r
49         this.displayBoxes = displayBoxes;\r
50         this.displayText = displayText;\r
51         this.colourText = colourText;\r
52         this.cs = scheme;\r
53     }\r
54 \r
55     public String getName() {\r
56         return groupName;\r
57     }\r
58 \r
59     public void setName(String name) {\r
60         groupName = name;\r
61     }\r
62 \r
63     public void addGroup(SequenceGroup sg) {\r
64         if (!sequenceGroups.contains(sg)) {\r
65             sequenceGroups.addElement(sg);\r
66         }\r
67     }\r
68 \r
69     public void addOrRemove(SequenceGroup sg) {\r
70         if (sequenceGroups.contains(sg)) {\r
71             deleteGroup(sg);\r
72         } else {\r
73             addGroup(sg);\r
74         }\r
75     }\r
76 \r
77     public void deleteGroup(SequenceGroup sg) {\r
78         sequenceGroups.removeElement(sg);\r
79     }\r
80 \r
81     public void setSuperGroupProperties(SequenceGroup sg) {\r
82         cs = sg.cs;\r
83         colourText = sg.colourText;\r
84         displayText = sg.displayText;\r
85         displayBoxes = sg.displayBoxes;\r
86 \r
87         for (int i = 0; i < sequenceGroups.size(); i++) {\r
88             SequenceGroup temp = (SequenceGroup) sequenceGroups.elementAt(i);\r
89             temp.cs = sg.cs;\r
90             temp.colourText = sg.colourText;\r
91             temp.displayText = sg.displayText;\r
92             temp.displayBoxes = sg.displayBoxes;\r
93         }\r
94     }\r
95 \r
96     public int getSize() {\r
97         return sequenceGroups.size();\r
98     }\r
99 \r
100     public SequenceGroup getGroupeAt(int i) {\r
101         return (SequenceGroup) sequenceGroups.elementAt(i);\r
102     }\r
103 }\r