JAL-1641 refactor
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Fri, 12 Jun 2015 16:43:51 +0000 (17:43 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Fri, 12 Jun 2015 16:43:51 +0000 (17:43 +0100)
12 files changed:
src/jalview/api/AlignViewControllerGuiI.java
src/jalview/api/ComplexAlignFile.java [new file with mode: 0644]
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/CutAndPasteTransfer.java
src/jalview/datamodel/Sequence.java
src/jalview/datamodel/SequenceI.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/CutAndPasteTransfer.java
src/jalview/io/AppletFormatAdapter.java
src/jalview/io/FileLoader.java
src/jalview/io/HtmlFile.java
src/jalview/io/JSONFile.java

index b08a0aa..584f596 100644 (file)
  */
 package jalview.api;
 
-import java.util.List;
-
 import jalview.commands.CommandI;
-import jalview.schemes.ColourSchemeI;
 
 /**
  * Interface implemented by gui implementations managing a Jalview Alignment
@@ -44,13 +41,4 @@ public interface AlignViewControllerGuiI
 
   void addHistoryItem(CommandI command);
 
-  void setShowSeqFeatures(boolean show);
-  
-  void setMenusForViewport();
-  
-  void changeColour(ColourSchemeI cs);
-
-  void hideColumns(List<int[]> colsToHide);
-
-  void syncHiddenSequences();
 }
diff --git a/src/jalview/api/ComplexAlignFile.java b/src/jalview/api/ComplexAlignFile.java
new file mode 100644 (file)
index 0000000..0d731cd
--- /dev/null
@@ -0,0 +1,17 @@
+package jalview.api;
+
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.SequenceI;
+import jalview.schemes.ColourSchemeI;
+
+public interface ComplexAlignFile
+{
+  public boolean isShowSeqFeatures();
+
+  public ColourSchemeI getColourScheme();
+
+  public ColumnSelection getColumnSelection();
+
+  public SequenceI[] getHiddenSequences();
+
+}
index 1b1a5b8..1510a14 100644 (file)
@@ -156,6 +156,20 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   public AlignFrame(AlignmentI al, JalviewLite applet,
           String title, boolean embedded, boolean addToDisplay)
   {
+    this(al, null, null, applet, title, embedded, addToDisplay);
+  }
+
+  public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
+          ColumnSelection columnSelection, JalviewLite applet,
+          String title, boolean embedded)
+  {
+    this(al, hiddenSeqs, columnSelection, applet, title, embedded, true);
+  }
+
+  public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
+          ColumnSelection columnSelection, JalviewLite applet,
+          String title, boolean embedded, boolean addToDisplay)
+  {
     if (applet != null)
     {
       jalviewServletURL = applet.getParameter("APPLICATION_URL");
@@ -191,6 +205,17 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       }
     }
     viewport = new AlignViewport(al, applet);
+
+    if (hiddenSeqs != null && hiddenSeqs.length > 0)
+    {
+      viewport.hideSequence(hiddenSeqs);
+      viewport.setHasHiddenRows(true);
+    }
+    if (columnSelection != null)
+    {
+      viewport.setColumnSelection(columnSelection);
+    }
+
     alignPanel = new AlignmentPanel(this, viewport);
     avc = new jalview.controller.AlignViewController(this, viewport,
             alignPanel);
@@ -4182,32 +4207,4 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   {
     this.splitFrame = sf;
   }
-
-  @Override
-  public void setShowSeqFeatures(boolean b)
-  {
-    this.sequenceFeatures.setState(b);
-    viewport.setShowSequenceFeatures(b);
-  }
-
-  @Override
-  public void setMenusForViewport()
-  {
-    // setMenusFromViewport(viewport);
-
-  }
-
-  @Override
-  public void hideColumns(List<int[]> colsToHide)
-  {
-    // TODO Auto-generated method stub
-
-  }
-
-  @Override
-  public void syncHiddenSequences()
-  {
-    // TODO Auto-generated method stub
-
-  }
 }
index 5b699a6..bb2fa12 100644 (file)
@@ -34,19 +34,20 @@ import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
 
 import jalview.analysis.AlignmentUtils;
+import jalview.api.ComplexAlignFile;
 import jalview.bin.JalviewLite;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentI;
+import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
 import jalview.io.AnnotationFile;
 import jalview.io.AppletFormatAdapter;
 import jalview.io.FileParse;
-import jalview.io.HtmlFile;
 import jalview.io.IdentifyFile;
-import jalview.io.JSONFile;
 import jalview.io.NewickFile;
 import jalview.io.TCoffeeScoreFile;
+import jalview.schemes.ColourSchemeI;
 import jalview.schemes.TCoffeeColourScheme;
 import jalview.util.MessageManager;
 
@@ -249,20 +250,32 @@ public class CutAndPasteTransfer extends Panel implements ActionListener,
       }
       if (newWindow)
       {
-        AlignFrame af = new AlignFrame(al, alignFrame.viewport.applet,
-                "Cut & Paste input - " + format, false);
-        af.statusBar
-                .setText(MessageManager
-                        .getString("label.successfully_pasted_annotation_to_alignment"));
+        AlignFrame af;
 
-        if (source instanceof HtmlFile)
+        if (source instanceof ComplexAlignFile)
         {
-          ((HtmlFile) source).applySettingsToAlignmentView(af);
+          ColumnSelection colSel = ((ComplexAlignFile) source)
+                  .getColumnSelection();
+          SequenceI[] hiddenSeqs = ((ComplexAlignFile) source)
+                  .getHiddenSequences();
+          boolean showSeqFeatures = ((ComplexAlignFile) source)
+                  .isShowSeqFeatures();
+          ColourSchemeI cs = ((ComplexAlignFile) source).getColourScheme();
+          af = new AlignFrame(al, hiddenSeqs, colSel,
+                  alignFrame.viewport.applet, "Cut & Paste input - "
+                          + format, false);
+          af.getAlignViewport().setShowSequenceFeatures(showSeqFeatures);
+          af.changeColour(cs);
         }
-        else if (source instanceof JSONFile)
+        else
         {
-          ((JSONFile) source).applySettingsToAlignmentView(af);
+          af = new AlignFrame(al, alignFrame.viewport.applet,
+                  "Cut & Paste input - " + format, false);
         }
+
+        af.statusBar
+                .setText(MessageManager
+                        .getString("label.successfully_pasted_annotation_to_alignment"));
       }
       else
       {
index 9f328ee..9e93444 100755 (executable)
@@ -59,7 +59,6 @@ public class Sequence implements SequenceI
 
   RNA rna;
 
-  private boolean hidden;
 
   /**
    * This annotation is displayed below the alignment but the positions are tied
@@ -1285,16 +1284,5 @@ public class Sequence implements SequenceI
     return result;
   }
 
-  @Override
-  public boolean isHidden()
-  {
-    return this.hidden;
-  }
-
-  @Override
-  public void setHidden(Boolean hidden)
-  {
-    this.hidden = hidden;
-  }
 
 }
index bd193fb..38ae372 100755 (executable)
@@ -419,17 +419,4 @@ public interface SequenceI
    */
   public List<int[]> getInsertions();
 
-  /**
-   * 
-   * @return returns true if the sequence is hidden
-   */
-  public boolean isHidden();
-
-  /**
-   * 
-   * @param hidden
-   *          visibility status of the sequence
-   */
-  public void setHidden(Boolean hidden);
-
 }
