Checks for null colour in groups
authoramwaterhouse <Andrew Waterhouse>
Mon, 22 Aug 2005 17:02:36 +0000 (17:02 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 22 Aug 2005 17:02:36 +0000 (17:02 +0000)
src/jalview/gui/Jalview2XML.java

index a8fb28d..ffa837d 100755 (executable)
@@ -294,36 +294,38 @@ public class Jalview2XML
                 groups[i].setStart(sg.getStartRes());\r
                 groups[i].setEnd(sg.getEndRes());\r
                 groups[i].setName(sg.getName());\r
-\r
-                if (sg.cs.conservationApplied())\r
+                if(sg.cs!=null)\r
                 {\r
-                  groups[i].setConsThreshold(sg.cs.getConservationInc());\r
+                  if (sg.cs.conservationApplied())\r
+                  {\r
+                    groups[i].setConsThreshold(sg.cs.getConservationInc());\r
 \r
-                  if (sg.cs instanceof jalview.schemes.UserColourScheme)\r
+                    if (sg.cs instanceof jalview.schemes.UserColourScheme)\r
+                    {\r
+                      groups[i].setColour(SetUserColourScheme(sg.cs,\r
+                          userColours,\r
+                          jms));\r
+                    }\r
+                    else\r
+                    {\r
+                      groups[i].setColour(ColourSchemeProperty.getColourName(sg.\r
+                          cs));\r
+                    }\r
+                  }\r
+                  else if (sg.cs instanceof jalview.schemes.UserColourScheme)\r
                   {\r
                     groups[i].setColour(SetUserColourScheme(sg.cs, userColours,\r
-                                                            jms));\r
+                        jms));\r
                   }\r
                   else\r
                   {\r
-                    groups[i].setColour(ColourSchemeProperty.getColourName(sg.cs));\r
+                    groups[i].setColour(ColourSchemeProperty.getColourName(\r
+                        sg.cs));\r
                   }\r
-                }\r
 \r
-               else if (sg.cs instanceof jalview.schemes.UserColourScheme)\r
-                {\r
-                    groups[i].setColour(SetUserColourScheme(sg.cs, userColours,\r
-                            jms));\r
-                }\r
-                else\r
-                {\r
-                  groups[i].setColour(ColourSchemeProperty.getColourName(\r
-                      sg.cs));\r
+                  groups[i].setPidThreshold(sg.cs.getThreshold());\r
                 }\r
 \r
-\r
-                groups[i].setPidThreshold( sg.cs.getThreshold() );\r
-\r
                 groups[i].setOutlineColour(sg.getOutlineColour().getRGB());\r
                 groups[i].setDisplayBoxes(sg.getDisplayBoxes());\r
                 groups[i].setDisplayText(sg.getDisplayText());\r
@@ -363,16 +365,19 @@ public class Jalview2XML
 \r
         ColourSchemeI cs = av.getGlobalColourScheme();\r
 \r
-        if (cs.conservationApplied())\r
+        if(cs!=null)\r
         {\r
+          if (cs.conservationApplied())\r
+          {\r
             view.setConsThreshold(cs.getConservationInc());\r
-            if(cs instanceof jalview.schemes.UserColourScheme)\r
+            if (cs instanceof jalview.schemes.UserColourScheme)\r
               view.setBgColour(SetUserColourScheme(cs, userColours, jms));\r
-        }\r
+          }\r
 \r
-        if (cs instanceof ResidueColourScheme)\r
-        {\r
-            view.setPidThreshold( cs.getThreshold() );\r
+          if (cs instanceof ResidueColourScheme)\r
+          {\r
+            view.setPidThreshold(cs.getThreshold());\r
+          }\r
         }\r
 \r
         view.setConservationSelected(av.getConservationSelected());\r
@@ -666,8 +671,7 @@ public class Jalview2XML
             }\r
         }\r
 \r
-        Desktop.addInternalFrame(af, view.getTitle(),\r
-            AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT);\r
+\r
         af.setBounds(view.getXpos(), view.getYpos(), view.getWidth(),\r
             view.getHeight());\r
         af.viewport.setStartRes(view.getStartRes());\r
@@ -724,19 +728,20 @@ public class Jalview2XML
                 cs = ColourSchemeProperty.getColour(al, view.getBgColour());\r
             }\r
 \r
-           cs.setThreshold(view.getPidThreshold(), true);\r
-\r
             if(cs!=null)\r
+            {\r
+              cs.setThreshold(view.getPidThreshold(), true);\r
               cs.setConsensus(af.viewport.vconsensus);\r
+            }\r
         }\r
 \r
         af.setColourSelected(view.getBgColour());\r
         af.viewport.setGlobalColourScheme(cs);\r
         af.viewport.setColourAppliesToAllGroups(false);\r
-        af.changeColour(af.viewport.getGlobalColourScheme());\r
-        if (view.getConservationSelected())\r
+        af.changeColour(cs);\r
+        if (view.getConservationSelected() && cs!=null)\r
         {\r
-          af.viewport.getGlobalColourScheme().setConservationInc(view.getConsThreshold());\r
+          cs.setConservationInc(view.getConsThreshold());\r
         }\r
 \r
         af.viewport.setColourAppliesToAllGroups(true);\r
@@ -780,12 +785,18 @@ public class Jalview2XML
                     if (tree.getCurrentTree())\r
                       af.viewport.setCurrentTree(tp.getTree());\r
                 }\r
+\r
             }\r
             catch (Exception ex)\r
             {\r
                 ex.printStackTrace();\r
             }\r
+\r
         }\r
+\r
+        Desktop.addInternalFrame(af, view.getTitle(),\r
+             AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT);\r
+\r
         return af;\r
     }\r
 }\r