JAL-1641 refactored out view settings from Desktop.java features/JAL-1641_JSON
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Fri, 8 May 2015 16:13:48 +0000 (17:13 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Fri, 8 May 2015 16:13:48 +0000 (17:13 +0100)
src/jalview/gui/CutAndPasteTransfer.java
src/jalview/gui/Desktop.java
src/jalview/io/JSONFile.java

index 10aa994..6511cd8 100644 (file)
@@ -23,6 +23,7 @@ package jalview.gui;
 import jalview.datamodel.Alignment;
 import jalview.io.FormatAdapter;
 import jalview.io.IdentifyFile;
+import jalview.io.JSONFile;
 import jalview.io.JalviewFileChooser;
 import jalview.io.JalviewFileView;
 import jalview.jbgui.GCutAndPasteTransfer;
@@ -219,9 +220,9 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
         af.statusBar.setText(MessageManager
                 .getString("label.successfully_pasted_alignment_file"));
 
-        af.setShowSeqFeatures(Desktop.isCurrentSeqFeaturesVisible());
+        af.setShowSeqFeatures(JSONFile.isSeqFeaturesEnabled());
 
-        af.changeColour(Desktop.getCurrentGlobalColourScheme());
+        af.changeColour(JSONFile.getColourScheme());
         af.setMenusForViewport();
 
         try
index 5038e4d..9e5bbff 100644 (file)
@@ -26,11 +26,11 @@ import jalview.bin.Cache;
 import jalview.io.FileLoader;
 import jalview.io.FormatAdapter;
 import jalview.io.IdentifyFile;
+import jalview.io.JSONFile;
 import jalview.io.JalviewFileChooser;
 import jalview.io.JalviewFileView;
 import jalview.jbgui.GSplitFrame;
 import jalview.jbgui.GStructureViewer;
-import jalview.schemes.ColourSchemeI;
 import jalview.structure.StructureSelectionManager;
 import jalview.util.ImageMaker;
 import jalview.util.MessageManager;
@@ -172,10 +172,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
   private static AlignFrame currentAlignFrame;
 
-  private static ColourSchemeI currentGlobalColourScheme;
-
-  private static boolean currentSeqFeaturesVisible;
-
   public static jalview.ws.jws1.Discoverer discoverer;
 
   public static Object[] jalviewClipboard;
@@ -1029,11 +1025,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       {
         new FileLoader().LoadFile(viewport, choice, FormatAdapter.FILE,
                 format);
-        viewport.setShowSequenceFeatures(isCurrentSeqFeaturesVisible());
+        viewport.setShowSequenceFeatures(JSONFile.isSeqFeaturesEnabled());
         AlignFrame af = viewport.getAlignPanel().alignFrame;
         if (af != null)
         {
-          af.changeColour(getCurrentGlobalColourScheme());
+          af.changeColour(JSONFile.getColourScheme());
           af.setMenusForViewport();
         }
       }
@@ -3098,26 +3094,5 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     Desktop.currentAlignFrame = currentAlignFrame;
   }
 
-  public static ColourSchemeI getCurrentGlobalColourScheme()
-  {
-    return currentGlobalColourScheme;
-  }
-
-  public static void setCurrentGlobalColourScheme(
-          ColourSchemeI currentGlobalColourScheme)
-  {
-    Desktop.currentGlobalColourScheme = currentGlobalColourScheme;
-  }
-
-  public static boolean isCurrentSeqFeaturesVisible()
-  {
-    return currentSeqFeaturesVisible;
-  }
-
-  public static void setCurrentSeqFeaturesVisible(
-          boolean currentSeqFeaturesVisible)
-  {
-    Desktop.currentSeqFeaturesVisible = currentSeqFeaturesVisible;
-  }
 
 }
index 7278157..26ffb7c 100644 (file)
@@ -34,7 +34,9 @@ import org.json.simple.parser.JSONParser;
 
 public class JSONFile extends AlignFile
 {
-  private ColourSchemeI cs;
+  private static ColourSchemeI colourScheme;
+
+  private static boolean seqFeaturesEnabled;
 
   private String jalviewVersion;
 
@@ -272,12 +274,13 @@ public class JSONFile extends AlignFile
                 .get("globalColorScheme");
         Boolean showFeatures = Boolean.valueOf(jvSettingsJsonObj.get(
                 "showSeqFeatures").toString());
-        cs = getJalviewColorScheme(jsColourScheme);
-        Desktop.setCurrentSeqFeaturesVisible(showFeatures);
+        setColourScheme(getJalviewColorScheme(jsColourScheme));
+        JSONFile.setSeqFeaturesEnabled(showFeatures);
+        // Desktop.setCurrentSeqFeaturesVisible(showFeatures);
       }
 
       seqMap = new Hashtable<String, Sequence>();
-      Desktop.setCurrentGlobalColourScheme(cs);
+      // Desktop.setCurrentGlobalColourScheme(cs);
       for (Iterator<JSONObject> sequenceIter = seqJsonArray.iterator(); sequenceIter
               .hasNext();)
       {
@@ -443,8 +446,8 @@ public class JSONFile extends AlignFile
 
   public void LoadAlignmentFeatures(AlignFrame af)
   {
-    af.setShowSeqFeatures(Desktop.isCurrentSeqFeaturesVisible());
-    af.changeColour(Desktop.getCurrentGlobalColourScheme());
+    af.setShowSeqFeatures(JSONFile.isSeqFeaturesEnabled());
+    af.changeColour(getColourScheme());
     af.setMenusForViewport();
   }
 
@@ -458,6 +461,26 @@ public class JSONFile extends AlignFile
     this.globalColorScheme = globalColorScheme;
   }
 
+  public static ColourSchemeI getColourScheme()
+  {
+    return colourScheme;
+  }
+
+  public static void setColourScheme(ColourSchemeI colourScheme)
+  {
+    JSONFile.colourScheme = colourScheme;
+  }
+
+  public static boolean isSeqFeaturesEnabled()
+  {
+    return seqFeaturesEnabled;
+  }
+
+  public static void setSeqFeaturesEnabled(boolean seqFeaturesEnabled)
+  {
+    JSONFile.seqFeaturesEnabled = seqFeaturesEnabled;
+  }
+
   public class JSONExportSettings
   {
     private boolean exportSequence;