ignore begin==0 and end==0 for the moment
[jalview.git] / src / jalview / gui / FeatureSettings.java
index 23f22a3..7917efa 100755 (executable)
@@ -69,11 +69,20 @@ public class FeatureSettings extends JPanel
     JPanel transPanel = new JPanel(new FlowLayout());\r
     transPanel.add(new JLabel("Transparency"));\r
     transPanel.add(transparency);\r
+    JButton button = new JButton("Invert Selection");\r
+    transPanel.add(button);\r
+    button.addActionListener(new ActionListener()\r
+        {\r
+          public void actionPerformed(ActionEvent evt)\r
+          {\r
+            invertSelection();\r
+          }\r
+        });\r
 \r
     //////////////////////////////////////////////\r
     //We're going to need those OK cancel buttons\r
     JPanel buttonPanel = new JPanel(new FlowLayout());\r
-    JButton button = new JButton("OK");\r
+    button = new JButton("OK");\r
     button.addActionListener(new ActionListener()\r
     {\r
       public void actionPerformed(ActionEvent evt)\r
@@ -160,9 +169,16 @@ public class FeatureSettings extends JPanel
       alignmentHasFeatures = true;\r
 \r
       tmpfeatures = av.alignment.getSequenceAt(i).getDatasetSequence().getSequenceFeatures();\r
+\r
       int index = 0;\r
       while (index < tmpfeatures.length)\r
       {\r
+        if(tmpfeatures[index].begin == 0 && tmpfeatures[index].end ==0)\r
+        {\r
+          index++;\r
+          continue;\r
+        }\r
+\r
         if(tmpfeatures[index].getFeatureGroup()!=null)\r
         {\r
           group = tmpfeatures[index].featureGroup;\r
@@ -248,6 +264,12 @@ public class FeatureSettings extends JPanel
         {\r
           group = tmpfeatures[index].featureGroup;\r
 \r
+          if(tmpfeatures[index].begin==0 && tmpfeatures[index].end==0)\r
+          {\r
+            index ++;\r
+            continue;\r
+          }\r
+\r
           if (group==null || fr.featureGroups.get(group)==null ||\r
               ((Boolean) fr.featureGroups.get(group)).booleanValue())\r
           {\r
@@ -291,6 +313,10 @@ public class FeatureSettings extends JPanel
       //which was just selected\r
       type = visibleChecks.elementAt(i).toString();\r
       data[dataIndex][0] = type;\r
+\r
+      if(fr.getColour(type)==null)\r
+        fr.createRandomColour(type);\r
+\r
       data[dataIndex][1] = fr.getColour(type);\r
       data[dataIndex][2] = new Boolean(true);\r
       dataIndex++;\r
@@ -420,8 +446,6 @@ public class FeatureSettings extends JPanel
             Enumeration e = fr.featureColours.keys();\r
            while(e.hasMoreElements())\r
            {\r
-\r
-\r
                 jalview.binding.Colour col = new jalview.binding.Colour();\r
                 col.setName(e.nextElement().toString());\r
                 col.setRGB(jalview.util.Format.getHexString(\r
@@ -437,6 +461,18 @@ public class FeatureSettings extends JPanel
             ex.printStackTrace();\r
         }\r
     }\r
+  }\r
+\r
+  public void invertSelection()\r
+  {\r
+    for(int i=0; i<table.getRowCount(); i++)\r
+    {\r
+      Boolean value = (Boolean)table.getValueAt(i,2);\r
+\r
+      table.setValueAt(\r
+          new Boolean(!value.booleanValue()),\r
+                       i,2);\r
+    }\r
 \r
   }\r
 \r