index 8462b8d..db61f77 100644 (file)
@@ -240,6 +240,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     this(al, hiddenColumns, width, height, null);
   }
 
+
   /**
    * Create alignment frame for al with hiddenColumns, a specific width and
    * height, and specific sequenceId
@@ -289,6 +290,29 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     init();
   }
 
+  public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
+          ColumnSelection hiddenColumns, int width, int height)
+  {
+    setSize(width, height);
+
+    if (al.getDataset() == null)
+    {
+      al.setDataset(null);
+    }
+
+    viewport = new AlignViewport(al, hiddenColumns);
+
+    if (hiddenSeqs != null && hiddenSeqs.length > 0)
+    {
+      viewport.hideSequence(hiddenSeqs);
+      viewport.setHasHiddenRows(true);
+    }
+    alignPanel = new AlignmentPanel(this, viewport);
+    addAlignmentPanel(alignPanel, true);
+    init();
+  }
+
+
   /**
    * Make a new AlignFrame from existing alignmentPanels
    * 
@@ -6108,33 +6132,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
   }
 
-  @Override
-  public void hideColumns(List<int[]> colsToHide)
-  {
-    for (int[] colRange : colsToHide)
-    {
-      viewport.hideColumns(colRange[0], colRange[1]);
-    }
-
-  }
-
-  @Override
-  public void syncHiddenSequences()
-  {
-    AlignmentI al = viewport.getAlignment();
-    HiddenSequences hiddenSeqs = al.getHiddenSequences();
-    boolean hasHiddenRows = false;
-    for (SequenceI seq : al.getSequencesArray())
-      {
-        if (seq.isHidden())
-        {
-        hiddenSeqs.hideSequence(seq);
-        hasHiddenRows = true;
-        }
-      }
-    viewport.setHasHiddenRows(hasHiddenRows);
-    firePropertyChange("alignment", null, al.getSequences());
-  }
 }
 
 class PrintThread extends Thread
index 6f15ddf..3d52ee1 100644 (file)
  */
 package jalview.gui;
 
