Merge remote-tracking branch 'origin/releases/Release_2_10_2b1_Branch'
[jalview.git] / src / jalview / io / JSONFile.java
index c293cd4..5d9c804 100644 (file)
@@ -218,9 +218,8 @@ public class JSONFile extends AlignFile implements ComplexAlignFile
         // are not exported
         if (globalColourScheme
                 .equalsIgnoreCase(JalviewColourScheme.RNAHelices.toString())
-                || globalColourScheme
-                        .equalsIgnoreCase(JalviewColourScheme.TCoffee
-                                .toString()))
+                || globalColourScheme.equalsIgnoreCase(
+                        JalviewColourScheme.TCoffee.toString()))
         {
           jsonAlignmentPojo.setGlobalColorScheme(ResidueColourScheme.NONE);
         }
@@ -342,9 +341,10 @@ public class JSONFile extends AlignFile implements ComplexAlignFile
           SequenceFeaturesPojo jsonFeature = new SequenceFeaturesPojo(
                   String.valueOf(seq.hashCode()));
 
-          String featureColour = (fr == null) ? null : jalview.util.Format
-                  .getHexString(finder.findFeatureColour(Color.white, seq,
-                          seq.findIndex(sf.getBegin())));
+          String featureColour = (fr == null) ? null
+                  : jalview.util.Format.getHexString(
+                          finder.findFeatureColour(Color.white, seq,
+                                  seq.findIndex(sf.getBegin())));
           jsonFeature.setXstart(seq.findIndex(sf.getBegin()) - 1);
           jsonFeature.setXend(seq.findIndex(sf.getEnd()));
           jsonFeature.setType(sf.getType());
@@ -409,8 +409,8 @@ public class JSONFile extends AlignFile implements ComplexAlignFile
           annotationPojo.setDisplayCharacter(displayChar);
           if (annotation.colour != null)
           {
-            annotationPojo.setColour(jalview.util.Format
-                    .getHexString(annotation.colour));
+            annotationPojo.setColour(
+                    jalview.util.Format.getHexString(annotation.colour));
           }
           alignAnnotPojo.getAnnotations().add(annotationPojo);
         }
@@ -454,8 +454,8 @@ public class JSONFile extends AlignFile implements ComplexAlignFile
       {
         globalColourScheme = (String) jvSettingsJsonObj
                 .get("globalColorScheme");
-        Boolean showFeatures = Boolean.valueOf(jvSettingsJsonObj.get(
-                "showSeqFeatures").toString());
+        Boolean showFeatures = Boolean.valueOf(
+                jvSettingsJsonObj.get("showSeqFeatures").toString());
         setShowSeqFeatures(showFeatures);
         parseHiddenSeqRefsAsList(jvSettingsJsonObj);
         parseHiddenCols(jvSettingsJsonObj);
@@ -463,8 +463,8 @@ public class JSONFile extends AlignFile implements ComplexAlignFile
 
       hiddenSequences = new ArrayList<>();
       seqMap = new Hashtable<>();
-      for (Iterator<JSONObject> sequenceIter = seqJsonArray.iterator(); sequenceIter
-              .hasNext();)
+      for (Iterator<JSONObject> sequenceIter = seqJsonArray
+              .iterator(); sequenceIter.hasNext();)
       {
         JSONObject sequence = sequenceIter.next();
         String sequcenceString = sequence.get("seq").toString();
@@ -484,22 +484,22 @@ public class JSONFile extends AlignFile implements ComplexAlignFile
 
       parseFeatures(jsonSeqArray);
 
-      for (Iterator<JSONObject> seqGrpIter = seqGrpJsonArray.iterator(); seqGrpIter
-              .hasNext();)
+      for (Iterator<JSONObject> seqGrpIter = seqGrpJsonArray
+              .iterator(); seqGrpIter.hasNext();)
       {
         JSONObject seqGrpObj = seqGrpIter.next();
         String grpName = seqGrpObj.get("groupName").toString();
         String colourScheme = seqGrpObj.get("colourScheme").toString();
         String description = (seqGrpObj.get("description") == null) ? null
                 : seqGrpObj.get("description").toString();
-        boolean displayBoxes = Boolean.valueOf(seqGrpObj
-                .get("displayBoxes").toString());
-        boolean displayText = Boolean.valueOf(seqGrpObj.get("displayText")
-                .toString());
-        boolean colourText = Boolean.valueOf(seqGrpObj.get("colourText")
-                .toString());
-        boolean showNonconserved = Boolean.valueOf(seqGrpObj.get(
-                "showNonconserved").toString());
+        boolean displayBoxes = Boolean
+                .valueOf(seqGrpObj.get("displayBoxes").toString());
+        boolean displayText = Boolean
+                .valueOf(seqGrpObj.get("displayText").toString());
+        boolean colourText = Boolean
+                .valueOf(seqGrpObj.get("colourText").toString());
+        boolean showNonconserved = Boolean
+                .valueOf(seqGrpObj.get("showNonconserved").toString());
         int startRes = Integer
                 .valueOf(seqGrpObj.get("startRes").toString());
         int endRes = Integer.valueOf(seqGrpObj.get("endRes").toString());
@@ -521,23 +521,23 @@ public class JSONFile extends AlignFile implements ComplexAlignFile
         }
         SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName, null,
                 displayBoxes, displayText, colourText, startRes, endRes);
-        seqGrp.setColourScheme(ColourSchemeMapper.getJalviewColourScheme(
-                colourScheme, seqGrp));
+        seqGrp.setColourScheme(ColourSchemeMapper
+                .getJalviewColourScheme(colourScheme, seqGrp));
         seqGrp.setShowNonconserved(showNonconserved);
         seqGrp.setDescription(description);
         this.seqGroups.add(seqGrp);
 
       }
 
