final AlignmentPanel ap;\r
final AlignViewport av;\r
final Frame frame;\r
+ Panel groupPanel;\r
+ Panel featurePanel = new Panel();\r
\r
public FeatureSettings(AlignViewport av, final AlignmentPanel ap)\r
{\r
\r
setTableData();\r
\r
+ this.setLayout(new BorderLayout());\r
+ ScrollPane sp = new ScrollPane();\r
+ sp.add(featurePanel);\r
+ add(sp, BorderLayout.CENTER);\r
+ if(groupPanel!=null)\r
+ {\r
+ sp = new ScrollPane();\r
+ sp.add(groupPanel);\r
+\r
+ add(sp, BorderLayout.NORTH);\r
+ sp.validate();\r
+ sp.setSize( 100, 55);\r
+ }\r
frame = new Frame();\r
frame.add(this);\r
- int height = this.getComponentCount()*50;\r
+ int height = featurePanel.getComponentCount()*50 ;\r
if (height>400)\r
height = 400;\r
\r
\r
void setTableData()\r
{\r
+ if(fr.featureGroups==null)\r
+ fr.featureGroups = new Hashtable();\r
+ else\r
+ fr.featureGroups.clear();\r
+\r
Vector allFeatures = new Vector();\r
- Vector features;\r
- Enumeration e;\r
+ Enumeration tmpfeatures;\r
SequenceFeature sf;\r
\r
for (int i = 0; i < av.alignment.getHeight(); i++)\r
{\r
- features = av.alignment.getSequenceAt(i).getSequenceFeatures();\r
- if (features == null)\r
+ if (av.alignment.getSequenceAt(i).getSequenceFeatures() == null)\r
continue;\r
\r
- e = features.elements();\r
- while (e.hasMoreElements())\r
+ tmpfeatures = av.alignment.getSequenceAt(i).getSequenceFeatures().elements();\r
+ while (tmpfeatures.hasMoreElements())\r
{\r
- sf = (SequenceFeature) e.nextElement();\r
+ sf = (SequenceFeature) tmpfeatures.nextElement();\r
if (!allFeatures.contains(sf.getType()))\r
{\r
allFeatures.addElement(sf.getType());\r
+ Color col = fr.getColour(sf.getType());\r
+ boolean displayed = true;\r
+ if (fr.featuresDisplayed != null)\r
+ displayed = fr.featuresDisplayed.contains(sf.getType());\r
+\r
+ Checkbox check = new Checkbox(sf.getType(), displayed);\r
+ check.addMouseListener(this);\r
+ check.addMouseMotionListener(this);\r
+ check.setBackground(col);\r
+ check.addItemListener(this);\r
+ featurePanel.add(check);\r
+ }\r
+ if(sf.getFeatureGroup()!=null\r
+ && !fr.featureGroups.containsKey(sf.getFeatureGroup()))\r
+ {\r
+ fr.featureGroups.put(sf.getFeatureGroup(), new Boolean(true));\r
+ if(groupPanel==null)\r
+ groupPanel = new Panel();\r
+\r
+ Checkbox check = new Checkbox(sf.getFeatureGroup(), true);\r
+ check.setFont(new Font("Serif", Font.BOLD, 12));\r
+ check.addItemListener(this);\r
+ groupPanel.add(check);\r
}\r
}\r
}\r
\r
- int fSize = allFeatures.size();\r
-\r
- String type;\r
- this.setLayout(new GridLayout(fSize, 2, 10,5));\r
-\r
- for (int i = 0; i < fSize; i++)\r
- {\r
- type = allFeatures.elementAt(i).toString();\r
- Color col = fr.getColour(type);\r
- boolean displayed = true;\r
- if(fr.featuresDisplayed!=null)\r
- displayed = fr.featuresDisplayed.contains(type);\r
-\r
- Checkbox check = new Checkbox(type, displayed);\r
- check.addMouseListener(this);\r
- check.addMouseMotionListener(this);\r
- check.setBackground(col);\r
- check.addItemListener(this);\r
- add(check);\r
- }\r
- validate();\r
+ featurePanel.setLayout(new GridLayout(allFeatures.size(), 2, 10,5));\r
+ featurePanel.validate();\r
}\r
\r
public void itemStateChanged(ItemEvent evt)\r
{\r
- Component [] comps = this.getComponents();\r
- int cSize = comps.length;\r
-\r
- Object [][] data = new Object[cSize][3];\r
-\r
- for(int i=0; i<cSize; i++)\r
+ if(evt!=null)\r
{\r
- Checkbox check = (Checkbox)comps[i];\r
- data[i][0] = check.getLabel();\r
- data[i][1] = fr.getColour(check.getLabel());\r
- data[i][2] = new Boolean(check.getState());\r
+ //Is the source a top level featureGroup?\r
+ Checkbox source = (Checkbox) evt.getSource();\r
+ if (fr.featureGroups.containsKey(source.getLabel()))\r
+ {\r
+ fr.featureGroups.put(source.getLabel(), new Boolean(source.getState()));\r
+ ap.seqPanel.seqCanvas.repaint();\r
+ if (ap.overviewPanel != null)\r
+ ap.overviewPanel.updateOverviewImage();\r
+\r
+ return;\r
+ }\r
}\r
\r
- fr.setFeaturePriority(data);\r
- ap.seqPanel.seqCanvas.repaint();\r
- if(ap.overviewPanel!=null)\r
- ap.overviewPanel.updateOverviewImage();\r
+ Component[] comps = featurePanel.getComponents();\r
+ int cSize = comps.length;\r
+\r
+ Object[][] data = new Object[cSize][3];\r
+\r
+ for (int i = 0; i < cSize; i++)\r
+ {\r
+ Checkbox check = (Checkbox) comps[i];\r
+ data[i][0] = check.getLabel();\r
+ data[i][1] = fr.getColour(check.getLabel());\r
+ data[i][2] = new Boolean(check.getState());\r
+ }\r
+\r
+ fr.setFeaturePriority(data);\r
+ ap.seqPanel.seqCanvas.repaint();\r
+ if (ap.overviewPanel != null)\r
+ ap.overviewPanel.updateOverviewImage();\r
}\r
\r
Checkbox selectedCheck;\r
\r
int height = evt.getY()+evt.getComponent().getLocation().y;\r
\r
+\r
if(height > this.getSize().height)\r
{\r
- comp = this.getComponent(this.getComponentCount()-1);\r
+ comp = featurePanel.getComponent(featurePanel.getComponentCount()-1);\r
}\r
else if(height < 0)\r
{\r
- comp = this.getComponent(0);\r
+ comp = featurePanel.getComponent(0);\r
}\r
else\r
{\r
- comp = this.getComponentAt(evt.getX(),\r
+ comp = featurePanel.getComponentAt(evt.getX(),\r
evt.getY() +\r
evt.getComponent().getLocation().y);\r
}\r
if (selectedCheck != null && target != null && selectedCheck != target)\r
{\r
int targetIndex = -1;\r
- for(int i=0; i<this.getComponentCount(); i++)\r
+ for(int i=0; i<featurePanel.getComponentCount(); i++)\r
{\r
- if(target==this.getComponent(i))\r
+ if(target==featurePanel.getComponent(i))\r
{ targetIndex = i; break; }\r
}\r
\r
\r
- this.remove(selectedCheck);\r
- this.add(selectedCheck, targetIndex);\r
- validate();\r
+ featurePanel.remove(selectedCheck);\r
+ featurePanel.add(selectedCheck, targetIndex);\r
+ featurePanel.validate();\r
itemStateChanged(null);\r
}\r
}\r