FeatureGroups added
authoramwaterhouse <Andrew Waterhouse>
Thu, 16 Feb 2006 15:49:43 +0000 (15:49 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 16 Feb 2006 15:49:43 +0000 (15:49 +0000)
src/jalview/gui/FeatureRenderer.java
src/jalview/gui/FeatureSettings.java

index 69ecf14..22789a1 100755 (executable)
@@ -46,6 +46,11 @@ public class FeatureRenderer
     // to be added, in the correct order or rendering\r
     Vector featuresDisplayed = null;\r
 \r
+    // A higher level for grouping features of a\r
+   // particular type\r
+    Hashtable featureGroups = null;\r
+\r
+\r
     /**\r
      * Creates a new FeatureRenderer object.\r
      *\r
@@ -98,7 +103,7 @@ public class FeatureRenderer
                              int start, int end, int x1, int y1, int width, int height)\r
     {\r
 \r
-//System.out.println(start+" "+end+" "+x1+" "+y1);\r
+        //System.out.println(start+" "+end+" "+x1+" "+y1);\r
       if (seq.getDatasetSequence().getSequenceFeatures() == null\r
           || seq.getDatasetSequence().getSequenceFeatures().size()==0)\r
         return;\r
@@ -135,6 +140,14 @@ public class FeatureRenderer
           if (!type.equals(sf.getType()))\r
             continue;\r
 \r
+          if(featureGroups!=null\r
+             && sf.getFeatureGroup()!=null\r
+             && featureGroups.containsKey(sf.getFeatureGroup())\r
+             && !((Boolean)featureGroups.get(sf.getFeatureGroup())).booleanValue())\r
+          {\r
+            continue;\r
+          }\r
+\r
           if (sf.getBegin() > seq.getEnd())\r
             continue;\r
 \r
index 47cedd3..eb74454 100755 (executable)
@@ -39,6 +39,7 @@ public class FeatureSettings extends JPanel
   final JInternalFrame frame;\r
   JScrollPane scrollPane = new JScrollPane();\r
   JTable table;\r
+  JPanel groupPanel;\r
 \r
   public FeatureSettings(AlignViewport av, final AlignmentPanel ap)\r
   {\r
@@ -122,6 +123,8 @@ public class FeatureSettings extends JPanel
     JPanel bigPanel = new JPanel(new BorderLayout());\r
     bigPanel.add(transPanel, BorderLayout.SOUTH);\r
     bigPanel.add(scrollPane, BorderLayout.CENTER);\r
+    if(groupPanel!=null)\r
+      bigPanel.add(groupPanel, BorderLayout.NORTH);\r
 \r
     add(bigPanel, BorderLayout.CENTER);\r
     add(buttonPanel, BorderLayout.SOUTH);\r
@@ -131,6 +134,11 @@ public class FeatureSettings extends JPanel
 \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
@@ -147,6 +155,32 @@ public class FeatureSettings extends JPanel
     while (e.hasMoreElements())\r
     {\r
       sf = (SequenceFeature) e.nextElement();\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 JPanel();\r
+\r
+          final JCheckBox check = new JCheckBox(sf.getFeatureGroup(), true);\r
+          check.setFont(new Font("Serif", Font.BOLD, 12));\r
+          check.addItemListener(new ItemListener()\r
+              {\r
+                public void itemStateChanged(ItemEvent evt)\r
+                {\r
+                  if (fr.featureGroups.containsKey(check.getText()))\r
+                  {\r
+                    fr.featureGroups.put(check.getText(),\r
+                                         new Boolean(check.isSelected()));\r
+                    ap.seqPanel.seqCanvas.repaint();\r
+                    if (ap.overviewPanel != null)\r
+                      ap.overviewPanel.updateOverviewImage();\r
+                  }\r
+\r
+                }\r
+              });\r
+          groupPanel.add(check);\r
+       }\r
       if (!allFeatures.contains(sf.getType()))\r
       {\r
         allFeatures.addElement(sf.getType());\r
@@ -155,9 +189,14 @@ public class FeatureSettings extends JPanel
   }\r
     if(allFeatures.size()<1)\r
      {\r
-       try{\r
-         frame.setClosed(true);\r
-       }catch(Exception ex){}\r
+       try\r
+       { frame.setClosed(true);  }\r
+       catch (Exception ex){}\r
+\r
+       JOptionPane.showInternalMessageDialog(\r
+           Desktop.desktop, "No features have been added to this alignment!",\r
+           "No Sequence Features", JOptionPane.WARNING_MESSAGE);\r
+\r
        return;\r
      }\r
 \r