-import jalview.datamodel.Alignment;
-import jalview.io.FileParse;
-import jalview.io.FormatAdapter;
-import jalview.io.HtmlFile;
-import jalview.io.IdentifyFile;
-import jalview.io.JSONFile;
-import jalview.io.JalviewFileChooser;
-import jalview.io.JalviewFileView;
-import jalview.jbgui.GCutAndPasteTransfer;
-import jalview.util.MessageManager;
-
 import java.awt.Toolkit;
 import java.awt.datatransfer.Clipboard;
 import java.awt.datatransfer.DataFlavor;
@@ -45,6 +34,19 @@ import javax.swing.JOptionPane;
 import javax.swing.JPopupMenu;
 import javax.swing.SwingUtilities;
 
+import jalview.api.ComplexAlignFile;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.SequenceI;
+import jalview.io.FileParse;
+import jalview.io.FormatAdapter;
+import jalview.io.IdentifyFile;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.jbgui.GCutAndPasteTransfer;
+import jalview.schemes.ColourSchemeI;
+import jalview.util.MessageManager;
+
 /**
  * Cut'n'paste files into the desktop See JAL-1105
  * 
@@ -218,23 +220,49 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
       }
       else
       {
-        AlignFrame af = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
-                AlignFrame.DEFAULT_HEIGHT);
-        af.currentFileFormat = format;
-        Desktop.addInternalFrame(af, title, AlignFrame.DEFAULT_WIDTH,
-                AlignFrame.DEFAULT_HEIGHT);
-        af.statusBar.setText(MessageManager
-                .getString("label.successfully_pasted_alignment_file"));
 
-        if (source instanceof HtmlFile)
+        AlignFrame af;
+        if (source instanceof ComplexAlignFile)
         {
-          ((HtmlFile) source).applySettingsToAlignmentView(af);
+          ColumnSelection colSel = ((ComplexAlignFile) source)
+                  .getColumnSelection();
+          SequenceI[] hiddenSeqs = ((ComplexAlignFile) source)
+                  .getHiddenSequences();
+          boolean showSeqFeatures = ((ComplexAlignFile) source)
+                  .isShowSeqFeatures();
+          ColourSchemeI cs = ((ComplexAlignFile) source).getColourScheme();
+          af = new AlignFrame(al, hiddenSeqs, colSel,
+                  AlignFrame.DEFAULT_WIDTH,
+                  AlignFrame.DEFAULT_HEIGHT);
+
+          af.getViewport().setShowSequenceFeatures(showSeqFeatures);
+          af.changeColour(cs);
+          // ((HtmlFile) source).applySettingsToAlignmentView(af);
         }
-        else if (source instanceof JSONFile)
+        // else if (source instanceof JSONFile)
+        // {
+        // ColumnSelection colSel = ((JSONFile) source).getColumnSelection();
+        // SequenceI[] hiddenSeqs = ((JSONFile) source).getHiddenSequences();
+        // boolean showSeqFeatures = ((HtmlFile) source).isShowSeqFeatures();
+        // ColourSchemeI cs = ((HtmlFile) source).getColourScheme();
+        // af = new AlignFrame(al, hiddenSeqs, colSel,
+        // AlignFrame.DEFAULT_WIDTH,
+        // AlignFrame.DEFAULT_HEIGHT);
+        // af.getViewport().setShowSequenceFeatures(showSeqFeatures);
+        // af.changeColour(cs);
+        // // ((JSONFile) source).applySettingsToAlignmentView(af);
+        // }
+        else
         {
-          ((JSONFile) source).applySettingsToAlignmentView(af);
+          af = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
+                  AlignFrame.DEFAULT_HEIGHT);
         }
 
+        af.currentFileFormat = format;
+        Desktop.addInternalFrame(af, title, AlignFrame.DEFAULT_WIDTH,
+                AlignFrame.DEFAULT_HEIGHT);
+        af.statusBar.setText(MessageManager
+                .getString("label.successfully_pasted_alignment_file"));
 
         try
         {
index e2cd43a..78aa86b 100755 (executable)
@@ -436,7 +436,6 @@ public class AppletFormatAdapter
       else if (format.equals(JSONFile.FILE_DESC))
       {
         alignFile = new JSONFile(source);
-        // ((JSONFile) afile).setViewport(viewport);
         al = new Alignment(alignFile.getSeqsAsArray());
         alignFile.addAnnotations(al);
         alignFile.addSeqGroups(al);
index a27777f..e27c666 100755 (executable)
  */
 package jalview.io;
 
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+
+import jalview.api.ComplexAlignFile;
 import jalview.datamodel.AlignmentI;
