{
if (!fs.resettingTable && !fs.handlingUpdate) {
fs.handlingUpdate=true;
- fs.resetTable(new String[] {}); // groups may be added
+ fs.resetTable(null); // groups may be added with new seuqence feature types only
fs.handlingUpdate=false;
}
}
if (!allGroups.contains(group))
{
allGroups.addElement(group);
-
- boolean visible;
- if (fr.featureGroups.containsKey(group))
- {
- visible = ( (Boolean) fr.featureGroups.get(group)).booleanValue();
- } else {
- visible=true; //initGroups || fr.av.featuresDisplayed.containsKey(tmpfeatures[index].getType());
- }
-
- if (groupPanel == null)
- {
- groupPanel = new JPanel();
- }
-
- boolean alreadyAdded = false;
- for (int g = 0; g < groupPanel.getComponentCount(); g++)
- {
- if ( ( (JCheckBox) groupPanel.getComponent(g))
- .getText().equals(group))
- {
- alreadyAdded = true;
- break;
- }
- }
-
- if (alreadyAdded)
+ if (checkGroupState(group))
{
-
- continue;
+ // continue; // skip this group's feature - we've done it already ?
}
-
- fr.featureGroups.put(group, new Boolean(visible));
- final String grp = group;
- final JCheckBox check = new JCheckBox(group, visible);
- check.setFont(new Font("Serif", Font.BOLD, 12));
- check.addItemListener(new ItemListener()
- {
- public void itemStateChanged(ItemEvent evt)
- {
- fr.featureGroups.put(check.getText(),
- new Boolean(check.isSelected()));
- af.alignPanel.seqPanel.seqCanvas.repaint();
- if (af.alignPanel.overviewPanel != null)
- {
- af.alignPanel.overviewPanel.updateOverviewImage();
- }
-
- resetTable(new String[] { grp } );
- }
- });
- groupPanel.add(check);
}
}
validate();
}
+ /**
+ *
+ * @param group
+ * @return true if group has been seen before and is already added to set.
+ */
+ private boolean checkGroupState(String group) {
+ boolean visible;
+ if (fr.featureGroups.containsKey(group))
+ {
+ visible = ( (Boolean) fr.featureGroups.get(group)).booleanValue();
+ } else {
+ visible=true; // new group is always made visible
+ }
+
+ if (groupPanel == null)
+ {
+ groupPanel = new JPanel();
+ }
+
+ boolean alreadyAdded = false;
+ for (int g = 0; g < groupPanel.getComponentCount(); g++)
+ {
+ if ( ( (JCheckBox) groupPanel.getComponent(g))
+ .getText().equals(group))
+ {
+ alreadyAdded = true;
+ ((JCheckBox)groupPanel.getComponent(g)).setSelected(visible);
+ break;
+ }
+ }
+
+ if (alreadyAdded)
+ {
+
+ return true;
+ }
+
+ fr.featureGroups.put(group, new Boolean(visible));
+ final String grp = group;
+ final JCheckBox check = new JCheckBox(group, visible);
+ check.setFont(new Font("Serif", Font.BOLD, 12));
+ check.addItemListener(new ItemListener()
+ {
+ public void itemStateChanged(ItemEvent evt)
+ {
+ fr.featureGroups.put(check.getText(),
+ new Boolean(check.isSelected()));
+ af.alignPanel.seqPanel.seqCanvas.repaint();
+ if (af.alignPanel.overviewPanel != null)
+ {
+ af.alignPanel.overviewPanel.updateOverviewImage();
+ }
+
+ resetTable(new String[] { grp } );
+ }
+ });
+ groupPanel.add(check);
+ return false;
+ }
boolean resettingTable=false;
void resetTable(String[] groupChanged)
{
resettingTable=true;
typeWidth=new Hashtable();
- Vector groupchanged = new Vector();
// TODO: change avWidth calculation to 'per-sequence' average and use long rather than float
float[] avWidth=null;
SequenceFeature[] tmpfeatures;
if (group == null || fr.featureGroups.get(group) == null ||
( (Boolean) fr.featureGroups.get(group)).booleanValue())
{
+ checkGroupState(group);
type = tmpfeatures[index].getType();
if (!visibleChecks.contains(type))
{