-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathGroupedSourceParameters.java
More file actions
218 lines (189 loc) · 5.17 KB
/
GroupedSourceParameters.java
File metadata and controls
218 lines (189 loc) · 5.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
package PamView;
import java.io.Serializable;
import PamModel.parametermanager.ManagedParameters;
import PamModel.parametermanager.PamParameterSet;
import PamModel.parametermanager.PamParameterSet.ParameterSetType;
import PamUtils.PamUtils;
import PamView.dialog.GroupedSourcePanel;
/**
* Specific parameters which always to with a GroupedSourcePanel
* @author Doug Gillespie
*
*/
public class GroupedSourceParameters implements Serializable, Cloneable, ManagedParameters {
public static final long serialVersionUID = 1L;
/**
* Name of data source
*/
private String dataSource;
/**
* Bitmap of all channels used. Note that this may be a sequence map and not a channel
* map, depending on the source being used
*/
private int channelBitmap;
/**
* integer list of which group each channel belongs to
*/
private int[] channelGroups;
/**
* Grouping selection
*/
private int groupingType = GroupedSourcePanel.GROUP_ALL;
/**
* Create a grouped source parameters object.
* @param dataSource data source
* @param channelBitmap channel bitmap
* @param channelGroups channel groups list
* @param groupingType grouping type.
*/
public GroupedSourceParameters(String dataSource, int channelBitmap, int[] channelGroups, int groupingType) {
super();
this.dataSource = dataSource;
this.channelBitmap = channelBitmap;
this.channelGroups = channelGroups;
this.groupingType = groupingType;
}
public GroupedSourceParameters() {
super();
}
/**
* Get the group bitmap. i.e. the group numbers. This is not
* the channel bitmap.
* @return the group bitmap.
*/
public int getGroupMap() {
return GroupedSourcePanel.getGroupMap(channelBitmap, channelGroups);
}
/**
* Get the total number of channel groups
* @return number of groups
*/
public int countChannelGroups() {
return GroupedSourcePanel.countChannelGroups(channelBitmap, channelGroups);
}
/**
* Get the specific channels associated with a particular group.
* @param iGroup group index (0, 1, 2, 3 whatever the actual group numbers are !)
* @return bitmap of group channels
*/
public int getGroupChannels(int iGroup) {
return GroupedSourcePanel.getGroupChannels(iGroup, channelBitmap, channelGroups);
}
/**
* @return the dataSource
*/
public String getDataSource() {
return dataSource;
}
/**
* @param dataSource the dataSource to set
*/
public void setDataSource(String dataSource) {
this.dataSource = dataSource;
}
/**
* Return the channel bitmap selected from the Source Pane. Note that this may actually be the sequence
* bitmap and not the channel bitmap, depending on the source that has been selected
* @return the channelBitmap or sequenceBitmap
*/
public int getChanOrSeqBitmap() {
return channelBitmap;
}
/**
* This method has been added so that the channelBitmap field will be included in XML output.
* @return
*/
public int getChannelBitmap() {
return getChanOrSeqBitmap();
}
/**
* Set the channel or sequence bitmap (depending on the source that has been selected)
* @param channelBitmap the channelBitmap to set
*/
public void setChanOrSeqBitmap(int channelBitmap) {
this.channelBitmap = channelBitmap;
}
/**
* @return the channelGroups
*/
public int[] getChannelGroups() {
return channelGroups;
}
// /**
// * Get a bitmap of each channel group in an int array
// */
// public void getChannelGroupBitMap() {
// int channels = PamUtils.getNumChannels(this.getChannelBitmap());
// int channelCount=0;
// int groupN=0;
// while (channelCount!=channels && channelCount<32) {
// for (int i=0; i<channels; i++) {
// if (channelGroups[i]==groupN) {
// //channel is part of group
// channelCount++;
// }
// }
// groupN++;
// }
// }
/**
* @param channelGroups the channelGroups to set
*/
public void setChannelGroups(int[] channelGroups) {
this.channelGroups = channelGroups;
}
/**
* @return the groupingType
*/
public int getGroupingType() {
return groupingType;
}
/**
* @param groupingType the groupingType to set
*/
public void setGroupingType(int groupingType) {
this.groupingType = groupingType;
}
/**
*
* @return true if at least one group has multiple elements, so
* might be able to calculate bearings.
*/
public boolean mayHaveBearings() {
int n = countChannelGroups();
int groupMap;
for (int i = 0 ; i< n; i++) {
groupMap = getGroupChannels(i);
if (PamUtils.getNumChannels(groupMap) > 1) {
return true;
}
}
return false;
}
/**
*
* @return true if mayHaveBearings is true and if there is more than one group
*/
public boolean mayHaveRange() {
return (mayHaveBearings() && countChannelGroups() > 1);
}
@Override
public GroupedSourceParameters clone() {
try {
return (GroupedSourceParameters) super.clone();
}
catch (CloneNotSupportedException e) {
e.printStackTrace();
return null;
}
}
/**
* Note that all the fields have getters, so even though they are private they will still
* be included in the output so we don't need to explicitly add them here
*/
@Override
public PamParameterSet getParameterSet() {
PamParameterSet ps = PamParameterSet.autoGenerate(this, ParameterSetType.DETECTOR);
return ps;
}
}