-      for (Iterator<JSONObject> alAnnotIter = alAnnotJsonArray.iterator(); alAnnotIter
-              .hasNext();)
+      for (Iterator<JSONObject> alAnnotIter = alAnnotJsonArray
+              .iterator(); alAnnotIter.hasNext();)
       {
         JSONObject alAnnot = alAnnotIter.next();
         JSONArray annotJsonArray = (JSONArray) alAnnot.get("annotations");
         Annotation[] annotations = new Annotation[annotJsonArray.size()];
         int count = 0;
-        for (Iterator<JSONObject> annotIter = annotJsonArray.iterator(); annotIter
-                .hasNext();)
+        for (Iterator<JSONObject> annotIter = annotJsonArray
+                .iterator(); annotIter.hasNext();)
         {
           JSONObject annot = annotIter.next();
           if (annot == null)
@@ -546,59 +546,64 @@ public class JSONFile extends AlignFile implements ComplexAlignFile
           }
           else
           {
-            float val = annot.get("value") == null ? null : Float
-                    .valueOf(annot.get("value").toString());
-            String desc = annot.get("description") == null ? null : annot
-                    .get("description").toString();
+            float val = annot.get("value") == null ? null
+                    : Float.valueOf(annot.get("value").toString());
+            String desc = annot.get("description") == null ? null
+                    : annot.get("description").toString();
             char ss = annot.get("secondaryStructure") == null
                     || annot.get("secondaryStructure").toString()
-                            .equalsIgnoreCase("u0000") ? ' ' : annot
-                    .get("secondaryStructure").toString().charAt(0);
+                            .equalsIgnoreCase("u0000") ? ' '
+                                    : annot.get("secondaryStructure")
+                                            .toString().charAt(0);
             String displayChar = annot.get("displayCharacter") == null ? ""
                     : annot.get("displayCharacter").toString();
 
             annotations[count] = new Annotation(displayChar, desc, ss, val);
             if (annot.get("colour") != null)
             {
-              Color color = ColorUtils.parseColourString(annot.get(
-                      "colour").toString());
+              Color color = ColorUtils
+                      .parseColourString(annot.get("colour").toString());
               annotations[count].colour = color;
             }
           }
           ++count;
         }
 
