From: jprocter Date: Mon, 2 Apr 2007 15:10:39 +0000 (+0000) Subject: update settings for new groups (always displayed) and new feature types (containing... X-Git-Tag: Release_2_3~273 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ed84efcfcce77244a2a7c04d15f665118cff54e0;p=jalview.git update settings for new groups (always displayed) and new feature types (containing group is checked and type is checked and displayed on top) --- diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index 6c5990a..7e817af 100755 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -132,7 +132,7 @@ public class FeatureSettings { 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; } } @@ -198,57 +198,10 @@ public class FeatureSettings 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); } } @@ -264,12 +217,70 @@ public class FeatureSettings 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; @@ -303,6 +314,7 @@ public class FeatureSettings if (group == null || fr.featureGroups.get(group) == null || ( (Boolean) fr.featureGroups.get(group)).booleanValue()) { + checkGroupState(group); type = tmpfeatures[index].getType(); if (!visibleChecks.contains(type)) {