+import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
 import jalview.gui.AlignViewport;
 import jalview.gui.Desktop;
 import jalview.gui.Jalview2XML;
+import jalview.schemes.ColourSchemeI;
 import jalview.structure.StructureSelectionManager;
 import jalview.util.MessageManager;
 
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-
 public class FileLoader implements Runnable
 {
   String file;
@@ -335,26 +338,38 @@ public class FileLoader implements Runnable
           }
           else
           {
-            alignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
-                    AlignFrame.DEFAULT_HEIGHT);
-
-            alignFrame.statusBar.setText(MessageManager.formatMessage(
-                    "label.successfully_loaded_file", new String[]
-                    { title }));
-
             if (!protocol.equals(AppletFormatAdapter.PASTE))
             {
               alignFrame.setFileName(file, format);
             }
-            if (source instanceof HtmlFile)
+            if (source instanceof ComplexAlignFile)
             {
-              ((HtmlFile) source).applySettingsToAlignmentView(alignFrame);
+              ColumnSelection colSel = ((ComplexAlignFile) source)
+                      .getColumnSelection();
+              SequenceI[] hiddenSeqs = ((ComplexAlignFile) source)
+                      .getHiddenSequences();
+              boolean showSeqFeatures = ((ComplexAlignFile) source)
+                      .isShowSeqFeatures();
+              ColourSchemeI cs = ((ComplexAlignFile) source)
+                      .getColourScheme();
+              alignFrame = new AlignFrame(al, hiddenSeqs, colSel,
+                      AlignFrame.DEFAULT_WIDTH,
+                      AlignFrame.DEFAULT_HEIGHT);
+
+              alignFrame.getViewport().setShowSequenceFeatures(
+                      showSeqFeatures);
+              alignFrame.changeColour(cs);
             }
-            else if (source instanceof JSONFile)
+            else
             {
-              ((JSONFile) source).applySettingsToAlignmentView(alignFrame);
+              alignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
+                      AlignFrame.DEFAULT_HEIGHT);
             }
 
