Save annotationColours
authoramwaterhouse <Andrew Waterhouse>
Wed, 5 Apr 2006 15:53:09 +0000 (15:53 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 5 Apr 2006 15:53:09 +0000 (15:53 +0000)
src/jalview/gui/Jalview2XML.java

index eb071e2..db60b8b 100755 (executable)
@@ -320,6 +320,14 @@ public class Jalview2XML
                 {\r
                   an.setGraph(true);\r
                   an.setGraphType(aa[i].graph);\r
+                  if(aa[i].getThreshold()!=null)\r
+                  {\r
+                    ThresholdLine line = new ThresholdLine();\r
+                    line.setLabel(aa[i].getThreshold().label);\r
+                    line.setValue(aa[i].getThreshold().value);\r
+                    line.setColour(aa[i].getThreshold().colour.getRGB());\r
+                    an.setThresholdLine(line);\r
+                  }\r
                 }\r
                 else\r
                   an.setGraph(false);\r
@@ -381,6 +389,12 @@ public class Jalview2XML
                           cs));\r
                     }\r
                   }\r
+                  else if(sg.cs instanceof jalview.schemes.AnnotationColourGradient)\r
+                  {\r
+                    groups[i].setColour(\r
+                        ColourSchemeProperty.getColourName(\r
+                      ( (jalview.schemes.AnnotationColourGradient) sg.cs).getBaseColour()));\r
+                  }\r
                   else if (sg.cs instanceof jalview.schemes.UserColourScheme)\r
                   {\r
                     groups[i].setColour(SetUserColourScheme(sg.cs, userColours,\r
@@ -427,6 +441,26 @@ public class Jalview2XML
             view.setBgColour(SetUserColourScheme(av.getGlobalColourScheme(),\r
                     userColours, jms));\r
         }\r
+        else if(av.getGlobalColourScheme() instanceof jalview.schemes.AnnotationColourGradient)\r
+        {\r
+           jalview.schemes.AnnotationColourGradient acg\r
+              = (jalview.schemes.AnnotationColourGradient)av.getGlobalColourScheme();\r
+\r
+            AnnotationColours ac = new AnnotationColours();\r
+            ac.setAboveThreshold(acg.getAboveThreshold());\r
+            ac.setThreshold(acg.getAnnotationThreshold());\r
+            ac.setAnnotation(acg.getAnnotation());\r
+            if(acg.getBaseColour() instanceof jalview.schemes.UserColourScheme)\r
+              ac.setColourScheme(SetUserColourScheme(acg.getBaseColour(),\r
+                    userColours, jms));\r
+            else\r
+              ac.setColourScheme(ColourSchemeProperty.getColourName(acg.getBaseColour()));\r
+\r
+            ac.setMaxColour(acg.getMaxColour().getRGB());\r
+            ac.setMinColour(acg.getMinColour().getRGB());\r
+            view.setAnnotationColours(ac);\r
+            view.setBgColour("AnnotationColourGradient");\r
+        }\r
         else\r
         {\r
             view.setBgColour(ColourSchemeProperty.getColourName(\r
@@ -761,9 +795,20 @@ public class Jalview2XML
 \r
                 if (an[i].getGraph())\r
                 {\r
-                    jaa = new jalview.datamodel.AlignmentAnnotation(an[i].getLabel(),\r
-                            an[i].getDescription(), anot, 0, 0,\r
-                            an[i].getGraphType());\r
+                  jaa = new jalview.datamodel.AlignmentAnnotation(an[i].getLabel(),\r
+                      an[i].getDescription(), anot, 0, 0,\r
+                      an[i].getGraphType());\r
+\r
+                  if (an[i].getThresholdLine() != null)\r
+                  {\r
+                    jaa.setThreshold(new jalview.datamodel.GraphLine(\r
+                                  an[i].getThresholdLine().getValue(),\r
+                                  an[i].getThresholdLine().getLabel(),\r
+                                new java.awt.Color(an[i].getThresholdLine().getColour()))\r
+                             );\r
+\r
+                  }\r
+\r
                 }\r
                 else\r
                 {\r
@@ -807,7 +852,8 @@ public class Jalview2XML
                                 groups[i].getColour());\r
                     }\r
 \r
-                    cs.setThreshold(groups[i].getPidThreshold(), true);\r
+                    if(cs!=null)\r
+                      cs.setThreshold(groups[i].getPidThreshold(), true);\r
                 }\r
 \r
                 Vector seqs = new Vector();\r
@@ -895,6 +941,96 @@ public class Jalview2XML
             {\r
                 cs = GetUserColourScheme(jms, view.getBgColour());\r
             }\r
+            else if(view.getBgColour().startsWith("Annotation"))\r
+            {\r
+              //int find annotation\r
+              for (int i = 0; i < af.viewport.alignment.getAlignmentAnnotation().length; i++)\r
+              {\r
+                if (af.viewport.alignment.getAlignmentAnnotation()[i].label.\r
+                    equals(view.getAnnotationColours().getAnnotation()))\r
+                {\r
+                  if (af.viewport.alignment.getAlignmentAnnotation()[i].\r
+                      getThreshold() == null)\r
+                  {\r
+                    af.viewport.alignment.getAlignmentAnnotation()[i].\r
+                        setThreshold(\r
+                            new jalview.datamodel.GraphLine(\r
+                                view.getAnnotationColours().getThreshold(),\r
+                                "Threshold", java.awt.Color.black)\r
+\r
+                        );\r
+                  }\r
+\r
+\r
+                  if (view.getAnnotationColours().getColourScheme().equals(\r
+                      "None"))\r
+                  {\r
+                    cs = new AnnotationColourGradient(\r
+                        af.viewport.alignment.getAlignmentAnnotation()[i],\r
+                        new java.awt.Color(view.getAnnotationColours().\r
+                                           getMinColour()),\r
+                        new java.awt.Color(view.getAnnotationColours().\r
+                                           getMaxColour()),\r
+                        view.getAnnotationColours().getAboveThreshold());\r
+                  }\r
+                  else if (view.getAnnotationColours().getColourScheme().\r
+                           startsWith("ucs"))\r
+                  {\r
+                     cs = new AnnotationColourGradient(\r
+                         af.viewport.alignment.getAlignmentAnnotation()[i],\r
+                         GetUserColourScheme(jms, view.getAnnotationColours().\r
+                                                        getColourScheme()),\r
+                         view.getAnnotationColours().getAboveThreshold()\r
+                         );\r
+                   }\r
+                   else\r
+                   {\r
+                     cs = new AnnotationColourGradient(\r
+                         af.viewport.alignment.getAlignmentAnnotation()[i],\r
+                         ColourSchemeProperty.getColour(al,\r
+                         view.getAnnotationColours().getColourScheme()),\r
+                         view.getAnnotationColours().getAboveThreshold()\r
+                         );\r
+                   }\r
+\r
+                  // Also use these settings for all the groups\r
+                  if (al.getGroups() != null)\r
+                    for (int g = 0; g < al.getGroups().size(); g++)\r
+                    {\r
+                      jalview.datamodel.SequenceGroup sg\r
+                          = (jalview.datamodel.SequenceGroup)al.getGroups().elementAt(g);\r
+\r
+                      if(sg.cs == null)\r
+                        continue;\r
+\r
+\r
+                  /*    if (view.getAnnotationColours().getColourScheme().equals("None"))\r
+                      {\r
+                        sg.cs = new AnnotationColourGradient(\r
+                            af.viewport.alignment.getAlignmentAnnotation()[i],\r
+                            new java.awt.Color(view.getAnnotationColours().\r
+                                               getMinColour()),\r
+                            new java.awt.Color(view.getAnnotationColours().\r
+                                               getMaxColour()),\r
+                            view.getAnnotationColours().getAboveThreshold());\r
+                      }\r
+                      else*/\r
+                      {\r
+                        sg.cs = new AnnotationColourGradient(\r
+                            af.viewport.alignment.getAlignmentAnnotation()[i],\r
+                            sg.cs,\r
+                            view.getAnnotationColours().getAboveThreshold()\r
+                            );\r
+                      }\r
+\r
+                    }\r
+\r
+\r
+                  break;\r
+                }\r
+\r
+              }\r
+            }\r
             else\r
             {\r
                 cs = ColourSchemeProperty.getColour(al, view.getBgColour());\r