final Frame frame;\r
Panel groupPanel;\r
Panel featurePanel = new Panel();\r
+ ScrollPane scrollPane;\r
\r
public FeatureSettings(AlignViewport av, final AlignmentPanel ap)\r
{\r
setTableData();\r
\r
this.setLayout(new BorderLayout());\r
- ScrollPane sp = new ScrollPane();\r
- sp.add(featurePanel);\r
- add(sp, BorderLayout.CENTER);\r
+ scrollPane = new ScrollPane();\r
+ scrollPane.add(featurePanel);\r
+ add(scrollPane, BorderLayout.CENTER);\r
if(groupPanel!=null)\r
{\r
- sp = new ScrollPane();\r
- sp.add(groupPanel);\r
+ groupPanel.setLayout(\r
+ new GridLayout(groupPanel.getComponentCount() / 4, 4));\r
+ groupPanel.validate();\r
\r
- add(sp, BorderLayout.NORTH);\r
- sp.validate();\r
- sp.setSize( 100, 55);\r
+ add(groupPanel, BorderLayout.NORTH);\r
}\r
frame = new Frame();\r
frame.add(this);\r
if (height>400)\r
height = 400;\r
\r
- jalview.bin.JalviewLite.addFrame(frame, "Feature Settings", 200,\r
+ jalview.bin.JalviewLite.addFrame(frame, "Feature Settings", 250,\r
height);\r
}\r
\r
fr.featureGroups.clear();\r
\r
Vector allFeatures = new Vector();\r
- Enumeration tmpfeatures;\r
- SequenceFeature sf;\r
+ SequenceFeature[] tmpfeatures;\r
\r
for (int i = 0; i < av.alignment.getHeight(); i++)\r
{\r
if (av.alignment.getSequenceAt(i).getSequenceFeatures() == null)\r
continue;\r
\r
- tmpfeatures = av.alignment.getSequenceAt(i).getSequenceFeatures().elements();\r
- while (tmpfeatures.hasMoreElements())\r
+ tmpfeatures = av.alignment.getSequenceAt(i).getSequenceFeatures();\r
+ int index = 0;\r
+ while (index < tmpfeatures.length)\r
{\r
- sf = (SequenceFeature) tmpfeatures.nextElement();\r
- if (!allFeatures.contains(sf.getType()))\r
+ if(tmpfeatures[index].getFeatureGroup()!=null\r
+ && tmpfeatures[index].getFeatureGroup().length()>0\r
+ && !fr.featureGroups.containsKey(tmpfeatures[index].getFeatureGroup()))\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
+ fr.featureGroups.put(tmpfeatures[index].getFeatureGroup(), new Boolean(true));\r
if(groupPanel==null)\r
+ {\r
groupPanel = new Panel();\r
+ }\r
\r
- Checkbox check = new Checkbox(sf.getFeatureGroup(), true);\r
+ Checkbox check = new Checkbox(tmpfeatures[index].getFeatureGroup(), true);\r
check.setFont(new Font("Serif", Font.BOLD, 12));\r
check.addItemListener(this);\r
groupPanel.add(check);\r
}\r
+\r
+ if (!allFeatures.contains(tmpfeatures[index].getType()))\r
+ {\r
+ allFeatures.addElement(tmpfeatures[index].getType());\r
+ }\r
+\r
+\r
+ index ++;\r
}\r
}\r
\r
+ resetTable();\r
featurePanel.setLayout(new GridLayout(allFeatures.size(), 2, 10,5));\r
featurePanel.validate();\r
}\r
\r
+ void resetTable()\r
+ {\r
+ featurePanel.removeAll();\r
+ Enumeration groups = fr.featureGroups.keys();\r
+ SequenceFeature [] tmpfeatures;\r
+ String group, type;\r
+ Vector checksAdded = new Vector();\r
+\r
+ while(groups.hasMoreElements())\r
+ {\r
+ group = groups.nextElement().toString();\r
+ if ( !( (Boolean) fr.featureGroups.get(group)).booleanValue())\r
+ continue;\r
+\r
+ for (int i = 0; i < av.alignment.getHeight(); i++)\r
+ {\r
+ if (av.alignment.getSequenceAt(i).getSequenceFeatures() == null)\r
+ continue;\r
+\r
+ tmpfeatures = av.alignment.getSequenceAt(i).getSequenceFeatures();\r
+ int index = 0;\r
+ while (index < tmpfeatures.length)\r
+ {\r
+ if (tmpfeatures[index].getFeatureGroup() != null &&\r
+ tmpfeatures[index].getFeatureGroup().equals(group))\r
+ {\r
+ type = tmpfeatures[index].getType();\r
+ if(!checksAdded.contains(type))\r
+ {\r
+ checksAdded.addElement(type);\r
+ Checkbox check = new Checkbox(type, true);\r
+ check.addMouseListener(this);\r
+ check.addMouseMotionListener(this);\r
+ check.setBackground(fr.getColour(type));\r
+ check.addItemListener(this);\r
+ featurePanel.add(check);\r
+ }\r
+ }\r
+ index++;\r
+ }\r
+ }\r
+ }\r
+ featurePanel.validate();\r
+ if(scrollPane!=null)\r
+ scrollPane.validate();\r
+ }\r
+\r
public void itemStateChanged(ItemEvent evt)\r
{\r
- if(evt!=null)\r
+ if (evt != null)\r
{\r
//Is the source a top level featureGroup?\r
Checkbox source = (Checkbox) evt.getSource();\r
if (ap.overviewPanel != null)\r
ap.overviewPanel.updateOverviewImage();\r
\r
+ resetTable();\r
return;\r
}\r
}\r
Component[] comps = featurePanel.getComponents();\r
int cSize = comps.length;\r
\r
- Object[][] data = new Object[cSize][3];\r
-\r
+ Object[][] tmp = new Object[cSize][3];\r
+ int tmpSize = 0;\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
+ if(!check.getState())\r
+ continue;\r
+\r
+ tmp[tmpSize][0] = check.getLabel();\r
+ tmp[tmpSize][1] = fr.getColour(check.getLabel());\r
+ tmp[tmpSize][2] = new Boolean(check.getState());\r
+ tmpSize++;\r
}\r
\r
+ Object[][]data = new Object[tmpSize][3];\r
+ System.arraycopy(tmp, 0, data,0, tmpSize);\r
+\r
fr.setFeaturePriority(data);\r
ap.seqPanel.seqCanvas.repaint();\r
if (ap.overviewPanel != null)\r