+            alignFrame.statusBar.setText(MessageManager.formatMessage(
+                    "label.successfully_loaded_file", new String[]
+                    { title }));
+
             if (raiseGUI)
             {
               // add the window to the GUI
index 3dd937d..73aa5d2 100644 (file)
 package jalview.io;
 
 import java.io.IOException;
-import java.util.List;
 
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 
-import jalview.api.AlignViewControllerGuiI;
+import jalview.api.ComplexAlignFile;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.SequenceI;
 import jalview.schemes.ColourSchemeI;
 
-public class HtmlFile extends AlignFile
+public class HtmlFile extends AlignFile implements ComplexAlignFile
 {
   public static final String FILE_EXT = "html";
 
@@ -41,7 +42,9 @@ public class HtmlFile extends AlignFile
 
   private boolean showSeqFeatures;
 
-  private List<int[]> hiddenColumns;
+  private ColumnSelection columnSelection;
+
+  private SequenceI[] hiddenSequences;
 
   public HtmlFile()
   {
@@ -80,21 +83,14 @@ public class HtmlFile extends AlignFile
       this.annotations = jsonFile.getAnnotations();
       this.showSeqFeatures = jsonFile.isShowSeqFeatures();
       this.colourScheme = jsonFile.getColourScheme();
-      this.hiddenColumns = jsonFile.getHiddenColumns();
+      this.hiddenSequences = jsonFile.getHiddenSequences();
+      this.columnSelection = jsonFile.getColumnSelection();
     } catch (Exception e)
     {
       e.printStackTrace();
     }
   }
 
-  public void applySettingsToAlignmentView(AlignViewControllerGuiI avc)
-  {
-    avc.setShowSeqFeatures(isShowSeqFeatures());
-    avc.changeColour(getColourScheme());
-    avc.setMenusForViewport();
-    avc.hideColumns(hiddenColumns);
-    avc.syncHiddenSequences();
-  }
 
   @Override
   public String print()
@@ -123,4 +119,24 @@ public class HtmlFile extends AlignFile
     this.colourScheme = colourScheme;
   }
 
+  public ColumnSelection getColumnSelection()
+  {
+    return columnSelection;
+  }
+
+  public void setColumnSelection(ColumnSelection columnSelection)
+  {
+    this.columnSelection = columnSelection;
+  }
+
+  public SequenceI[] getHiddenSequences()
+  {
+    return hiddenSequences;
+  }
+
+  public void setHiddenSequences(SequenceI[] hiddenSequences)
+  {
+    this.hiddenSequences = hiddenSequences;
+  }
+
 }
index 621604c..39d713d 100644 (file)
@@ -33,17 +33,20 @@ import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 import org.json.simple.parser.JSONParser;
 
-import jalview.api.AlignViewControllerGuiI;
 import jalview.api.AlignViewportI;
+import jalview.api.ComplexAlignFile;
 import jalview.api.FeatureRenderer;
 import jalview.api.FeaturesDisplayedI;
 import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
 import jalview.datamodel.Annotation;
+import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.HiddenSequences;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
+import jalview.gui.AlignViewport;
 import jalview.json.binding.v1.AlignmentAnnotationPojo;
 import jalview.json.binding.v1.AlignmentPojo;
 import jalview.json.binding.v1.AlignmentPojo.JalviewBioJsColorSchemeMapper;
@@ -54,7 +57,7 @@ import jalview.json.binding.v1.SequencePojo;
 import jalview.schemes.ColourSchemeI;
 import jalview.schemes.ColourSchemeProperty;
 
-public class JSONFile extends AlignFile
+public class JSONFile extends AlignFile implements ComplexAlignFile
 {
   private ColourSchemeI colourScheme;
 
@@ -82,8 +85,12 @@ public class JSONFile extends AlignFile
 
   private List<int[]> hiddenColumns;
 
+  private ColumnSelection columnSelection;
+
   private List<String> hiddenSeqRefs;
 
+  private ArrayList<SequenceI> hiddenSequences;
+
   public JSONFile()
   {
     super();
@@ -234,11 +241,9 @@ public class JSONFile extends AlignFile
       return null;
     }
 
-    System.out.println("--- Hidden Sections ---");
     // hidden column business
     if (getViewport().hasHiddenColumns())
     {
-      System.out.print("Hidden Cols : ");
       List<int[]> hiddenCols = getViewport().getColumnSelection()
               .getHiddenColumns();
       StringBuilder hiddenColsBuilder = new StringBuilder();
@@ -250,7 +255,6 @@ public class JSONFile extends AlignFile
 
       hiddenColsBuilder.deleteCharAt(0);
       hiddenSections[0] = hiddenColsBuilder.toString();
-      System.out.println(hiddenSections[0]);
     }
 
     // hidden rows/seqs business
@@ -390,6 +394,7 @@ public class JSONFile extends AlignFile
         parseHiddenCols(jvSettingsJsonObj);
       }
 