-        AlignmentAnnotation alignAnnot = new AlignmentAnnotation(alAnnot
-                .get("label").toString(), alAnnot.get("description")
-                .toString(), annotations);
-        alignAnnot.graph = (alAnnot.get("graphType") == null) ? 0 : Integer
-                .valueOf(alAnnot.get("graphType").toString());
+        AlignmentAnnotation alignAnnot = new AlignmentAnnotation(
+                alAnnot.get("label").toString(),
+                alAnnot.get("description").toString(), annotations);
+        alignAnnot.graph = (alAnnot.get("graphType") == null) ? 0
+                : Integer.valueOf(alAnnot.get("graphType").toString());
 
         JSONObject diplaySettings = (JSONObject) alAnnot
                 .get("annotationSettings");
         if (diplaySettings != null)
         {
 
-          alignAnnot.scaleColLabel = (diplaySettings.get("scaleColLabel") == null) ? false
-                  : Boolean.valueOf(diplaySettings.get("scaleColLabel")
-                          .toString());
+          alignAnnot.scaleColLabel = (diplaySettings
+                  .get("scaleColLabel") == null) ? false
+                          : Boolean.valueOf(diplaySettings
+                                  .get("scaleColLabel").toString());
           alignAnnot.showAllColLabels = (diplaySettings
-                  .get("showAllColLabels") == null) ? true : Boolean
-                  .valueOf(diplaySettings.get("showAllColLabels")
-                          .toString());
+                  .get("showAllColLabels") == null) ? true
+                          : Boolean.valueOf(diplaySettings
+                                  .get("showAllColLabels").toString());
           alignAnnot.centreColLabels = (diplaySettings
                   .get("centreColLabels") == null) ? true
-                  : Boolean.valueOf(diplaySettings.get("centreColLabels")
-                          .toString());
-          alignAnnot.belowAlignment = (diplaySettings.get("belowAlignment") == null) ? false
-                  : Boolean.valueOf(diplaySettings.get("belowAlignment")
-                          .toString());
-          alignAnnot.visible = (diplaySettings.get("visible") == null) ? true
-                  : Boolean.valueOf(diplaySettings.get("visible")
-                          .toString());
-          alignAnnot.hasIcons = (diplaySettings.get("hasIcon") == null) ? true
-                  : Boolean.valueOf(diplaySettings.get("hasIcon")
-                          .toString());
+                          : Boolean.valueOf(diplaySettings
+                                  .get("centreColLabels").toString());
+          alignAnnot.belowAlignment = (diplaySettings
+                  .get("belowAlignment") == null) ? false
+                          : Boolean.valueOf(diplaySettings
+                                  .get("belowAlignment").toString());
+          alignAnnot.visible = (diplaySettings.get("visible") == null)
+                  ? true
+                  : Boolean.valueOf(
+                          diplaySettings.get("visible").toString());
+          alignAnnot.hasIcons = (diplaySettings.get("hasIcon") == null)
+                  ? true
+                  : Boolean.valueOf(
+                          diplaySettings.get("hasIcon").toString());
 
         }
         if (alAnnot.get("score") != null)
@@ -607,11 +612,12 @@ public class JSONFile extends AlignFile implements ComplexAlignFile
                   .valueOf(alAnnot.get("score").toString());
         }
 
-        String calcId = (alAnnot.get("calcId") == null) ? "" : alAnnot.get(
-                "calcId").toString();
+        String calcId = (alAnnot.get("calcId") == null) ? ""
+                : alAnnot.get("calcId").toString();
         alignAnnot.setCalcId(calcId);
-        String seqHash = (alAnnot.get("sequenceRef") != null) ? alAnnot
-                .get("sequenceRef").toString() : null;
+        String seqHash = (alAnnot.get("sequenceRef") != null)
+                ? alAnnot.get("sequenceRef").toString()
+                : null;
 
         Sequence sequence = (seqHash != null) ? seqMap.get(seqHash) : null;
         if (sequence != null)
@@ -673,8 +679,8 @@ public class JSONFile extends AlignFile implements ComplexAlignFile
     if (jsonSeqFeatures != null)
     {
       displayedFeatures = new FeaturesDisplayed();
-      for (Iterator<JSONObject> seqFeatureItr = jsonSeqFeatures.iterator(); seqFeatureItr
-              .hasNext();)
+      for (Iterator<JSONObject> seqFeatureItr = jsonSeqFeatures
+              .iterator(); seqFeatureItr.hasNext();)
       {
         JSONObject jsonFeature = seqFeatureItr.next();
         Long begin = (Long) jsonFeature.get("xStart");
@@ -757,8 +763,8 @@ public class JSONFile extends AlignFile implements ComplexAlignFile
         }
       }
     }
-    globalColourScheme = ColourSchemeProperty.getColourName(viewport
-            .getGlobalColourScheme());
+    globalColourScheme = ColourSchemeProperty
+            .getColourName(viewport.getGlobalColourScheme());
     setDisplayedFeatures(viewport.getFeaturesDisplayed());
     showSeqFeatures = viewport.isShowSequenceFeatures();