+      hiddenSequences = new ArrayList<SequenceI>();
       seqMap = new Hashtable<String, Sequence>();
       for (Iterator<JSONObject> sequenceIter = seqJsonArray.iterator(); sequenceIter
               .hasNext();)
@@ -404,7 +409,7 @@ public class JSONFile extends AlignFile
                 end);
         if (hiddenSeqRefs != null && hiddenSeqRefs.contains(seqUniqueId))
         {
-          seq.setHidden(true);
+          hiddenSequences.add(seq);
         }
         seqs.add(seq);
         seqMap.put(seqUniqueId, seq);
@@ -513,14 +518,17 @@ public class JSONFile extends AlignFile
 
   public void parseHiddenCols(JSONObject jvSettingsJson)
   {
-    hiddenColumns = new ArrayList<int[]>();
+    // hiddenColumns = new ArrayList<int[]>();
     String hiddenCols = (String) jvSettingsJson.get("hiddenCols");
     if(hiddenCols != null && !hiddenCols.isEmpty()){
+      columnSelection = new ColumnSelection();
       String[] rangeStrings = hiddenCols.split(";");
       for(String rangeString : rangeStrings){
         String[] range = rangeString.split("-");
-        hiddenColumns.add(new int[]
-        { Integer.valueOf(range[0]), Integer.valueOf(range[1]) });
+        // hiddenColumns.add(new int[]
+        // { Integer.valueOf(range[0]), Integer.valueOf(range[1]) });
+        columnSelection.hideColumns(Integer.valueOf(range[0]),
+                Integer.valueOf(range[1]));
       }
     }
   }
@@ -584,13 +592,12 @@ public class JSONFile extends AlignFile
     return jalviewColor;
   }
 
-  public void applySettingsToAlignmentView(AlignViewControllerGuiI avc)
+  public AlignViewportI getViewport(AlignmentI al)
   {
-    avc.setShowSeqFeatures(isShowSeqFeatures());
-    avc.changeColour(getColourScheme());
-    avc.setMenusForViewport();
-    avc.hideColumns(hiddenColumns);
-    avc.syncHiddenSequences();
+    AlignViewportI viewport = new AlignViewport(al, getColumnSelection());
+    viewport.setGlobalColourScheme(getColourScheme());
+    viewport.setShowSequenceFeatures(isShowSeqFeatures());
+    return viewport;
   }
 
   public String getGlobalColorScheme()
@@ -633,6 +640,7 @@ public class JSONFile extends AlignFile
     this.jsonExportSettings = jsonExportSettings;
   }
 
+
   public static String getJSONData(AlignViewportI av)
   {
     JSONFile jsonFile = new JSONFile();
@@ -682,6 +690,34 @@ public class JSONFile extends AlignFile
     return hiddenColumns;
   }
 
+  public ColumnSelection getColumnSelection()
+  {
+    return columnSelection;
+  }
+
+  public void setColumnSelection(ColumnSelection columnSelection)
+  {
+    this.columnSelection = columnSelection;
+  }
+
+  public SequenceI[] getHiddenSequences()
+  {
+    if (hiddenSequences == null || hiddenSequences.isEmpty())
+    {
+      return new SequenceI[]
+      {};
+    }
+    synchronized (hiddenSequences)
+    {
+      return hiddenSequences.toArray(new SequenceI[hiddenSequences.size()]);
+    }
+  }
+
+  public void setHiddenSequences(ArrayList<SequenceI> hiddenSequences)
+  {
+    this.hiddenSequences = hiddenSequences;
+  }
+
   public class JSONExportSettings
   {
     private boolean exportSequence;