(JAL-969) refactored alignmentViewport base class to own package and pulled up most...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 27 Oct 2011 11:28:12 +0000 (12:28 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 27 Oct 2011 11:28:12 +0000 (12:28 +0100)
59 files changed:
src/jalview/appletgui/APopupMenu.java
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/AlignViewport.java
src/jalview/appletgui/AlignmentPanel.java
src/jalview/appletgui/AnnotationColourChooser.java
src/jalview/appletgui/AnnotationLabels.java
src/jalview/appletgui/AnnotationPanel.java
src/jalview/appletgui/CutAndPasteTransfer.java
src/jalview/appletgui/FeatureRenderer.java
src/jalview/appletgui/FeatureSettings.java
src/jalview/appletgui/IdCanvas.java
src/jalview/appletgui/IdPanel.java
src/jalview/appletgui/OverviewPanel.java
src/jalview/appletgui/PCAPanel.java
src/jalview/appletgui/PaintRefresher.java
src/jalview/appletgui/PairwiseAlignPanel.java
src/jalview/appletgui/RedundancyPanel.java
src/jalview/appletgui/RotatableCanvas.java
src/jalview/appletgui/ScalePanel.java
src/jalview/appletgui/SeqCanvas.java
src/jalview/appletgui/SeqPanel.java
src/jalview/appletgui/SequenceRenderer.java
src/jalview/appletgui/SliderPanel.java
src/jalview/appletgui/TreeCanvas.java
src/jalview/appletgui/TreePanel.java
src/jalview/datamodel/AlignmentViewport.java [deleted file]
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/AnnotationColourChooser.java
src/jalview/gui/AnnotationExporter.java
src/jalview/gui/AnnotationLabels.java
src/jalview/gui/AnnotationPanel.java
src/jalview/gui/Desktop.java
src/jalview/gui/FeatureRenderer.java
src/jalview/gui/FeatureSettings.java
src/jalview/gui/Finder.java
src/jalview/gui/IdCanvas.java
src/jalview/gui/IdPanel.java
src/jalview/gui/Jalview2XML.java
src/jalview/gui/Jalview2XML_V1.java
src/jalview/gui/OverviewPanel.java
src/jalview/gui/PCAPanel.java
src/jalview/gui/PaintRefresher.java
src/jalview/gui/PairwiseAlignPanel.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/RNAHelicesColourChooser.java
src/jalview/gui/RedundancyPanel.java
src/jalview/gui/RotatableCanvas.java
src/jalview/gui/ScalePanel.java
src/jalview/gui/SeqCanvas.java
src/jalview/gui/SeqPanel.java
src/jalview/gui/SequenceFetcher.java
src/jalview/gui/SequenceRenderer.java
src/jalview/gui/SliderPanel.java
src/jalview/gui/TextColourChooser.java
src/jalview/gui/TreeCanvas.java
src/jalview/gui/TreePanel.java
src/jalview/viewmodel/AlignmentViewport.java [new file with mode: 0644]

index 17bc65f..7a99a20 100755 (executable)
@@ -157,7 +157,7 @@ public class APopupMenu extends java.awt.PopupMenu implements
       showColourText.setState(sg.getColourText());
       showBoxes.setState(sg.getDisplayBoxes());
       displayNonconserved.setState(sg.getShowNonconserved());
-      if (!ap.av.alignment.getGroups().contains(sg))
+      if (!ap.av.getAlignment().getGroups().contains(sg))
       {
         groupMenu.remove(unGroupMenuItem);
       }
@@ -300,12 +300,12 @@ public class APopupMenu extends java.awt.PopupMenu implements
       remove(seqMenu);
     }
 
-    if (!ap.av.hasHiddenRows)
+    if (!ap.av.hasHiddenRows())
     {
       remove(revealAll);
       remove(revealSeq);
     } else {
-      final int index = ap.av.alignment.findIndex(seq);
+      final int index = ap.av.getAlignment().findIndex(seq);
 
       if (ap.av.adjustForHiddenSeqs(index)
               - ap.av.adjustForHiddenSeqs(index - 1) > 1)
@@ -513,8 +513,8 @@ public class APopupMenu extends java.awt.PopupMenu implements
           EditCommand editCommand = new EditCommand("Edit Sequences",
                   EditCommand.REPLACE, dialog.getName().replace(' ',
                           ap.av.getGapCharacter()),
-                  sg.getSequencesAsArray(ap.av.hiddenRepSequences),
-                  sg.getStartRes(), sg.getEndRes() + 1, ap.av.alignment);
+                  sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
+                  sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
 
           ap.alignFrame.addHistoryItem(editCommand);
 
@@ -529,44 +529,9 @@ public class APopupMenu extends java.awt.PopupMenu implements
       Vector regions = new Vector();
       if (sg != null)
       {
-        int start = sg.getStartRes();
-        int end = sg.getEndRes() + 1;
-
-        do
-        {
-          if (ap.av.hasHiddenColumns)
-          {
-            if (start == 0)
-            {
-              start = ap.av.colSel.adjustForHiddenColumns(start);
-            }
-
-            end = ap.av.colSel.getHiddenBoundaryRight(start);
-            if (start == end)
-            {
-              end = sg.getEndRes() + 1;
-            }
-            if (end > sg.getEndRes())
-            {
-              end = sg.getEndRes() + 1;
-            }
-          }
-
-          regions.addElement(new int[]
-          { start, end });
-
-          if (ap.av.hasHiddenColumns)
-          {
-            start = ap.av.colSel.adjustForHiddenColumns(end);
-            start = ap.av.colSel.getHiddenBoundaryLeft(start) + 1;
-          }
-        } while (end < sg.getEndRes());
-
-        int[][] startEnd = new int[regions.size()][2];
-        for (int i = 0; i < regions.size(); i++)
-        {
-          startEnd[i] = (int[]) regions.elementAt(i);
-        }
+        // TODO test change case behaves identically in JvLite
+        int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
+                sg.getEndRes() + 1);
 
         String description;
         int caseChange;
@@ -588,7 +553,7 @@ public class APopupMenu extends java.awt.PopupMenu implements
         }
 
         ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
-                sg.getSequencesAsArray(ap.av.hiddenRepSequences), startEnd,
+                sg.getSequencesAsArray(ap.av.getHiddenRepSequences()), startEnd,
                 caseChange);
 
         ap.alignFrame.addHistoryItem(caseCommand);
@@ -652,6 +617,8 @@ public class APopupMenu extends java.awt.PopupMenu implements
     frame.add(cap);
     jalview.bin.JalviewLite.addFrame(frame,
             "Selection output - " + e.getActionCommand(), 600, 500);
+    // JBPNote: getSelectionAsNewSequence behaviour has changed - this method now returns a full copy of sequence data
+    // TODO consider using getSequenceSelection instead here
 
     cap.setText(new jalview.io.AppletFormatAdapter().formatSequences(
             e.getActionCommand(),
@@ -833,8 +800,8 @@ public class APopupMenu extends java.awt.PopupMenu implements
   {
     SequenceGroup sg = getGroup();
     sg.cs = new ClustalxColourScheme(
-            sg.getSequences(ap.av.hiddenRepSequences),
-            ap.av.alignment.getWidth());
+            sg.getSequences(ap.av.getHiddenRepSequences()),
+            ap.av.getAlignment().getWidth());
     refresh();
   }
 
@@ -897,8 +864,8 @@ public class APopupMenu extends java.awt.PopupMenu implements
     if (abovePIDColour.getState())
     {
       sg.cs.setConsensus(AAFrequency.calculate(
-              sg.getSequences(ap.av.hiddenRepSequences), 0,
-              ap.av.alignment.getWidth()));
+              sg.getSequences(ap.av.getHiddenRepSequences()), 0,
+              ap.av.getAlignment().getWidth()));
       int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
               .getName());
 
@@ -927,8 +894,8 @@ public class APopupMenu extends java.awt.PopupMenu implements
     SequenceGroup sg = getGroup();
     sg.cs = new PIDColourScheme();
     sg.cs.setConsensus(AAFrequency.calculate(
-            sg.getSequences(ap.av.hiddenRepSequences), 0,
-            ap.av.alignment.getWidth()));
+            sg.getSequences(ap.av.getHiddenRepSequences()), 0,
+            ap.av.getAlignment().getWidth()));
     refresh();
   }
 
@@ -939,8 +906,8 @@ public class APopupMenu extends java.awt.PopupMenu implements
     sg.cs = new Blosum62ColourScheme();
 
     sg.cs.setConsensus(AAFrequency.calculate(
-            sg.getSequences(ap.av.hiddenRepSequences), 0,
-            ap.av.alignment.getWidth()));
+            sg.getSequences(ap.av.getHiddenRepSequences()), 0,
+            ap.av.getAlignment().getWidth()));
 
     refresh();
   }
@@ -964,8 +931,8 @@ public class APopupMenu extends java.awt.PopupMenu implements
 
       sg.cs.setConservation(Conservation.calculateConservation("Group",
               ResidueProperties.propHash, 3,
-              sg.getSequences(ap.av.hiddenRepSequences), 0,
-              ap.av.alignment.getWidth(),
+              sg.getSequences(ap.av.getHiddenRepSequences()), 0,
+              ap.av.getAlignment().getWidth(),
               false, ap.av.getConsPercGaps(),false));
       SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
       SliderPanel.showConservationSlider();
@@ -986,7 +953,7 @@ public class APopupMenu extends java.awt.PopupMenu implements
     // this method won't add a new group if it already exists
     if (sg != null)
     {
-      ap.av.alignment.addGroup(sg);
+      ap.av.getAlignment().addGroup(sg);
     }
 
     return sg;
@@ -995,7 +962,7 @@ public class APopupMenu extends java.awt.PopupMenu implements
   void unGroupMenuItem_actionPerformed()
   {
     SequenceGroup sg = ap.av.getSelectionGroup();
-    ap.av.alignment.deleteGroup(sg);
+    ap.av.getAlignment().deleteGroup(sg);
     ap.av.setSelectionGroup(null);
     ap.paintAlignment(true);
   }
index b24488f..3ebc083 100644 (file)
@@ -69,12 +69,12 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     viewport.updateConsensus(alignPanel);\r
 \r
     annotationPanelMenuItem.setState(viewport.showAnnotation);\r
-    displayNonconservedMenuItem.setState(viewport.getShowunconserved());\r
+    displayNonconservedMenuItem.setState(viewport.getShowUnconserved());\r
     followMouseOverFlag.setState(viewport.getFollowHighlight());\r
-    showGroupConsensus.setState(viewport.showGroupConsensus);\r
-    showGroupConservation.setState(viewport.showGroupConservation);\r
-    showConsensusHistogram.setState(viewport.showConsensusHistogram);\r
-    showSequenceLogo.setState(viewport.showSequenceLogo);\r
+    showGroupConsensus.setState(viewport.isShowGroupConsensus());\r
+    showGroupConservation.setState(viewport.isShowGroupConservation());\r
+    showConsensusHistogram.setState(viewport.isShowConsensusHistogram());\r
+    showSequenceLogo.setState(viewport.isShowSequenceLogo());\r
 \r
     seqLimits.setState(viewport.showJVSuffix);\r
 \r
@@ -186,7 +186,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     try\r
     {\r
       featuresFile = new jalview.io.FeaturesFile(file, type)\r
-              .parse(viewport.alignment,\r
+              .parse(viewport.getAlignment(),\r
                       alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureColours,\r
                       featureLinks, true, viewport.applet.getDefaultParameter("relaxedidmatch", false));\r
     } catch (Exception ex)\r
@@ -488,7 +488,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       // Hide everything by the current selection - this is a hack - we do the\r
       // invert and then hide\r
       // first check that there will be visible columns after the invert.\r
-      if ((viewport.colSel != null && viewport.colSel.getSelected() != null && viewport.colSel\r
+      if ((viewport.getColumnSelection() != null && viewport.getColumnSelection().getSelected() != null && viewport.getColumnSelection()\r
               .getSelected().size() > 0)\r
               || (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg\r
                       .getEndRes()))\r
@@ -512,12 +512,12 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 \r
     if (toggleSeqs)\r
     {\r
-      if (sg != null && sg.getSize() != viewport.alignment.getHeight())\r
+      if (sg != null && sg.getSize() != viewport.getAlignment().getHeight())\r
       {\r
         hide = true;\r
         viewport.hideAllSelectedSeqs();\r
       }\r
-      else if (!(toggleCols && viewport.colSel.getSelected().size() > 0))\r
+      else if (!(toggleCols && viewport.getColumnSelection().getSelected().size() > 0))\r
       {\r
         viewport.showAllHiddenSeqs();\r
       }\r
@@ -525,12 +525,12 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 \r
     if (toggleCols)\r
     {\r
-      if (viewport.colSel.getSelected().size() > 0)\r
+      if (viewport.getColumnSelection().getSelected().size() > 0)\r
       {\r
         viewport.hideSelectedColumns();\r
         if (!toggleSeqs)\r
         {\r
-          viewport.selectionGroup = sg;\r
+          viewport.setSelectionGroup(sg);\r
         }\r
       }\r
       else if (!hide)\r
@@ -614,7 +614,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     }\r
     else if (evt.getSource() == autoCalculate)\r
     {\r
-      viewport.autocalculateConsensus = autoCalculate.getState();\r
+      viewport.autoCalculateConsensus = autoCalculate.getState();\r
     }\r
     else if (evt.getSource() == sortByTree)\r
     {\r
@@ -864,7 +864,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     else if (source == alProperties)\r
     {\r
       StringBuffer contents = new jalview.io.AlignmentProperties(\r
-              viewport.alignment).formatAsString();\r
+              viewport.getAlignment()).formatAsString();\r
       CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);\r
       cap.setText(contents.toString());\r
       Frame frame = new Frame();\r
@@ -884,8 +884,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     {\r
       abovePIDThreshold.setState(false);\r
       changeColour(new ClustalxColourScheme(\r
-              viewport.alignment.getSequences(),\r
-              viewport.alignment.getWidth()));\r
+              viewport.getAlignment().getSequences(),\r
+              viewport.getAlignment().getWidth()));\r
     }\r
     else if (source == zappoColour)\r
     {\r
@@ -1032,10 +1032,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   public String outputAnnotations(boolean displayTextbox)\r
   {\r
     String annotation = new AnnotationFile().printAnnotations(\r
-            viewport.showAnnotation ? viewport.alignment\r
-                    .getAlignmentAnnotation() : null, viewport.alignment\r
+            viewport.showAnnotation ? viewport.getAlignment()\r
+                    .getAlignmentAnnotation() : null, viewport.getAlignment()\r
                     .getGroups(),\r
-            ((Alignment) viewport.alignment).alignmentProperties);\r
+            ((Alignment) viewport.getAlignment()).alignmentProperties);\r
 \r
     if (displayTextbox)\r
     {\r
@@ -1072,13 +1072,13 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     if (format.equalsIgnoreCase("Jalview"))\r
     {\r
       features = new FeaturesFile().printJalviewFormat(\r
-              viewport.alignment.getSequencesArray(),\r
+              viewport.getAlignment().getSequencesArray(),\r
               getDisplayedFeatureCols());\r
     }\r
     else\r
     {\r
       features = new FeaturesFile().printGFFFormat(\r
-              viewport.alignment.getSequencesArray(),\r
+              viewport.getAlignment().getSequencesArray(),\r
               getDisplayedFeatureCols());\r
     }\r
 \r
@@ -1254,7 +1254,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       viewport.historyList.push(command);\r
       viewport.redoList.removeAllElements();\r
       updateEditMenuBar();\r
-      viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;\r
+      viewport.updateHiddenColumns();\r
     }\r
   }\r
 \r
@@ -1276,11 +1276,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     command.undoCommand(null);\r
 \r
     AlignViewport originalSource = getOriginatingSource(command);\r
-\r
-    originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;\r
+    // JBPNote Test\r
+    if (originalSource!=viewport) {\r
+      System.err.println("Warning: Viewport object mismatch whilst undoing");\r
+    }\r
+    originalSource.updateHiddenColumns(); //    originalSource.hasHiddenColumns = viewport.getColumnSelection().getHiddenColumns() != null;\r
     updateEditMenuBar();\r
     originalSource.firePropertyChange("alignment", null,\r
-            originalSource.alignment.getSequences());\r
+            originalSource.getAlignment().getSequences());\r
   }\r
 \r
   /**\r
@@ -1301,11 +1304,15 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     command.doCommand(null);\r
 \r
     AlignViewport originalSource = getOriginatingSource(command);\r
-    originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;\r
+    // JBPNote Test\r
+    if (originalSource!=viewport) {\r
+      System.err.println("Warning: Viewport object mismatch whilst re-doing");\r
+    }\r
+    originalSource.updateHiddenColumns(); //sethasHiddenColumns(); = viewport.getColumnSelection().getHiddenColumns() != null;\r
 \r
     updateEditMenuBar();\r
     originalSource.firePropertyChange("alignment", null,\r
-            originalSource.alignment.getSequences());\r
+            originalSource.getAlignment().getSequences());\r
   }\r
 \r
   AlignViewport getOriginatingSource(CommandI command)\r
@@ -1325,7 +1332,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       {\r
         if (comps.elementAt(i) instanceof AlignmentPanel)\r
         {\r
-          if (al == ((AlignmentPanel) comps.elementAt(i)).av.alignment)\r
+          if (al == ((AlignmentPanel) comps.elementAt(i)).av.getAlignment())\r
           {\r
             originalSource = ((AlignmentPanel) comps.elementAt(i)).av;\r
             break;\r
@@ -1340,7 +1347,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       // the current view against the closed view first\r
       if (al != null)\r
       {\r
-        PaintRefresher.validateSequences(al, viewport.alignment);\r
+        PaintRefresher.validateSequences(al, viewport.getAlignment());\r
       }\r
 \r
       originalSource = viewport;\r
@@ -1359,42 +1366,42 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 \r
     if (up)\r
     {\r
-      for (int i = 1; i < viewport.alignment.getHeight(); i++)\r
+      for (int i = 1; i < viewport.getAlignment().getHeight(); i++)\r
       {\r
-        SequenceI seq = viewport.alignment.getSequenceAt(i);\r
+        SequenceI seq = viewport.getAlignment().getSequenceAt(i);\r
         if (!sg.getSequences(null).contains(seq))\r
         {\r
           continue;\r
         }\r
 \r
-        SequenceI temp = viewport.alignment.getSequenceAt(i - 1);\r
+        SequenceI temp = viewport.getAlignment().getSequenceAt(i - 1);\r
         if (sg.getSequences(null).contains(temp))\r
         {\r
           continue;\r
         }\r
 \r
-        viewport.alignment.getSequences().setElementAt(temp, i);\r
-        viewport.alignment.getSequences().setElementAt(seq, i - 1);\r
+        viewport.getAlignment().getSequences().setElementAt(temp, i);\r
+        viewport.getAlignment().getSequences().setElementAt(seq, i - 1);\r
       }\r
     }\r
     else\r
     {\r
-      for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)\r
+      for (int i = viewport.getAlignment().getHeight() - 2; i > -1; i--)\r
       {\r
-        SequenceI seq = viewport.alignment.getSequenceAt(i);\r
-        if (!sg.getSequences(viewport.hiddenRepSequences).contains(seq))\r
+        SequenceI seq = viewport.getAlignment().getSequenceAt(i);\r
+        if (!sg.getSequences(viewport.getHiddenRepSequences()).contains(seq))\r
         {\r
           continue;\r
         }\r
 \r
-        SequenceI temp = viewport.alignment.getSequenceAt(i + 1);\r
-        if (sg.getSequences(viewport.hiddenRepSequences).contains(temp))\r
+        SequenceI temp = viewport.getAlignment().getSequenceAt(i + 1);\r
+        if (sg.getSequences(viewport.getHiddenRepSequences()).contains(temp))\r
         {\r
           continue;\r
         }\r
 \r
-        viewport.alignment.getSequences().setElementAt(temp, i);\r
-        viewport.alignment.getSequences().setElementAt(seq, i + 1);\r
+        viewport.getAlignment().getSequences().setElementAt(temp, i);\r
+        viewport.getAlignment().getSequences().setElementAt(seq, i + 1);\r
       }\r
     }\r
 \r
@@ -1406,15 +1413,15 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     Vector sg = new Vector();\r
     if (viewport.cursorMode)\r
     {\r
-      sg.addElement(viewport.alignment\r
+      sg.addElement(viewport.getAlignment()\r
               .getSequenceAt(alignPanel.seqPanel.seqCanvas.cursorY));\r
     }\r
     else if (viewport.getSelectionGroup() != null\r
-            && viewport.getSelectionGroup().getSize() != viewport.alignment\r
+            && viewport.getSelectionGroup().getSize() != viewport.getAlignment()\r
                     .getHeight())\r
     {\r
       sg = viewport.getSelectionGroup().getSequences(\r
-              viewport.hiddenRepSequences);\r
+              viewport.getHiddenRepSequences());\r
     }\r
 \r
     if (sg.size() < 1)\r
@@ -1424,10 +1431,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 \r
     Vector invertGroup = new Vector();\r
 \r
-    for (int i = 0; i < viewport.alignment.getHeight(); i++)\r
+    for (int i = 0; i < viewport.getAlignment().getHeight(); i++)\r
     {\r
-      if (!sg.contains(viewport.alignment.getSequenceAt(i)))\r
-        invertGroup.addElement(viewport.alignment.getSequenceAt(i));\r
+      if (!sg.contains(viewport.getAlignment().getSequenceAt(i)))\r
+        invertGroup.addElement(viewport.getAlignment().getSequenceAt(i));\r
     }\r
 \r
     SequenceI[] seqs1 = new SequenceI[sg.size()];\r
@@ -1502,14 +1509,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     for (int i = 0; i < sg.getSize(); i++)\r
     {\r
       SequenceI seq = sg.getSequenceAt(i);\r
-      int index = viewport.alignment.findIndex(seq);\r
+      int index = viewport.getAlignment().findIndex(seq);\r
       orderedSeqs.put(index + "", seq);\r
     }\r
 \r
     int index = 0, startRes, endRes;\r
     char ch;\r
 \r
-    if (viewport.hasHiddenColumns && viewport.getSelectionGroup() != null)\r
+    if (viewport.hasHiddenColumns() && viewport.getSelectionGroup() != null)\r
     {\r
       copiedHiddenColumns = new Vector();\r
       int hiddenOffset = viewport.getSelectionGroup().getStartRes();\r
@@ -1656,17 +1663,17 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   {\r
     for (int i = 0; i < seqs.length; i++)\r
     {\r
-      viewport.alignment.addSequence(seqs[i]);\r
+      viewport.getAlignment().addSequence(seqs[i]);\r
     }\r
 \r
     // !newAlignment\r
     addHistoryItem(new EditCommand("Add sequences", EditCommand.PASTE,\r
-            seqs, 0, viewport.alignment.getWidth(), viewport.alignment));\r
+            seqs, 0, viewport.getAlignment().getWidth(), viewport.getAlignment()));\r
 \r
-    viewport.setEndSeq(viewport.alignment.getHeight());\r
-    viewport.alignment.getWidth();\r
+    viewport.setEndSeq(viewport.getAlignment().getHeight());\r
+    viewport.getAlignment().getWidth();\r
     viewport.firePropertyChange("alignment", null,\r
-            viewport.alignment.getSequences());\r
+            viewport.getAlignment().getSequences());\r
 \r
   }\r
 \r
@@ -1694,7 +1701,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     }\r
 \r
     // If the cut affects all sequences, remove highlighted columns\r
-    if (sg.getSize() == viewport.alignment.getHeight())\r
+    if (sg.getSize() == viewport.getAlignment().getHeight())\r
     {\r
       viewport.getColumnSelection().removeElements(sg.getStartRes(),\r
               sg.getEndRes() + 1);\r
@@ -1711,10 +1718,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
      */\r
     addHistoryItem(new EditCommand("Cut Sequences", EditCommand.CUT, cut,\r
             sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1,\r
-            viewport.alignment));\r
+            viewport.getAlignment()));\r
 \r
     viewport.setSelectionGroup(null);\r
-    viewport.alignment.deleteGroup(sg);\r
+    viewport.getAlignment().deleteGroup(sg);\r
 \r
     viewport.firePropertyChange("alignment", null, viewport.getAlignment()\r
             .getSequences());\r
@@ -1784,8 +1791,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
               viewport.getSequenceSelection(),\r
               viewport.getAlignmentView(true).getSequenceStrings(\r
                       viewport.getGapCharacter()),\r
-              viewport.alignment.getGroups());\r
-      viewport.alignment.deleteAllGroups();\r
+              viewport.getAlignment().getGroups());\r
+      viewport.getAlignment().deleteAllGroups();\r
       viewport.sequenceColours = null;\r
       viewport.setSelectionGroup(null);\r
       // set view properties for each group\r
@@ -1793,7 +1800,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       {\r
         // gps[g].setShowunconserved(viewport.getShowUnconserved());\r
         gps[g].setshowSequenceLogo(viewport.isShowSequenceLogo());\r
-        viewport.alignment.addGroup(gps[g]);\r
+        viewport.getAlignment().addGroup(gps[g]);\r
         Color col = new Color((int) (Math.random() * 255),\r
                 (int) (Math.random() * 255), (int) (Math.random() * 255));\r
         col = col.brighter();\r
@@ -1810,7 +1817,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 \r
   protected void deleteGroups_actionPerformed()\r
   {\r
-    viewport.alignment.deleteAllGroups();\r
+    viewport.getAlignment().deleteAllGroups();\r
     viewport.sequenceColours = null;\r
     viewport.setSelectionGroup(null);\r
 \r
@@ -1824,7 +1831,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     {\r
       sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);\r
     }\r
-    sg.setEndRes(viewport.alignment.getWidth() - 1);\r
+    sg.setEndRes(viewport.getAlignment().getWidth() - 1);\r
     viewport.setSelectionGroup(sg);\r
     alignPanel.paintAlignment(true);\r
     PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());\r
@@ -1888,11 +1895,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       if (viewport.getSelectionGroup() != null)\r
       {\r
         seqs = viewport.getSelectionGroup().getSequencesAsArray(\r
-                viewport.hiddenRepSequences);\r
+                viewport.getHiddenRepSequences());\r
       }\r
       else\r
       {\r
-        seqs = viewport.alignment.getSequencesArray();\r
+        seqs = viewport.getAlignment().getSequencesArray();\r
       }\r
 \r
       TrimRegionCommand trimRegion;\r
@@ -1900,23 +1907,23 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       {\r
         trimRegion = new TrimRegionCommand("Remove Left",\r
                 TrimRegionCommand.TRIM_LEFT, seqs, column,\r
-                viewport.alignment, viewport.colSel,\r
-                viewport.selectionGroup);\r
+                viewport.getAlignment(), viewport.getColumnSelection(),\r
+                viewport.getSelectionGroup());\r
         viewport.setStartRes(0);\r
       }\r
       else\r
       {\r
         trimRegion = new TrimRegionCommand("Remove Right",\r
                 TrimRegionCommand.TRIM_RIGHT, seqs, column,\r
-                viewport.alignment, viewport.colSel,\r
-                viewport.selectionGroup);\r
+                viewport.getAlignment(), viewport.getColumnSelection(),\r
+                viewport.getSelectionGroup());\r
       }\r
 \r
       statusBar.setText("Removed " + trimRegion.getSize() + " columns.");\r
 \r
       addHistoryItem(trimRegion);\r
 \r
-      Vector groups = viewport.alignment.getGroups();\r
+      Vector groups = viewport.getAlignment().getGroups();\r
 \r
       for (int i = 0; i < groups.size(); i++)\r
       {\r
@@ -1925,7 +1932,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
         if ((trimLeft && !sg.adjustForRemoveLeft(column))\r
                 || (!trimLeft && !sg.adjustForRemoveRight(column)))\r
         {\r
-          viewport.alignment.deleteGroup(sg);\r
+          viewport.getAlignment().deleteGroup(sg);\r
         }\r
       }\r
 \r
@@ -1936,23 +1943,23 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 \r
   public void removeGappedColumnMenuItem_actionPerformed()\r
   {\r
-    int start = 0, end = viewport.alignment.getWidth() - 1;\r
+    int start = 0, end = viewport.getAlignment().getWidth() - 1;\r
 \r
     SequenceI[] seqs;\r
     if (viewport.getSelectionGroup() != null)\r
     {\r
       seqs = viewport.getSelectionGroup().getSequencesAsArray(\r
-              viewport.hiddenRepSequences);\r
+              viewport.getHiddenRepSequences());\r
       start = viewport.getSelectionGroup().getStartRes();\r
       end = viewport.getSelectionGroup().getEndRes();\r
     }\r
     else\r
     {\r
-      seqs = viewport.alignment.getSequencesArray();\r
+      seqs = viewport.getAlignment().getSequencesArray();\r
     }\r
 \r
     RemoveGapColCommand removeGapCols = new RemoveGapColCommand(\r
-            "Remove Gapped Columns", seqs, start, end, viewport.alignment);\r
+            "Remove Gapped Columns", seqs, start, end, viewport.getAlignment());\r
 \r
     addHistoryItem(removeGapCols);\r
 \r
@@ -1961,7 +1968,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 \r
     // This is to maintain viewport position on first residue\r
     // of first sequence\r
-    SequenceI seq = viewport.alignment.getSequenceAt(0);\r
+    SequenceI seq = viewport.getAlignment().getSequenceAt(0);\r
     int startRes = seq.findPosition(viewport.startRes);\r
     // ShiftList shifts;\r
     // viewport.getAlignment().removeGaps(shifts=new ShiftList());\r
@@ -1976,28 +1983,28 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 \r
   public void removeAllGapsMenuItem_actionPerformed()\r
   {\r
-    int start = 0, end = viewport.alignment.getWidth() - 1;\r
+    int start = 0, end = viewport.getAlignment().getWidth() - 1;\r
 \r
     SequenceI[] seqs;\r
     if (viewport.getSelectionGroup() != null)\r
     {\r
       seqs = viewport.getSelectionGroup().getSequencesAsArray(\r
-              viewport.hiddenRepSequences);\r
+              viewport.getHiddenRepSequences());\r
       start = viewport.getSelectionGroup().getStartRes();\r
       end = viewport.getSelectionGroup().getEndRes();\r
     }\r
     else\r
     {\r
-      seqs = viewport.alignment.getSequencesArray();\r
+      seqs = viewport.getAlignment().getSequencesArray();\r
     }\r
 \r
     // This is to maintain viewport position on first residue\r
     // of first sequence\r
-    SequenceI seq = viewport.alignment.getSequenceAt(0);\r
+    SequenceI seq = viewport.getAlignment().getSequenceAt(0);\r
     int startRes = seq.findPosition(viewport.startRes);\r
 \r
     addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end,\r
-            viewport.alignment));\r
+            viewport.getAlignment()));\r
 \r
     viewport.setStartRes(seq.findIndex(startRes) - 1);\r
 \r
@@ -2020,30 +2027,30 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   public AlignFrame newView(String viewtitle)\r
   {\r
     AlignmentI newal;\r
-    if (viewport.hasHiddenRows)\r
+    if (viewport.hasHiddenRows())\r
     {\r
       newal = new Alignment(viewport.getAlignment().getHiddenSequences()\r
               .getFullAlignment().getSequencesArray());\r
     }\r
     else\r
     {\r
-      newal = new Alignment(viewport.alignment.getSequencesArray());\r
+      newal = new Alignment(viewport.getAlignment().getSequencesArray());\r
     }\r
 \r
-    if (viewport.alignment.getAlignmentAnnotation() != null)\r
+    if (viewport.getAlignment().getAlignmentAnnotation() != null)\r
     {\r
-      for (int i = 0; i < viewport.alignment.getAlignmentAnnotation().length; i++)\r
+      for (int i = 0; i < viewport.getAlignment().getAlignmentAnnotation().length; i++)\r
       {\r
-        if (!viewport.alignment.getAlignmentAnnotation()[i].autoCalculated)\r
+        if (!viewport.getAlignment().getAlignmentAnnotation()[i].autoCalculated)\r
         {\r
-          newal.addAnnotation(viewport.alignment.getAlignmentAnnotation()[i]);\r
+          newal.addAnnotation(viewport.getAlignment().getAlignmentAnnotation()[i]);\r
         }\r
       }\r
     }\r
 \r
     AlignFrame newaf = new AlignFrame(newal, viewport.applet, "", false);\r
 \r
-    newaf.viewport.sequenceSetID = alignPanel.av.getSequenceSetId();\r
+    newaf.viewport.setSequenceSetId(alignPanel.av.getSequenceSetId());\r
     PaintRefresher.Register(alignPanel, alignPanel.av.getSequenceSetId());\r
     PaintRefresher.Register(newaf.alignPanel,\r
             newaf.alignPanel.av.getSequenceSetId());\r
@@ -2223,7 +2230,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       if (viewport.getConservationSelected())\r
       {\r
 \r
-        Alignment al = (Alignment) viewport.alignment;\r
+        Alignment al = (Alignment) viewport.getAlignment();\r
         Conservation c = new Conservation("All",\r
                 ResidueProperties.propHash, 3, al.getSequences(), 0,\r
                 al.getWidth() - 1);\r
@@ -2242,14 +2249,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
         cs.setConservation(null);\r
       }\r
 \r
-      cs.setConsensus(viewport.hconsensus);\r
+      cs.setConsensus(viewport.getSequenceConsensusHash());\r
 \r
     }\r
     viewport.setGlobalColourScheme(cs);\r
 \r
     if (viewport.getColourAppliesToAllGroups())\r
     {\r
-      Vector groups = viewport.alignment.getGroups();\r
+      Vector groups = viewport.getAlignment().getGroups();\r
       for (int i = 0; i < groups.size(); i++)\r
       {\r
         SequenceGroup sg = (SequenceGroup) groups.elementAt(i);\r
@@ -2262,7 +2269,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
         if (cs instanceof ClustalxColourScheme)\r
         {\r
           sg.cs = new ClustalxColourScheme(\r
-                  sg.getSequences(viewport.hiddenRepSequences),\r
+                  sg.getSequences(viewport.getHiddenRepSequences()),\r
                   sg.getWidth());\r
         }\r
         else\r
@@ -2283,7 +2290,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
         {\r
           sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
           sg.cs.setConsensus(AAFrequency.calculate(\r
-                  sg.getSequences(viewport.hiddenRepSequences), 0,\r
+                  sg.getSequences(viewport.getHiddenRepSequences()), 0,\r
                   sg.getWidth()));\r
         }\r
         else\r
@@ -2295,8 +2302,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
         {\r
           Conservation c = new Conservation("Group",\r
                   ResidueProperties.propHash, 3,\r
-                  sg.getSequences(viewport.hiddenRepSequences), 0,\r
-                  viewport.alignment.getWidth() - 1);\r
+                  sg.getSequences(viewport.getHiddenRepSequences()), 0,\r
+                  viewport.getAlignment().getWidth() - 1);\r
           c.calculate();\r
           c.verdict(false, viewport.getConsPercGaps());\r
           sg.cs.setConservation(c);\r
@@ -2325,7 +2332,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   protected void modifyPID_actionPerformed()\r
   {\r
     if (viewport.getAbovePIDThreshold()\r
-            && viewport.globalColourScheme != null)\r
+            && viewport.getGlobalColourScheme() != null)\r
     {\r
       SliderPanel.setPIDSliderSource(alignPanel,\r
               viewport.getGlobalColourScheme(), "Background");\r
@@ -2336,10 +2343,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   protected void modifyConservation_actionPerformed()\r
   {\r
     if (viewport.getConservationSelected()\r
-            && viewport.globalColourScheme != null)\r
+            && viewport.getGlobalColourScheme() != null)\r
     {\r
       SliderPanel.setConservationSlider(alignPanel,\r
-              viewport.globalColourScheme, "Background");\r
+              viewport.getGlobalColourScheme(), "Background");\r
       SliderPanel.showConservationSlider();\r
     }\r
   }\r
@@ -2375,7 +2382,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
             .getAlignment().getSequenceAt(0), null);\r
 \r
     addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,\r
-            viewport.alignment));\r
+            viewport.getAlignment()));\r
     alignPanel.paintAlignment(true);\r
   }\r
 \r
@@ -2383,7 +2390,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   {\r
     SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();\r
     AlignmentSorter.sortByID(viewport.getAlignment());\r
-    addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.alignment));\r
+    addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.getAlignment()));\r
     alignPanel.paintAlignment(true);\r
   }\r
 \r
@@ -2392,7 +2399,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();\r
     AlignmentSorter.sortByLength(viewport.getAlignment());\r
     addHistoryItem(new OrderCommand("Length Sort", oldOrder,\r
-            viewport.alignment));\r
+            viewport.getAlignment()));\r
     alignPanel.paintAlignment(true);\r
   }\r
 \r
@@ -2401,7 +2408,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();\r
     AlignmentSorter.sortByGroup(viewport.getAlignment());\r
     addHistoryItem(new OrderCommand("Group Sort", oldOrder,\r
-            viewport.alignment));\r
+            viewport.getAlignment()));\r
     alignPanel.paintAlignment(true);\r
 \r
   }\r
@@ -2426,7 +2433,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   public void PCAMenuItem_actionPerformed()\r
   {\r
     // are the sequences aligned?\r
-    if (!viewport.alignment.isAligned(false))\r
+    if (!viewport.getAlignment().isAligned(false))\r
     {\r
       SequenceI current;\r
       int Width = viewport.getAlignment().getWidth();\r
@@ -2483,7 +2490,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   void NewTreePanel(String type, String pwType, String title)\r
   {\r
     // are the sequences aligned?\r
-    if (!viewport.alignment.isAligned(false))\r
+    if (!viewport.getAlignment().isAligned(false))\r
     {\r
       SequenceI current;\r
       int Width = viewport.getAlignment().getWidth();\r
@@ -2503,7 +2510,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 \r
     if ((viewport.getSelectionGroup() != null && viewport\r
             .getSelectionGroup().getSize() > 1)\r
-            || (viewport.getSelectionGroup() == null && viewport.alignment\r
+            || (viewport.getSelectionGroup() == null && viewport.getAlignment()\r
                     .getHeight() > 1))\r
     {\r
       final TreePanel tp = new TreePanel(alignPanel, type, pwType);\r
@@ -2547,7 +2554,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     // addHistoryItem(new HistoryItem("Sort", viewport.alignment,\r
     // HistoryItem.SORT));\r
     addHistoryItem(new OrderCommand("Order by " + title, oldOrder,\r
-            viewport.alignment));\r
+            viewport.getAlignment()));\r
     alignPanel.paintAlignment(true);\r
   }\r
 \r
@@ -2599,7 +2606,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     AlignmentSorter.sortBy(viewport.getAlignment(), alorder);\r
     if (undoname!=null)\r
     {\r
-      addHistoryItem(new OrderCommand(undoname, oldOrder, viewport.alignment));\r
+      addHistoryItem(new OrderCommand(undoname, oldOrder, viewport.getAlignment()));\r
     }\r
     alignPanel.paintAlignment(true);\r
     return true;\r
index e48c0ea..ab9a25d 100644 (file)
@@ -29,7 +29,9 @@ import jalview.datamodel.*;
 import jalview.schemes.*;
 import jalview.structure.SelectionSource;
 import jalview.structure.VamsasSource;
+import jalview.viewmodel.AlignmentViewport;
 import jalview.workers.ConservationThread;
+import jalview.workers.ConsensusThread;
 
 public class AlignViewport extends AlignmentViewport implements AlignViewportI, SelectionSource, VamsasSource 
 {
@@ -69,14 +71,10 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
 
   boolean colourAppliesToAllGroups = true;
 
-  ColourSchemeI globalColourScheme = null;
-
   boolean conservationColourSelected = false;
 
   boolean abovePIDThreshold = false;
 
-  SequenceGroup selectionGroup;
-
   int charHeight;
 
   int charWidth;
@@ -87,10 +85,6 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
 
   boolean validCharWidth = true;
 
-  AlignmentI alignment;
-
-  ColumnSelection colSel = new ColumnSelection();
-
   int threshold;
 
   int increment;
@@ -107,31 +101,9 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
   // currently visible, in the correct order or rendering
   public Hashtable featuresDisplayed;
 
-  boolean hasHiddenColumns = false;
-
-  boolean hasHiddenRows = false;
 
   boolean showHiddenMarkers = true;
 
-  public Hashtable[] hconsensus;
-
-  AlignmentAnnotation consensus;
-
-  AlignmentAnnotation conservation;
-
-  AlignmentAnnotation quality;
-
-  AlignmentAnnotation[] groupConsensus;
-
-  AlignmentAnnotation[] groupConservation;
-
-  boolean autocalculateConsensus = true;
-
-  private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
-          this);
-
-  boolean ignoreGapsInConsensusCalculation = false;
-
   public jalview.bin.JalviewLite applet;
 
   Hashtable sequenceColours;
@@ -141,13 +113,7 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
   Stack historyList = new Stack();
 
   Stack redoList = new Stack();
-
-  String sequenceSetID;
-
-  Hashtable hiddenRepSequences;
-  
-  AlignCalcManagerI calculator=new jalview.workers.AlignCalcManager();
-  
+    
   public void finalize() {
     applet=null;
     quality=null;
@@ -157,8 +123,11 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
 
   public AlignViewport(AlignmentI al, JalviewLite applet)
   {
+    calculator = new jalview.workers.AlignCalcManager();
     this.applet = applet;
     setAlignment(al);
+    // we always pad gaps
+    this.setPadGaps(true);
     this.startRes = 0;
     this.endRes = al.getWidth() - 1;
     this.startSeq = 0;
@@ -337,145 +306,6 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
   }
 
 
-  ConsensusThread consensusThread;
-  
-//  StrucConsensusThread strucConsensusThread;
-
-
-  boolean consUpdateNeeded = false;
-
-  static boolean UPDATING_CONSENSUS = false;
-
-  static boolean UPDATING_STRUC_CONSENSUS = false;
-
-  static boolean UPDATING_CONSERVATION = false;
-
-  boolean updatingConsensus = false;
-
-  boolean updatingStrucConsensus = false;
-
-  boolean updatingConservation = false;
-
-  /**
-   * DOCUMENT ME!
-   */
-  public void updateConservation(final AlignmentPanel ap)
-  {
-    if (alignment.isNucleotide() || conservation == null)
-    {
-      return;
-    }
-
-    calculator.startWorker(new ConservationThread(this, ap));
-  }
-
-  /**
-   * DOCUMENT ME!
-   */
-  public void updateConsensus(final AlignmentPanel ap)
-  {
-    consensusThread = new ConsensusThread(ap);
-    consensusThread.start();
-  }
-
-  class ConsensusThread extends Thread
-  {
-    AlignmentPanel ap;
-
-    public ConsensusThread(AlignmentPanel ap)
-    {
-      this.ap = ap;
-    }
-
-    public void run()
-    {
-      updatingConsensus = true;
-      while (UPDATING_CONSENSUS)
-      {
-        try
-        {
-          if (ap != null)
-          {
-            ap.paintAlignment(false);
-          }
-
-          Thread.sleep(200);
-        } catch (Exception ex)
-        {
-          ex.printStackTrace();
-        }
-      }
-
-      UPDATING_CONSENSUS = true;
-
-      try
-      {
-        int aWidth = alignment==null ? -1 : alignment.getWidth();
-        if (aWidth < 0)
-        {
-          UPDATING_CONSENSUS = false;
-          updatingConsensus = false;
-          return;
-        }
-
-        consensus.annotations = null;
-        consensus.annotations = new Annotation[aWidth];
-
-        hconsensus = new Hashtable[aWidth];
-        AAFrequency.calculate(alignment.getSequencesArray(), 0,
-                alignment.getWidth(), hconsensus, true); // always calculate the
-                                                         // full profile
-        updateAnnotation(true);
-        //AAFrequency.completeConsensus(consensus, hconsensus, 0, aWidth,
-        //        ignoreGapsInConsensusCalculation,
-        //        true);
-        
-        if (globalColourScheme != null)
-        {
-          globalColourScheme.setConsensus(hconsensus);
-        }
-
-      } catch (OutOfMemoryError error)
-      {
-        alignment.deleteAnnotation(consensus);
-
-        consensus = null;
-        hconsensus = null;
-        System.out.println("Out of memory calculating consensus!!");
-        System.gc();
-      }
-      UPDATING_CONSENSUS = false;
-      updatingConsensus = false;
-
-      if (ap != null)
-      {
-        ap.paintAlignment(true);
-      }
-    }
-
-    /**
-     * update the consensus annotation from the sequence profile data using
-     * current visualization settings.
-     */
-    public void updateAnnotation()
-    {
-      updateAnnotation(false);
-    }
-
-    protected void updateAnnotation(boolean immediate)
-    {
-      // TODO: make calls thread-safe, so if another thread calls this method,
-      // it will either return or wait until one calculation is finished.
-      if (immediate
-              || (!updatingConsensus && consensus != null && hconsensus != null))
-      {
-        AAFrequency.completeConsensus(consensus, hconsensus, 0,
-                hconsensus.length, ignoreGapsInConsensusCalculation,
-                showSequenceLogo);
-      }
-    }
-  }
-
   /**
    * get the consensus sequence as displayed under the PID consensus annotation
    * row.
@@ -513,16 +343,6 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
     return sq;
   }
 
-  public SequenceGroup getSelectionGroup()
-  {
-    return selectionGroup;
-  }
-
-  public void setSelectionGroup(SequenceGroup sg)
-  {
-    selectionGroup = sg;
-  }
-
   public boolean getConservationSelected()
   {
     return conservationColourSelected;
@@ -558,16 +378,6 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
     return startSeq;
   }
 
-  public void setGlobalColourScheme(ColourSchemeI cs)
-  {
-    globalColourScheme = cs;
-  }
-
-  public ColourSchemeI getGlobalColourScheme()
-  {
-    return globalColourScheme;
-  }
-
   public void setStartRes(int res)
   {
     this.startRes = res;
@@ -756,20 +566,6 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
     return increment;
   }
 
-  public void setHiddenColumns(ColumnSelection colsel)
-  {
-    this.colSel = colsel;
-    if (colSel.getHiddenColumns() != null)
-    {
-      hasHiddenColumns = true;
-    }
-  }
-
-  public ColumnSelection getColumnSelection()
-  {
-    return colSel;
-  }
-
   public void resetSeqLimits(int height)
   {
     setEndSeq(height / getCharHeight());
@@ -857,390 +653,9 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
     }
   }
 
-  /**
-   * Property change listener for changes in alignment
-   * 
-   * @param listener
-   *          DOCUMENT ME!
-   */
-  public void addPropertyChangeListener(
-          java.beans.PropertyChangeListener listener)
-  {
-    changeSupport.addPropertyChangeListener(listener);
-  }
 
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param listener
-   *          DOCUMENT ME!
-   */
-  public void removePropertyChangeListener(
-          java.beans.PropertyChangeListener listener)
-  {
-    changeSupport.removePropertyChangeListener(listener);
-  }
 
-  /**
-   * Property change listener for changes in alignment
-   * 
-   * @param prop
-   *          DOCUMENT ME!
-   * @param oldvalue
-   *          DOCUMENT ME!
-   * @param newvalue
-   *          DOCUMENT ME!
-   */
-  public void firePropertyChange(String prop, Object oldvalue,
-          Object newvalue)
-  {
-    changeSupport.firePropertyChange(prop, oldvalue, newvalue);
-  }
-
-  public boolean getIgnoreGapsConsensus()
-  {
-    return ignoreGapsInConsensusCalculation;
-  }
-
-  public void hideSelectedColumns()
-  {
-    if (colSel.size() < 1)
-    {
-      return;
-    }
-
-    colSel.hideSelectedColumns();
-    setSelectionGroup(null);
-
-    hasHiddenColumns = true;
-  }
-
-  public void invertColumnSelection()
-  {
-    for (int i = 0; i < alignment.getWidth(); i++)
-    {
-      if (colSel.contains(i))
-      {
-        colSel.removeElement(i);
-      }
-      else
-      {
-        if (!hasHiddenColumns || colSel.isVisible(i))
-        {
-          colSel.addElement(i);
-        }
-      }
-    }
-  }
-
-  public void hideColumns(int start, int end)
-  {
-    if (start == end)
-    {
-      colSel.hideColumns(start);
-    }
-    else
-    {
-      colSel.hideColumns(start, end);
-    }
-
-    hasHiddenColumns = true;
-  }
-
-  public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
-  {
-    int sSize = sg.getSize();
-    if (sSize < 2)
-    {
-      return;
-    }
-
-    if (hiddenRepSequences == null)
-    {
-      hiddenRepSequences = new Hashtable();
-    }
-
-    hiddenRepSequences.put(repSequence, sg);
-
-    // Hide all sequences except the repSequence
-    SequenceI[] seqs = new SequenceI[sSize - 1];
-    int index = 0;
-    for (int i = 0; i < sSize; i++)
-    {
-      if (sg.getSequenceAt(i) != repSequence)
-      {
-        if (index == sSize - 1)
-        {
-          return;
-        }
-
-        seqs[index++] = sg.getSequenceAt(i);
-      }
-    }
-
-    hideSequence(seqs);
-
-  }
-
-  public void hideAllSelectedSeqs()
-  {
-    if (selectionGroup == null || selectionGroup.getSize() < 1)
-    {
-      return;
-    }
-
-    SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
-
-    hideSequence(seqs);
-
-    setSelectionGroup(null);
-  }
-
-  public void hideSequence(SequenceI[] seq)
-  {
-    if (seq != null)
-    {
-      for (int i = 0; i < seq.length; i++)
-      {
-        alignment.getHiddenSequences().hideSequence(seq[i]);
-      }
-
-      hasHiddenRows = true;
-      firePropertyChange("alignment", null, alignment.getSequences());
-    }
-  }
-  public void showSequence(int index)
-  {
-    Vector tmp = alignment.getHiddenSequences().showSequence(index,
-            hiddenRepSequences);
-    if (tmp.size() > 0)
-    {
-      if (selectionGroup == null)
-      {
-        selectionGroup = new SequenceGroup();
-        selectionGroup.setEndRes(alignment.getWidth() - 1);
-      }
-
-      for (int t = 0; t < tmp.size(); t++)
-      {
-        selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
-      }
-      firePropertyChange("alignment", null, alignment.getSequences());
-      sendSelection();
-    }
-
-    if (alignment.getHiddenSequences().getSize() < 1)
-    {
-      hasHiddenRows = false;
-    }
-  }
-  public void showColumn(int col)
-  {
-    colSel.revealHiddenColumns(col);
-    if (colSel.getHiddenColumns() == null)
-    {
-      hasHiddenColumns = false;
-    }
-  }
-
-  public void showAllHiddenColumns()
-  {
-    colSel.revealAllHiddenColumns();
-    hasHiddenColumns = false;
-  }
-
-  public void showAllHiddenSeqs()
-  {
-    if (alignment.getHiddenSequences().getSize() > 0)
-    {
-      if (selectionGroup == null)
-      {
-        selectionGroup = new SequenceGroup();
-        selectionGroup.setEndRes(alignment.getWidth() - 1);
-      }
-      Vector tmp = alignment.getHiddenSequences().showAll(
-              hiddenRepSequences);
-      for (int t = 0; t < tmp.size(); t++)
-      {
-        selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
-      }
-      firePropertyChange("alignment", null, alignment.getSequences());
-      hasHiddenRows = false;
-      hiddenRepSequences = null;
-      sendSelection();
-    }
-  }
-
-  public int adjustForHiddenSeqs(int alignmentIndex)
-  {
-    return alignment.getHiddenSequences().adjustForHiddenSeqs(
-            alignmentIndex);
-  }
-
-  /**
-   * This method returns the a new SequenceI [] with the selection sequence and
-   * start and end points adjusted
-   * 
-   * @return String[]
-   */
-  public SequenceI[] getSelectionAsNewSequence()
-  {
-    SequenceI[] sequences;
-
-    if (selectionGroup == null)
-    {
-      sequences = alignment.getSequencesArray();
-    }
-    else
-    {
-      sequences = selectionGroup.getSelectionAsNewSequences(alignment);
-    }
-
-    return sequences;
-  }
-
-  /**
-   * get the currently selected sequence objects or all the sequences in the
-   * alignment.
-   * 
-   * @return array of references to sequence objects
-   */
-  public SequenceI[] getSequenceSelection()
-  {
-    SequenceI[] sequences = null;
-    if (selectionGroup != null)
-    {
-      sequences = selectionGroup.getSequencesInOrder(alignment);
-    }
-    if (sequences == null)
-    {
-      sequences = alignment.getSequencesArray();
-    }
-    return sequences;
-  }
-
-  /**
-   * This method returns the visible alignment as text, as seen on the GUI, ie
-   * if columns are hidden they will not be returned in the result. Use this for
-   * calculating trees, PCA, redundancy etc on views which contain hidden
-   * columns.
-   * 
-   * @return String[]
-   */
-  public jalview.datamodel.CigarArray getViewAsCigars(
-          boolean selectedRegionOnly)
-  {
-    return new jalview.datamodel.CigarArray(alignment, (hasHiddenColumns ? colSel : null), (selectedRegionOnly ? selectionGroup : null));
-  }
-
-  /**
-   * return a compact representation of the current alignment selection to pass
-   * to an analysis function
-   * 
-   * @param selectedOnly
-   *          boolean true to just return the selected view
-   * @return AlignmentView
-   */
-  jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly)
-  {    
-    return getAlignmentView(selectedOnly, false);
-  }
-  
-  /**
-   * return a compact representation of the current alignment selection to pass
-   * to an analysis function
-   * 
-   * @param selectedOnly
-   *          boolean true to just return the selected view
-   * @param markGroups
-   *          boolean true to annotate the alignment view with groups on the alignment (and intersecting with selected region if selectedOnly is true) 
-   * @return AlignmentView
-   */
-  public jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly, boolean markGroups)
-  {
-    return new AlignmentView(alignment, colSel, selectionGroup, hasHiddenColumns, selectedOnly, markGroups);
-  }
-  /**
-   * This method returns the visible alignment as text, as seen on the GUI, ie
-   * if columns are hidden they will not be returned in the result. Use this for
-   * calculating trees, PCA, redundancy etc on views which contain hidden
-   * columns.
-   * 
-   * @return String[]
-   */
-  public String[] getViewAsString(boolean selectedRegionOnly)
-  {
-    String[] selection = null;
-    SequenceI[] seqs = null;
-    int i, iSize;
-    int start = 0, end = 0;
-    if (selectedRegionOnly && selectionGroup != null)
-    {
-      iSize = selectionGroup.getSize();
-      seqs = selectionGroup.getSequencesInOrder(alignment);
-      start = selectionGroup.getStartRes();
-      end = selectionGroup.getEndRes() + 1;
-    }
-    else
-    {
-      iSize = alignment.getHeight();
-      seqs = alignment.getSequencesArray();
-      end = alignment.getWidth();
-    }
-
-    selection = new String[iSize];
-
-    for (i = 0; i < iSize; i++)
-    {
-      if (hasHiddenColumns)
-      {
-        StringBuffer visibleSeq = new StringBuffer();
-        Vector regions = colSel.getHiddenColumns();
-
-        int blockStart = start, blockEnd = end;
-        int[] region;
-        int hideStart, hideEnd;
-
-        for (int j = 0; j < regions.size(); j++)
-        {
-          region = (int[]) regions.elementAt(j);
-          hideStart = region[0];
-          hideEnd = region[1];
-
-          if (hideStart < start)
-          {
-            continue;
-          }
-
-          blockStart = Math.min(blockStart, hideEnd + 1);
-          blockEnd = Math.min(blockEnd, hideStart);
-
-          if (blockStart > blockEnd)
-          {
-            break;
-          }
-
-          visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
-
-          blockStart = hideEnd + 1;
-          blockEnd = end;
-        }
-
-        if (end > blockStart)
-        {
-          visibleSeq.append(seqs[i].getSequence(blockStart, end));
-        }
-
-        selection[i] = visibleSeq.toString();
-      }
-      else
-      {
-        selection[i] = seqs[i].getSequenceAsString(start, end);
-      }
-    }
-
-    return selection;
-  }
 
   public boolean getShowHiddenMarkers()
   {
@@ -1281,98 +696,6 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
     }
   }
 
-  public String getSequenceSetId()
-  {
-    if (sequenceSetID == null)
-    {
-      sequenceSetID = alignment.hashCode() + "";
-    }
-
-    return sequenceSetID;
-  }
-  /**
-   * unique viewId for synchronizing state (e.g. with stored Jalview Project)
-   * 
-   */
-  private String viewId = null;
-
-  public String getViewId()
-  {
-    if (viewId == null)
-    {
-      viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
-    }
-    return viewId;
-  }
-
-  public void alignmentChanged(AlignmentPanel ap)
-  {
-    alignment.padGaps();
-
-    if (hconsensus != null && autocalculateConsensus)
-    {
-      updateConsensus(ap);
-      updateConservation(ap);
-    }
-
-    // Reset endRes of groups if beyond alignment width
-    int alWidth = alignment.getWidth();
-    Vector groups = alignment.getGroups();
-    if (groups != null)
-    {
-      for (int i = 0; i < groups.size(); i++)
-      {
-        SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
-        if (sg.getEndRes() > alWidth)
-        {
-          sg.setEndRes(alWidth - 1);
-        }
-      }
-    }
-
-    if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
-    {
-      selectionGroup.setEndRes(alWidth - 1);
-    }
-
-    resetAllColourSchemes();
-
-    // AW alignment.adjustSequenceAnnotations();
-  }
-
-  void resetAllColourSchemes()
-  {
-    ColourSchemeI cs = globalColourScheme;
-    if (cs != null)
-    {
-      if (cs instanceof ClustalxColourScheme)
-      {
-        ((ClustalxColourScheme) cs).resetClustalX(alignment.getSequences(),
-                alignment.getWidth());
-      }
-
-      cs.setConsensus(hconsensus);
-      if (cs.conservationApplied())
-      {
-        cs.setConservation(Conservation.calculateConservation("All",
-                ResidueProperties.propHash, 3, alignment.getSequences(), 0,
-                alignment.getWidth(), false, getConsPercGaps(), false));
-      }
-    }
-
-    int s, sSize = alignment.getGroups().size();
-    for (s = 0; s < sSize; s++)
-    {
-      SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
-      if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
-      {
-        ((ClustalxColourScheme) sg.cs).resetClustalX(
-                sg.getSequences(hiddenRepSequences), sg.getWidth());
-      }
-      sg.recalcConservation();
-    }
-  }
-
   boolean centreColumnLabels;
 
   public boolean getCentreColumnLabels()
@@ -1388,7 +711,7 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
       SequenceGroup sg = (SequenceGroup) groups.elementAt(ig);
       if (sg.idColour != null)
       {
-        Vector sqs = sg.getSequences(hiddenRepSequences);
+        Vector sqs = sg.getSequences(getHiddenRepSequences());
         for (int s = 0, sSize = sqs.size(); s < sSize; s++)
         {
           this.setSequenceColour((SequenceI) sqs.elementAt(s), sg.idColour);
@@ -1414,42 +737,6 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
   {
     return followSelection;
   }
-
-  private long sgrouphash = -1, colselhash = -1;
-
-  /**
-   * checks current SelectionGroup against record of last hash value, and
-   * updates record.
-   * 
-   * @return true if SelectionGroup changed since last call
-   */
-  boolean isSelectionGroupChanged()
-  {
-    int hc = (selectionGroup == null) ? -1 : selectionGroup.hashCode();
-    if (hc != sgrouphash)
-    {
-      sgrouphash = hc;
-      return true;
-    }
-    return false;
-  }
-
-  /**
-   * checks current colsel against record of last hash value, and updates
-   * record.
-   * 
-   * @return true if colsel changed since last call
-   */
-  boolean isColSelChanged()
-  {
-    int hc = (colSel == null) ? -1 : colSel.hashCode();
-    if (hc != colselhash)
-    {
-      colselhash = hc;
-      return true;
-    }
-    return false;
-  }
   public void sendSelection()
   {
     jalview.structure.StructureSelectionManager
@@ -1462,137 +749,6 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
 
 
   /**
-   * show non-conserved residues only
-   */
-  public boolean showUnconserved = false;
-
-  /**
-   * when set, alignment should be reordered according to a newly opened tree
-   */
-  public boolean sortByTree = false;
-
-  /**
-   * @return the showUnconserved
-   */
-  public boolean getShowunconserved()
-  {
-    return showUnconserved;
-  }
-
-  /**
-   * @param showNonconserved
-   *          the showUnconserved to set
-   */
-  public void setShowunconserved(boolean displayNonconserved)
-  {
-    this.showUnconserved = displayNonconserved;
-  }
-
-  /**
-   * should conservation rows be shown for groups
-   */
-  boolean showGroupConservation = false;
-
-  /**
-   * should consensus rows be shown for groups
-   */
-  boolean showGroupConsensus = false;
-
-  /**
-   * should consensus profile be rendered by default
-   */
-  public boolean showSequenceLogo = false;
-  /**
-   * should consensus profile be rendered normalised to row height
-   */
-  public  boolean normaliseSequenceLogo = false;
-
-  /**
-   * should consensus histograms be rendered by default
-   */
-  public boolean showConsensusHistogram = true;
-
-  /**
-   * @return the showConsensusProfile
-   */
-  public boolean isShowSequenceLogo()
-  {
-    return showSequenceLogo;
-  }
-
-  /**
-   * @param showSequenceLogo
-   *          the new value
-   */
-  public void setShowSequenceLogo(boolean showSequenceLogo)
-  {
-    if (showSequenceLogo != this.showSequenceLogo)
-    {
-      // TODO: decouple settings setting from calculation when refactoring
-      // annotation update method from alignframe to viewport
-      this.showSequenceLogo = showSequenceLogo;
-      if (consensusThread != null)
-      {
-        consensusThread.updateAnnotation();
-      }
-    }
-    this.showSequenceLogo = showSequenceLogo;
-  }
-
-  /**
-   * @param showConsensusHistogram
-   *          the showConsensusHistogram to set
-   */
-  public void setShowConsensusHistogram(boolean showConsensusHistogram)
-  {
-    this.showConsensusHistogram = showConsensusHistogram;
-  }
-
-  /**
-   * @return the showGroupConservation
-   */
-  public boolean isShowGroupConservation()
-  {
-    return showGroupConservation;
-  }
-
-  /**
-   * @param showGroupConservation
-   *          the showGroupConservation to set
-   */
-  public void setShowGroupConservation(boolean showGroupConservation)
-  {
-    this.showGroupConservation = showGroupConservation;
-  }
-
-  /**
-   * @return the showGroupConsensus
-   */
-  public boolean isShowGroupConsensus()
-  {
-    return showGroupConsensus;
-  }
-
-  /**
-   * @param showGroupConsensus
-   *          the showGroupConsensus to set
-   */
-  public void setShowGroupConsensus(boolean showGroupConsensus)
-  {
-    this.showGroupConsensus = showGroupConsensus;
-  }
-
-  /**
-   * 
-   * @return flag to indicate if the consensus histogram should be rendered by
-   *         default
-   */
-  public boolean isShowConsensusHistogram()
-  {
-    return this.showConsensusHistogram;
-  }
-
-  /**
    * synthesize a column selection if none exists so it covers the given
    * selection group. if wholewidth is false, no column selection is made if the
    * selection group covers the whole alignment width.
@@ -1641,27 +797,6 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
     normaliseSequenceLogo = state;
   }
 
-  public boolean isCalcInProgress()
-  {
-    // TODO generalise to iterate over all calculators associated with av
-    return updatingConsensus || updatingConservation || updatingStrucConsensus;
-  }
-
-  public boolean isCalculationInProgress(
-          AlignmentAnnotation alignmentAnnotation)
-  {
-    if (!alignmentAnnotation.autoCalculated)
-      return false;
-    if ((updatingConsensus && consensus==alignmentAnnotation)
-            || (updatingConservation && (conservation==alignmentAnnotation || quality==alignmentAnnotation))
-            // || (updatingStrucConsensus && strucConsensus==alignmentAnnotation)
-            )
-    {
-      return true;
-    }
-    return false;
-  }
-
   /**
    * 
    * @return true if alignment characters should be displayed 
@@ -1671,43 +806,4 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
     return validCharWidth;
   }
 
-  @Override
-  public Hashtable[] getSequenceConsensusHash()
-  {
-    return hconsensus;
-  }
-
-  @Override
-  public Hashtable[] getRnaStructureConsensusHash()
-  {
-    return null; // TODO: JAL-891 port to jvlite : refactor and introduce hStrucConsensus;
-  }
-
-  @Override
-  public AlignmentAnnotation getAlignmentQualityAnnot()
-  {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-  @Override
-  public AlignmentAnnotation getAlignmentConservationAnnotation()
-  {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-  @Override
-  public boolean isClosed()
-  {
-    System.err.println("Alignment is "+alignment==null ? "closed" : "open");
-    return alignment==null;
-  }
-
-  @Override
-  public AlignCalcManagerI getCalcManager()
-  {
-    // TODO Auto-generated method stub
-    return null;
-  }
 }
index c5adccb..99084ba 100644 (file)
@@ -286,13 +286,14 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme
     // do we need to scroll the panel?
     if (results != null && results.getSize() > 0)
     {
-      int seqIndex = av.alignment.findIndex(results);
+      AlignmentI alignment=av.getAlignment();
+      int seqIndex = alignment.findIndex(results);
       if (seqIndex == -1)
       {
         return false;
       }
-      SequenceI seq = av.alignment.getSequenceAt(seqIndex);
-      int[] r = results.getResults(seq, 0,av.alignment.getWidth());
+      SequenceI seq = alignment.getSequenceAt(seqIndex);
+      int[] r = results.getResults(seq, 0,alignment.getWidth());
       if (r == null)
       {
         if (av.applet.debug) {// DEBUG
@@ -327,13 +328,13 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme
            int startv, endv, starts, ends, width;
 
          int start=-1;
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       start = av.getColumnSelection().findColumnPosition(ostart);
       end = av.getColumnSelection().findColumnPosition(end);
       if (start == end)
       {
-        if (!scrollToNearest && !av.colSel.isVisible(ostart))
+        if (!scrollToNearest && !av.getColumnSelection().isVisible(ostart))
         {
           // don't scroll - position isn't visible
           return false;
@@ -373,18 +374,18 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme
                 || (av.getEndRes() < start)
                 || ((av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex)))
         {
-          if (start > av.alignment.getWidth() - hextent)
+          if (start > av.getAlignment().getWidth() - hextent)
           {
-            start = av.alignment.getWidth() - hextent;
+            start = av.getAlignment().getWidth() - hextent;
             if (start < 0)
             {
               start = 0;
             }
 
           }
-          if (seqIndex > av.alignment.getHeight() - vextent)
+          if (seqIndex > av.getAlignment().getHeight() - vextent)
           {
-            seqIndex = av.alignment.getHeight() - vextent;
+            seqIndex = av.getAlignment().getHeight() - vextent;
             if (seqIndex < 0)
             {
               seqIndex = 0;
@@ -588,10 +589,10 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme
 
   public void setScrollValues(int x, int y)
   {
-    int width = av.alignment.getWidth();
-    int height = av.alignment.getHeight();
+    int width = av.getAlignment().getWidth();
+    int height = av.getAlignment().getHeight();
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       width = av.getColumnSelection().findColumnPosition(width);
     }
@@ -636,9 +637,9 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme
     av.setStartSeq(y);
 
     int endSeq = y + vextent;
-    if (endSeq > av.alignment.getHeight())
+    if (endSeq > av.getAlignment().getHeight())
     {
-      endSeq = av.alignment.getHeight();
+      endSeq = av.getAlignment().getHeight();
     }
 
     av.setEndSeq(endSeq);
@@ -768,9 +769,9 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme
     
     if (av.getWrapAlignment())
     {
-      int maxwidth = av.alignment.getWidth();
+      int maxwidth = av.getAlignment().getWidth();
 
-      if (av.hasHiddenColumns)
+      if (av.hasHiddenColumns())
       {
         maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
       }
@@ -918,10 +919,10 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme
     // remove old automatic annotation
     // add any new annotation
 
-    Vector gr = av.alignment.getGroups(); // OrderedBy(av.alignment.getSequencesArray());
+    Vector gr = av.getAlignment().getGroups(); // OrderedBy(av.alignment.getSequencesArray());
     // intersect alignment annotation with alignment groups
 
-    AlignmentAnnotation[] aan = av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aan = av.getAlignment().getAlignmentAnnotation();
     Hashtable oldrfs = new Hashtable();
     if (aan != null)
     {
@@ -930,7 +931,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme
         if (aan[an].autoCalculated && aan[an].groupRef != null)
         {
           oldrfs.put(aan[an].groupRef, aan[an].groupRef);
-          av.alignment.deleteAnnotation(aan[an]);
+          av.getAlignment().deleteAnnotation(aan[an]);
           aan[an] = null;
         }
       }
@@ -951,12 +952,12 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme
         if (conv)
         {
           updateCalcs = true;
-          av.alignment.addAnnotation(sg.getConservationRow(), 0);
+          av.getAlignment().addAnnotation(sg.getConservationRow(), 0);
         }
         if (cons)
         {
           updateCalcs = true;
-          av.alignment.addAnnotation(sg.getConsensus(), 0);
+          av.getAlignment().addAnnotation(sg.getConsensus(), 0);
         }
         // refresh the annotation rows
         if (updateCalcs)
@@ -972,7 +973,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme
   @Override
   public AlignmentI getAlignment()
   {
-    return av.alignment;
+    return av.getAlignment();
   }
   @Override
   public StructureSelectionManager getStructureSelectionManager()
index 4ff027b..a3f9fa6 100755 (executable)
@@ -55,10 +55,10 @@ public class AnnotationColourChooser extends Panel implements
     }
 
     oldcs = av.getGlobalColourScheme();
-    if (av.alignment.getGroups() != null)
+    if (av.getAlignment().getGroups() != null)
     {
       oldgroupColours = new Hashtable();
-      Vector allGroups = ap.av.alignment.getGroups();
+      Vector allGroups = ap.av.getAlignment().getGroups();
       SequenceGroup sg;
       for (int g = 0; g < allGroups.size(); g++)
       {
@@ -79,7 +79,7 @@ public class AnnotationColourChooser extends Panel implements
     slider.addAdjustmentListener(this);
     slider.addMouseListener(this);
 
-    if (av.alignment.getAlignmentAnnotation() == null)
+    if (av.getAlignment().getAlignmentAnnotation() == null)
     {
       return;
     }
@@ -100,9 +100,9 @@ public class AnnotationColourChooser extends Panel implements
 
     Vector list = new Vector();
     int index = 1;
-    for (int i = 0; i < av.alignment.getAlignmentAnnotation().length; i++)
+    for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
     {
-      String label = av.alignment.getAlignmentAnnotation()[i].label;
+      String label = av.getAlignment().getAlignmentAnnotation()[i].label;
       if (!list.contains(label))
         list.addElement(label);
       else
@@ -395,7 +395,7 @@ public class AnnotationColourChooser extends Panel implements
       return;
     }
 
-    currentAnnotation = av.alignment.getAlignmentAnnotation()[annotations
+    currentAnnotation = av.getAlignment().getAlignmentAnnotation()[annotations
             .getSelectedIndex()];
 
     int aboveThreshold = -1;
@@ -464,9 +464,9 @@ public class AnnotationColourChooser extends Panel implements
 
     av.setGlobalColourScheme(acg);
 
-    if (av.alignment.getGroups() != null)
+    if (av.getAlignment().getGroups() != null)
     {
-      Vector allGroups = ap.av.alignment.getGroups();
+      Vector allGroups = ap.av.getAlignment().getGroups();
       SequenceGroup sg;
       for (int g = 0; g < allGroups.size(); g++)
       {
@@ -499,9 +499,9 @@ public class AnnotationColourChooser extends Panel implements
   void reset()
   {
     av.setGlobalColourScheme(oldcs);
-    if (av.alignment.getGroups() != null)
+    if (av.getAlignment().getGroups() != null)
     {
-      Vector allGroups = ap.av.alignment.getGroups();
+      Vector allGroups = ap.av.getAlignment().getGroups();
       SequenceGroup sg;
       for (int g = 0; g < allGroups.size(); g++)
       {
index 29a79dd..635535c 100755 (executable)
@@ -107,7 +107,7 @@ public class AnnotationLabels extends Panel implements ActionListener,
   int getSelectedRow(int y)
   {
     int row = -2;
-    AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aa = ap.av.getAlignment().getAlignmentAnnotation();
 
     if (aa == null)
     {
@@ -134,20 +134,20 @@ public class AnnotationLabels extends Panel implements ActionListener,
 
   public void actionPerformed(ActionEvent evt)
   {
-    AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
 
     if (evt.getActionCommand().equals(ADDNEW))
     {
       AlignmentAnnotation newAnnotation = new AlignmentAnnotation("", null,
-              new Annotation[ap.av.alignment.getWidth()]);
+              new Annotation[ap.av.getAlignment().getWidth()]);
 
       if (!editLabelDescription(newAnnotation))
       {
         return;
       }
 
-      ap.av.alignment.addAnnotation(newAnnotation);
-      ap.av.alignment.setAnnotationIndex(newAnnotation, 0);
+      ap.av.getAlignment().addAnnotation(newAnnotation);
+      ap.av.getAlignment().setAnnotationIndex(newAnnotation, 0);
     }
     else if (evt.getActionCommand().equals(EDITNAME))
     {
@@ -228,7 +228,7 @@ public class AnnotationLabels extends Panel implements ActionListener,
 
     if (row > -1)
     {
-      ParseHtmlBodyAndLinks phb = new ParseHtmlBodyAndLinks(av.alignment.getAlignmentAnnotation()[row].getDescription(true), true, "\n");
+      ParseHtmlBodyAndLinks phb = new ParseHtmlBodyAndLinks(av.getAlignment().getAlignmentAnnotation()[row].getDescription(true), true, "\n");
       if (tooltip == null)
       {
         tooltip = new Tooltip(phb.getNonHtmlContent(), this);
@@ -337,17 +337,17 @@ public class AnnotationLabels extends Panel implements ActionListener,
       if (start>-1 && start != end)
       {
         // Swap these annotations
-        AlignmentAnnotation startAA = ap.av.alignment
+        AlignmentAnnotation startAA = ap.av.getAlignment()
                 .getAlignmentAnnotation()[start];
         if (end == -1)
         {
-          end = ap.av.alignment.getAlignmentAnnotation().length - 1;
+          end = ap.av.getAlignment().getAlignmentAnnotation().length - 1;
         }
-        AlignmentAnnotation endAA = ap.av.alignment
+        AlignmentAnnotation endAA = ap.av.getAlignment()
                 .getAlignmentAnnotation()[end];
 
-        ap.av.alignment.getAlignmentAnnotation()[end] = startAA;
-        ap.av.alignment.getAlignmentAnnotation()[start] = endAA;
+        ap.av.getAlignment().getAlignmentAnnotation()[end] = startAA;
+        ap.av.getAlignment().getAlignmentAnnotation()[start] = endAA;
       }
     }
     resizePanel = false;
@@ -395,7 +395,7 @@ public class AnnotationLabels extends Panel implements ActionListener,
     // todo: move below to mouseClicked ?
     selectedRow = getSelectedRow(evt.getY() + scrollOffset);
 
-    AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aa = ap.av.getAlignment().getAlignmentAnnotation();
 
     // DETECT RIGHT MOUSE BUTTON IN AWT
     if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
@@ -622,7 +622,7 @@ public class AnnotationLabels extends Panel implements ActionListener,
     jalview.appletgui.AlignFrame.copiedSequences.append(sq.getName() + "\t"
             + sq.getStart() + "\t" + sq.getEnd() + "\t"
             + sq.getSequenceAsString() + "\n");
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       jalview.appletgui.AlignFrame.copiedHiddenColumns = new Vector();
       for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); i++)
@@ -665,7 +665,7 @@ public class AnnotationLabels extends Panel implements ActionListener,
     g.translate(0, -scrollOffset);
     g.setColor(Color.black);
 
-    AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
     int y = 0, fy = g.getFont().getSize();
     int x = 0, offset;
 
index f068a3c..d533498 100755 (executable)
@@ -113,7 +113,7 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
    */
   public void actionPerformed(ActionEvent evt)
   {
-    AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
     if (aa == null)
     {
       return;
@@ -129,8 +129,8 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
     }
 
     String label = "";
-    if (av.colSel != null && av.colSel.size() > 0
-            && anot[av.colSel.getMin()] != null)
+    if (av.getColumnSelection() != null && av.getColumnSelection().size() > 0
+            && anot[av.getColumnSelection().getMin()] != null)
       label = anot[av.getColumnSelection().getMin()].displayCharacter;
 
     if (evt.getActionCommand().equals(REMOVE))
@@ -158,7 +158,7 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
       {
         int index = av.getColumnSelection().columnAt(i);
 
-        if (!av.colSel.isVisible(index))
+        if (!av.getColumnSelection().isVisible(index))
           continue;
 
         if (anot[index] == null)
@@ -180,7 +180,7 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
       {
         int index = av.getColumnSelection().columnAt(i);
 
-        if (!av.colSel.isVisible(index))
+        if (!av.getColumnSelection().isVisible(index))
           continue;
 
         if (anot[index] == null)
@@ -228,7 +228,7 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
       {
         int index = av.getColumnSelection().columnAt(i);
 
-        if (!av.colSel.isVisible(index))
+        if (!av.getColumnSelection().isVisible(index))
           continue;
 
         if (anot[index] == null)
@@ -260,7 +260,7 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
 
   public void mousePressed(MouseEvent evt)
   {
-    AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
     if (aa == null)
     {
       return;
@@ -354,11 +354,11 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
   {
     if (graphStretch > -1)
     {
-      av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight += graphStretchY
+      av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight += graphStretchY
               - evt.getY();
-      if (av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight < 0)
+      if (av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight < 0)
       {
-        av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight = 0;
+        av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight = 0;
       }
       graphStretchY = evt.getY();
       calcPanelHeight();
@@ -373,7 +373,7 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
 
   public void mouseMoved(MouseEvent evt)
   {
-    AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
     if (aa == null)
     {
       return;
@@ -398,7 +398,7 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
 
     int res = evt.getX() / av.getCharWidth() + av.getStartRes();
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       res = av.getColumnSelection().adjustForHiddenColumns(res);
     }
@@ -448,7 +448,7 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
   public int calcPanelHeight()
   {
     // setHeight of panels
-    AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
     int height = 0;
 
     if (aa != null)
@@ -498,7 +498,7 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
   {
     if (activeRow == -1)
     {
-      AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+      AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
       if (aa == null)
       {
         return;
@@ -563,8 +563,8 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
 
   public void fastPaint(int horizontal)
   {
-    if (horizontal == 0 || av.alignment.getAlignmentAnnotation() == null
-            || av.alignment.getAlignmentAnnotation().length < 1)
+    if (horizontal == 0 || av.getAlignment().getAlignmentAnnotation() == null
+            || av.getAlignment().getAlignmentAnnotation().length < 1)
     {
       repaint();
       return;
@@ -617,8 +617,8 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
       fm = g.getFontMetrics();
     }
 
-    if ((av.alignment.getAlignmentAnnotation() == null)
-            || (av.alignment.getAlignmentAnnotation().length < 1))
+    if ((av.getAlignment().getAlignmentAnnotation() == null)
+            || (av.getAlignment().getAlignmentAnnotation().length < 1))
     {
       g.setColor(Color.white);
       g.fillRect(0, 0, getSize().width, getSize().height);
index 99a761b..b00a621 100755 (executable)
@@ -157,7 +157,7 @@ public class CutAndPasteTransfer extends Panel implements ActionListener,
     else if (annotationImport)
     {
       if (new AnnotationFile().readAnnotationFile(
-              alignFrame.viewport.alignment, textarea.getText(),
+              alignFrame.viewport.getAlignment(), textarea.getText(),
               jalview.io.AppletFormatAdapter.PASTE))
       {
         alignFrame.alignPanel.fontChanged();
index 2727aad..259030f 100755 (executable)
@@ -786,10 +786,10 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
     av.featuresDisplayed = new Hashtable();
     Vector allfeatures = new Vector();
     minmax = new Hashtable();
-
-    for (int i = 0; i < av.alignment.getHeight(); i++)
+    AlignmentI alignment=av.getAlignment();
+    for (int i = 0; i < alignment.getHeight(); i++)
     {
-      SequenceFeature[] features = av.alignment.getSequenceAt(i)
+      SequenceFeature[] features = alignment.getSequenceAt(i)
               .getSequenceFeatures();
 
       if (features == null)
@@ -1110,16 +1110,17 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
     ArrayList allGroups = new ArrayList();
     SequenceFeature[] tmpfeatures;
     String group;
-    for (int i = 0; i < av.alignment.getHeight(); i++)
+    AlignmentI alignment=av.getAlignment();
+    for (int i = 0; i < alignment.getHeight(); i++)
     {
-      if (av.alignment.getSequenceAt(i).getSequenceFeatures() == null)
+      if (alignment.getSequenceAt(i).getSequenceFeatures() == null)
       {
         continue;
       }
 
       alignmentHasFeatures = true;
 
-      tmpfeatures = av.alignment.getSequenceAt(i).getSequenceFeatures();
+      tmpfeatures = alignment.getSequenceAt(i).getSequenceFeatures();
       int index = 0;
       while (index < tmpfeatures.length)
       {
@@ -1175,16 +1176,17 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
     Vector allFeatures = new Vector();
     SequenceFeature[] tmpfeatures;
     String group;
-    for (int i = 0; i < av.alignment.getHeight(); i++)
+    AlignmentI alignment=av.getAlignment();
+    for (int i = 0; i < alignment.getHeight(); i++)
     {
-      if (av.alignment.getSequenceAt(i).getSequenceFeatures() == null)
+      if (alignment.getSequenceAt(i).getSequenceFeatures() == null)
       {
         continue;
       }
 
       alignmentHasFeatures = true;
 
-      tmpfeatures = av.alignment.getSequenceAt(i).getSequenceFeatures();
+      tmpfeatures = alignment.getSequenceAt(i).getSequenceFeatures();
       int index = 0;
       while (index < tmpfeatures.length)
       {
index 4a0ae16..de9d231 100755 (executable)
@@ -291,15 +291,15 @@ public class FeatureSettings extends Panel implements ItemListener,
     SequenceFeature[] tmpfeatures;
     String group = null, type;
     Vector visibleChecks = new Vector();
-
-    for (int i = 0; i < av.alignment.getHeight(); i++)
+    AlignmentI alignment=av.getAlignment();
+    for (int i = 0; i < alignment.getHeight(); i++)
     {
-      if (av.alignment.getSequenceAt(i).getSequenceFeatures() == null)
+      if (alignment.getSequenceAt(i).getSequenceFeatures() == null)
       {
         continue;
       }
 
-      tmpfeatures = av.alignment.getSequenceAt(i).getSequenceFeatures();
+      tmpfeatures = alignment.getSequenceAt(i).getSequenceFeatures();
       int index = 0;
       while (index < tmpfeatures.length)
       {
index 1dfe57e..67bba32 100755 (executable)
@@ -80,7 +80,7 @@ public class IdCanvas extends Panel
             ((i - starty) * charHeight) + ypos + charHeight
                     - (charHeight / 5));
 
-    if (av.hasHiddenRows && av.showHiddenMarkers)
+    if (av.hasHiddenRows() && av.showHiddenMarkers)
     {
       drawMarker(i, starty, ypos);
     }
@@ -186,10 +186,10 @@ public class IdCanvas extends Panel
 
     if (av.getWrapAlignment())
     {
-      int maxwidth = av.alignment.getWidth();
-      int alheight = av.alignment.getHeight();
+      int maxwidth = av.getAlignment().getWidth();
+      int alheight = av.getAlignment().getHeight();
 
-      if (av.hasHiddenColumns)
+      if (av.hasHiddenColumns())
       {
         maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
       }
@@ -221,9 +221,9 @@ public class IdCanvas extends Panel
         for (int i = starty; i < alheight; i++)
         {
 
-          SequenceI s = av.alignment.getSequenceAt(i);
+          SequenceI s = av.getAlignment().getSequenceAt(i);
           gg.setFont(italic);
-          if (av.hasHiddenRows)
+          if (av.hasHiddenRows())
           {
             setHiddenFont(s);
           }
@@ -246,14 +246,14 @@ public class IdCanvas extends Panel
       for (int i = starty; i < endy; i++)
       {
 
-        seq = av.alignment.getSequenceAt(i);
+        seq = av.getAlignment().getSequenceAt(i);
         if (seq == null)
         {
           continue;
         }
         gg.setFont(italic);
         // boolean isrep=false;
-        if (av.hasHiddenRows)
+        if (av.hasHiddenRows())
         {
           // isrep =
           setHiddenFont(seq);
@@ -288,7 +288,7 @@ public class IdCanvas extends Panel
                 (((i - starty) * av.charHeight) + av.charHeight)
                         - (av.charHeight / 5));
 
-        if (av.hasHiddenRows && av.showHiddenMarkers)
+        if (av.hasHiddenRows() && av.showHiddenMarkers)
         {
           drawMarker(i, starty, 0);
         }
@@ -304,7 +304,7 @@ public class IdCanvas extends Panel
 
   void drawMarker(int i, int starty, int yoffset)
   {
-    SequenceI[] hseqs = av.alignment.getHiddenSequences().hiddenSequences;
+    SequenceI[] hseqs = av.getAlignment().getHiddenSequences().hiddenSequences;
     // Use this method here instead of calling hiddenSeq adjust
     // 3 times.
     int hSize = hseqs.length;
@@ -362,8 +362,8 @@ public class IdCanvas extends Panel
     Font bold = new Font(av.getFont().getName(), Font.BOLD, av.getFont()
             .getSize());
 
-    if (av.hiddenRepSequences != null
-            && av.hiddenRepSequences.containsKey(seq))
+    if (av.getHiddenRepSequences() != null
+            && av.getHiddenRepSequences().containsKey(seq))
     {
       gg.setFont(bold);
       return true;
index d2832f8..a6bff67 100755 (executable)
@@ -272,7 +272,7 @@ public class IdPanel extends Panel implements MouseListener,
     }
 
     if (mouseDragging && e.getY() >= getSize().height
-            && av.alignment.getHeight() > av.getEndSeq())
+            && av.getAlignment().getHeight() > av.getEndSeq())
     {
       scrollThread = new ScrollThread(false);
     }
@@ -331,7 +331,7 @@ public class IdPanel extends Panel implements MouseListener,
     {
       av.setSelectionGroup(new SequenceGroup());
       av.getSelectionGroup().setStartRes(0);
-      av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1);
+      av.getSelectionGroup().setEndRes(av.getAlignment().getWidth() - 1);
     }
 
     if (e.isShiftDown() && lastid != -1)
@@ -409,7 +409,7 @@ public class IdPanel extends Panel implements MouseListener,
       return;
     }
 
-    int index = av.alignment.findIndex((SequenceI) found.elementAt(0));
+    int index = av.getAlignment().findIndex((SequenceI) found.elementAt(0));
 
     // do we need to scroll the panel?
     if (av.getStartSeq() > index || av.getEndSeq() < index)
@@ -454,7 +454,7 @@ public class IdPanel extends Panel implements MouseListener,
           {
             selectSeqs(lastid - 1, seq);
           }
-          else if (seq > lastid && seq < av.alignment.getHeight())
+          else if (seq > lastid && seq < av.getAlignment().getHeight())
           {
             selectSeqs(lastid + 1, seq);
           }
index fc4fb8c..4b646c3 100755 (executable)
@@ -17,6 +17,8 @@
  */
 package jalview.appletgui;
 
+import jalview.datamodel.AlignmentI;
+
 import java.awt.*;
 import java.awt.event.*;
 
@@ -65,17 +67,17 @@ public class OverviewPanel extends Panel implements Runnable,
     sr.forOverview = true;
     fr = new FeatureRenderer(av);
     fr.overview = true;
-
+    
     // scale the initial size of overviewpanel to shape of alignment
-    float initialScale = (float) av.alignment.getWidth()
-            / (float) av.alignment.getHeight();
+    float initialScale = (float) av.getAlignment().getWidth()
+            / (float) av.getAlignment().getHeight();
 
-    if (av.hconsensus == null)
+    if (av.getSequenceConsensusHash() == null)
     {
       graphHeight = 0;
     }
 
-    if (av.alignment.getWidth() > av.alignment.getHeight())
+    if (av.getAlignment().getWidth() > av.getAlignment().getHeight())
     {
       // wider
       width = 400;
@@ -174,7 +176,7 @@ public class OverviewPanel extends Panel implements Runnable,
 
     if (boxX > (width - boxWidth))
     {
-      if (av.hasHiddenColumns)
+      if (av.hasHiddenColumns())
       {
         // Try smallest possible box
         boxWidth = (int) ((av.endRes - av.startRes + 1) * av.getCharWidth() * scalew);
@@ -185,7 +187,7 @@ public class OverviewPanel extends Panel implements Runnable,
     int col = (int) (boxX / scalew / av.getCharWidth());
     int row = (int) (boxY / scaleh / av.getCharHeight());
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       if (!av.getColumnSelection().isVisible(col))
       {
@@ -195,9 +197,9 @@ public class OverviewPanel extends Panel implements Runnable,
       col = av.getColumnSelection().findColumnPosition(col);
     }
 
-    if (av.hasHiddenRows)
+    if (av.hasHiddenRows())
     {
-      row = av.alignment.getHiddenSequences().findIndexWithoutHiddenSeqs(
+      row = av.getAlignment().getHiddenSequences().findIndexWithoutHiddenSeqs(
               row);
     }
 
@@ -243,8 +245,8 @@ public class OverviewPanel extends Panel implements Runnable,
   public void run()
   {
     miniMe = null;
-    int alwidth = av.alignment.getWidth();
-    int alheight = av.alignment.getHeight();
+    int alwidth = av.getAlignment().getWidth();
+    int alheight = av.getAlignment().getHeight();
 
     if (av.showSequenceFeatures)
     {
@@ -278,6 +280,7 @@ public class OverviewPanel extends Panel implements Runnable,
     int row, col, sameRow = 0, sameCol = 0;
     jalview.datamodel.SequenceI seq;
     boolean hiddenRow = false;
+    AlignmentI alignment=av.getAlignment();
     for (row = 0; row <= sequencesHeight; row++)
     {
       if ((int) (row * sampleRow) == lastrow)
@@ -287,15 +290,15 @@ public class OverviewPanel extends Panel implements Runnable,
       }
 
       hiddenRow = false;
-      if (av.hasHiddenRows)
+      if (av.hasHiddenRows())
       {
-        seq = av.alignment.getHiddenSequences().getHiddenSequence(lastrow);
+        seq = alignment.getHiddenSequences().getHiddenSequence(lastrow);
         if (seq == null)
         {
-          int index = av.alignment.getHiddenSequences()
+          int index = alignment.getHiddenSequences()
                   .findIndexWithoutHiddenSeqs(lastrow);
 
-          seq = av.alignment.getSequenceAt(index);
+          seq = alignment.getSequenceAt(index);
         }
         else
         {
@@ -304,7 +307,7 @@ public class OverviewPanel extends Panel implements Runnable,
       }
       else
       {
-        seq = av.alignment.getSequenceAt(lastrow);
+        seq = alignment.getSequenceAt(lastrow);
       }
 
       for (col = 0; col < width; col++)
@@ -333,7 +336,7 @@ public class OverviewPanel extends Panel implements Runnable,
         }
 
         if (hiddenRow
-                || (av.hasHiddenColumns && !av.getColumnSelection()
+                || (av.hasHiddenColumns() && !av.getColumnSelection()
                         .isVisible(lastcol)))
         {
           color = color.darker().darker();
@@ -357,14 +360,14 @@ public class OverviewPanel extends Panel implements Runnable,
       sameRow = 1;
     }
 
-    if (av.conservation != null)
+    if (av.getAlignmentConservationAnnotation()!= null)
     {
       for (col = 0; col < width; col++)
       {
         lastcol = (int) (col * sampleCol);
         {
           mg.translate(col, sequencesHeight);
-          ap.annotationPanel.renderer.drawGraph(mg, av.conservation,
+          ap.annotationPanel.renderer.drawGraph(mg, av.getAlignmentConservationAnnotation(),
                   (int) (sampleCol) + 1, graphHeight,
                   (int) (col * sampleCol), (int) (col * sampleCol) + 1);
           mg.translate(-col, -sequencesHeight);
@@ -386,14 +389,14 @@ public class OverviewPanel extends Panel implements Runnable,
 
   public void setBoxPosition()
   {
-    int fullsizeWidth = av.alignment.getWidth() * av.getCharWidth();
-    int fullsizeHeight = (av.alignment.getHeight() + av.alignment
+    int fullsizeWidth = av.getAlignment().getWidth() * av.getCharWidth();
+    int fullsizeHeight = (av.getAlignment().getHeight() + av.getAlignment()
             .getHiddenSequences().getSize()) * av.getCharHeight();
 
     int startRes = av.getStartRes();
     int endRes = av.getEndRes();
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       startRes = av.getColumnSelection().adjustForHiddenColumns(startRes);
       endRes = av.getColumnSelection().adjustForHiddenColumns(endRes);
@@ -402,12 +405,12 @@ public class OverviewPanel extends Panel implements Runnable,
     int startSeq = av.startSeq;
     int endSeq = av.endSeq;
 
-    if (av.hasHiddenRows)
+    if (av.hasHiddenRows())
     {
-      startSeq = av.alignment.getHiddenSequences().adjustForHiddenSeqs(
+      startSeq = av.getAlignment().getHiddenSequences().adjustForHiddenSeqs(
               startSeq);
 
-      endSeq = av.alignment.getHiddenSequences()
+      endSeq = av.getAlignment().getHiddenSequences()
               .adjustForHiddenSeqs(endSeq);
 
     }
@@ -418,7 +421,7 @@ public class OverviewPanel extends Panel implements Runnable,
     boxX = (int) (startRes * av.getCharWidth() * scalew);
     boxY = (int) (startSeq * av.getCharHeight() * scaleh);
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew);
     }
index 89999d9..6568b5b 100755 (executable)
@@ -61,11 +61,11 @@ public class PCAPanel extends EmbmenuFrame implements Runnable,
     seqstrings = av.getAlignmentView(av.getSelectionGroup() != null);
     if (av.getSelectionGroup() == null)
     {
-      seqs = av.alignment.getSequencesArray();
+      seqs = av.getAlignment().getSequencesArray();
     }
     else
     {
-      seqs = av.getSelectionGroup().getSequencesInOrder(av.alignment);
+      seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
     }
     SeqCigar sq[] = seqstrings.getSequences();
     int length = sq[0].getWidth();
index 50e5a62..25e529b 100755 (executable)
@@ -122,8 +122,8 @@ public class PaintRefresher
       else if (validateSequences && comp instanceof AlignmentPanel
               && source instanceof AlignmentPanel)
       {
-        validateSequences(((AlignmentPanel) source).av.alignment,
-                ((AlignmentPanel) comp).av.alignment);
+        validateSequences(((AlignmentPanel) source).av.getAlignment(),
+                ((AlignmentPanel) comp).av.getAlignment());
       }
 
       if (comp instanceof AlignmentPanel && alignmentChanged)
index 354d8bf..a1fb5ea 100755 (executable)
@@ -48,17 +48,17 @@ public class PairwiseAlignPanel extends Panel implements ActionListener
 
     if (ap.av.getSelectionGroup() == null)
     {
-      seqs = ap.av.alignment.getSequencesArray();
+      seqs = ap.av.getAlignment().getSequencesArray();
     }
     else
     {
-      seqs = ap.av.getSelectionGroup().getSequencesInOrder(ap.av.alignment);
+      seqs = ap.av.getSelectionGroup().getSequencesInOrder(ap.av.getAlignment());
     }
 
     float scores[][] = new float[seqs.length][seqs.length];
     double totscore = 0;
     int count = ap.av.getSelectionGroup().getSize();
-    String type = (ap.av.alignment.isNucleotide()) ? AlignSeq.DNA
+    String type = (ap.av.getAlignment().isNucleotide()) ? AlignSeq.DNA
             : AlignSeq.PEP;
     Sequence seq;
 
index 77c9691..0b4987c 100755 (executable)
@@ -28,8 +28,6 @@ import jalview.datamodel.*;
 public class RedundancyPanel extends SliderPanel implements Runnable,
         WindowListener
 {
-  AlignmentPanel ap;
-
   Stack historyList = new Stack(); // simpler than synching with alignFrame.
 
   float[] redundancy;
@@ -109,15 +107,15 @@ public class RedundancyPanel extends SliderPanel implements Runnable,
 
     if ((sg != null) && (sg.getSize() >= 1))
     {
-      originalSequences = sg.getSequencesInOrder(ap.av.alignment);
+      originalSequences = sg.getSequencesInOrder(ap.av.getAlignment());
       start = sg.getStartRes();
       end = sg.getEndRes();
     }
     else
     {
-      originalSequences = ap.av.alignment.getSequencesArray();
+      originalSequences = ap.av.getAlignment().getSequencesArray();
       start = 0;
-      end = ap.av.alignment.getWidth();
+      end = ap.av.getAlignment().getWidth();
     }
 
     height = originalSequences.length;
@@ -241,11 +239,11 @@ public class RedundancyPanel extends SliderPanel implements Runnable,
       }
 
       EditCommand cut = new EditCommand("Remove Redundancy",
-              EditCommand.CUT, deleted, 0, width, ap.av.alignment);
-
+              EditCommand.CUT, deleted, 0, width, ap.av.getAlignment());
+      AlignmentI alignment=ap.av.getAlignment();
       for (int i = 0; i < del.size(); i++)
       {
-        ap.av.alignment.deleteSequence(deleted[i]);
+        alignment.deleteSequence(deleted[i]);
         PaintRefresher.Refresh(this, ap.av.getSequenceSetId(), true, true);
         if (sg != null)
         {
index 43af670..ce03ef0 100755 (executable)
@@ -518,13 +518,13 @@ public class RotatableCanvas extends Panel implements MouseListener,
       if (av.getSelectionGroup() != null)
       {
         av.getSelectionGroup().addOrRemove(found, true);
-        av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1);
+        av.getSelectionGroup().setEndRes(av.getAlignment().getWidth() - 1);
       }
       else
       {
         av.setSelectionGroup(new SequenceGroup());
         av.getSelectionGroup().addOrRemove(found, true);
-        av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1);
+        av.getSelectionGroup().setEndRes(av.getAlignment().getWidth() - 1);
 
       }
       PaintRefresher.Refresh(this, av.getSequenceSetId());
index cb9c4e1..8fe6e30 100755 (executable)
@@ -60,7 +60,7 @@ public class ScalePanel extends Panel implements MouseMotionListener,
     int x = (evt.getX() / av.getCharWidth()) + av.getStartRes();
     final int res;
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       res = av.getColumnSelection().adjustForHiddenColumns(x);
     }
@@ -122,7 +122,7 @@ public class ScalePanel extends Panel implements MouseMotionListener,
           {
             av.hideColumns(res, res);
             if (av.getSelectionGroup() != null
-                    && av.getSelectionGroup().getSize() == av.alignment
+                    && av.getSelectionGroup().getSize() == av.getAlignment()
                             .getHeight())
             {
               av.setSelectionGroup(null);
@@ -150,9 +150,9 @@ public class ScalePanel extends Panel implements MouseMotionListener,
 
       av.getColumnSelection().addElement(res);
       SequenceGroup sg = new SequenceGroup();
-      for (int i = 0; i < av.alignment.getSequences().size(); i++)
+      for (int i = 0; i < av.getAlignment().getSequences().size(); i++)
       {
-        sg.addSequence(av.alignment.getSequenceAt(i), false);
+        sg.addSequence(av.getAlignment().getSequenceAt(i), false);
       }
 
       sg.setStartRes(res);
@@ -182,12 +182,12 @@ public class ScalePanel extends Panel implements MouseMotionListener,
 
     int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
 
-    if (res > av.alignment.getWidth())
+    if (res > av.getAlignment().getWidth())
     {
-      res = av.alignment.getWidth() - 1;
+      res = av.getAlignment().getWidth() - 1;
     }
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       res = av.getColumnSelection().adjustForHiddenColumns(res);
     }
@@ -225,14 +225,14 @@ public class ScalePanel extends Panel implements MouseMotionListener,
       res = 0;
     }
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       res = av.getColumnSelection().adjustForHiddenColumns(res);
     }
 
-    if (res > av.alignment.getWidth())
+    if (res > av.getAlignment().getWidth())
     {
-      res = av.alignment.getWidth() - 1;
+      res = av.getAlignment().getWidth() - 1;
     }
 
     if (res < min)
@@ -307,7 +307,7 @@ public class ScalePanel extends Panel implements MouseMotionListener,
 
   public void mouseMoved(MouseEvent evt)
   {
-    if (!av.hasHiddenColumns)
+    if (!av.hasHiddenColumns())
     {
       return;
     }
@@ -360,7 +360,7 @@ public class ScalePanel extends Panel implements MouseMotionListener,
     for (int i = 0; i < cs.size(); i++)
     {
       int sel = cs.columnAt(i);
-      if (av.hasHiddenColumns)
+      if (av.hasHiddenColumns())
       {
         sel = av.getColumnSelection().findColumnPosition(sel);
       }
@@ -417,7 +417,7 @@ public class ScalePanel extends Panel implements MouseMotionListener,
       }
     }
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       gg.setColor(Color.blue);
       int res;
index 1ddcaf7..2296ab1 100755 (executable)
@@ -78,7 +78,7 @@ public class SeqCanvas extends Panel
     for (int i = scalestartx; i < endx; i += 10)
     {
       int value = i;
-      if (av.hasHiddenColumns)
+      if (av.hasHiddenColumns())
       {
         value = av.getColumnSelection().adjustForHiddenColumns(value);
       }
@@ -97,22 +97,22 @@ public class SeqCanvas extends Panel
   {
     FontMetrics fm = getFontMetrics(av.getFont());
     ypos += av.charHeight;
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       startx = av.getColumnSelection().adjustForHiddenColumns(startx);
       endx = av.getColumnSelection().adjustForHiddenColumns(endx);
     }
 
-    int maxwidth = av.alignment.getWidth();
-    if (av.hasHiddenColumns)
+    int maxwidth = av.getAlignment().getWidth();
+    if (av.hasHiddenColumns())
     {
       maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
     }
 
     // WEST SCALE
-    for (int i = 0; i < av.alignment.getHeight(); i++)
+    for (int i = 0; i < av.getAlignment().getHeight(); i++)
     {
-      SequenceI seq = av.alignment.getSequenceAt(i);
+      SequenceI seq = av.getAlignment().getSequenceAt(i);
       int index = startx;
       int value = -1;
 
@@ -125,7 +125,7 @@ public class SeqCanvas extends Panel
           continue;
         }
 
-        value = av.alignment.getSequenceAt(i).findPosition(index);
+        value = av.getAlignment().getSequenceAt(i).findPosition(index);
 
         break;
       }
@@ -144,16 +144,16 @@ public class SeqCanvas extends Panel
   {
     ypos += av.charHeight;
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       endx = av.getColumnSelection().adjustForHiddenColumns(endx);
     }
 
     SequenceI seq;
     // EAST SCALE
-    for (int i = 0; i < av.alignment.getHeight(); i++)
+    for (int i = 0; i < av.getAlignment().getHeight(); i++)
     {
-      seq = av.alignment.getSequenceAt(i);
+      seq = av.getAlignment().getSequenceAt(i);
       int index = endx;
       int value = -1;
 
@@ -348,9 +348,10 @@ public class SeqCanvas extends Panel
     String mask = "0";
     int maxWidth = 0;
     int tmp;
-    for (int i = 0; i < av.alignment.getHeight(); i++)
+    AlignmentI alignment=av.getAlignment();
+    for (int i = 0; i < alignment.getHeight(); i++)
     {
-      tmp = av.alignment.getSequenceAt(i).getEnd();
+      tmp = alignment.getSequenceAt(i).getEnd();
       if (tmp > maxWidth)
       {
         maxWidth = tmp;
@@ -397,9 +398,9 @@ public class SeqCanvas extends Panel
     int endx;
     int ypos = hgap;
 
-    int maxwidth = av.alignment.getWidth() - 1;
+    int maxwidth = av.getAlignment().getWidth() - 1;
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
     }
@@ -433,7 +434,7 @@ public class SeqCanvas extends Panel
       {
         drawNorthScale(g, startRes, endx, ypos);
       }
-      if (av.hasHiddenColumns && av.showHiddenMarkers)
+      if (av.hasHiddenColumns() && av.showHiddenMarkers)
       {
         g.setColor(Color.blue);
         int res;
@@ -506,7 +507,7 @@ public class SeqCanvas extends Panel
   void drawPanel(Graphics g1, int startRes, int endRes, int startSeq,
           int endSeq, int offset)
   {
-    if (!av.hasHiddenColumns)
+    if (!av.hasHiddenColumns())
     {
       draw(g1, startRes, endRes, startSeq, endSeq, offset);
     }
@@ -575,14 +576,14 @@ public class SeqCanvas extends Panel
     // ///////////////////////////
     for (int i = startSeq; i < endSeq; i++)
     {
-      nextSeq = av.alignment.getSequenceAt(i);
+      nextSeq = av.getAlignment().getSequenceAt(i);
 
       if (nextSeq == null)
       {
         continue;
       }
 
-      sr.drawSequence(nextSeq, av.alignment.findAllGroups(nextSeq),
+      sr.drawSequence(nextSeq, av.getAlignment().findAllGroups(nextSeq),
               startRes, endRes, offset + ((i - startSeq) * av.charHeight));
 
       if (av.showSequenceFeatures)
@@ -619,7 +620,7 @@ public class SeqCanvas extends Panel
     }
 
     if (av.getSelectionGroup() != null
-            || av.alignment.getGroups().size() > 0)
+            || av.getAlignment().getGroups().size() > 0)
     {
       drawGroupsBoundaries(g, startRes, endRes, startSeq, endSeq, offset);
     }
@@ -640,9 +641,9 @@ public class SeqCanvas extends Panel
     int ex = -1;
     int groupIndex = -1;
 
-    if ((group == null) && (av.alignment.getGroups().size() > 0))
+    if ((group == null) && (av.getAlignment().getGroups().size() > 0))
     {
-      group = (SequenceGroup) av.alignment.getGroups().elementAt(0);
+      group = (SequenceGroup) av.getAlignment().getGroups().elementAt(0);
       groupIndex = 0;
     }
 
@@ -655,7 +656,7 @@ public class SeqCanvas extends Panel
         boolean inGroup = false;
         int top = -1;
         int bottom = -1;
-        int alHeight = av.alignment.getHeight() - 1;
+        int alHeight = av.getAlignment().getHeight() - 1;
 
         for (i = startSeq; i < endSeq; i++)
         {
@@ -670,11 +671,11 @@ public class SeqCanvas extends Panel
 
           if ((sx <= (endRes - startRes) * av.charWidth)
                   && group.getSequences(null).contains(
-                          av.alignment.getSequenceAt(i)))
+                          av.getAlignment().getSequenceAt(i)))
           {
             if ((bottom == -1)
                     && (i >= alHeight || !group.getSequences(null)
-                            .contains(av.alignment.getSequenceAt(i + 1))))
+                            .contains(av.getAlignment().getSequenceAt(i + 1))))
             {
               bottom = sy + av.charHeight;
             }
@@ -683,7 +684,7 @@ public class SeqCanvas extends Panel
             {
               if (((top == -1) && (i == 0))
                       || !group.getSequences(null).contains(
-                              av.alignment.getSequenceAt(i - 1)))
+                              av.getAlignment().getSequenceAt(i - 1)))
               {
                 top = sy;
               }
@@ -793,14 +794,14 @@ public class SeqCanvas extends Panel
 
         groupIndex++;
 
-        if (groupIndex >= av.alignment.getGroups().size())
+        if (groupIndex >= av.getAlignment().getGroups().size())
         {
           break;
         }
 
-        group = (SequenceGroup) av.alignment.getGroups().elementAt(
+        group = (SequenceGroup) av.getAlignment().getGroups().elementAt(
                 groupIndex);
-      } while (groupIndex < av.alignment.getGroups().size());
+      } while (groupIndex < av.getAlignment().getGroups().size());
 
     }
   }
index c7e9432..79e6ed7 100644 (file)
@@ -154,19 +154,19 @@ public class SeqPanel extends Panel implements MouseMotionListener,
   {
     seqCanvas.cursorX += dx;
     seqCanvas.cursorY += dy;
-    if (av.hasHiddenColumns && !av.colSel.isVisible(seqCanvas.cursorX))
+    if (av.hasHiddenColumns() && !av.getColumnSelection().isVisible(seqCanvas.cursorX))
     {
       int original = seqCanvas.cursorX - dx;
-      int maxWidth = av.alignment.getWidth();
+      int maxWidth = av.getAlignment().getWidth();
 
-      while (!av.colSel.isVisible(seqCanvas.cursorX)
+      while (!av.getColumnSelection().isVisible(seqCanvas.cursorX)
               && seqCanvas.cursorX < maxWidth && seqCanvas.cursorX > 0)
       {
         seqCanvas.cursorX += dx;
       }
 
       if (seqCanvas.cursorX >= maxWidth
-              || !av.colSel.isVisible(seqCanvas.cursorX))
+              || !av.getColumnSelection().isVisible(seqCanvas.cursorX))
       {
         seqCanvas.cursorX = original;
       }
@@ -180,18 +180,18 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     {
       seqCanvas.cursorX = 0;
     }
-    else if (seqCanvas.cursorX > av.alignment.getWidth() - 1)
+    else if (seqCanvas.cursorX > av.getAlignment().getWidth() - 1)
     {
-      seqCanvas.cursorX = av.alignment.getWidth() - 1;
+      seqCanvas.cursorX = av.getAlignment().getWidth() - 1;
     }
 
     if (seqCanvas.cursorY < 0)
     {
       seqCanvas.cursorY = 0;
     }
-    else if (seqCanvas.cursorY > av.alignment.getHeight() - 1)
+    else if (seqCanvas.cursorY > av.getAlignment().getHeight() - 1)
     {
-      seqCanvas.cursorY = av.alignment.getHeight() - 1;
+      seqCanvas.cursorY = av.getAlignment().getHeight() - 1;
     }
 
     endEditing();
@@ -209,7 +209,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
       {
         ap.scrollUp(false);
       }
-      while (seqCanvas.cursorX < av.colSel
+      while (seqCanvas.cursorX < av.getColumnSelection()
               .adjustForHiddenColumns(av.startRes))
       {
 
@@ -218,7 +218,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
           break;
         }
       }
-      while (seqCanvas.cursorX > av.colSel
+      while (seqCanvas.cursorX > av.getColumnSelection()
               .adjustForHiddenColumns(av.endRes))
       {
         if (!ap.scrollRight(true))
@@ -227,7 +227,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
         }
       }
     }
-    setStatusMessage(av.alignment.getSequenceAt(seqCanvas.cursorY),
+    setStatusMessage(av.getAlignment().getSequenceAt(seqCanvas.cursorY),
             seqCanvas.cursorX, seqCanvas.cursorY);
 
     seqCanvas.repaint();
@@ -240,12 +240,12 @@ public class SeqPanel extends Panel implements MouseMotionListener,
 
     if (av.getSelectionGroup() != null)
     {
-      SequenceGroup sg = av.selectionGroup;
+      SequenceGroup sg = av.getSelectionGroup();
       // Find the top and bottom of this group
-      int min = av.alignment.getHeight(), max = 0;
+      int min = av.getAlignment().getHeight(), max = 0;
       for (int i = 0; i < sg.getSize(); i++)
       {
-        int index = av.alignment.findIndex(sg.getSequenceAt(i));
+        int index = av.getAlignment().findIndex(sg.getSequenceAt(i));
         if (index > max)
         {
           max = index;
@@ -290,7 +290,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
         sg.getSequences(null).removeAllElements();
         for (int i = min; i < max; i++)
         {
-          sg.addSequence(av.alignment.getSequenceAt(i), false);
+          sg.addSequence(av.getAlignment().getSequenceAt(i), false);
         }
       }
     }
@@ -372,7 +372,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
             + sequence.getName());
 
     Object obj = null;
-    if (av.alignment.isNucleotide())
+    if (av.getAlignment().isNucleotide())
     {
       obj = ResidueProperties.nucleotideName.get(sequence.getCharAt(res)
               + "");
@@ -455,7 +455,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
 
   public void mouseClicked(MouseEvent evt)
   {
-    SequenceI sequence = av.alignment.getSequenceAt(findSeq(evt));
+    SequenceI sequence = av.getAlignment().getSequenceAt(findSeq(evt));
     if (evt.getClickCount() > 1)
     {
       if (av.getSelectionGroup()!=null && av.getSelectionGroup().getSize() == 1
@@ -543,7 +543,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
       res = (x / av.getCharWidth()) + av.getStartRes();
     }
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       res = av.getColumnSelection().adjustForHiddenColumns(res);
     }
@@ -582,7 +582,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
       y -= hgap;
 
       seq = Math.min((y % cHeight) / av.getCharHeight(),
-              av.alignment.getHeight() - 1);
+              av.getAlignment().getHeight() - 1);
       if (seq < 0)
       {
         seq = -1;
@@ -591,7 +591,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     else
     {
       seq = Math.min((y / av.getCharHeight()) + av.getStartSeq(),
-              av.alignment.getHeight() - 1);
+              av.getAlignment().getHeight() - 1);
       if (seq < 0)
       {
         seq = -1;
@@ -688,7 +688,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
             + sequence.getName());
 
     Object obj = null;
-    if (av.alignment.isNucleotide())
+    if (av.getAlignment().isNucleotide())
     {
       obj = ResidueProperties.nucleotideName.get(sequence.getCharAt(res)
               + "");
@@ -717,7 +717,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     ap.alignFrame.statusBar.setText(text.toString());
 
     StringBuffer tooltipText = new StringBuffer();
-    SequenceGroup[] groups = av.alignment.findAllGroups(sequence);
+    SequenceGroup[] groups = av.getAlignment().findAllGroups(sequence);
     if (groups != null)
     {
       for (int g = 0; g < groups.length; g++)
@@ -916,14 +916,14 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     boolean fixedColumns = false;
     SequenceGroup sg = av.getSelectionGroup();
 
-    SequenceI seq = av.alignment.getSequenceAt(startseq);
+    SequenceI seq = av.getAlignment().getSequenceAt(startseq);
 
-    if (!groupEditing && av.hasHiddenRows)
+    if (!groupEditing && av.hasHiddenRows())
     {
-      if (av.hiddenRepSequences != null
-              && av.hiddenRepSequences.containsKey(seq))
+      if (av.getHiddenRepSequences() != null
+              && av.getHiddenRepSequences().containsKey(seq))
       {
-        sg = (SequenceGroup) av.hiddenRepSequences.get(seq);
+        sg = (SequenceGroup) av.getHiddenRepSequences().get(seq);
         groupEditing = true;
       }
     }
@@ -965,7 +965,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
 
     // Are we editing within a selection group?
     if (groupEditing
-            || (sg != null && sg.getSequences(av.hiddenRepSequences)
+            || (sg != null && sg.getSequences(av.getHiddenRepSequences())
                     .contains(seq)))
     {
       fixedColumns = true;
@@ -974,14 +974,14 @@ public class SeqPanel extends Panel implements MouseMotionListener,
       // but the sequence represents a group
       if (sg == null)
       {
-        if (av.hiddenRepSequences == null
-                || !av.hiddenRepSequences.containsKey(seq))
+        if (av.getHiddenRepSequences() == null
+                || !av.getHiddenRepSequences().containsKey(seq))
         {
           endEditing();
           return;
         }
 
-        sg = (SequenceGroup) av.hiddenRepSequences.get(seq);
+        sg = (SequenceGroup) av.getHiddenRepSequences().get(seq);
       }
 
       fixedLeft = sg.getStartRes();
@@ -1008,7 +1008,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
       }
     }
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       fixedColumns = true;
       int y1 = av.getColumnSelection().getHiddenBoundaryLeft(startres);
@@ -1038,7 +1038,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
 
     if (groupEditing)
     {
-      Vector vseqs = sg.getSequences(av.hiddenRepSequences);
+      Vector vseqs = sg.getSequences(av.getHiddenRepSequences());
       int g, groupSize = vseqs.size();
       SequenceI[] groupSeqs = new SequenceI[groupSize];
       for (g = 0; g < groupSeqs.length; g++)
@@ -1052,9 +1052,9 @@ public class SeqPanel extends Panel implements MouseMotionListener,
         // If the user has selected the whole sequence, and is dragging to
         // the right, we can still extend the alignment and selectionGroup
         if (sg.getStartRes() == 0 && sg.getEndRes() == fixedRight
-                && sg.getEndRes() == av.alignment.getWidth() - 1)
+                && sg.getEndRes() == av.getAlignment().getWidth() - 1)
         {
-          sg.setEndRes(av.alignment.getWidth() + startres - lastres);
+          sg.setEndRes(av.getAlignment().getWidth() + startres - lastres);
           fixedRight = sg.getEndRes();
         }
 
@@ -1086,19 +1086,19 @@ public class SeqPanel extends Panel implements MouseMotionListener,
 
         if (!blank)
         {
-          if (sg.getSize() == av.alignment.getHeight())
+          if (sg.getSize() == av.getAlignment().getHeight())
           {
-            if ((av.hasHiddenColumns && startres < av.getColumnSelection()
+            if ((av.hasHiddenColumns() && startres < av.getColumnSelection()
                     .getHiddenBoundaryRight(startres)))
             {
               endEditing();
               return;
             }
 
-            int alWidth = av.alignment.getWidth();
-            if (av.hasHiddenRows)
+            int alWidth = av.getAlignment().getWidth();
+            if (av.hasHiddenRows())
             {
-              int hwidth = av.alignment.getHiddenSequences().getWidth();
+              int hwidth = av.getAlignment().getHiddenSequences().getWidth();
               if (hwidth > alWidth)
               {
                 alWidth = hwidth;
@@ -1155,7 +1155,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
         else
         {
           editCommand.appendEdit(EditCommand.INSERT_GAP, groupSeqs,
-                  startres, startres - lastres, av.alignment, true);
+                  startres, startres - lastres, av.getAlignment(), true);
         }
       }
       else
@@ -1171,7 +1171,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
         else
         {
           editCommand.appendEdit(EditCommand.DELETE_GAP, groupSeqs,
-                  startres, lastres - startres, av.alignment, true);
+                  startres, lastres - startres, av.getAlignment(), true);
         }
 
       }
@@ -1193,7 +1193,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
         else
         {
           editCommand.appendEdit(EditCommand.INSERT_GAP, new SequenceI[]
-          { seq }, lastres, startres - lastres, av.alignment, true);
+          { seq }, lastres, startres - lastres, av.getAlignment(), true);
         }
       }
       else
@@ -1228,7 +1228,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
           if (max > 0)
           {
             editCommand.appendEdit(EditCommand.DELETE_GAP, new SequenceI[]
-            { seq }, startres, max, av.alignment, true);
+            { seq }, startres, max, av.getAlignment(), true);
           }
         }
       }
@@ -1264,9 +1264,9 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     }
 
     editCommand.appendEdit(EditCommand.DELETE_GAP, seq, blankColumn, 1,
-            av.alignment, true);
+            av.getAlignment(), true);
 
-    editCommand.appendEdit(EditCommand.INSERT_GAP, seq, j, 1, av.alignment,
+    editCommand.appendEdit(EditCommand.INSERT_GAP, seq, j, 1, av.getAlignment(),
             true);
 
   }
@@ -1274,11 +1274,11 @@ public class SeqPanel extends Panel implements MouseMotionListener,
   void deleteChar(int j, SequenceI[] seq, int fixedColumn)
   {
 
-    editCommand.appendEdit(EditCommand.DELETE_GAP, seq, j, 1, av.alignment,
+    editCommand.appendEdit(EditCommand.DELETE_GAP, seq, j, 1, av.getAlignment(),
             true);
 
     editCommand.appendEdit(EditCommand.INSERT_GAP, seq, fixedColumn, 1,
-            av.alignment, true);
+            av.getAlignment(), true);
   }
 
   // ////////////////////////////////////////
@@ -1313,7 +1313,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
 
     if (stretchGroup == null)
     {
-      stretchGroup = av.alignment.findGroup(sequence);
+      stretchGroup = av.getAlignment().findGroup(sequence);
       if (stretchGroup != null && res > stretchGroup.getStartRes()
               && res < stretchGroup.getEndRes())
       {
@@ -1331,7 +1331,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     {
       stretchGroup = null;
 
-      SequenceGroup[] allGroups = av.alignment.findAllGroups(sequence);
+      SequenceGroup[] allGroups = av.getAlignment().findAllGroups(sequence);
 
       if (allGroups != null)
       {
@@ -1424,7 +1424,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
       if (stretchGroup.cs instanceof ClustalxColourScheme)
       {
         ((ClustalxColourScheme) stretchGroup.cs).resetClustalX(
-                stretchGroup.getSequences(av.hiddenRepSequences),
+                stretchGroup.getSequences(av.getHiddenRepSequences()),
                 stretchGroup.getWidth());
       }
 
@@ -1473,14 +1473,14 @@ public class SeqPanel extends Panel implements MouseMotionListener,
 
     mouseDragging = true;
 
-    if (y > av.alignment.getHeight())
+    if (y > av.getAlignment().getHeight())
     {
-      y = av.alignment.getHeight() - 1;
+      y = av.getAlignment().getHeight() - 1;
     }
 
-    if (res >= av.alignment.getWidth())
+    if (res >= av.getAlignment().getWidth())
     {
-      res = av.alignment.getWidth() - 1;
+      res = av.getAlignment().getWidth() - 1;
     }
 
     if (stretchGroup.getEndRes() == res)
@@ -1525,7 +1525,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
       dragDirection = -1;
     }
 
-    while ((y != oldSeq) && (oldSeq > -1) && (y < av.alignment.getHeight()))
+    while ((y != oldSeq) && (oldSeq > -1) && (y < av.getAlignment().getHeight()))
     {
       // This routine ensures we don't skip any sequences, as the
       // selection is quite slow.
@@ -1662,7 +1662,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
           }
 
           if (mouseDragging && evt.getY() >= getSize().height
-                  && av.alignment.getHeight() > av.getEndSeq())
+                  && av.getAlignment().getHeight() > av.getEndSeq())
           {
             running = ap.scrollUp(false);
           }
@@ -1709,12 +1709,12 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     // rules are: colsel is copied if there is a real intersection between
     // sequence selection
     boolean repaint = false, copycolsel = true;
-    if (av.selectionGroup == null || !av.isSelectionGroupChanged())
+    if (av.getSelectionGroup() == null || !av.isSelectionGroupChanged(true))
     {
       SequenceGroup sgroup = null;
       if (seqsel != null && seqsel.getSize()>0)
       {
-        if (av.alignment == null)
+        if (av.getAlignment() == null)
         {
           System.out
                   .println("Selection message: alignviewport av SeqSetId="
@@ -1723,8 +1723,8 @@ public class SeqPanel extends Panel implements MouseMotionListener,
                           + " 's alignment is NULL! returning immediatly.");
           return;
         }
-        sgroup = seqsel.intersect(av.alignment,
-                (av.hasHiddenRows) ? av.hiddenRepSequences : null);
+        sgroup = seqsel.intersect(av.getAlignment(),
+                (av.hasHiddenRows()) ? av.getHiddenRepSequences() : null);
         if ((sgroup == null || sgroup.getSize() == 0)
                 && (colsel == null || colsel.size() == 0))
         {
@@ -1740,35 +1740,35 @@ public class SeqPanel extends Panel implements MouseMotionListener,
       {
         av.setSelectionGroup(null);
       }
-      repaint = av.isSelectionGroupChanged();
+      repaint = av.isSelectionGroupChanged(true);
     }
-    if (copycolsel && (av.colSel == null || !av.isColSelChanged()))
+    if (copycolsel && (av.getColumnSelection() == null || !av.isColSelChanged(true)))
     {
       // the current selection is unset or from a previous message
       // so import the new colsel.
       if (colsel == null || colsel.size() == 0)
       {
-        if (av.colSel != null)
+        if (av.getColumnSelection() != null)
         {
-          av.colSel.clear();
+          av.getColumnSelection().clear();
         }
       }
       else
       {
         // TODO: shift colSel according to the intersecting sequences
-        if (av.colSel == null)
+        if (av.getColumnSelection() == null)
         {
-          av.colSel = new ColumnSelection(colsel);
+          av.setColumnSelection(new ColumnSelection(colsel));
         }
         else
         {
-          av.colSel.setElementsFrom(colsel);
+          av.getColumnSelection().setElementsFrom(colsel);
         }
       }
-      repaint |= av.isColSelChanged();
+      repaint |= av.isColSelChanged(true);
     }
-    if (copycolsel && av.hasHiddenColumns
-            && (av.colSel == null || av.colSel.getHiddenColumns() == null))
+    if (copycolsel && av.hasHiddenColumns()
+            && (av.getColumnSelection() == null || av.getColumnSelection().getHiddenColumns() == null))
     {
       System.err.println("Bad things");
     }
index caf20ee..afbc7e3 100755 (executable)
@@ -61,7 +61,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
 
   public Color getResidueBoxColour(SequenceI seq, int i)
   {
-    allGroups = av.alignment.findAllGroups(seq);
+    allGroups = av.getAlignment().findAllGroups(seq);
 
     if (inCurrentSequenceGroup(i))
     {
@@ -72,7 +72,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
     }
     else if (av.getShowBoxes())
     {
-      getBoxColour(av.globalColourScheme, seq, i);
+      getBoxColour(av.getGlobalColourScheme(), seq, i);
     }
 
     return resBoxColour;
@@ -98,7 +98,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
 
   public Color findSequenceColour(SequenceI seq, int i)
   {
-    allGroups = av.alignment.findAllGroups(seq);
+    allGroups = av.getAlignment().findAllGroups(seq);
     drawBoxes(seq, i, i, 0);
     return resBoxColour;
   }
@@ -223,7 +223,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
         {
           // cheat - use this if we have a consensus for each group: s =
           // getDisplayChar(currentSequenceGroup.getConsensus(), i, s, '.');
-          s = getDisplayChar(av.consensus, i, s, '.');
+          s = getDisplayChar(av.getAlignmentConsensusAnnotation(), i, s, '.');
         }
       }
       else
@@ -245,9 +245,9 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
             graphics.setColor(resBoxColour);
           }
         }
-        if (av.getShowunconserved())
+        if (av.getShowUnconserved())
         {
-          s = getDisplayChar(av.consensus, i, s, '.');
+          s = getDisplayChar(av.getAlignmentConsensusAnnotation(), i, s, '.');
 
         }
       }
index 8a4eb29..f7522be 100755 (executable)
@@ -57,7 +57,7 @@ public class SliderPanel extends Panel implements ActionListener,
 
     conservationSlider.setTitle("Conservation Colour Increment  (" + source
             + ")");
-    if (ap.av.alignment.getGroups() != null)
+    if (ap.av.getAlignment().getGroups() != null)
     {
       sp.setAllGroupsCheckEnabled(true);
     }
@@ -112,7 +112,7 @@ public class SliderPanel extends Panel implements ActionListener,
     }
     PIDSlider.setTitle("Percentage Identity Threshold (" + source + ")");
 
-    if (ap.av.alignment.getGroups() != null)
+    if (ap.av.getAlignment().getGroups() != null)
     {
       pid.setAllGroupsCheckEnabled(true);
     }
@@ -200,7 +200,7 @@ public class SliderPanel extends Panel implements ActionListener,
 
     if (allGroupsCheck.getState())
     {
-      allGroups = ap.av.alignment.getGroups();
+      allGroups = ap.av.getAlignment().getGroups();
       groupIndex = allGroups.size() - 1;
     }
     else
index 2ab7bf7..9a4c82c 100755 (executable)
@@ -87,7 +87,7 @@ public class TreeCanvas extends Panel implements MouseListener,
       av.setSelectionGroup(selected);
     }
 
-    selected.setEndRes(av.alignment.getWidth() - 1);
+    selected.setEndRes(av.getAlignment().getWidth() - 1);
     selected.addOrRemove(sequence, true);
   }
 
@@ -570,7 +570,7 @@ public class TreeCanvas extends Panel implements MouseListener,
         setColor(tree.getTopNode(), Color.black);
 
         av.setSelectionGroup(null);
-        av.alignment.deleteAllGroups();
+        av.getAlignment().deleteAllGroups();
         av.sequenceColours = null;
 
         colourGroups();
@@ -619,7 +619,7 @@ public class TreeCanvas extends Panel implements MouseListener,
         }
         else
         {
-          cs = ColourSchemeProperty.getColour(sequences, av.alignment
+          cs = ColourSchemeProperty.getColour(sequences, av.getAlignment()
                   .getWidth(), ColourSchemeProperty.getColourName(av
                   .getGlobalColourScheme()));
         }
@@ -632,7 +632,7 @@ public class TreeCanvas extends Panel implements MouseListener,
       }
 
       SequenceGroup sg = new SequenceGroup(sequences, "", cs, true, true,
-              false, 0, av.alignment.getWidth() - 1);
+              false, 0, av.getAlignment().getWidth() - 1);
 
       sg.setName("JTreeGroup:" + sg.hashCode());
       sg.setIdColour(col);
@@ -651,7 +651,7 @@ public class TreeCanvas extends Panel implements MouseListener,
 
       }
 
-      av.alignment.addGroup(sg);
+      av.getAlignment().addGroup(sg);
 
     }
     ap.updateAnnotation();
index 29e5654..aa57908 100644 (file)
@@ -186,11 +186,11 @@ public class TreePanel extends EmbmenuFrame implements ActionListener,
       {
         if (odata == null)
         {
-          tree = new NJTree(av.alignment.getSequencesArray(), newtree);
+          tree = new NJTree(av.getAlignment().getSequencesArray(), newtree);
         }
         else
         {
-          tree = new NJTree(av.alignment.getSequencesArray(), odata,
+          tree = new NJTree(av.getAlignment().getSequencesArray(), odata,
                   newtree);
         }
 
@@ -204,14 +204,14 @@ public class TreePanel extends EmbmenuFrame implements ActionListener,
         if (av.getSelectionGroup() == null)
         {
           start = 0;
-          end = av.alignment.getWidth();
-          seqs = av.alignment.getSequencesArray();
+          end = av.getAlignment().getWidth();
+          seqs = av.getAlignment().getSequencesArray();
         }
         else
         {
           start = av.getSelectionGroup().getStartRes();
           end = av.getSelectionGroup().getEndRes() + 1;
-          seqs = av.getSelectionGroup().getSequencesInOrder(av.alignment);
+          seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
         }
 
         tree = new NJTree(seqs, seqStrings, type, pwtype, start, end);
diff --git a/src/jalview/datamodel/AlignmentViewport.java b/src/jalview/datamodel/AlignmentViewport.java
deleted file mode 100644 (file)
index 7573401..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-package jalview.datamodel;
-
-/**
- * base class holding visualization and analysis attributes for an active alignment view displayed in the GUI
- * @author jimp
- *
- */
-public class AlignmentViewport
-{
-
-  /**
-   * percentage gaps allowed in a column before all amino acid properties should be considered unconserved
-   */
-  int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
-
-
-  public int getConsPercGaps()
-  {
-    return ConsPercGaps;
-  }
-
-}
index 850450b..50a0f41 100755 (executable)
@@ -283,7 +283,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    */
   void init()
   {
-    if (viewport.conservation == null)
+    if (viewport.getAlignmentConservationAnnotation()== null)
     {
       BLOSUM62Colour.setEnabled(false);
       conservationMenuItem.setEnabled(false);
@@ -309,7 +309,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     {
       this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
       addServiceListeners();
-      setGUINucleotide(viewport.alignment.isNucleotide());
+      setGUINucleotide(viewport.getAlignment().isNucleotide());
     }
 
     setMenusFromViewport(viewport);
@@ -584,9 +584,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     if (newPanel)
     {
-      if (ap.av.padGaps)
+      if (ap.av.isPadGaps())
       {
-        ap.av.alignment.padGaps();
+        ap.av.getAlignment().padGaps();
       }
       ap.av.updateConservation(ap);
       ap.av.updateConsensus(ap);
@@ -691,7 +691,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    */
   void setMenusFromViewport(AlignViewport av)
   {
-    padGapsMenuitem.setSelected(av.padGaps);
+    padGapsMenuitem.setSelected(av.isPadGaps());
     colourTextMenuItem.setSelected(av.showColourText);
     abovePIDThreshold.setSelected(av.getAbovePIDThreshold());
     conservationMenuItem.setSelected(av.getConservationSelected());
@@ -706,12 +706,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     annotationPanelMenuItem.setState(av.showAnnotation);
     viewBoxesMenuItem.setSelected(av.showBoxes);
     viewTextMenuItem.setSelected(av.showText);
-    showNonconservedMenuItem.setSelected(av.showUnconserved);
-    showGroupConsensus.setSelected(av.showGroupConsensus);
-    showGroupConservation.setSelected(av.showGroupConservation);
-    showConsensusHistogram.setSelected(av.showConsensusHistogram);
-    showSequenceLogo.setSelected(av.showSequenceLogo);
-    normaliseSequenceLogo.setSelected(av.normaliseSequenceLogo);
+    showNonconservedMenuItem.setSelected(av.getShowUnconserved());
+    showGroupConsensus.setSelected(av.isShowGroupConsensus());
+    showGroupConservation.setSelected(av.isShowGroupConservation());
+    showConsensusHistogram.setSelected(av.isShowConsensusHistogram());
+    showSequenceLogo.setSelected(av.isShowSequenceLogo());
+    normaliseSequenceLogo.setSelected(av.isNormaliseSequenceLogo());
     
     setColourSelected(ColourSchemeProperty.getColourName(av
             .getGlobalColourScheme()));
@@ -724,7 +724,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     autoCalculate.setSelected(av.autoCalculateConsensus);
     sortByTree.setSelected(av.sortByTree);
     listenToViewSelections.setSelected(av.followSelection);
-    rnahelicesColour.setEnabled(av.alignment.hasRNAStructure());
+    rnahelicesColour.setEnabled(av.getAlignment().hasRNAStructure());
     rnahelicesColour.setSelected(av.getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
     setShowProductsEnabled();
 
@@ -1018,7 +1018,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
       String[] omitHidden = null;
 
-      if (viewport.hasHiddenColumns)
+      if (viewport.hasHiddenColumns())
       {
         int reply = JOptionPane
                 .showInternalConfirmDialog(
@@ -1036,9 +1036,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       }
       FormatAdapter f = new FormatAdapter();
       String output = f.formatSequences(format,
-              (Alignment) viewport.alignment, // class cast exceptions will
+              (Alignment) viewport.getAlignment(), // class cast exceptions will
               // occur in the distant future
-              omitHidden, f.getCacheSuffixDefault(format), viewport.colSel);
+              omitHidden, f.getCacheSuffixDefault(format), viewport.getColumnSelection());
 
       if (output == null)
       {
@@ -1098,7 +1098,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   {
     String[] omitHidden = null;
 
-    if (viewport.hasHiddenColumns)
+    if (viewport.hasHiddenColumns())
     {
       int reply = JOptionPane
               .showInternalConfirmDialog(
@@ -1121,7 +1121,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     try
     {
       cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
-              viewport.alignment, omitHidden, viewport.colSel));
+              viewport.getAlignment(), omitHidden, viewport.getColumnSelection()));
       Desktop.addInternalFrame(cap,
               "Alignment output - " + e.getActionCommand(), 600, 500);
     } catch (OutOfMemoryError oom)
@@ -1200,10 +1200,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   {
     new AnnotationExporter().exportAnnotations(
             alignPanel,
-            viewport.showAnnotation ? viewport.alignment
-                    .getAlignmentAnnotation() : null, viewport.alignment
+            viewport.showAnnotation ? viewport.getAlignment()
+                    .getAlignmentAnnotation() : null, viewport.getAlignment()
                     .getGroups(),
-            ((Alignment) viewport.alignment).alignmentProperties);
+            ((Alignment) viewport.getAlignment()).alignmentProperties);
   }
 
   public void associatedData_actionPerformed(ActionEvent e)
@@ -1341,9 +1341,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       viewport.historyList.push(command);
       viewport.redoList.clear();
       updateEditMenuBar();
-      viewport.hasHiddenColumns = (viewport.colSel != null
-              && viewport.colSel.getHiddenColumns() != null && viewport.colSel
-              .getHiddenColumns().size() > 0);
+      viewport.updateHiddenColumns();
+//      viewport.hasHiddenColumns = (viewport.getColumnSelection() != null
+//              && viewport.getColumnSelection().getHiddenColumns() != null && viewport.getColumnSelection()
+//              .getHiddenColumns().size() > 0);
     }
   }
 
@@ -1366,7 +1367,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     if (viewport != null)
     {
       return new AlignmentI[]
-      { viewport.alignment };
+      { viewport.getAlignment() };
     }
     return null;
   }
@@ -1390,11 +1391,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     if (originalSource != null)
     {
-      originalSource.hasHiddenColumns = (viewport.colSel != null
-              && viewport.colSel.getHiddenColumns() != null && viewport.colSel
-              .getHiddenColumns().size() > 0);
+      if (originalSource!=viewport)
+      {
+        Cache.log.warn("Implementation worry: mismatch of viewport origin for undo");
+      }
+      originalSource.updateHiddenColumns();
+//      originalSource.hasHiddenColumns = (viewport.getColumnSelection() != null
+//              && viewport.getColumnSelection().getHiddenColumns() != null && viewport.getColumnSelection()
+//              .getHiddenColumns().size() > 0);
       originalSource.firePropertyChange("alignment", null,
-              originalSource.alignment.getSequences());
+              originalSource.getAlignment().getSequences());
     }
   }
 
@@ -1420,11 +1426,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     if (originalSource != null)
     {
-      originalSource.hasHiddenColumns = (viewport.colSel != null
-              && viewport.colSel.getHiddenColumns() != null && viewport.colSel
-              .getHiddenColumns().size() > 0);
+
+      if (originalSource!=viewport)
+      {
+        Cache.log.warn("Implementation worry: mismatch of viewport origin for redo");
+      }
+      originalSource.updateHiddenColumns();
+      //originalSource.hasHiddenColumns = (viewport.getColumnSelection() != null
+      //        && viewport.getColumnSelection().getHiddenColumns() != null && viewport.getColumnSelection()
+      //        .getHiddenColumns().size() > 0);
       originalSource.firePropertyChange("alignment", null,
-              originalSource.alignment.getSequences());
+              originalSource.getAlignment().getSequences());
     }
   }
 
@@ -1446,7 +1458,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       {
         if (comps.elementAt(i) instanceof AlignmentPanel)
         {
-          if (al == ((AlignmentPanel) comps.elementAt(i)).av.alignment)
+          if (al == ((AlignmentPanel) comps.elementAt(i)).av.getAlignment())
           {
             originalSource = ((AlignmentPanel) comps.elementAt(i)).av;
             break;
@@ -1461,7 +1473,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       // the current view against the closed view first
       if (al != null)
       {
-        PaintRefresher.validateSequences(al, viewport.alignment);
+        PaintRefresher.validateSequences(al, viewport.getAlignment());
       }
 
       originalSource = viewport;
@@ -1487,46 +1499,46 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     if (up)
     {
-      for (int i = 1; i < viewport.alignment.getHeight(); i++)
+      for (int i = 1; i < viewport.getAlignment().getHeight(); i++)
       {
-        SequenceI seq = viewport.alignment.getSequenceAt(i);
+        SequenceI seq = viewport.getAlignment().getSequenceAt(i);
 
         if (!sg.getSequences(null).contains(seq))
         {
           continue;
         }
 
-        SequenceI temp = viewport.alignment.getSequenceAt(i - 1);
+        SequenceI temp = viewport.getAlignment().getSequenceAt(i - 1);
 
         if (sg.getSequences(null).contains(temp))
         {
           continue;
         }
 
-        viewport.alignment.getSequences().setElementAt(temp, i);
-        viewport.alignment.getSequences().setElementAt(seq, i - 1);
+        viewport.getAlignment().getSequences().setElementAt(temp, i);
+        viewport.getAlignment().getSequences().setElementAt(seq, i - 1);
       }
     }
     else
     {
-      for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)
+      for (int i = viewport.getAlignment().getHeight() - 2; i > -1; i--)
       {
-        SequenceI seq = viewport.alignment.getSequenceAt(i);
+        SequenceI seq = viewport.getAlignment().getSequenceAt(i);
 
         if (!sg.getSequences(null).contains(seq))
         {
           continue;
         }
 
-        SequenceI temp = viewport.alignment.getSequenceAt(i + 1);
+        SequenceI temp = viewport.getAlignment().getSequenceAt(i + 1);
 
         if (sg.getSequences(null).contains(temp))
         {
           continue;
         }
 
-        viewport.alignment.getSequences().setElementAt(temp, i);
-        viewport.alignment.getSequences().setElementAt(seq, i + 1);
+        viewport.getAlignment().getSequences().setElementAt(temp, i);
+        viewport.getAlignment().getSequences().setElementAt(seq, i + 1);
       }
     }
 
@@ -1538,15 +1550,15 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     Vector sg = new Vector();
     if (viewport.cursorMode)
     {
-      sg.addElement(viewport.alignment
+      sg.addElement(viewport.getAlignment()
               .getSequenceAt(alignPanel.seqPanel.seqCanvas.cursorY));
     }
     else if (viewport.getSelectionGroup() != null
-            && viewport.getSelectionGroup().getSize() != viewport.alignment
+            && viewport.getSelectionGroup().getSize() != viewport.getAlignment()
                     .getHeight())
     {
       sg = viewport.getSelectionGroup().getSequences(
-              viewport.hiddenRepSequences);
+              viewport.getHiddenRepSequences());
     }
 
     if (sg.size() < 1)
@@ -1556,10 +1568,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     Vector invertGroup = new Vector();
 
-    for (int i = 0; i < viewport.alignment.getHeight(); i++)
+    for (int i = 0; i < viewport.getAlignment().getHeight(); i++)
     {
-      if (!sg.contains(viewport.alignment.getSequenceAt(i)))
-        invertGroup.add(viewport.alignment.getSequenceAt(i));
+      if (!sg.contains(viewport.getAlignment().getSequenceAt(i)))
+        invertGroup.add(viewport.getAlignment().getSequenceAt(i));
     }
 
     SequenceI[] seqs1 = new SequenceI[sg.size()];
@@ -1635,7 +1647,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     SequenceI[] seqs = viewport.getSelectionAsNewSequence();
     String[] omitHidden = null;
 
-    if (viewport.hasHiddenColumns)
+    if (viewport.hasHiddenColumns())
     {
       omitHidden = viewport.getViewAsString(true);
     }
@@ -1662,7 +1674,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
 
     Vector hiddenColumns = null;
-    if (viewport.hasHiddenColumns)
+    if (viewport.hasHiddenColumns())
     {
       hiddenColumns = new Vector();
       int hiddenOffset = viewport.getSelectionGroup().getStartRes(), hiddenCutoff = viewport
@@ -1681,7 +1693,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
 
     Desktop.jalviewClipboard = new Object[]
-    { seqs, viewport.alignment.getDataset(), hiddenColumns };
+    { seqs, viewport.getAlignment().getDataset(), hiddenColumns };
     statusBar.setText("Copied " + seqs.length + " sequences to clipboard.");
   }
 
@@ -2012,7 +2024,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
 
     // If the cut affects all sequences, remove highlighted columns
-    if (sg.getSize() == viewport.alignment.getHeight())
+    if (sg.getSize() == viewport.getAlignment().getHeight())
     {
       viewport.getColumnSelection().removeElements(sg.getStartRes(),
               sg.getEndRes() + 1);
@@ -2029,11 +2041,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
      */
     addHistoryItem(new EditCommand("Cut Sequences", EditCommand.CUT, cut,
             sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1,
-            viewport.alignment));
+            viewport.getAlignment()));
 
     viewport.setSelectionGroup(null);
     viewport.sendSelection();
-    viewport.alignment.deleteGroup(sg);
+    viewport.getAlignment().deleteGroup(sg);
 
     viewport.firePropertyChange("alignment", null, viewport.getAlignment()
             .getSequences());
@@ -2056,7 +2068,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    */
   protected void deleteGroups_actionPerformed(ActionEvent e)
   {
-    viewport.alignment.deleteAllGroups();
+    viewport.getAlignment().deleteAllGroups();
     viewport.sequenceColours = null;
     viewport.setSelectionGroup(null);
     PaintRefresher.Refresh(this, viewport.getSequenceSetId());
@@ -2079,7 +2091,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
     }
 
-    sg.setEndRes(viewport.alignment.getWidth() - 1);
+    sg.setEndRes(viewport.getAlignment().getWidth() - 1);
     viewport.setSelectionGroup(sg);
     viewport.sendSelection();
     alignPanel.paintAlignment(true);
@@ -2185,11 +2197,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       if (viewport.getSelectionGroup() != null)
       {
         seqs = viewport.getSelectionGroup().getSequencesAsArray(
-                viewport.hiddenRepSequences);
+                viewport.getHiddenRepSequences());
       }
       else
       {
-        seqs = viewport.alignment.getSequencesArray();
+        seqs = viewport.getAlignment().getSequencesArray();
       }
 
       TrimRegionCommand trimRegion;
@@ -2197,23 +2209,23 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       {
         trimRegion = new TrimRegionCommand("Remove Left",
                 TrimRegionCommand.TRIM_LEFT, seqs, column,
-                viewport.alignment, viewport.colSel,
-                viewport.selectionGroup);
+                viewport.getAlignment(), viewport.getColumnSelection(),
+                viewport.getSelectionGroup());
         viewport.setStartRes(0);
       }
       else
       {
         trimRegion = new TrimRegionCommand("Remove Right",
                 TrimRegionCommand.TRIM_RIGHT, seqs, column,
-                viewport.alignment, viewport.colSel,
-                viewport.selectionGroup);
+                viewport.getAlignment(), viewport.getColumnSelection(),
+                viewport.getSelectionGroup());
       }
 
       statusBar.setText("Removed " + trimRegion.getSize() + " columns.");
 
       addHistoryItem(trimRegion);
 
-      Vector groups = viewport.alignment.getGroups();
+      Vector groups = viewport.getAlignment().getGroups();
 
       for (int i = 0; i < groups.size(); i++)
       {
@@ -2222,7 +2234,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         if ((trimLeft && !sg.adjustForRemoveLeft(column))
                 || (!trimLeft && !sg.adjustForRemoveRight(column)))
         {
-          viewport.alignment.deleteGroup(sg);
+          viewport.getAlignment().deleteGroup(sg);
         }
       }
 
@@ -2239,23 +2251,23 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    */
   public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
   {
-    int start = 0, end = viewport.alignment.getWidth() - 1;
+    int start = 0, end = viewport.getAlignment().getWidth() - 1;
 
     SequenceI[] seqs;
     if (viewport.getSelectionGroup() != null)
     {
       seqs = viewport.getSelectionGroup().getSequencesAsArray(
-              viewport.hiddenRepSequences);
+              viewport.getHiddenRepSequences());
       start = viewport.getSelectionGroup().getStartRes();
       end = viewport.getSelectionGroup().getEndRes();
     }
     else
     {
-      seqs = viewport.alignment.getSequencesArray();
+      seqs = viewport.getAlignment().getSequencesArray();
     }
 
     RemoveGapColCommand removeGapCols = new RemoveGapColCommand(
-            "Remove Gapped Columns", seqs, start, end, viewport.alignment);
+            "Remove Gapped Columns", seqs, start, end, viewport.getAlignment());
 
     addHistoryItem(removeGapCols);
 
@@ -2264,7 +2276,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     // This is to maintain viewport position on first residue
     // of first sequence
-    SequenceI seq = viewport.alignment.getSequenceAt(0);
+    SequenceI seq = viewport.getAlignment().getSequenceAt(0);
     int startRes = seq.findPosition(viewport.startRes);
     // ShiftList shifts;
     // viewport.getAlignment().removeGaps(shifts=new ShiftList());
@@ -2285,28 +2297,28 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    */
   public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
   {
-    int start = 0, end = viewport.alignment.getWidth() - 1;
+    int start = 0, end = viewport.getAlignment().getWidth() - 1;
 
     SequenceI[] seqs;
     if (viewport.getSelectionGroup() != null)
     {
       seqs = viewport.getSelectionGroup().getSequencesAsArray(
-              viewport.hiddenRepSequences);
+              viewport.getHiddenRepSequences());
       start = viewport.getSelectionGroup().getStartRes();
       end = viewport.getSelectionGroup().getEndRes();
     }
     else
     {
-      seqs = viewport.alignment.getSequencesArray();
+      seqs = viewport.getAlignment().getSequencesArray();
     }
 
     // This is to maintain viewport position on first residue
     // of first sequence
-    SequenceI seq = viewport.alignment.getSequenceAt(0);
+    SequenceI seq = viewport.getAlignment().getSequenceAt(0);
     int startRes = seq.findPosition(viewport.startRes);
 
     addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end,
-            viewport.alignment));
+            viewport.getAlignment()));
 
     viewport.setStartRes(seq.findIndex(startRes) - 1);
 
@@ -2323,7 +2335,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    */
   public void padGapsMenuitem_actionPerformed(ActionEvent e)
   {
-    viewport.padGaps = padGapsMenuitem.isSelected();
+    viewport.setPadGaps(padGapsMenuitem.isSelected());
     viewport.firePropertyChange("alignment", null, viewport.getAlignment()
             .getSequences());
   }
@@ -2391,13 +2403,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     if (!copyAnnotation)
     {
       // just remove all the current annotation except for the automatic stuff
-      newap.av.alignment.deleteAllGroups();
-      for (AlignmentAnnotation alan : newap.av.alignment
+      newap.av.getAlignment().deleteAllGroups();
+      for (AlignmentAnnotation alan : newap.av.getAlignment()
               .getAlignmentAnnotation())
       {
         if (!alan.autoCalculated)
         {
-          newap.av.alignment.deleteAnnotation(alan);
+          newap.av.getAlignment().deleteAnnotation(alan);
         }
         ;
       }
@@ -2581,7 +2593,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       // Hide everything by the current selection - this is a hack - we do the
       // invert and then hide
       // first check that there will be visible columns after the invert.
-      if ((viewport.colSel != null && viewport.colSel.getSelected() != null && viewport.colSel
+      if ((viewport.getColumnSelection() != null && viewport.getColumnSelection().getSelected() != null && viewport.getColumnSelection()
               .getSelected().size() > 0)
               || (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg
                       .getEndRes()))
@@ -2605,12 +2617,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     if (toggleSeqs)
     {
-      if (sg != null && sg.getSize() != viewport.alignment.getHeight())
+      if (sg != null && sg.getSize() != viewport.getAlignment().getHeight())
       {
         hideSelSequences_actionPerformed(null);
         hide = true;
       }
-      else if (!(toggleCols && viewport.colSel.getSelected().size() > 0))
+      else if (!(toggleCols && viewport.getColumnSelection().getSelected().size() > 0))
       {
         showAllSeqs_actionPerformed(null);
       }
@@ -2618,12 +2630,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     if (toggleCols)
     {
-      if (viewport.colSel.getSelected().size() > 0)
+      if (viewport.getColumnSelection().getSelected().size() > 0)
       {
         hideSelColumns_actionPerformed(null);
         if (!toggleSeqs)
         {
-          viewport.selectionGroup = sg;
+          viewport.setSelectionGroup(sg);
         }
       }
       else if (!hide)
@@ -2832,7 +2844,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   {
     JEditorPane editPane = new JEditorPane("text/html", "");
     editPane.setEditable(false);
-    StringBuffer contents = new AlignmentProperties(viewport.alignment)
+    StringBuffer contents = new AlignmentProperties(viewport.getAlignment())
             .formatAsHtml();
     editPane.setText("<html>" + contents.toString() + "</html>");
     JInternalFrame frame = new JInternalFrame();
@@ -2899,8 +2911,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   public void clustalColour_actionPerformed(ActionEvent e)
   {
     changeColour(new ClustalxColourScheme(
-            viewport.alignment.getSequences(),
-            viewport.alignment.getWidth()));
+            viewport.getAlignment().getSequences(),
+            viewport.getAlignment().getWidth()));
   }
 
   /**
@@ -2998,7 +3010,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   /*
   public void covariationColour_actionPerformed(ActionEvent e)
   {
-    changeColour(new CovariationColourScheme(viewport.alignment.getAlignmentAnnotation()[0]));
+    changeColour(new CovariationColourScheme(viewport.getAlignment().getAlignmentAnnotation()[0]));
   }
   */
   public void annotationColour_actionPerformed(ActionEvent e)
@@ -3051,7 +3063,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       if (viewport.getConservationSelected())
       {
 
-        Alignment al = (Alignment) viewport.alignment;
+        Alignment al = (Alignment) viewport.getAlignment();
         Conservation c = new Conservation("All",
                 ResidueProperties.propHash, 3, al.getSequences(), 0,
                 al.getWidth() - 1);
@@ -3069,14 +3081,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         cs.setConservation(null);
       }
 
-      cs.setConsensus(viewport.hconsensus);
+      cs.setConsensus(viewport.getSequenceConsensusHash());
     }
 
     viewport.setGlobalColourScheme(cs);
 
     if (viewport.getColourAppliesToAllGroups())
     {
-      Vector groups = viewport.alignment.getGroups();
+      Vector groups = viewport.getAlignment().getGroups();
 
       for (int i = 0; i < groups.size(); i++)
       {
@@ -3091,7 +3103,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         if (cs instanceof ClustalxColourScheme)
         {
           sg.cs = new ClustalxColourScheme(
-                  sg.getSequences(viewport.hiddenRepSequences),
+                  sg.getSequences(viewport.getHiddenRepSequences()),
                   sg.getWidth());
         }
         else if (cs instanceof UserColourScheme)
@@ -3115,7 +3127,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
 
           sg.cs.setConsensus(AAFrequency.calculate(
-                  sg.getSequences(viewport.hiddenRepSequences),
+                  sg.getSequences(viewport.getHiddenRepSequences()),
                   sg.getStartRes(), sg.getEndRes() + 1));
         }
         else
@@ -3127,7 +3139,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         {
           Conservation c = new Conservation("Group",
                   ResidueProperties.propHash, 3,
-                  sg.getSequences(viewport.hiddenRepSequences),
+                  sg.getSequences(viewport.getHiddenRepSequences()),
                   sg.getStartRes(), sg.getEndRes() + 1);
           c.calculate();
           c.verdict(false, viewport.getConsPercGaps());
@@ -3157,7 +3169,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   protected void modifyPID_actionPerformed(ActionEvent e)
   {
     if (viewport.getAbovePIDThreshold()
-            && viewport.globalColourScheme != null)
+            && viewport.getGlobalColourScheme() != null)
     {
       SliderPanel.setPIDSliderSource(alignPanel,
               viewport.getGlobalColourScheme(), "Background");
@@ -3174,10 +3186,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   protected void modifyConservation_actionPerformed(ActionEvent e)
   {
     if (viewport.getConservationSelected()
-            && viewport.globalColourScheme != null)
+            && viewport.getGlobalColourScheme()!= null)
     {
       SliderPanel.setConservationSlider(alignPanel,
-              viewport.globalColourScheme, "Background");
+              viewport.getGlobalColourScheme(), "Background");
       SliderPanel.showConservationSlider();
     }
   }
@@ -3344,7 +3356,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     AlignmentSorter.sortByPID(viewport.getAlignment(), viewport
             .getAlignment().getSequenceAt(0), null);
     addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,
-            viewport.alignment));
+            viewport.getAlignment()));
     alignPanel.paintAlignment(true);
   }
 
@@ -3358,7 +3370,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   {
     SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
     AlignmentSorter.sortByID(viewport.getAlignment());
-    addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.alignment));
+    addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.getAlignment()));
     alignPanel.paintAlignment(true);
   }
 
@@ -3373,7 +3385,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
     AlignmentSorter.sortByLength(viewport.getAlignment());
     addHistoryItem(new OrderCommand("Length Sort", oldOrder,
-            viewport.alignment));
+            viewport.getAlignment()));
     alignPanel.paintAlignment(true);
   }
 
@@ -3388,7 +3400,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
     AlignmentSorter.sortByGroup(viewport.getAlignment());
     addHistoryItem(new OrderCommand("Group Sort", oldOrder,
-            viewport.alignment));
+            viewport.getAlignment()));
 
     alignPanel.paintAlignment(true);
   }
@@ -3569,7 +3581,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     else
     {
       // are the visible sequences aligned?
-      if (!viewport.alignment.isAligned(false))
+      if (!viewport.getAlignment().isAligned(false))
       {
         JOptionPane
                 .showMessageDialog(
@@ -3583,7 +3595,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         return;
       }
 
-      if (viewport.alignment.getHeight() < 2)
+      if (viewport.getAlignment().getHeight() < 2)
       {
         return;
       }
@@ -3627,7 +3639,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         AlignmentSorter.sortBy(viewport.getAlignment(), order);
 
         addHistoryItem(new OrderCommand(order.getName(), oldOrder,
-                viewport.alignment));
+                viewport.getAlignment()));
 
         alignPanel.paintAlignment(true);
       }
@@ -3656,7 +3668,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         AlignmentSorter.sortByAnnotationScore(scoreLabel,
                 viewport.getAlignment());// ,viewport.getSelectionGroup());
         addHistoryItem(new OrderCommand("Sort by " + scoreLabel, oldOrder,
-                viewport.alignment));
+                viewport.getAlignment()));
         alignPanel.paintAlignment(true);
       }
     });
@@ -3676,18 +3688,18 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    */
   public void buildSortByAnnotationScoresMenu()
   {
-    if (viewport.alignment.getAlignmentAnnotation() == null)
+    if (viewport.getAlignment().getAlignmentAnnotation() == null)
     {
       return;
     }
 
-    if (viewport.alignment.getAlignmentAnnotation().hashCode() != _annotationScoreVectorHash)
+    if (viewport.getAlignment().getAlignmentAnnotation().hashCode() != _annotationScoreVectorHash)
     {
       sortByAnnotScore.removeAll();
       // almost certainly a quicker way to do this - but we keep it simple
       Hashtable scoreSorts = new Hashtable();
       AlignmentAnnotation aann[];
-      Enumeration sq = viewport.alignment.getSequences().elements();
+      Enumeration sq = viewport.getAlignment().getSequences().elements();
       while (sq.hasMoreElements())
       {
         aann = ((SequenceI) sq.nextElement()).getAnnotation();
@@ -3708,7 +3720,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       sortByAnnotScore.setVisible(scoreSorts.size() > 0);
       scoreSorts.clear();
 
-      _annotationScoreVectorHash = viewport.alignment
+      _annotationScoreVectorHash = viewport.getAlignment()
               .getAlignmentAnnotation().hashCode();
     }
   }
@@ -3777,7 +3789,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     if (undoname != null)
     {
       addHistoryItem(new OrderCommand(undoname, oldOrder,
-              viewport.alignment));
+              viewport.getAlignment()));
     }
     alignPanel.paintAlignment(true);
     return true;
@@ -3844,9 +3856,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
     // limit sequences - JBPNote in future - could spawn multiple prediction
     // jobs
-    // TODO: viewport.alignment.isAligned is a global state - the local
+    // TODO: viewport.getAlignment().isAligned is a global state - the local
     // selection may well be aligned - we preserve 2.0.8 behaviour for moment.
-    if (!viewport.alignment.isAligned(false))
+    if (!viewport.getAlignment().isAligned(false))
     {
       seqs.setSequences(new SeqCigar[]
       { seqs.getSequences()[0] });
@@ -4141,8 +4153,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
      * AlignFrame af = this; testAlView.addActionListener(new ActionListener() {
      * 
      * @Override public void actionPerformed(ActionEvent e) {
-     * jalview.datamodel.AlignmentView.testSelectionViews(af.viewport.alignment,
-     * af.viewport.colSel, af.viewport.selectionGroup); }
+     * jalview.datamodel.AlignmentView.testSelectionViews(af.viewport.getAlignment(),
+     * af.viewport.getColumnSelection(), af.viewport.selectionGroup); }
      * 
      * }); webService.add(testAlView);
      */
@@ -4268,7 +4280,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         ths.setProgressBar("Searching for sequences from " + fsrc, sttime);
         try
         {
-          Alignment ds = ths.getViewport().alignment.getDataset(); // update
+          Alignment ds = ths.getViewport().getAlignment().getDataset(); // update
           // our local
           // dataset
           // reference
@@ -4390,8 +4402,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     {
       al = jalview.analysis.Dna.CdnaTranslate(selection, seqstring,
               viewport.getViewAsVisibleContigs(true), viewport
-                      .getGapCharacter(), viewport.alignment
-                      .getAlignmentAnnotation(), viewport.alignment
+                      .getGapCharacter(), viewport.getAlignment()
+                      .getAlignmentAnnotation(), viewport.getAlignment()
                       .getWidth(), viewport.getAlignment().getDataset());
     } catch (Exception ex)
     {
@@ -4429,7 +4441,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     try
     {
       featuresFile = new FeaturesFile(file, type)
-              .parse(viewport.alignment.getDataset(),
+              .parse(viewport.getAlignment().getDataset(),
                       alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureColours,
                       false, jalview.bin.Cache.getDefault(
                               "RELAXEDSEQIDMATCHING", false));
@@ -4679,7 +4691,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       // try to parse as annotation.
       boolean isAnnotation = (format == null || format
               .equalsIgnoreCase("PFAM")) ? new AnnotationFile()
-              .readAnnotationFile(viewport.alignment, file, protocol)
+              .readAnnotationFile(viewport.getAlignment(), file, protocol)
               : false;
 
       if (!isAnnotation)
@@ -4786,7 +4798,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   protected void extractScores_actionPerformed(ActionEvent e)
   {
     ParseProperties pp = new jalview.analysis.ParseProperties(
-            viewport.alignment);
+            viewport.getAlignment());
     // TODO: verify regex and introduce GUI dialog for version 2.5
     // if (pp.getScoresFromDescription("col", "score column ",
     // "\\W*([-+]?\\d*\\.?\\d*e?-?\\d*)\\W+([-+]?\\d*\\.?\\d*e?-?\\d*)",
@@ -5068,8 +5080,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               viewport.getSequenceSelection(),
               viewport.getAlignmentView(true).getSequenceStrings(
                       viewport.getGapCharacter()),
-              viewport.alignment.getGroups());
-      viewport.alignment.deleteAllGroups();
+              viewport.getAlignment().getGroups());
+      viewport.getAlignment().deleteAllGroups();
       viewport.sequenceColours = null;
       viewport.setSelectionGroup(null);
       // set view properties for each group
@@ -5077,7 +5089,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       {
         gps[g].setShowNonconserved(viewport.getShowUnconserved());
         gps[g].setshowSequenceLogo(viewport.isShowSequenceLogo());
-        viewport.alignment.addGroup(gps[g]);
+        viewport.getAlignment().addGroup(gps[g]);
         Color col = new Color((int) (Math.random() * 255),
                 (int) (Math.random() * 255), (int) (Math.random() * 255));
         col = col.brighter();
index 1b39869..c168b7b 100644 (file)
@@ -53,8 +53,11 @@ import jalview.schemes.*;
 import jalview.structure.SelectionSource;
 import jalview.structure.StructureSelectionManager;
 import jalview.structure.VamsasSource;
+import jalview.viewmodel.AlignmentViewport;
 import jalview.workers.AlignCalcManager;
+import jalview.workers.ConsensusThread;
 import jalview.workers.ConservationThread;
+import jalview.workers.StrucConsensusThread;
 
 /**
  * DOCUMENT ME!
@@ -92,14 +95,10 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
 
   boolean colourAppliesToAllGroups = true;
 
-  ColourSchemeI globalColourScheme = null;
-
   boolean conservationColourSelected = false;
 
   boolean abovePIDThreshold = false;
 
-  SequenceGroup selectionGroup;
-
   int charHeight;
 
   int charWidth;
@@ -112,10 +111,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
 
   boolean seqNameItalics;
 
-  AlignmentI alignment;
-
-  ColumnSelection colSel = new ColumnSelection();
-
   int threshold;
 
   int increment;
@@ -128,10 +123,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
 
   boolean scaleRightWrapped = true;
 
-  boolean hasHiddenColumns = false;
-
-  boolean hasHiddenRows = false;
-
   boolean showHiddenMarkers = true;
 
   boolean cursorMode = false;
@@ -142,45 +133,15 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
    */
   Hashtable featuresDisplayed = null;
 
-  /** DOCUMENT ME!! */
-  public Hashtable[] hconsensus;
-
-  public Hashtable[] hStrucConsensus;
-
-  AlignmentAnnotation consensus;
-
-  AlignmentAnnotation strucConsensus;
-
-  AlignmentAnnotation conservation;
-
-  AlignmentAnnotation quality;
-
-  AlignmentAnnotation[] groupConsensus;
-
-  AlignmentAnnotation[] groupConservation;
-
-  boolean autoCalculateConsensus = true;
-
-  boolean autoCalculateStrucConsensus = true;
-
-  // JBPNote Prolly only need this in the applet version.
-  private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
-          this);
-
-  boolean ignoreGapsInConsensusCalculation = false;
 
   boolean isDataset = false;
 
   boolean antiAlias = false;
 
-  boolean padGaps = false;
-
   Rectangle explodedPosition;
 
   String viewName;
 
-  String sequenceSetID;
-
   boolean gatherViewsHere = false;
 
   Stack historyList = new Stack();
@@ -197,10 +158,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
 
   boolean rightAlignIds = false;
 
-  Hashtable hiddenRepSequences;
-
-  boolean sortByTree;
-
   /**
    * Creates a new AlignViewport object.
    * 
@@ -342,7 +299,7 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
     centreColumnLabels = Cache.getDefault("CENTRE_COLUMN_LABELS", false);
     autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
 
-    padGaps = Cache.getDefault("PAD_GAPS", true);
+    setPadGaps(Cache.getDefault("PAD_GAPS", true));
     shownpfeats = Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true);
     showdbrefs = Cache.getDefault("SHOW_DBREFS_TOOLTIP", true);
 
@@ -477,26 +434,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
   {
     return showSequenceFeatures;
   }
-  
-  AlignCalcManagerI calculator=new AlignCalcManager();
-
-  ConsensusThread consensusThread;
-
-  StrucConsensusThread strucConsensusThread;
-
-  boolean consUpdateNeeded = false;
-
-  static boolean UPDATING_CONSENSUS = false;
-
-  static boolean UPDATING_STRUC_CONSENSUS = false;
-
-  static boolean UPDATING_CONSERVATION = false;
-
-  boolean updatingConsensus = false;
-
-  boolean updatingStrucConsensus = false;
-
-  boolean updatingConservation = false;
 
   /**
    * centre columnar annotation labels in displayed alignment annotation TODO:
@@ -508,252 +445,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
 
   private boolean shownpfeats;
 
-  /**
-   * trigger update of conservation annotation
-   */
-  public void updateConservation(final AlignmentViewPanel ap)
-  {
-    // see note in mantis : issue number 8585
-    if (alignment.isNucleotide() || conservation == null
-            || !autoCalculateConsensus)
-    {
-      return;
-    }
-    
-    calculator.startWorker(new jalview.workers.ConservationThread(this, ap));
-  }
-
-  /**
-   * trigger update of consensus annotation
-   */
-  public void updateConsensus(final AlignmentPanel ap)
-  {
-    // see note in mantis : issue number 8585
-    if (consensus == null || !autoCalculateConsensus)
-    {
-      return;
-    }
-    consensusThread = new ConsensusThread(ap);
-    consensusThread.start();
-  }
-
-  class ConsensusThread extends Thread
-  {
-    AlignmentViewPanel ap;
-    public ConsensusThread(AlignmentPanel ap)
-    {
-      this.ap = ap;
-    }
-
-    public void run()
-    {
-      updatingConsensus = true;
-      while (UPDATING_CONSENSUS)
-      {
-        try
-        {
-          if (ap != null)
-          {
-            ap.paintAlignment(false);
-          }
-
-          Thread.sleep(200);
-        } catch (Exception ex)
-        {
-          ex.printStackTrace();
-        }
-      }
-
-      UPDATING_CONSENSUS = true;
-
-      try
-      {
-        int aWidth = (alignment != null) ? alignment.getWidth() : -1; // null
-        // pointer
-        // possibility
-        // here.
-        if (aWidth <= 0)
-        {
-          updatingConsensus = false;
-          UPDATING_CONSENSUS = false;
-          return;
-        }
-
-        consensus.annotations = null;
-        consensus.annotations = new Annotation[aWidth];
-
-        hconsensus = new Hashtable[aWidth];
-        AAFrequency.calculate(alignment.getSequencesArray(), 0, alignment
-                .getWidth(), hconsensus, true);
-        updateAnnotation(true);
-        if (globalColourScheme != null)
-        {
-          globalColourScheme.setConsensus(hconsensus);
-        }
-
-      } catch (OutOfMemoryError error)
-      {
-        alignment.deleteAnnotation(consensus);
-
-        consensus = null;
-        hconsensus = null; 
-        ap.raiseOOMWarning("calculating consensus", error);
-      }
-      UPDATING_CONSENSUS = false;
-      updatingConsensus = false;
-
-      if (ap != null)
-      {
-        ap.paintAlignment(true);
-      }
-    }
-
-    /**
-     * update the consensus annotation from the sequence profile data using
-     * current visualization settings.
-     */
-    public void updateAnnotation()
-    {
-      updateAnnotation(false);
-    }
-
-    protected void updateAnnotation(boolean immediate)
-    {
-      // TODO: make calls thread-safe, so if another thread calls this method,
-      // it will either return or wait until one calculation is finished.
-      if (immediate
-              || (!updatingConsensus && consensus != null && hconsensus != null))
-      {
-        AAFrequency.completeConsensus(consensus, hconsensus, 0,
-                hconsensus.length, ignoreGapsInConsensusCalculation,
-                showSequenceLogo);
-      }
-    }
-  }
-
-  // --------START Structure Conservation
-  public void updateStrucConsensus(final AlignmentPanel ap)
-  {
-    // see note in mantis : issue number 8585
-    if (strucConsensus == null || !autoCalculateStrucConsensus)
-    {
-      return;
-    }
-    strucConsensusThread = new StrucConsensusThread(ap);
-    strucConsensusThread.start();
-  }
-
-  class StrucConsensusThread extends Thread
-  {
-    AlignmentPanel ap;
-
-    public StrucConsensusThread(AlignmentPanel ap)
-    {
-      this.ap = ap;
-    }
-
-    public void run()
-    {
-      updatingStrucConsensus = true;
-      while (UPDATING_STRUC_CONSENSUS)
-      {
-        try
-        {
-          if (ap != null)
-          {
-            ap.paintAlignment(false);
-          }
-
-          Thread.sleep(200);
-        } catch (Exception ex)
-        {
-          ex.printStackTrace();
-        }
-      }
-
-      UPDATING_STRUC_CONSENSUS = true;
-
-      try
-      {
-        int aWidth = (alignment != null) ? alignment.getWidth() : -1; // null
-        // pointer
-        // possibility
-        // here.
-        if (aWidth <= 0)
-        {
-          updatingStrucConsensus = false;
-          UPDATING_STRUC_CONSENSUS = false;
-          return;
-        }
-
-        strucConsensus.annotations = null;
-        strucConsensus.annotations = new Annotation[aWidth];
-
-        hStrucConsensus = new Hashtable[aWidth];
-
-        AlignmentAnnotation[] aa = ap.av.getAlignment()
-                .getAlignmentAnnotation();
-        AlignmentAnnotation rnaStruc = null;
-        for (int i = 0; i < aa.length; i++)
-        {
-          if (aa[i].getRNAStruc() != null)
-          {
-            rnaStruc = aa[i];
-            break;
-          }
-        }
-
-        AlignmentAnnotation rna = ap.av.getAlignment()
-                .getAlignmentAnnotation()[0];
-        StructureFrequency.calculate(alignment.getSequencesArray(), 0,
-                alignment.getWidth(), hStrucConsensus, true, rnaStruc);
-        // TODO AlignmentAnnotation rnaStruc!!!
-        updateAnnotation(true);
-        if (globalColourScheme != null)
-        {
-          globalColourScheme.setConsensus(hStrucConsensus);
-        }
-
-      } catch (OutOfMemoryError error)
-      {
-        alignment.deleteAnnotation(strucConsensus);
-
-        strucConsensus = null;
-        hStrucConsensus = null;
-        new OOMWarning("calculating structure consensus", error);
-      }
-      UPDATING_STRUC_CONSENSUS = false;
-      updatingStrucConsensus = false;
-
-      if (ap != null)
-      {
-        ap.paintAlignment(true);
-      }
-    }
-
-    /**
-     * update the consensus annotation from the sequence profile data using
-     * current visualization settings.
-     */
-    public void updateAnnotation()
-    {
-      updateAnnotation(false);
-    }
-
-    protected void updateAnnotation(boolean immediate)
-    {
-      // TODO: make calls thread-safe, so if another thread calls this method,
-      // it will either return or wait until one calculation is finished.
-      if (immediate
-              || (!updatingStrucConsensus && strucConsensus != null && hStrucConsensus != null))
-      {
-        StructureFrequency.completeConsensus(strucConsensus,
-                hStrucConsensus, 0, hStrucConsensus.length, false,
-                showSequenceLogo);
-      }
-    }
-  }
-
   // --------END Structure Conservation
 
   /**
@@ -794,27 +485,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
     return sq;
   }
 
-  /**
-   * 
-   * 
-   * @return null or the currently selected sequence region
-   */
-  public SequenceGroup getSelectionGroup()
-  {
-    return selectionGroup;
-  }
-
-  /**
-   * Set the selection group for this window.
-   * 
-   * @param sg
-   *          - group holding references to sequences in this alignment view
-   * 
-   */
-  public void setSelectionGroup(SequenceGroup sg)
-  {
-    selectionGroup = sg;
-  }
 
   /**
    * GUI state
@@ -892,27 +562,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
   /**
    * DOCUMENT ME!
    * 
-   * @param cs
-   *          DOCUMENT ME!
-   */
-  public void setGlobalColourScheme(ColourSchemeI cs)
-  {
-    globalColourScheme = cs;
-  }
-
-  /**
-   * DOCUMENT ME!
-   * 
-   * @return DOCUMENT ME!
-   */
-  public ColourSchemeI getGlobalColourScheme()
-  {
-    return globalColourScheme;
-  }
-
-  /**
-   * DOCUMENT ME!
-   * 
    * @param res
    *          DOCUMENT ME!
    */
@@ -1101,7 +750,7 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
               Desktop.instance).removeMappings(alignment.getCodonFrames());
     }
     this.alignment = align;
-    if (alignment.getCodonFrames() != null)
+    if (alignment!=null && alignment.getCodonFrames() != null)
     {
       StructureSelectionManager.getStructureSelectionManager(
               Desktop.instance).addMappings(alignment.getCodonFrames());
@@ -1426,61 +1075,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
     scaleRightWrapped = b;
   }
 
-  /**
-   * Property change listener for changes in alignment
-   * 
-   * @param listener
-   *          DOCUMENT ME!
-   */
-  public void addPropertyChangeListener(
-          java.beans.PropertyChangeListener listener)
-  {
-    changeSupport.addPropertyChangeListener(listener);
-  }
-
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param listener
-   *          DOCUMENT ME!
-   */
-  public void removePropertyChangeListener(
-          java.beans.PropertyChangeListener listener)
-  {
-    changeSupport.removePropertyChangeListener(listener);
-  }
-
-  /**
-   * Property change listener for changes in alignment
-   * 
-   * @param prop
-   *          DOCUMENT ME!
-   * @param oldvalue
-   *          DOCUMENT ME!
-   * @param newvalue
-   *          DOCUMENT ME!
-   */
-  public void firePropertyChange(String prop, Object oldvalue,
-          Object newvalue)
-  {
-    changeSupport.firePropertyChange(prop, oldvalue, newvalue);
-  }
-
-  public void setIgnoreGapsConsensus(boolean b, AlignmentPanel ap)
-  {
-    ignoreGapsInConsensusCalculation = b;
-    updateConsensus(ap);
-    if (globalColourScheme != null)
-    {
-      globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
-              ignoreGapsInConsensusCalculation);
-    }
-  }
-
-  public boolean getIgnoreGapsConsensus()
-  {
-    return ignoreGapsInConsensusCalculation;
-  }
 
   public void setDataset(boolean b)
   {
@@ -1492,529 +1086,70 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
     return isDataset;
   }
 
-  public void hideSelectedColumns()
-  {
-    if (colSel.size() < 1)
-    {
-      return;
-    }
 
-    colSel.hideSelectedColumns();
-    setSelectionGroup(null);
 
-    hasHiddenColumns = true;
+  public boolean getShowHiddenMarkers()
+  {
+    return showHiddenMarkers;
+  }
+
+  public void setShowHiddenMarkers(boolean show)
+  {
+    showHiddenMarkers = show;
   }
 
-  public void hideColumns(int start, int end)
+  public Color getSequenceColour(SequenceI seq)
   {
-    if (start == end)
+    if (sequenceColours == null || !sequenceColours.containsKey(seq))
     {
-      colSel.hideColumns(start);
+      return Color.white;
     }
     else
     {
-      colSel.hideColumns(start, end);
+      return (Color) sequenceColours.get(seq);
     }
-
-    hasHiddenColumns = true;
   }
 
-  public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
+  public void setSequenceColour(SequenceI seq, Color col)
   {
-    int sSize = sg.getSize();
-    if (sSize < 2)
+    if (sequenceColours == null)
     {
-      return;
+      sequenceColours = new Hashtable();
     }
 
-    if (hiddenRepSequences == null)
+    if (col == null)
     {
-      hiddenRepSequences = new Hashtable();
+      sequenceColours.remove(seq);
     }
-
-    hiddenRepSequences.put(repSequence, sg);
-
-    // Hide all sequences except the repSequence
-    SequenceI[] seqs = new SequenceI[sSize - 1];
-    int index = 0;
-    for (int i = 0; i < sSize; i++)
+    else
     {
-      if (sg.getSequenceAt(i) != repSequence)
-      {
-        if (index == sSize - 1)
-        {
-          return;
-        }
-
-        seqs[index++] = sg.getSequenceAt(i);
-      }
+      sequenceColours.put(seq, col);
     }
-    sg.setSeqrep(repSequence);
-    sg.setHidereps(true);
-    hideSequence(seqs);
-
   }
 
-  public void hideAllSelectedSeqs()
+  /**
+   * returns the visible column regions of the alignment
+   * 
+   * @param selectedRegionOnly
+   *          true to just return the contigs intersecting with the selected
+   *          area
+   * @return
+   */
+  public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
   {
-    if (selectionGroup == null || selectionGroup.getSize() < 1)
+    int[] viscontigs = null;
+    int start = 0, end = 0;
+    if (selectedRegionOnly && selectionGroup != null)
     {
-      return;
+      start = selectionGroup.getStartRes();
+      end = selectionGroup.getEndRes() + 1;
     }
-
-    SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
-
-    hideSequence(seqs);
-
-    setSelectionGroup(null);
-  }
-
-  public void hideSequence(SequenceI[] seq)
-  {
-    if (seq != null)
+    else
     {
-      for (int i = 0; i < seq.length; i++)
-      {
-        alignment.getHiddenSequences().hideSequence(seq[i]);
-      }
-      hasHiddenRows = true;
-      firePropertyChange("alignment", null, alignment.getSequences());
+      end = alignment.getWidth();
     }
-  }
-
-  public void showSequence(int index)
-  {
-    Vector tmp = alignment.getHiddenSequences().showSequence(index,
-            hiddenRepSequences);
-    if (tmp.size() > 0)
-    {
-      if (selectionGroup == null)
-      {
-        selectionGroup = new SequenceGroup();
-        selectionGroup.setEndRes(alignment.getWidth() - 1);
-      }
-
-      for (int t = 0; t < tmp.size(); t++)
-      {
-        selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
-      }
-      firePropertyChange("alignment", null, alignment.getSequences());
-      sendSelection();
-    }
-
-    if (alignment.getHiddenSequences().getSize() < 1)
-    {
-      hasHiddenRows = false;
-    }
-  }
-
-  public void showColumn(int col)
-  {
-    colSel.revealHiddenColumns(col);
-    if (colSel.getHiddenColumns() == null)
-    {
-      hasHiddenColumns = false;
-    }
-  }
-
-  public void showAllHiddenColumns()
-  {
-    colSel.revealAllHiddenColumns();
-    hasHiddenColumns = false;
-  }
-
-  public void showAllHiddenSeqs()
-  {
-    if (alignment.getHiddenSequences().getSize() > 0)
-    {
-      if (selectionGroup == null)
-      {
-        selectionGroup = new SequenceGroup();
-        selectionGroup.setEndRes(alignment.getWidth() - 1);
-      }
-      Vector tmp = alignment.getHiddenSequences().showAll(
-              hiddenRepSequences);
-      for (int t = 0; t < tmp.size(); t++)
-      {
-        selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
-      }
-      firePropertyChange("alignment", null, alignment.getSequences());
-      sendSelection();
-      hasHiddenRows = false;
-      hiddenRepSequences = null;
-    }
-  }
-
-  public void invertColumnSelection()
-  {
-    colSel.invertColumnSelection(0, alignment.getWidth());
-  }
-
-  public int adjustForHiddenSeqs(int alignmentIndex)
-  {
-    return alignment.getHiddenSequences().adjustForHiddenSeqs(
-            alignmentIndex);
-  }
-
-  /**
-   * This method returns an array of new SequenceI objects derived from the
-   * whole alignment or just the current selection with start and end points
-   * adjusted
-   * 
-   * @note if you need references to the actual SequenceI objects in the
-   *       alignment or currently selected then use getSequenceSelection()
-   * @return selection as new sequenceI objects
-   */
-  public SequenceI[] getSelectionAsNewSequence()
-  {
-    SequenceI[] sequences;
-
-    if (selectionGroup == null)
-    {
-      sequences = alignment.getSequencesArray();
-      AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
-      for (int i = 0; i < sequences.length; i++)
-      {
-        sequences[i] = new Sequence(sequences[i], annots); // construct new
-        // sequence with
-        // subset of visible
-        // annotation
-      }
-    }
-    else
-    {
-      sequences = selectionGroup.getSelectionAsNewSequences(alignment);
-    }
-
-    return sequences;
-  }
-
-  /**
-   * get the currently selected sequence objects or all the sequences in the
-   * alignment.
-   * 
-   * @return array of references to sequence objects
-   */
-  public SequenceI[] getSequenceSelection()
-  {
-    SequenceI[] sequences = null;
-    if (selectionGroup != null)
-    {
-      sequences = selectionGroup.getSequencesInOrder(alignment);
-    }
-    if (sequences == null)
-    {
-      sequences = alignment.getSequencesArray();
-    }
-    return sequences;
-  }
-
-  /**
-   * This method returns the visible alignment as text, as seen on the GUI, ie
-   * if columns are hidden they will not be returned in the result. Use this for
-   * calculating trees, PCA, redundancy etc on views which contain hidden
-   * columns.
-   * 
-   * @return String[]
-   */
-  public jalview.datamodel.CigarArray getViewAsCigars(
-          boolean selectedRegionOnly)
-  {
-    return new jalview.datamodel.CigarArray(alignment,
-            (hasHiddenColumns ? colSel : null),
-            (selectedRegionOnly ? selectionGroup : null));
-  }
-
-  /**
-   * return a compact representation of the current alignment selection to pass
-   * to an analysis function
-   * 
-   * @param selectedOnly
-   *          boolean true to just return the selected view
-   * @return AlignmentView
-   */
-  public jalview.datamodel.AlignmentView getAlignmentView(
-          boolean selectedOnly)
-  {
-    return getAlignmentView(selectedOnly, false);
-  }
-
-  /**
-   * return a compact representation of the current alignment selection to pass
-   * to an analysis function
-   * 
-   * @param selectedOnly
-   *          boolean true to just return the selected view
-   * @param markGroups
-   *          boolean true to annotate the alignment view with groups on the
-   *          alignment (and intersecting with selected region if selectedOnly
-   *          is true)
-   * @return AlignmentView
-   */
-  public jalview.datamodel.AlignmentView getAlignmentView(
-          boolean selectedOnly, boolean markGroups)
-  {
-    return new AlignmentView(alignment, colSel, selectionGroup,
-            hasHiddenColumns, selectedOnly, markGroups);
-  }
-
-  /**
-   * This method returns the visible alignment as text, as seen on the GUI, ie
-   * if columns are hidden they will not be returned in the result. Use this for
-   * calculating trees, PCA, redundancy etc on views which contain hidden
-   * columns.
-   * 
-   * @return String[]
-   */
-  public String[] getViewAsString(boolean selectedRegionOnly)
-  {
-    String[] selection = null;
-    SequenceI[] seqs = null;
-    int i, iSize;
-    int start = 0, end = 0;
-    if (selectedRegionOnly && selectionGroup != null)
-    {
-      iSize = selectionGroup.getSize();
-      seqs = selectionGroup.getSequencesInOrder(alignment);
-      start = selectionGroup.getStartRes();
-      end = selectionGroup.getEndRes() + 1;
-    }
-    else
-    {
-      iSize = alignment.getHeight();
-      seqs = alignment.getSequencesArray();
-      end = alignment.getWidth();
-    }
-
-    selection = new String[iSize];
-    if (hasHiddenColumns)
-    {
-      selection = colSel.getVisibleSequenceStrings(start, end, seqs);
-    }
-    else
-    {
-      for (i = 0; i < iSize; i++)
-      {
-        selection[i] = seqs[i].getSequenceAsString(start, end);
-      }
-
-    }
-    return selection;
-  }
-
-  public int[][] getVisibleRegionBoundaries(int min, int max)
-  {
-    Vector regions = new Vector();
-    int start = min;
-    int end = max;
-
-    do
-    {
-      if (hasHiddenColumns)
-      {
-        if (start == 0)
-        {
-          start = colSel.adjustForHiddenColumns(start);
-        }
-
-        end = colSel.getHiddenBoundaryRight(start);
-        if (start == end)
-        {
-          end = max;
-        }
-        if (end > max)
-        {
-          end = max;
-        }
-      }
-
-      regions.addElement(new int[]
-      { start, end });
-
-      if (hasHiddenColumns)
-      {
-        start = colSel.adjustForHiddenColumns(end);
-        start = colSel.getHiddenBoundaryLeft(start) + 1;
-      }
-    } while (end < max);
-
-    int[][] startEnd = new int[regions.size()][2];
-
-    regions.copyInto(startEnd);
-
-    return startEnd;
-
-  }
-
-  public boolean getShowHiddenMarkers()
-  {
-    return showHiddenMarkers;
-  }
-
-  public void setShowHiddenMarkers(boolean show)
-  {
-    showHiddenMarkers = show;
-  }
-
-  public String getSequenceSetId()
-  {
-    if (sequenceSetID == null)
-    {
-      sequenceSetID = alignment.hashCode() + "";
-    }
-
-    return sequenceSetID;
-  }
-
-  /**
-   * unique viewId for synchronizing state with stored Jalview Project
-   * 
-   */
-  private String viewId = null;
-
-  public String getViewId()
-  {
-    if (viewId == null)
-    {
-      viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
-    }
-    return viewId;
-  }
-
-  public void alignmentChanged(AlignmentPanel ap)
-  {
-    if (padGaps)
-    {
-      alignment.padGaps();
-    }
-    if (hconsensus != null && autoCalculateConsensus)
-    {
-      updateConservation(ap);
-    }
-    if (autoCalculateConsensus)
-    {
-      updateConsensus(ap);
-    }
-    if (autoCalculateStrucConsensus)
-    {
-      updateStrucConsensus(ap);
-    }
-
-    // Reset endRes of groups if beyond alignment width
-    int alWidth = alignment.getWidth();
-    Vector groups = alignment.getGroups();
-    if (groups != null)
-    {
-      for (int i = 0; i < groups.size(); i++)
-      {
-        SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
-        if (sg.getEndRes() > alWidth)
-        {
-          sg.setEndRes(alWidth - 1);
-        }
-      }
-    }
-
-    if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
-    {
-      selectionGroup.setEndRes(alWidth - 1);
-    }
-
-    resetAllColourSchemes();
-
-    // alignment.adjustSequenceAnnotations();
-  }
-
-  void resetAllColourSchemes()
-  {
-    ColourSchemeI cs = globalColourScheme;
-    if (cs != null)
-    {
-      if (cs instanceof ClustalxColourScheme)
-      {
-        ((ClustalxColourScheme) cs).resetClustalX(alignment.getSequences(),
-                alignment.getWidth());
-      }
-
-      cs.setConsensus(hconsensus);
-      if (cs.conservationApplied())
-      {
-        AlignmentI al = (Alignment) alignment;
-        Conservation c = new Conservation("All",
-                ResidueProperties.propHash, 3, al.getSequences(), 0, al
-                        .getWidth() - 1);
-        c.calculate();
-        c.verdict(false, getConsPercGaps());
-
-        cs.setConservation(c);
-      }
-    }
-
-    int s, sSize = alignment.getGroups().size();
-    for (s = 0; s < sSize; s++)
-    {
-      SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
-      if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
-      {
-        ((ClustalxColourScheme) sg.cs).resetClustalX(sg
-                .getSequences(hiddenRepSequences), sg.getWidth());
-      }
-      sg.recalcConservation();
-    }
-  }
-
-  public Color getSequenceColour(SequenceI seq)
-  {
-    if (sequenceColours == null || !sequenceColours.containsKey(seq))
-    {
-      return Color.white;
-    }
-    else
-    {
-      return (Color) sequenceColours.get(seq);
-    }
-  }
-
-  public void setSequenceColour(SequenceI seq, Color col)
-  {
-    if (sequenceColours == null)
-    {
-      sequenceColours = new Hashtable();
-    }
-
-    if (col == null)
-    {
-      sequenceColours.remove(seq);
-    }
-    else
-    {
-      sequenceColours.put(seq, col);
-    }
-  }
-
-  /**
-   * returns the visible column regions of the alignment
-   * 
-   * @param selectedRegionOnly
-   *          true to just return the contigs intersecting with the selected
-   *          area
-   * @return
-   */
-  public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
-  {
-    int[] viscontigs = null;
-    int start = 0, end = 0;
-    if (selectedRegionOnly && selectionGroup != null)
-    {
-      start = selectionGroup.getStartRes();
-      end = selectionGroup.getEndRes() + 1;
-    }
-    else
-    {
-      end = alignment.getWidth();
-    }
-    viscontigs = colSel.getVisibleContigs(start, end);
-    return viscontigs;
+    viscontigs = colSel.getVisibleContigs(start, end);
+    return viscontigs;
   }
 
   /**
@@ -2084,7 +1219,7 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
       SequenceGroup sg = (SequenceGroup) groups.elementAt(ig);
       if (sg.idColour != null)
       {
-        Vector sqs = sg.getSequences(hiddenRepSequences);
+        Vector sqs = sg.getSequences(getHiddenRepSequences());
         for (int s = 0, sSize = sqs.size(); s < sSize; s++)
         {
           sequenceColours.put(sqs.elementAt(s), sg.idColour);
@@ -2175,57 +1310,8 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
     return followSelection;
   }
 
-  private long sgrouphash = -1, colselhash = -1;
-
   boolean showSeqFeaturesHeight;
 
-  /**
-   * checks current SelectionGroup against record of last hash value, and
-   * updates record.
-   * 
-   * @param b
-   *          update the record of last hash value
-   * 
-   * @return true if SelectionGroup changed since last call (when b is true)
-   */
-  boolean isSelectionGroupChanged(boolean b)
-  {
-    int hc = (selectionGroup == null || selectionGroup.getSize() == 0) ? -1
-            : selectionGroup.hashCode();
-    if (hc != -1 && hc != sgrouphash)
-    {
-      if (b)
-      {
-        sgrouphash = hc;
-      }
-      return true;
-    }
-    return false;
-  }
-
-  /**
-   * checks current colsel against record of last hash value, and optionally
-   * updates record.
-   * 
-   * @param b
-   *          update the record of last hash value
-   * @return true if colsel changed since last call (when b is true)
-   */
-  boolean isColSelChanged(boolean b)
-  {
-    int hc = (colSel == null || colSel.size() == 0) ? -1 : colSel
-            .hashCode();
-    if (hc != -1 && hc != colselhash)
-    {
-      if (b)
-      {
-        colselhash = hc;
-      }
-      return true;
-    }
-    return false;
-  }
-
   public void sendSelection()
   {
     jalview.structure.StructureSelectionManager
@@ -2244,18 +1330,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
     return showSeqFeaturesHeight;
   }
 
-  boolean showUnconserved = false;
-
-  public boolean getShowUnconserved()
-  {
-    return showUnconserved;
-  }
-
-  public void setShowUnconserved(boolean showunconserved)
-  {
-    showUnconserved = showunconserved;
-  }
-
   /**
    * return the alignPanel containing the given viewport. Use this to get the
    * components currently handling the given viewport.
@@ -2290,113 +1364,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
   }
 
   /**
-   * should conservation rows be shown for groups
-   */
-  boolean showGroupConservation = false;
-
-  /**
-   * should consensus rows be shown for groups
-   */
-  boolean showGroupConsensus = false;
-
-  /**
-   * should consensus profile be rendered by default
-   */
-  public boolean showSequenceLogo = false;
-  /**
-   * should consensus profile be rendered normalised to row height
-   */
-  public  boolean normaliseSequenceLogo = false;
-  /**
-   * should consensus histograms be rendered by default
-   */
-  public boolean showConsensusHistogram = true;
-
-  /**
-   * @return the showConsensusProfile
-   */
-  public boolean isShowSequenceLogo()
-  {
-    return showSequenceLogo;
-  }
-
-  /**
-   * @param showSequenceLogo
-   *          the new value
-   */
-  public void setShowSequenceLogo(boolean showSequenceLogo)
-  {
-    if (showSequenceLogo != this.showSequenceLogo)
-    {
-      // TODO: decouple settings setting from calculation when refactoring
-      // annotation update method from alignframe to viewport
-      this.showSequenceLogo = showSequenceLogo;
-      if (consensusThread != null)
-      {
-        consensusThread.updateAnnotation();
-      }
-      if (strucConsensusThread != null)
-      {
-        strucConsensusThread.updateAnnotation();
-      }
-    }
-    this.showSequenceLogo = showSequenceLogo;
-  }
-
-  /**
-   * @param showConsensusHistogram
-   *          the showConsensusHistogram to set
-   */
-  public void setShowConsensusHistogram(boolean showConsensusHistogram)
-  {
-    this.showConsensusHistogram = showConsensusHistogram;
-  }
-
-  /**
-   * @return the showGroupConservation
-   */
-  public boolean isShowGroupConservation()
-  {
-    return showGroupConservation;
-  }
-
-  /**
-   * @param showGroupConservation
-   *          the showGroupConservation to set
-   */
-  public void setShowGroupConservation(boolean showGroupConservation)
-  {
-    this.showGroupConservation = showGroupConservation;
-  }
-
-  /**
-   * @return the showGroupConsensus
-   */
-  public boolean isShowGroupConsensus()
-  {
-    return showGroupConsensus;
-  }
-
-  /**
-   * @param showGroupConsensus
-   *          the showGroupConsensus to set
-   */
-  public void setShowGroupConsensus(boolean showGroupConsensus)
-  {
-    this.showGroupConsensus = showGroupConsensus;
-  }
-
-  /**
-   * 
-   * @return flag to indicate if the consensus histogram should be rendered by
-   *         default
-   */
-  public boolean isShowConsensusHistogram()
-  {
-    return this.showConsensusHistogram;
-  }
-
-  /**
    * synthesize a column selection if none exists so it covers the given
    * selection group. if wholewidth is false, no column selection is made if the
    * selection group covers the whole alignment width.
@@ -2482,26 +1449,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
     normaliseSequenceLogo = state;
   }
 
-  public boolean isCalcInProgress()
-  {
-    // TODO generalise to iterate over all calculators associated with av
-    return updatingConsensus || updatingConservation || updatingStrucConsensus;
-  }
-
-  public boolean isCalculationInProgress(
-          AlignmentAnnotation alignmentAnnotation)
-  {
-    if (!alignmentAnnotation.autoCalculated)
-      return false;
-    if ((updatingConsensus && consensus==alignmentAnnotation)
-            || (updatingConservation && (conservation==alignmentAnnotation || quality==alignmentAnnotation))
-            || (updatingStrucConsensus && strucConsensus==alignmentAnnotation)
-            )
-    {
-      return true;
-    }
-    return false;
-  }
 
   /**
    * 
@@ -2511,41 +1458,4 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
   {
     return validCharWidth;
   }
-
-  @Override
-  public Hashtable[] getSequenceConsensusHash()
-  {
-    return hconsensus;
-  }
-
-  @Override
-  public Hashtable[] getRnaStructureConsensusHash()
-  {
-    return hStrucConsensus;
-  }
-
-  @Override
-  public AlignmentAnnotation getAlignmentQualityAnnot()
-  {
-    return quality;
-  }
-
-  @Override
-  public AlignmentAnnotation getAlignmentConservationAnnotation()
-  {
-    return conservation;
-  }
-
-  @Override
-  public boolean isClosed()
-  {
-    // TODO: check that this isClosed is only true after panel is closed, not before it is fully constructed.
-    return alignment==null;
-  }
-
-  @Override
-  public AlignCalcManagerI getCalcManager()
-  {
-    return calculator;
-  }
 }
index bcfb088..bfbaf4d 100644 (file)
@@ -262,16 +262,16 @@ public class AlignmentPanel extends GAlignmentPanel implements
     // do we need to scroll the panel?
     // TODO: tons of nullpointereexceptions raised here.
     if (results != null && results.getSize() > 0 && av != null
-            && av.alignment != null)
+            && av.getAlignment() != null)
     {
-      int seqIndex = av.alignment.findIndex(results);
+      int seqIndex = av.getAlignment().findIndex(results);
       if (seqIndex == -1)
       {
         return false;
       }
-      SequenceI seq = av.alignment.getSequenceAt(seqIndex);
+      SequenceI seq = av.getAlignment().getSequenceAt(seqIndex);
       
-      int[] r=results.getResults(seq, 0, av.alignment.getWidth());
+      int[] r=results.getResults(seq, 0, av.getAlignment().getWidth());
       if (r == null)
       {
         return false;
@@ -288,13 +288,13 @@ public class AlignmentPanel extends GAlignmentPanel implements
       {
         return false;
       }
-      if (av.hasHiddenColumns)
+      if (av.hasHiddenColumns())
       {
         start = av.getColumnSelection().findColumnPosition(start);
         end = av.getColumnSelection().findColumnPosition(end);
         if (start==end)
         {
-          if (!av.colSel.isVisible(r[0]))
+          if (!av.getColumnSelection().isVisible(r[0]))
           {
             // don't scroll - position isn't visible
             return false;
@@ -533,14 +533,14 @@ public class AlignmentPanel extends GAlignmentPanel implements
   public void setScrollValues(int x, int y)
   {
     // System.err.println("Scroll to "+x+","+y);
-    if (av == null || av.alignment == null)
+    if (av == null || av.getAlignment() == null)
     {
       return;
     }
-    int width = av.alignment.getWidth();
-    int height = av.alignment.getHeight();
+    int width = av.getAlignment().getWidth();
+    int height = av.getAlignment().getHeight();
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       width = av.getColumnSelection().findColumnPosition(width);
     }
@@ -709,9 +709,9 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
     if (av.getWrapAlignment())
     {
-      int maxwidth = av.alignment.getWidth();
+      int maxwidth = av.getAlignment().getWidth();
 
-      if (av.hasHiddenColumns)
+      if (av.hasHiddenColumns())
       {
         maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
       }
@@ -835,7 +835,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
       endSeq = av.getAlignment().getHeight();
     }
 
-    int pagesHigh = ((av.alignment.getHeight() / totalSeq) + 1) * pheight;
+    int pagesHigh = ((av.getAlignment().getHeight() / totalSeq) + 1) * pheight;
 
     if (av.showAnnotation)
     {
@@ -906,7 +906,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
     pg.translate(idWidth, 0);
     seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq, 0);
 
-    if (av.showAnnotation && (endSeq == av.alignment.getHeight()))
+    if (av.showAnnotation && (endSeq == av.getAlignment().getHeight()))
     {
       pg.translate(-idWidth - 3, (endSeq - startSeq) * av.charHeight + 3);
       alabels.drawComponent((Graphics2D) pg, idWidth);
@@ -957,8 +957,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
     int idWidth = getVisibleIdWidth();
 
-    int maxwidth = av.alignment.getWidth();
-    if (av.hasHiddenColumns)
+    int maxwidth = av.getAlignment().getWidth();
+    if (av.hasHiddenColumns())
     {
       maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
     }
@@ -984,10 +984,10 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
     do
     {
-      for (int i = 0; i < av.alignment.getHeight(); i++)
+      for (int i = 0; i < av.getAlignment().getHeight(); i++)
       {
         pg.setFont(idPanel.idCanvas.idfont);
-        SequenceI s = av.alignment.getSequenceAt(i);
+        SequenceI s = av.getAlignment().getSequenceAt(i);
         String string = s.getDisplayId(av.getShowJVSuffix());
         int xPos = 0;
         if (av.rightAlignIds)
@@ -1037,13 +1037,13 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
   void makeAlignmentImage(int type, File file)
   {
-    int maxwidth = av.alignment.getWidth();
-    if (av.hasHiddenColumns)
+    int maxwidth = av.getAlignment().getWidth();
+    if (av.hasHiddenColumns())
     {
       maxwidth = av.getColumnSelection().findColumnPosition(maxwidth);
     }
 
-    int height = ((av.alignment.getHeight() + 1) * av.charHeight)
+    int height = ((av.getAlignment().getHeight() + 1) * av.charHeight)
             + scalePanel.getHeight();
     int width = getVisibleIdWidth() + (maxwidth * av.charWidth);
 
@@ -1145,7 +1145,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
     {
       try
       {
-        int s, sSize = av.alignment.getHeight(), res, alwidth = av.alignment
+        int s, sSize = av.getAlignment().getHeight(), res, alwidth = av.getAlignment()
                 .getWidth(), g, gSize, f, fSize, sy;
         StringBuffer text = new StringBuffer();
         PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));
@@ -1158,15 +1158,15 @@ public class AlignmentPanel extends GAlignmentPanel implements
         {
           sy = s * av.charHeight + scaleHeight;
 
-          SequenceI seq = av.alignment.getSequenceAt(s);
+          SequenceI seq = av.getAlignment().getSequenceAt(s);
           SequenceFeature[] features = seq.getDatasetSequence()
                   .getSequenceFeatures();
-          SequenceGroup[] groups = av.alignment.findAllGroups(seq);
+          SequenceGroup[] groups = av.getAlignment().findAllGroups(seq);
           for (res = 0; res < alwidth; res++)
           {
             text = new StringBuffer();
             Object obj = null;
-            if (av.alignment.isNucleotide())
+            if (av.getAlignment().isNucleotide())
             {
               obj = ResidueProperties.nucleotideName.get(seq.getCharAt(res)
                       + "");
@@ -1302,8 +1302,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
     int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap
             + annotationHeight;
 
-    int maxwidth = av.alignment.getWidth();
-    if (av.hasHiddenColumns)
+    int maxwidth = av.getAlignment().getWidth();
+    if (av.hasHiddenColumns())
     {
       maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
     }
@@ -1327,7 +1327,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
       jalview.structure.StructureSelectionManager ssm = av.getStructureSelectionManager();
       ssm.removeStructureViewerListener(seqPanel, null);
       ssm.removeSelectionListener(seqPanel);
-      av.alignment = null;
+      av.setAlignment(null);
       av = null;
     }
     else
@@ -1363,10 +1363,10 @@ public class AlignmentPanel extends GAlignmentPanel implements
     // remove old automatic annotation
     // add any new annotation
 
-    Vector gr = av.alignment.getGroups(); // OrderedBy(av.alignment.getSequencesArray());
+    Vector gr = av.getAlignment().getGroups(); // OrderedBy(av.getAlignment().getSequencesArray());
     // intersect alignment annotation with alignment groups
 
-    AlignmentAnnotation[] aan = av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aan = av.getAlignment().getAlignmentAnnotation();
     Hashtable oldrfs = new Hashtable();
     if (aan != null)
     {
@@ -1375,7 +1375,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
         if (aan[an].autoCalculated && aan[an].groupRef != null)
         {
           oldrfs.put(aan[an].groupRef, aan[an].groupRef);
-          av.alignment.deleteAnnotation(aan[an]);
+          av.getAlignment().deleteAnnotation(aan[an]);
           aan[an] = null;
         }
       }
@@ -1397,12 +1397,12 @@ public class AlignmentPanel extends GAlignmentPanel implements
         if (conv)
         {
           updateCalcs = true;
-          av.alignment.addAnnotation(sg.getConservationRow(), 0);
+          av.getAlignment().addAnnotation(sg.getConservationRow(), 0);
         }
         if (cons)
         {
           updateCalcs = true;
-          av.alignment.addAnnotation(sg.getConsensus(), 0);
+          av.getAlignment().addAnnotation(sg.getConsensus(), 0);
         }
         // refresh the annotation rows
         if (updateCalcs)
@@ -1418,7 +1418,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
   @Override
   public AlignmentI getAlignment()
   {
-    return av.alignment;
+    return av.getAlignment();
   }
 
   /**
index 2b9787f..7fb868f 100755 (executable)
@@ -51,10 +51,10 @@ public class AnnotationColourChooser extends JPanel
   public AnnotationColourChooser(AlignViewport av, final AlignmentPanel ap)
   {
     oldcs = av.getGlobalColourScheme();
-    if (av.alignment.getGroups() != null)
+    if (av.getAlignment().getGroups() != null)
     {
       oldgroupColours = new Hashtable();
-      Vector allGroups = ap.av.alignment.getGroups();
+      Vector allGroups = ap.av.getAlignment().getGroups();
       SequenceGroup sg;
       for (int g = 0; g < allGroups.size(); g++)
       {
@@ -91,7 +91,7 @@ public class AnnotationColourChooser extends JPanel
       }
     });
 
-    if (av.alignment.getAlignmentAnnotation() == null)
+    if (av.getAlignment().getAlignmentAnnotation() == null)
     {
       return;
     }
@@ -113,9 +113,9 @@ public class AnnotationColourChooser extends JPanel
     adjusting = true;
     Vector list = new Vector();
     int index = 1;
-    for (int i = 0; i < av.alignment.getAlignmentAnnotation().length; i++)
+    for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
     {
-      String label = av.alignment.getAlignmentAnnotation()[i].label;
+      String label = av.getAlignment().getAlignmentAnnotation()[i].label;
       if (!list.contains(label))
         list.addElement(label);
       else
@@ -378,7 +378,7 @@ public class AnnotationColourChooser extends JPanel
       return;
     }
 
-    currentAnnotation = av.alignment.getAlignmentAnnotation()[annotations
+    currentAnnotation = av.getAlignment().getAlignmentAnnotation()[annotations
             .getSelectedIndex()];
 
     int aboveThreshold = -1;
@@ -450,9 +450,9 @@ public class AnnotationColourChooser extends JPanel
 
     av.setGlobalColourScheme(acg);
 
-    if (av.alignment.getGroups() != null)
+    if (av.getAlignment().getGroups() != null)
     {
-      Vector allGroups = ap.av.alignment.getGroups();
+      Vector allGroups = ap.av.getAlignment().getGroups();
       SequenceGroup sg;
       for (int g = 0; g < allGroups.size(); g++)
       {
@@ -508,9 +508,9 @@ public class AnnotationColourChooser extends JPanel
   void reset()
   {
     av.setGlobalColourScheme(oldcs);
-    if (av.alignment.getGroups() != null)
+    if (av.getAlignment().getGroups() != null)
     {
-      Vector allGroups = ap.av.alignment.getGroups();
+      Vector allGroups = ap.av.getAlignment().getGroups();
       SequenceGroup sg;
       for (int g = 0; g < allGroups.size(); g++)
       {
index 75399b6..ffc5c1c 100755 (executable)
@@ -105,13 +105,13 @@ public class AnnotationExporter extends JPanel
       {\r
         if (GFFFormat.isSelected())\r
         {\r
-          text = new FeaturesFile().printGFFFormat(ap.av.alignment\r
+          text = new FeaturesFile().printGFFFormat(ap.av.getAlignment()\r
                   .getDataset().getSequencesArray(),\r
                   getDisplayedFeatureCols(), true, ap.av.isShowNpFeats());// ap.av.featuresDisplayed//);\r
         }\r
         else\r
         {\r
-          text = new FeaturesFile().printJalviewFormat(ap.av.alignment\r
+          text = new FeaturesFile().printJalviewFormat(ap.av.getAlignment()\r
                   .getDataset().getSequencesArray(),\r
                   getDisplayedFeatureCols(), true, ap.av.isShowNpFeats()); // ap.av.featuresDisplayed);\r
         }\r
@@ -152,13 +152,13 @@ public class AnnotationExporter extends JPanel
     {\r
       if (GFFFormat.isSelected())\r
       {\r
-        text = new FeaturesFile().printGFFFormat(ap.av.alignment\r
+        text = new FeaturesFile().printGFFFormat(ap.av.getAlignment()\r
                 .getDataset().getSequencesArray(),\r
                 getDisplayedFeatureCols(), true, ap.av.isShowNpFeats());\r
       }\r
       else\r
       {\r
-        text = new FeaturesFile().printJalviewFormat(ap.av.alignment\r
+        text = new FeaturesFile().printJalviewFormat(ap.av.getAlignment()\r
                 .getDataset().getSequencesArray(),\r
                 getDisplayedFeatureCols(), true, ap.av.isShowNpFeats());\r
       }\r
index 7967ae6..6d32c04 100755 (executable)
@@ -143,7 +143,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
   void getSelectedRow(int y)
   {
     int height = 0;
-    AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aa = ap.av.getAlignment().getAlignmentAnnotation();
     selectedRow = -2;
     if (aa != null)
     {
@@ -175,20 +175,20 @@ public class AnnotationLabels extends JPanel implements MouseListener,
    */
   public void actionPerformed(ActionEvent evt)
   {
-    AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aa = ap.av.getAlignment().getAlignmentAnnotation();
 
     if (evt.getActionCommand().equals(ADDNEW))
     {
       AlignmentAnnotation newAnnotation = new AlignmentAnnotation(null,
-              null, new Annotation[ap.av.alignment.getWidth()]);
+              null, new Annotation[ap.av.getAlignment().getWidth()]);
 
       if (!editLabelDescription(newAnnotation))
       {
         return;
       }
 
-      ap.av.alignment.addAnnotation(newAnnotation);
-      ap.av.alignment.setAnnotationIndex(newAnnotation, 0);
+      ap.av.getAlignment().addAnnotation(newAnnotation);
+      ap.av.getAlignment().setAnnotationIndex(newAnnotation, 0);
     }
     else if (evt.getActionCommand().equals(EDITNAME))
     {
@@ -201,7 +201,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
     }
     else if (evt.getActionCommand().equals(DELETE))
     {
-      ap.av.alignment.deleteAnnotation(aa[selectedRow]);
+      ap.av.getAlignment().deleteAnnotation(aa[selectedRow]);
     }
     else if (evt.getActionCommand().equals(SHOWALL))
     {
@@ -305,16 +305,16 @@ public class AnnotationLabels extends JPanel implements MouseListener,
     if (start != end)
     {
       // Swap these annotations
-      AlignmentAnnotation startAA = ap.av.alignment
+      AlignmentAnnotation startAA = ap.av.getAlignment()
               .getAlignmentAnnotation()[start];
       if (end == -1)
       {
-        end = ap.av.alignment.getAlignmentAnnotation().length - 1;
+        end = ap.av.getAlignment().getAlignmentAnnotation().length - 1;
       }
-      AlignmentAnnotation endAA = ap.av.alignment.getAlignmentAnnotation()[end];
+      AlignmentAnnotation endAA = ap.av.getAlignment().getAlignmentAnnotation()[end];
 
-      ap.av.alignment.getAlignmentAnnotation()[end] = startAA;
-      ap.av.alignment.getAlignmentAnnotation()[start] = endAA;
+      ap.av.getAlignment().getAlignmentAnnotation()[end] = startAA;
+      ap.av.getAlignment().getAlignmentAnnotation()[start] = endAA;
     }
 
     resizePanel = false;
@@ -402,9 +402,9 @@ public class AnnotationLabels extends JPanel implements MouseListener,
     getSelectedRow(evt.getY() - scrollOffset);
 
     if (selectedRow > -1
-            && ap.av.alignment.getAlignmentAnnotation().length > selectedRow)
+            && ap.av.getAlignment().getAlignmentAnnotation().length > selectedRow)
     {
-      AlignmentAnnotation aa = ap.av.alignment.getAlignmentAnnotation()[selectedRow];
+      AlignmentAnnotation aa = ap.av.getAlignment().getAlignmentAnnotation()[selectedRow];
       
       StringBuffer desc = new StringBuffer();
       if (aa.description != null
@@ -460,7 +460,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
    */
   public void mouseClicked(MouseEvent evt)
   {
-    AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aa = ap.av.getAlignment().getAlignmentAnnotation();
     if (SwingUtilities.isLeftMouseButton(evt))
     {
       if (selectedRow > -1 && selectedRow < aa.length)
@@ -744,7 +744,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
       sq.setDatasetSequence(dseqs[0]);
     }
     Alignment ds = new Alignment(dseqs);
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       omitHidden = av.getColumnSelection().getVisibleSequenceStrings(0,
               sq.getLength(), seqs);
@@ -757,7 +757,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
             .setContents(new StringSelection(output), Desktop.instance);
 
     Vector hiddenColumns = null;
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       hiddenColumns = new Vector();
       for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); i++)
@@ -826,7 +826,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
     g.translate(0, scrollOffset);
     g.setColor(Color.black);
 
-    AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
     int fontHeight = g.getFont().getSize();
     int y = 0;
     int x = 0;
index eb0189e..e77fbed 100755 (executable)
@@ -169,7 +169,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
   public int calcPanelHeight()
   {
     // setHeight of panels
-    AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
     int height = 0;
 
     if (aa != null)
@@ -227,7 +227,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
    */
   public void actionPerformed(ActionEvent evt)
   {
-    AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
     if (aa == null)
     {
       return;
@@ -269,7 +269,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
       {
         int index = av.getColumnSelection().columnAt(i);
 
-        if (!av.colSel.isVisible(index))
+        if (!av.getColumnSelection().isVisible(index))
           continue;
 
         if (anot[index] == null)
@@ -294,7 +294,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
       {
         int index = av.getColumnSelection().columnAt(i);
 
-        if (!av.colSel.isVisible(index))
+        if (!av.getColumnSelection().isVisible(index))
           continue;
 
         if (anot[index] == null)
@@ -350,7 +350,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
       {
         int index = av.getColumnSelection().columnAt(i);
 
-        if (!av.colSel.isVisible(index))
+        if (!av.getColumnSelection().isVisible(index))
           continue;
 
         if (anot[index] == null)
@@ -374,11 +374,12 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
   {
     String collatedInput = "";
     String last = "";
+    // TODO: refactor and save av.getColumnSelection for efficiency
     for (int i = 0; i < columnSelection.size(); i++)
     {
       int index = columnSelection.columnAt(i);
       // always check for current display state - just in case
-      if (!av.colSel.isVisible(index))
+      if (!av.getColumnSelection().isVisible(index))
         continue;
       String tlabel = null;
       if (anot[index] != null)
@@ -422,7 +423,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
   public void mousePressed(MouseEvent evt)
   {
 
-    AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
     if (aa == null)
     {
       return;
@@ -467,7 +468,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
       /*
        * Just display the needed structure options
        */
-      if (av.alignment.isNucleotide() == true)
+      if (av.getAlignment().isNucleotide() == true)
       {
         item = new JMenuItem(STEM);
         item.addActionListener(this);
@@ -551,11 +552,11 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
   {
     if (graphStretch > -1)
     {
-      av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight += graphStretchY
+      av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight += graphStretchY
               - evt.getY();
-      if (av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight < 0)
+      if (av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight < 0)
       {
-        av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight = 0;
+        av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight = 0;
       }
       graphStretchY = evt.getY();
       adjustPanelHeight();
@@ -575,7 +576,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
    */
   public void mouseMoved(MouseEvent evt)
   {
-    AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
 
     if (aa == null)
     {
@@ -609,7 +610,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
 
     int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       res = av.getColumnSelection().adjustForHiddenColumns(res);
     }
@@ -676,7 +677,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
   {
     if (activeRow != -1)
     {
-      AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+      AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
       AlignmentAnnotation anot = aa[activeRow];
 
       if (anot.description.equals("secondary structure"))
@@ -765,9 +766,9 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
   {
 
     if ((horizontal == 0) || gg == null
-            || av.alignment.getAlignmentAnnotation() == null
-            || av.alignment.getAlignmentAnnotation().length < 1
-            || av.updatingConsensus || av.updatingConservation)
+            || av.getAlignment().getAlignmentAnnotation() == null
+            || av.getAlignment().getAlignmentAnnotation().length < 1
+            || av.isCalcInProgress())
     {
       repaint();
       return;
@@ -811,7 +812,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
    */
   public void drawComponent(Graphics g, int startRes, int endRes)
   {
-    if (av.updatingConsensus || av.updatingConservation)
+    if (av.isCalcInProgress())
     {
       if (image == null)
       {
@@ -852,8 +853,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
       fm = g.getFontMetrics();
     }
 
-    if ((av.alignment.getAlignmentAnnotation() == null)
-            || (av.alignment.getAlignmentAnnotation().length < 1))
+    if ((av.getAlignment().getAlignmentAnnotation() == null)
+            || (av.getAlignment().getAlignmentAnnotation().length < 1))
     {
       g.setColor(Color.white);
       g.fillRect(0, 0, getWidth(), getHeight());
index 01a7e69..768e130 100644 (file)
@@ -1611,7 +1611,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     source.viewport.gatherViewsHere = true;
     source.viewport.explodedPosition = source.getBounds();
     JInternalFrame[] frames = desktop.getAllFrames();
-    String viewId = source.viewport.sequenceSetID;
+    String viewId = source.viewport.getSequenceSetId();
 
     for (int t = 0; t < frames.length; t++)
     {
index 8d194f3..2db75bf 100755 (executable)
@@ -685,9 +685,10 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
     {
       minmax = new Hashtable();
     }
-    for (int i = 0; i < av.alignment.getHeight(); i++)
+    AlignmentI alignment=av.getAlignment();
+    for (int i = 0; i < alignment.getHeight(); i++)
     {
-      SequenceFeature[] features = av.alignment.getSequenceAt(i)
+      SequenceFeature[] features = alignment.getSequenceAt(i)
               .getDatasetSequence().getSequenceFeatures();
 
       if (features == null)
index bc663e6..18d17f4 100755 (executable)
@@ -313,15 +313,15 @@ public class FeatureSettings extends JPanel
     Vector allGroups = new Vector();
     SequenceFeature[] tmpfeatures;
     String group;
-    for (int i = 0; i < af.getViewport().alignment.getHeight(); i++)
+    for (int i = 0; i < af.getViewport().getAlignment().getHeight(); i++)
     {
-      if (af.getViewport().alignment.getSequenceAt(i).getDatasetSequence()
+      if (af.getViewport().getAlignment().getSequenceAt(i).getDatasetSequence()
               .getSequenceFeatures() == null)
       {
         continue;
       }
 
-      tmpfeatures = af.getViewport().alignment.getSequenceAt(i)
+      tmpfeatures = af.getViewport().getAlignment().getSequenceAt(i)
               .getDatasetSequence().getSequenceFeatures();
 
       int index = 0;
@@ -442,10 +442,10 @@ public class FeatureSettings extends JPanel
     // Find out which features should be visible depending on which groups
     // are selected / deselected
     // and recompute average width ordering
-    for (int i = 0; i < af.getViewport().alignment.getHeight(); i++)
+    for (int i = 0; i < af.getViewport().getAlignment().getHeight(); i++)
     {
 
-      tmpfeatures = af.getViewport().alignment.getSequenceAt(i)
+      tmpfeatures = af.getViewport().getAlignment().getSequenceAt(i)
               .getDatasetSequence().getSequenceFeatures();
       if (tmpfeatures == null)
       {
index c758166..3bcb2c0 100755 (executable)
@@ -195,7 +195,7 @@ public class Finder extends GFinder
     // TODO: add switches to control what is searched - sequences, IDS,
     // descriptions, features
     jalview.analysis.Finder finder = new jalview.analysis.Finder(
-            av.alignment, av.getSelectionGroup(), seqIndex, resIndex);
+            av.getAlignment(), av.getSelectionGroup(), seqIndex, resIndex);
     finder.setCaseSensitive(caseSensitive.isSelected());
     finder.setFindAll(findAll);
 
index 59d9f8f..2a2acfb 100755 (executable)
@@ -123,7 +123,7 @@ public class IdCanvas extends JPanel
     gg.drawString(s.getDisplayId(av.getShowJVSuffix()), xPos,
             (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5));
 
-    if (av.hasHiddenRows && av.showHiddenMarkers)
+    if (av.hasHiddenRows() && av.showHiddenMarkers)
     {
       drawMarker(i, starty, ypos);
     }
@@ -264,10 +264,10 @@ public class IdCanvas extends JPanel
 
     if (av.getWrapAlignment())
     {
-      int maxwidth = av.alignment.getWidth();
-      int alheight = av.alignment.getHeight();
+      int maxwidth = av.getAlignment().getWidth();
+      int alheight = av.getAlignment().getHeight();
 
-      if (av.hasHiddenColumns)
+      if (av.hasHiddenColumns())
       {
         maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
       }
@@ -304,8 +304,8 @@ public class IdCanvas extends JPanel
       {
         for (int i = starty; i < alheight; i++)
         {
-          SequenceI s = av.alignment.getSequenceAt(i);
-          if (av.hasHiddenRows)
+          SequenceI s = av.getAlignment().getSequenceAt(i);
+          if (av.hasHiddenRows())
           {
             setHiddenFont(s);
           }
@@ -338,14 +338,14 @@ public class IdCanvas extends JPanel
       // Now draw the id strings
       for (int i = starty; i < endy; i++)
       {
-        sequence = av.alignment.getSequenceAt(i);
+        sequence = av.getAlignment().getSequenceAt(i);
 
         if (sequence == null)
         {
           continue;
         }
 
-        if (av.hasHiddenRows)
+        if (av.hasHiddenRows())
         {
           setHiddenFont(sequence);
         }
@@ -387,7 +387,7 @@ public class IdCanvas extends JPanel
                 (((i - starty) * av.charHeight) + av.charHeight)
                         - (av.charHeight / 5));
 
-        if (av.hasHiddenRows && av.showHiddenMarkers)
+        if (av.hasHiddenRows() && av.showHiddenMarkers)
         {
           drawMarker(i, starty, 0);
         }
@@ -400,7 +400,7 @@ public class IdCanvas extends JPanel
   void drawMarker(int i, int starty, int yoffset)
   {
 
-    SequenceI[] hseqs = av.alignment.getHiddenSequences().hiddenSequences;
+    SequenceI[] hseqs = av.getAlignment().getHiddenSequences().hiddenSequences;
     // Use this method here instead of calling hiddenSeq adjust
     // 3 times.
     int hSize = hseqs.length;
@@ -463,8 +463,7 @@ public class IdCanvas extends JPanel
     Font bold = new Font(av.getFont().getName(), Font.BOLD, av.getFont()
             .getSize());
 
-    if (av.hiddenRepSequences != null
-            && av.hiddenRepSequences.containsKey(seq))
+    if (av.isHiddenRepSequence(seq))
     {
       gg.setFont(bold);
     }
index 11ef52a..9d1cae4 100755 (executable)
@@ -85,9 +85,9 @@ public class IdPanel extends JPanel implements MouseListener,
     SeqPanel sp = alignPanel.seqPanel;
     int seq = Math.max(0, sp.findSeq(e));
     String tmp;
-    if (seq > -1 && seq < av.alignment.getHeight())
+    if (seq > -1 && seq < av.getAlignment().getHeight())
     {
-      SequenceI sequence = av.alignment.getSequenceAt(seq);
+      SequenceI sequence = av.getAlignment().getSequenceAt(seq);
       StringBuffer tip = new StringBuffer();
       tip.append("<i>");
 
@@ -287,7 +287,7 @@ public class IdPanel extends JPanel implements MouseListener,
     }
 
     if (mouseDragging && (e.getY() >= getHeight())
-            && (av.alignment.getHeight() > av.getEndSeq()))
+            && (av.getAlignment().getHeight() > av.getEndSeq()))
     {
       scrollThread = new ScrollThread(false);
     }
@@ -342,7 +342,7 @@ public class IdPanel extends JPanel implements MouseListener,
     {
       av.setSelectionGroup(new SequenceGroup());
       av.getSelectionGroup().setStartRes(0);
-      av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1);
+      av.getSelectionGroup().setEndRes(av.getAlignment().getWidth() - 1);
     }
 
     if (e.isShiftDown() && (lastid != -1))
@@ -441,7 +441,7 @@ public class IdPanel extends JPanel implements MouseListener,
       return;
     }
 
-    int index = av.alignment.findIndex((SequenceI) found.get(0));
+    int index = av.getAlignment().findIndex((SequenceI) found.get(0));
 
     // do we need to scroll the panel?
     if ((av.getStartSeq() > index) || (av.getEndSeq() < index))
index d5b5fae..dc1ef4f 100644 (file)
@@ -426,9 +426,9 @@ public class Jalview2XML
     object.setCreationDate(new java.util.Date(System.currentTimeMillis()));
     object.setVersion(jalview.bin.Cache.getProperty("VERSION"));
 
-    jalview.datamodel.AlignmentI jal = av.alignment;
+    jalview.datamodel.AlignmentI jal = av.getAlignment();
 
-    if (av.hasHiddenRows)
+    if (av.hasHiddenRows())
     {
       jal = jal.getHiddenSequences().getFullAlignment();
     }
@@ -497,15 +497,13 @@ public class Jalview2XML
 
       jseq.setId(id); // jseq id should be a string not a number
 
-      if (av.hasHiddenRows)
+      if (av.hasHiddenRows())
       {
-        jseq.setHidden(av.alignment.getHiddenSequences().isHidden(jds));
+        jseq.setHidden(av.getAlignment().getHiddenSequences().isHidden(jds));
 
-        if (av.hiddenRepSequences != null
-                && av.hiddenRepSequences.containsKey(jal.getSequenceAt(i)))
+        if (av.isHiddenRepSequence(jal.getSequenceAt(i)))
         {
-          jalview.datamodel.SequenceI[] reps = ((jalview.datamodel.SequenceGroup) av.hiddenRepSequences
-                  .get(jal.getSequenceAt(i))).getSequencesInOrder(jal);
+          jalview.datamodel.SequenceI[] reps = av.getRepresentedSequences(jal.getSequenceAt(i)).getSequencesInOrder(jal);
 
           for (int h = 0; h < reps.length; h++)
           {
@@ -706,9 +704,9 @@ public class Jalview2XML
       jms.addJSeq(jseq);
     }
 
-    if (av.hasHiddenRows)
+    if (av.hasHiddenRows())
     {
-      jal = av.alignment;
+      jal = av.getAlignment();
     }
     // SAVE MAPPINGS
     if (jal.getCodonFrames() != null && jal.getCodonFrames().length > 0)
@@ -764,7 +762,7 @@ public class Jalview2XML
           {
             TreePanel tp = (TreePanel) frames[t];
 
-            if (tp.treeCanvas.av.alignment == jal)
+            if (tp.treeCanvas.av.getAlignment() == jal)
             {
               Tree tree = new Tree();
               tree.setTitle(tp.getTitle());
@@ -864,8 +862,8 @@ public class Jalview2XML
 
         an.setLabel(aa[i].label);
 
-        if (aa[i] == av.quality || aa[i] == av.conservation
-                || aa[i] == av.consensus || aa[i].autoCalculated)
+        if (aa[i] == av.getAlignmentQualityAnnot() || aa[i] == av.getAlignmentConservationAnnotation()
+                || aa[i] == av.getAlignmentConsensusAnnotation() || aa[i].autoCalculated)
         {
           // new way of indicating autocalculated annotation -
           an.setAutoCalculated(aa[i].autoCalculated);
@@ -1204,7 +1202,7 @@ public class Jalview2XML
 
     }
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       if (av.getColumnSelection() == null
               || av.getColumnSelection().getHiddenColumns() == null)
@@ -2907,7 +2905,7 @@ public class Jalview2XML
 
     for (int i = 0; i < JSEQ.length; i++)
     {
-      af.viewport.setSequenceColour(af.viewport.alignment.getSequenceAt(i),
+      af.viewport.setSequenceColour(af.viewport.getAlignment().getSequenceAt(i),
               new java.awt.Color(JSEQ[i].getColour()));
     }
 
@@ -2918,7 +2916,7 @@ public class Jalview2XML
       jalview.gui.AlignViewport av = (jalview.gui.AlignViewport) viewportsAdded
               .get(uniqueSeqSetId);
 
-      af.viewport.sequenceSetID = uniqueSeqSetId;
+      af.viewport.setSequenceSetId(uniqueSeqSetId);
       if (av != null)
       {
         // propagate shared settings to this new view
@@ -3008,18 +3006,18 @@ public class Jalview2XML
       else if (view.getBgColour().startsWith("Annotation"))
       {
         // int find annotation
-        if (af.viewport.alignment.getAlignmentAnnotation() != null)
+        if (af.viewport.getAlignment().getAlignmentAnnotation() != null)
         {
-          for (int i = 0; i < af.viewport.alignment
+          for (int i = 0; i < af.viewport.getAlignment()
                   .getAlignmentAnnotation().length; i++)
           {
-            if (af.viewport.alignment.getAlignmentAnnotation()[i].label
+            if (af.viewport.getAlignment().getAlignmentAnnotation()[i].label
                     .equals(view.getAnnotationColours().getAnnotation()))
             {
-              if (af.viewport.alignment.getAlignmentAnnotation()[i]
+              if (af.viewport.getAlignment().getAlignmentAnnotation()[i]
                       .getThreshold() == null)
               {
-                af.viewport.alignment.getAlignmentAnnotation()[i]
+                af.viewport.getAlignment().getAlignmentAnnotation()[i]
                         .setThreshold(new jalview.datamodel.GraphLine(view
                                 .getAnnotationColours().getThreshold(),
                                 "Threshold", java.awt.Color.black)
@@ -3031,7 +3029,7 @@ public class Jalview2XML
                       .equals("None"))
               {
                 cs = new AnnotationColourGradient(
-                        af.viewport.alignment.getAlignmentAnnotation()[i],
+                        af.viewport.getAlignment().getAlignmentAnnotation()[i],
                         new java.awt.Color(view.getAnnotationColours()
                                 .getMinColour()), new java.awt.Color(view
                                 .getAnnotationColours().getMaxColour()),
@@ -3041,7 +3039,7 @@ public class Jalview2XML
                       .startsWith("ucs"))
               {
                 cs = new AnnotationColourGradient(
-                        af.viewport.alignment.getAlignmentAnnotation()[i],
+                        af.viewport.getAlignment().getAlignmentAnnotation()[i],
                         GetUserColourScheme(jms, view
                                 .getAnnotationColours().getColourScheme()),
                         view.getAnnotationColours().getAboveThreshold());
@@ -3049,7 +3047,7 @@ public class Jalview2XML
               else
               {
                 cs = new AnnotationColourGradient(
-                        af.viewport.alignment.getAlignmentAnnotation()[i],
+                        af.viewport.getAlignment().getAlignmentAnnotation()[i],
                         ColourSchemeProperty.getColour(al, view
                                 .getAnnotationColours().getColourScheme()),
                         view.getAnnotationColours().getAboveThreshold());
@@ -3072,7 +3070,7 @@ public class Jalview2XML
                    * if
                    * (view.getAnnotationColours().getColourScheme().equals("None"
                    * )) { sg.cs = new AnnotationColourGradient(
-                   * af.viewport.alignment.getAlignmentAnnotation()[i], new
+                   * af.viewport.getAlignment().getAlignmentAnnotation()[i], new
                    * java.awt.Color(view.getAnnotationColours().
                    * getMinColour()), new
                    * java.awt.Color(view.getAnnotationColours().
@@ -3081,7 +3079,7 @@ public class Jalview2XML
                    */
                   {
                     sg.cs = new AnnotationColourGradient(
-                            af.viewport.alignment.getAlignmentAnnotation()[i],
+                            af.viewport.getAlignment().getAlignmentAnnotation()[i],
                             sg.cs, view.getAnnotationColours()
                                     .getAboveThreshold());
                   }
@@ -3103,7 +3101,7 @@ public class Jalview2XML
       if (cs != null)
       {
         cs.setThreshold(view.getPidThreshold(), true);
-        cs.setConsensus(af.viewport.hconsensus);
+        cs.setConsensus(af.viewport.getSequenceConsensusHash());
       }
     }
 
@@ -3129,8 +3127,8 @@ public class Jalview2XML
     }
     if (view.hasIgnoreGapsinConsensus())
     {
-      af.viewport.ignoreGapsInConsensusCalculation = view
-              .getIgnoreGapsinConsensus();
+      af.viewport.setIgnoreGapsConsensus(view
+              .getIgnoreGapsinConsensus(), null);
     }
     if (view.hasFollowHighlight())
     {
@@ -3151,11 +3149,11 @@ public class Jalview2XML
     }
     if (view.hasShowSequenceLogo())
     {
-      af.viewport.showSequenceLogo = view.getShowSequenceLogo();
+      af.viewport.setShowSequenceLogo(view.getShowSequenceLogo());
     }
     else
     {
-      af.viewport.showSequenceLogo = false;
+      af.viewport.setShowSequenceLogo(false);
     }
     if (view.hasShowDbRefTooltip())
     {
@@ -3719,11 +3717,11 @@ public class Jalview2XML
     af.closeMenuItem_actionPerformed(true);
 
     /*
-     * if(ap.av.alignment.getAlignmentAnnotation()!=null) { for(int i=0;
-     * i<ap.av.alignment.getAlignmentAnnotation().length; i++) {
-     * if(!ap.av.alignment.getAlignmentAnnotation()[i].autoCalculated) {
-     * af.alignPanel.av.alignment.getAlignmentAnnotation()[i] =
-     * ap.av.alignment.getAlignmentAnnotation()[i]; } } }
+     * if(ap.av.getAlignment().getAlignmentAnnotation()!=null) { for(int i=0;
+     * i<ap.av.getAlignment().getAlignmentAnnotation().length; i++) {
+     * if(!ap.av.getAlignment().getAlignmentAnnotation()[i].autoCalculated) {
+     * af.alignPanel.av.getAlignment().getAlignmentAnnotation()[i] =
+     * ap.av.getAlignment().getAlignmentAnnotation()[i]; } } }
      */
 
     return af.alignPanel;
index 64d00ff..e264b68 100755 (executable)
@@ -271,7 +271,7 @@ public class Jalview2XML_V1
 \r
     for (int i = 0; i < JSEQ.length; i++)\r
     {\r
-      af.viewport.setSequenceColour(af.viewport.alignment.getSequenceAt(i),\r
+      af.viewport.setSequenceColour(af.viewport.getAlignment().getSequenceAt(i),\r
               new java.awt.Color(JSEQ[i].getColour()));\r
     }\r
 \r
@@ -371,7 +371,7 @@ public class Jalview2XML_V1
       if (cs != null)\r
       {\r
         cs.setThreshold(view.getPidThreshold(), true);\r
-        cs.setConsensus(af.viewport.hconsensus);\r
+        cs.setConsensus(af.viewport.getSequenceConsensusHash());\r
       }\r
     }\r
 \r
index 7e00f2e..c844315 100755 (executable)
@@ -83,15 +83,15 @@ public class OverviewPanel extends JPanel implements Runnable
     fr = new FeatureRenderer(ap);
 
     // scale the initial size of overviewpanel to shape of alignment
-    float initialScale = (float) av.alignment.getWidth()
-            / (float) av.alignment.getHeight();
+    float initialScale = (float) av.getAlignment().getWidth()
+            / (float) av.getAlignment().getHeight();
 
-    if (av.conservation == null)
+    if (av.getAlignmentConservationAnnotation()== null)
     {
       graphHeight = 0;
     }
 
-    if (av.alignment.getWidth() > av.alignment.getHeight())
+    if (av.getAlignment().getWidth() > av.getAlignment().getHeight())
     {
       // wider
       width = 400;
@@ -178,7 +178,7 @@ public class OverviewPanel extends JPanel implements Runnable
 
     if (boxX > (width - boxWidth))
     {
-      if (av.hasHiddenColumns)
+      if (av.hasHiddenColumns())
       {
         // Try smallest possible box
         boxWidth = (int) ((av.endRes - av.startRes + 1) * av.getCharWidth() * scalew);
@@ -189,7 +189,7 @@ public class OverviewPanel extends JPanel implements Runnable
     int col = (int) (boxX / scalew / av.getCharWidth());
     int row = (int) (boxY / scaleh / av.getCharHeight());
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       if (!av.getColumnSelection().isVisible(col))
       {
@@ -199,9 +199,9 @@ public class OverviewPanel extends JPanel implements Runnable
       col = av.getColumnSelection().findColumnPosition(col);
     }
 
-    if (av.hasHiddenRows)
+    if (av.hasHiddenRows())
     {
-      row = av.alignment.getHiddenSequences().findIndexWithoutHiddenSeqs(
+      row = av.getAlignment().getHiddenSequences().findIndexWithoutHiddenSeqs(
               row);
     }
 
@@ -251,9 +251,9 @@ public class OverviewPanel extends JPanel implements Runnable
       fr.transferSettings(ap.seqPanel.seqCanvas.getFeatureRenderer());
     }
 
-    int alwidth = av.alignment.getWidth();
-    int alheight = av.alignment.getHeight()
-            + av.alignment.getHiddenSequences().getSize();
+    int alwidth = av.getAlignment().getWidth();
+    int alheight = av.getAlignment().getHeight()
+            + av.getAlignment().getHiddenSequences().getSize();
 
     setPreferredSize(new Dimension(width, sequencesHeight + graphHeight));
 
@@ -294,15 +294,15 @@ public class OverviewPanel extends JPanel implements Runnable
       lastrow = (int) (row * sampleRow);
 
       hiddenRow = false;
-      if (av.hasHiddenRows)
+      if (av.hasHiddenRows())
       {
-        seq = av.alignment.getHiddenSequences().getHiddenSequence(lastrow);
+        seq = av.getAlignment().getHiddenSequences().getHiddenSequence(lastrow);
         if (seq == null)
         {
-          int index = av.alignment.getHiddenSequences()
+          int index = av.getAlignment().getHiddenSequences()
                   .findIndexWithoutHiddenSeqs(lastrow);
 
-          seq = av.alignment.getSequenceAt(index);
+          seq = av.getAlignment().getSequenceAt(index);
         }
         else
         {
@@ -311,7 +311,7 @@ public class OverviewPanel extends JPanel implements Runnable
       }
       else
       {
-        seq = av.alignment.getSequenceAt(lastrow);
+        seq = av.getAlignment().getSequenceAt(lastrow);
       }
 
       if (seq == null)
@@ -346,7 +346,7 @@ public class OverviewPanel extends JPanel implements Runnable
         }
 
         if (hiddenRow
-                || (av.hasHiddenColumns && !av.getColumnSelection()
+                || (av.hasHiddenColumns() && !av.getColumnSelection()
                         .isVisible(lastcol)))
         {
           color = new Color(color).darker().darker().getRGB();
@@ -357,7 +357,7 @@ public class OverviewPanel extends JPanel implements Runnable
       }
     }
 
-    if (av.conservation != null)
+    if (av.getAlignmentConservationAnnotation()!= null)
     {
       renderer.updateFromAlignViewport(av); 
       for (col = 0; col < width; col++)
@@ -365,7 +365,7 @@ public class OverviewPanel extends JPanel implements Runnable
         lastcol = (int) (col * sampleCol);
         {
           mg.translate(col, sequencesHeight);
-          renderer.drawGraph(mg, av.conservation,
+          renderer.drawGraph(mg, av.getAlignmentConservationAnnotation(),
                   (int) (sampleCol) + 1, graphHeight,
                   (int) (col * sampleCol), (int) (col * sampleCol) + 1);
           mg.translate(-col, -sequencesHeight);
@@ -390,14 +390,14 @@ public class OverviewPanel extends JPanel implements Runnable
    */
   public void setBoxPosition()
   {
-    int fullsizeWidth = av.alignment.getWidth() * av.getCharWidth();
-    int fullsizeHeight = (av.alignment.getHeight() + av.alignment
+    int fullsizeWidth = av.getAlignment().getWidth() * av.getCharWidth();
+    int fullsizeHeight = (av.getAlignment().getHeight() + av.getAlignment()
             .getHiddenSequences().getSize()) * av.getCharHeight();
 
     int startRes = av.getStartRes();
     int endRes = av.getEndRes();
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       startRes = av.getColumnSelection().adjustForHiddenColumns(startRes);
       endRes = av.getColumnSelection().adjustForHiddenColumns(endRes);
@@ -406,12 +406,12 @@ public class OverviewPanel extends JPanel implements Runnable
     int startSeq = av.startSeq;
     int endSeq = av.endSeq;
 
-    if (av.hasHiddenRows)
+    if (av.hasHiddenRows())
     {
-      startSeq = av.alignment.getHiddenSequences().adjustForHiddenSeqs(
+      startSeq = av.getAlignment().getHiddenSequences().adjustForHiddenSeqs(
               startSeq);
 
-      endSeq = av.alignment.getHiddenSequences()
+      endSeq = av.getAlignment().getHiddenSequences()
               .adjustForHiddenSeqs(endSeq);
 
     }
@@ -422,7 +422,7 @@ public class OverviewPanel extends JPanel implements Runnable
     boxX = (int) (startRes * av.getCharWidth() * scalew);
     boxY = (int) (startSeq * av.getCharHeight() * scaleh);
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew);
     }
index 6f199c5..fe0c4f9 100755 (executable)
@@ -69,11 +69,11 @@ public class PCAPanel extends GPCAPanel implements Runnable
     seqstrings = av.getAlignmentView(av.getSelectionGroup() != null);
     if (av.getSelectionGroup() == null)
     {
-      seqs = av.alignment.getSequencesArray();
+      seqs = av.getAlignment().getSequencesArray();
     }
     else
     {
-      seqs = av.getSelectionGroup().getSequencesInOrder(av.alignment);
+      seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
     }
     SeqCigar sq[] = seqstrings.getSequences();
     int length = sq[0].getWidth();
index 5f0a33d..9dc7f32 100755 (executable)
@@ -118,8 +118,8 @@ public class PaintRefresher
       if (validateSequences && comp instanceof AlignmentPanel
               && source instanceof AlignmentPanel)
       {
-        validateSequences(((AlignmentPanel) source).av.alignment,
-                ((AlignmentPanel) comp).av.alignment);
+        validateSequences(((AlignmentPanel) source).av.getAlignment(),
+                ((AlignmentPanel) comp).av.getAlignment());
       }
 
       if (comp instanceof AlignmentPanel && alignmentChanged)
index 95d38d5..fedd8d2 100755 (executable)
@@ -56,14 +56,14 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel
 
     if (av.getSelectionGroup() == null)
     {
-      seqs = av.alignment.getSequencesArray();
+      seqs = av.getAlignment().getSequencesArray();
     }
     else
     {
-      seqs = av.getSelectionGroup().getSequencesInOrder(av.alignment);
+      seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
     }
 
-    String type = (av.alignment.isNucleotide()) ? AlignSeq.DNA
+    String type = (av.getAlignment().isNucleotide()) ? AlignSeq.DNA
             : AlignSeq.PEP;
 
     float[][] scores = new float[seqs.length][seqs.length];
index d87a62b..45e976f 100644 (file)
@@ -255,16 +255,16 @@ public class PopupMenu extends JPopupMenu
       }
       else
       {
-        if (ap.av.alignment.isNucleotide() == false)
+        if (ap.av.getAlignment().isNucleotide() == false)
         {
         structureMenu.remove(viewStructureMenu);
         }
         // structureMenu.remove(colStructureMenu);
       }
 
-      if (ap.av.alignment.isNucleotide() == true)
+      if (ap.av.getAlignment().isNucleotide() == true)
       {
-        AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
+        AlignmentAnnotation[] aa = ap.av.getAlignment().getAlignmentAnnotation();
         for (int i = 0; i < aa.length; i++)
         {
           if (aa[i].getRNAStruc() != null)
@@ -340,9 +340,9 @@ public class PopupMenu extends JPopupMenu
         sequenceMenu.add(menuItem);
       }
 
-      if (ap.av.hasHiddenRows)
+      if (ap.av.hasHiddenRows())
       {
-        final int index = ap.av.alignment.findIndex(seq);
+        final int index = ap.av.getAlignment().findIndex(seq);
 
         if (ap.av.adjustForHiddenSeqs(index)
                 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
@@ -364,7 +364,7 @@ public class PopupMenu extends JPopupMenu
       }
     }
     // for the case when no sequences are even visible
-    if (ap.av.hasHiddenRows) {
+    if (ap.av.hasHiddenRows()) {
       {
         menuItem = new JMenuItem("Reveal All");
         menuItem.addActionListener(new ActionListener()
@@ -506,7 +506,7 @@ public class PopupMenu extends JPopupMenu
       editMenu.setVisible(false);
     }
 
-    if (!ap.av.alignment.getGroups().contains(sg))
+    if (!ap.av.getAlignment().getGroups().contains(sg))
     {
       unGroupMenuItem.setVisible(false);
     }
@@ -1289,8 +1289,8 @@ public class PopupMenu extends JPopupMenu
   {
     SequenceGroup sg = getGroup();
     sg.cs = new ClustalxColourScheme(
-            sg.getSequences(ap.av.hiddenRepSequences),
-            ap.av.alignment.getWidth());
+            sg.getSequences(ap.av.getHiddenRepSequences()),
+            ap.av.getAlignment().getWidth());
     refresh();
   }
 
@@ -1417,7 +1417,7 @@ public class PopupMenu extends JPopupMenu
     if (abovePIDColour.isSelected())
     {
       sg.cs.setConsensus(AAFrequency.calculate(
-              sg.getSequences(ap.av.hiddenRepSequences), sg.getStartRes(),
+              sg.getSequences(ap.av.getHiddenRepSequences()), sg.getStartRes(),
               sg.getEndRes() + 1));
 
       int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
@@ -1471,7 +1471,7 @@ public class PopupMenu extends JPopupMenu
     SequenceGroup sg = getGroup();
     sg.cs = new PIDColourScheme();
     sg.cs.setConsensus(AAFrequency.calculate(
-            sg.getSequences(ap.av.hiddenRepSequences), sg.getStartRes(),
+            sg.getSequences(ap.av.getHiddenRepSequences()), sg.getStartRes(),
             sg.getEndRes() + 1));
     refresh();
   }
@@ -1489,7 +1489,7 @@ public class PopupMenu extends JPopupMenu
     sg.cs = new Blosum62ColourScheme();
 
     sg.cs.setConsensus(AAFrequency.calculate(
-            sg.getSequences(ap.av.hiddenRepSequences), sg.getStartRes(),
+            sg.getSequences(ap.av.getHiddenRepSequences()), sg.getStartRes(),
             sg.getEndRes() + 1));
 
     refresh();
@@ -1525,7 +1525,7 @@ public class PopupMenu extends JPopupMenu
     {
       Conservation c = new Conservation("Group",
               ResidueProperties.propHash, 3,
-              sg.getSequences(ap.av.hiddenRepSequences), sg.getStartRes(),
+              sg.getSequences(ap.av.getHiddenRepSequences()), sg.getStartRes(),
               sg.getEndRes() + 1);
 
       c.calculate();
@@ -1599,7 +1599,7 @@ public class PopupMenu extends JPopupMenu
     // this method won't add a new group if it already exists
     if (sg != null)
     {
-      ap.av.alignment.addGroup(sg);
+      ap.av.getAlignment().addGroup(sg);
     }
 
     return sg;
@@ -1653,7 +1653,7 @@ public class PopupMenu extends JPopupMenu
   void unGroupMenuItem_actionPerformed()
   {
     SequenceGroup sg = ap.av.getSelectionGroup();
-    ap.av.alignment.deleteGroup(sg);
+    ap.av.getAlignment().deleteGroup(sg);
     ap.av.setSelectionGroup(null);
     refresh();
   }
@@ -1807,7 +1807,7 @@ public class PopupMenu extends JPopupMenu
       }
 
       ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
-              sg.getSequencesAsArray(ap.av.hiddenRepSequences), startEnd,
+              sg.getSequencesAsArray(ap.av.getHiddenRepSequences()), startEnd,
               caseChange);
 
       ap.alignFrame.addHistoryItem(caseCommand);
@@ -1834,7 +1834,7 @@ public class PopupMenu extends JPopupMenu
     ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection());
     omitHidden = ap.av.getViewAsString(true);
     Alignment oal = new Alignment(ap.av.getSequenceSelection());
-    AlignmentAnnotation[] nala = ap.av.alignment.getAlignmentAnnotation();
+    AlignmentAnnotation[] nala = ap.av.getAlignment().getAlignmentAnnotation();
     if (nala != null)
     {
       for (int i = 0; i < nala.length; i++)
@@ -1882,10 +1882,11 @@ public class PopupMenu extends JPopupMenu
 
   public void discoverPDB_actionPerformed()
   {
+    // TODO: test: verify PDB sequence discovery behaves correctly for group selections
 
-    final SequenceI[] sequences = ((ap.av.selectionGroup == null) ? new SequenceI[]
+    final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
     { sequence }
-            : ap.av.selectionGroup.getSequencesInOrder(ap.av.alignment));
+            : ap.av.getSequenceSelection());
     Thread discpdb = new Thread(new Runnable()
     {
       public void run()
@@ -1954,10 +1955,10 @@ public class PopupMenu extends JPopupMenu
     AlignmentAnnotation an = new AlignmentAnnotation("Structure",
             "Coloured by " + pdbid, anots);
 
-    ap.av.alignment.addAnnotation(an);
+    ap.av.getAlignment().addAnnotation(an);
     an.createSequenceMapping(sequence, 0, true);
     // an.adjustForAlignment();
-    ap.av.alignment.setAnnotationIndex(an, 0);
+    ap.av.getAlignment().setAnnotationIndex(an, 0);
 
     ap.adjustAnnotationHeight();
 
@@ -1984,8 +1985,8 @@ public class PopupMenu extends JPopupMenu
         EditCommand editCommand = new EditCommand("Edit Sequences",
                 EditCommand.REPLACE, dialog.getName().replace(' ',
                         ap.av.getGapCharacter()),
-                sg.getSequencesAsArray(ap.av.hiddenRepSequences),
-                sg.getStartRes(), sg.getEndRes() + 1, ap.av.alignment);
+                sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
+                sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
 
         ap.alignFrame.addHistoryItem(editCommand);
 
index cdb000a..e575b91 100644 (file)
@@ -48,10 +48,10 @@ public class RNAHelicesColourChooser
   public RNAHelicesColourChooser(AlignViewport av, final AlignmentPanel ap)
   {
     oldcs = av.getGlobalColourScheme();
-    if (av.alignment.getGroups() != null)
+    if (av.getAlignment().getGroups() != null)
     {
       oldgroupColours = new Hashtable();
-      Vector allGroups = ap.av.alignment.getGroups();
+      Vector allGroups = ap.av.getAlignment().getGroups();
       SequenceGroup sg;
       for (int g = 0; g < allGroups.size(); g++)
       {
@@ -74,9 +74,9 @@ public class RNAHelicesColourChooser
     adjusting = true;
     Vector list = new Vector();
     int index = 1;
-    for (int i = 0; i < av.alignment.getAlignmentAnnotation().length; i++)
+    for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
     {
-      String label = av.alignment.getAlignmentAnnotation()[i].label;
+      String label = av.getAlignment().getAlignmentAnnotation()[i].label;
       if (!list.contains(label))
         list.addElement(label);
       else
@@ -97,7 +97,7 @@ public class RNAHelicesColourChooser
       return;
     }
 
-    currentAnnotation = av.alignment.getAlignmentAnnotation()[0];// annotations.getSelectedIndex()];
+    currentAnnotation = av.getAlignment().getAlignmentAnnotation()[0];// annotations.getSelectedIndex()];
 
     RNAHelicesColour rhc = null;
 
@@ -105,9 +105,9 @@ public class RNAHelicesColourChooser
 
     av.setGlobalColourScheme(rhc);
 
-    if (av.alignment.getGroups() != null)
+    if (av.getAlignment().getGroups() != null)
     {
-      Vector allGroups = ap.av.alignment.getGroups();
+      Vector allGroups = ap.av.getAlignment().getGroups();
       SequenceGroup sg;
       for (int g = 0; g < allGroups.size(); g++)
       {
@@ -129,9 +129,9 @@ public class RNAHelicesColourChooser
   void reset()
   {
     av.setGlobalColourScheme(oldcs);
-    if (av.alignment.getGroups() != null)
+    if (av.getAlignment().getGroups() != null)
     {
-      Vector allGroups = ap.av.alignment.getGroups();
+      Vector allGroups = ap.av.getAlignment().getGroups();
       SequenceGroup sg;
       for (int g = 0; g < allGroups.size(); g++)
       {
index c4d7e3b..9f117b6 100755 (executable)
@@ -131,15 +131,15 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
 
     if ((sg != null) && (sg.getSize() >= 1))
     {
-      originalSequences = sg.getSequencesInOrder(ap.av.alignment);
+      originalSequences = sg.getSequencesInOrder(ap.av.getAlignment());
       start = sg.getStartRes();
       end = sg.getEndRes();
     }
     else
     {
-      originalSequences = ap.av.alignment.getSequencesArray();
+      originalSequences = ap.av.getAlignment().getSequencesArray();
       start = 0;
-      end = ap.av.alignment.getWidth();
+      end = ap.av.getAlignment().getWidth();
     }
 
     height = originalSequences.length;
@@ -150,7 +150,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
       redundancy[i] = 0f;
     }
 
-    if (ap.av.hasHiddenColumns)
+    if (ap.av.hasHiddenColumns())
     {
       omitHidden = ap.av.getViewAsString(sg != null);
     }
@@ -273,11 +273,11 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
       }
 
       EditCommand cut = new EditCommand("Remove Redundancy",
-              EditCommand.CUT, deleted, 0, width, ap.av.alignment);
+              EditCommand.CUT, deleted, 0, width, ap.av.getAlignment());
 
       for (int i = 0; i < del.size(); i++)
       {
-        ap.av.alignment.deleteSequence(deleted[i]);
+        ap.av.getAlignment().deleteSequence(deleted[i]);
         PaintRefresher.Refresh(this, ap.av.getSequenceSetId(), true, true);
         if (sg != null)
         {
index eda4d35..f3312c3 100755 (executable)
@@ -644,7 +644,7 @@ public class RotatableCanvas extends JPanel implements MouseListener,
           aps[a].av.setSelectionGroup(new SequenceGroup());
           aps[a].av.getSelectionGroup().addOrRemove(found, true);
           aps[a].av.getSelectionGroup().setEndRes(
-                  aps[a].av.alignment.getWidth() - 1);
+                  aps[a].av.getAlignment().getWidth() - 1);
         }
       }
       PaintRefresher.Refresh(this, av.getSequenceSetId());
index b5a19b2..c70f3c1 100755 (executable)
@@ -70,14 +70,14 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
     int x = (evt.getX() / av.getCharWidth()) + av.getStartRes();
     final int res;
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       x = av.getColumnSelection().adjustForHiddenColumns(x);
     }
 
-    if (x >= av.alignment.getWidth())
+    if (x >= av.getAlignment().getWidth())
     {
-      res = av.alignment.getWidth() - 1;
+      res = av.getAlignment().getWidth() - 1;
     }
     else
     {
@@ -137,7 +137,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
           {
             av.hideColumns(res, res);
             if (av.getSelectionGroup() != null
-                    && av.getSelectionGroup().getSize() == av.alignment
+                    && av.getSelectionGroup().getSize() == av.getAlignment()
                             .getHeight())
             {
               av.setSelectionGroup(null);
@@ -165,7 +165,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
       av.getColumnSelection().addElement(res);
       SequenceGroup sg = new SequenceGroup();
       // try to be as quick as possible
-      SequenceI[] iVec = av.alignment.getSequencesArray();
+      SequenceI[] iVec = av.getAlignment().getSequencesArray();
       for (int i = 0; i < iVec.length; i++)
       {
         sg.addSequence(iVec[i], false);
@@ -205,14 +205,14 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
 
     int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       res = av.getColumnSelection().adjustForHiddenColumns(res);
     }
 
-    if (res >= av.alignment.getWidth())
+    if (res >= av.getAlignment().getWidth())
     {
-      res = av.alignment.getWidth() - 1;
+      res = av.getAlignment().getWidth() - 1;
     }
 
     if (!stretchingGroup)
@@ -256,14 +256,14 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
       res = 0;
     }
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       res = av.getColumnSelection().adjustForHiddenColumns(res);
     }
 
-    if (res >= av.alignment.getWidth())
+    if (res >= av.getAlignment().getWidth())
     {
-      res = av.alignment.getWidth() - 1;
+      res = av.getAlignment().getWidth() - 1;
     }
 
     if (res < min)
@@ -337,7 +337,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
 
   public void mouseMoved(MouseEvent evt)
   {
-    if (!av.hasHiddenColumns)
+    if (!av.hasHiddenColumns())
     {
       return;
     }
@@ -409,7 +409,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
       for (int i = 0; i < cs.size(); i++)
       {
         int sel = cs.columnAt(i);
-        if (av.hasHiddenColumns)
+        if (av.hasHiddenColumns())
         {
           if (cs.isVisible(sel))
           {
@@ -473,7 +473,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
       }
     }
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       gg.setColor(Color.blue);
       int res;
index 9e3f8a2..f982ccc 100755 (executable)
@@ -105,7 +105,7 @@ public class SeqCanvas extends JComponent
     for (int i = scalestartx; i < endx; i += 10)
     {
       int value = i;
-      if (av.hasHiddenColumns)
+      if (av.hasHiddenColumns())
       {
         value = av.getColumnSelection().adjustForHiddenColumns(value);
       }
@@ -137,22 +137,22 @@ public class SeqCanvas extends JComponent
     FontMetrics fm = getFontMetrics(av.getFont());
     ypos += av.charHeight;
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       startx = av.getColumnSelection().adjustForHiddenColumns(startx);
       endx = av.getColumnSelection().adjustForHiddenColumns(endx);
     }
 
-    int maxwidth = av.alignment.getWidth();
-    if (av.hasHiddenColumns)
+    int maxwidth = av.getAlignment().getWidth();
+    if (av.hasHiddenColumns())
     {
       maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
     }
 
     // WEST SCALE
-    for (int i = 0; i < av.alignment.getHeight(); i++)
+    for (int i = 0; i < av.getAlignment().getHeight(); i++)
     {
-      SequenceI seq = av.alignment.getSequenceAt(i);
+      SequenceI seq = av.getAlignment().getSequenceAt(i);
       int index = startx;
       int value = -1;
 
@@ -165,7 +165,7 @@ public class SeqCanvas extends JComponent
           continue;
         }
 
-        value = av.alignment.getSequenceAt(i).findPosition(index);
+        value = av.getAlignment().getSequenceAt(i).findPosition(index);
 
         break;
       }
@@ -196,16 +196,16 @@ public class SeqCanvas extends JComponent
   {
     ypos += av.charHeight;
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       endx = av.getColumnSelection().adjustForHiddenColumns(endx);
     }
 
     SequenceI seq;
     // EAST SCALE
-    for (int i = 0; i < av.alignment.getHeight(); i++)
+    for (int i = 0; i < av.getAlignment().getHeight(); i++)
     {
-      seq = av.alignment.getSequenceAt(i);
+      seq = av.getAlignment().getSequenceAt(i);
       int index = endx;
       int value = -1;
 
@@ -425,9 +425,9 @@ public class SeqCanvas extends JComponent
     String mask = "00";
     int maxWidth = 0;
     int tmp;
-    for (int i = 0; i < av.alignment.getHeight(); i++)
+    for (int i = 0; i < av.getAlignment().getHeight(); i++)
     {
-      tmp = av.alignment.getSequenceAt(i).getEnd();
+      tmp = av.getAlignment().getSequenceAt(i).getEnd();
       if (tmp > maxWidth)
       {
         maxWidth = tmp;
@@ -485,9 +485,9 @@ public class SeqCanvas extends JComponent
 
     int endx;
     int ypos = hgap;
-    int maxwidth = av.alignment.getWidth() - 1;
+    int maxwidth = av.getAlignment().getWidth() - 1;
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
     }
@@ -523,7 +523,7 @@ public class SeqCanvas extends JComponent
         drawNorthScale(g, startRes, endx, ypos);
       }
 
-      if (av.hasHiddenColumns && av.showHiddenMarkers)
+      if (av.hasHiddenColumns() && av.showHiddenMarkers)
       {
         g.setColor(Color.blue);
         int res;
@@ -620,7 +620,7 @@ public class SeqCanvas extends JComponent
   void drawPanel(Graphics g1, int startRes, int endRes, int startSeq,
           int endSeq, int offset)
   {
-    if (!av.hasHiddenColumns)
+    if (!av.hasHiddenColumns())
     {
       draw(g1, startRes, endRes, startSeq, endSeq, offset);
     }
@@ -690,14 +690,14 @@ public class SeqCanvas extends JComponent
     // ///////////////////////////
     for (int i = startSeq; i < endSeq; i++)
     {
-      nextSeq = av.alignment.getSequenceAt(i);
+      nextSeq = av.getAlignment().getSequenceAt(i);
       if (nextSeq == null)
       {
         // occasionally, a race condition occurs such that the alignment row is
         // empty
         continue;
       }
-      sr.drawSequence(nextSeq, av.alignment.findAllGroups(nextSeq),
+      sr.drawSequence(nextSeq, av.getAlignment().findAllGroups(nextSeq),
               startRes, endRes, offset + ((i - startSeq) * av.charHeight));
 
       if (av.showSequenceFeatures)
@@ -734,7 +734,7 @@ public class SeqCanvas extends JComponent
     }
 
     if (av.getSelectionGroup() != null
-            || av.alignment.getGroups().size() > 0)
+            || av.getAlignment().getGroups().size() > 0)
     {
       drawGroupsBoundaries(g, startRes, endRes, startSeq, endSeq, offset);
     }
@@ -757,9 +757,9 @@ public class SeqCanvas extends JComponent
     int groupIndex = -1;
     int visWidth = (endRes - startRes + 1) * av.charWidth;
 
-    if ((group == null) && (av.alignment.getGroups().size() > 0))
+    if ((group == null) && (av.getAlignment().getGroups().size() > 0))
     {
-      group = (SequenceGroup) av.alignment.getGroups().elementAt(0);
+      group = (SequenceGroup) av.getAlignment().getGroups().elementAt(0);
       groupIndex = 0;
     }
 
@@ -786,11 +786,11 @@ public class SeqCanvas extends JComponent
 
           if ((sx <= (endRes - startRes) * av.charWidth)
                   && group.getSequences(null).contains(
-                          av.alignment.getSequenceAt(i)))
+                          av.getAlignment().getSequenceAt(i)))
           {
             if ((bottom == -1)
                     && !group.getSequences(null).contains(
-                            av.alignment.getSequenceAt(i + 1)))
+                            av.getAlignment().getSequenceAt(i + 1)))
             {
               bottom = sy + av.charHeight;
             }
@@ -799,7 +799,7 @@ public class SeqCanvas extends JComponent
             {
               if (((top == -1) && (i == 0))
                       || !group.getSequences(null).contains(
-                              av.alignment.getSequenceAt(i - 1)))
+                              av.getAlignment().getSequenceAt(i - 1)))
               {
                 top = sy;
               }
@@ -915,15 +915,15 @@ public class SeqCanvas extends JComponent
 
         g.setStroke(new BasicStroke());
 
-        if (groupIndex >= av.alignment.getGroups().size())
+        if (groupIndex >= av.getAlignment().getGroups().size())
         {
           break;
         }
 
-        group = (SequenceGroup) av.alignment.getGroups().elementAt(
+        group = (SequenceGroup) av.getAlignment().getGroups().elementAt(
                 groupIndex);
 
-      } while (groupIndex < av.alignment.getGroups().size());
+      } while (groupIndex < av.getAlignment().getGroups().size());
 
     }
 
index 1903294..b8902bd 100644 (file)
@@ -176,7 +176,7 @@ public class SeqPanel extends JPanel implements MouseListener,
       res = (x / av.getCharWidth()) + av.getStartRes();
     }
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       res = av.getColumnSelection().adjustForHiddenColumns(res);
     }
@@ -204,12 +204,12 @@ public class SeqPanel extends JPanel implements MouseListener,
       y -= hgap;
 
       seq = Math.min((y % cHeight) / av.getCharHeight(),
-              av.alignment.getHeight() - 1);
+              av.getAlignment().getHeight() - 1);
     }
     else
     {
       seq = Math.min((y / av.getCharHeight()) + av.getStartSeq(),
-              av.alignment.getHeight() - 1);
+              av.getAlignment().getHeight() - 1);
     }
 
     return seq;
@@ -308,19 +308,19 @@ public class SeqPanel extends JPanel implements MouseListener,
   {
     seqCanvas.cursorX += dx;
     seqCanvas.cursorY += dy;
-    if (av.hasHiddenColumns && !av.colSel.isVisible(seqCanvas.cursorX))
+    if (av.hasHiddenColumns() && !av.getColumnSelection().isVisible(seqCanvas.cursorX))
     {
       int original = seqCanvas.cursorX - dx;
-      int maxWidth = av.alignment.getWidth();
+      int maxWidth = av.getAlignment().getWidth();
 
-      while (!av.colSel.isVisible(seqCanvas.cursorX)
+      while (!av.getColumnSelection().isVisible(seqCanvas.cursorX)
               && seqCanvas.cursorX < maxWidth && seqCanvas.cursorX > 0)
       {
         seqCanvas.cursorX += dx;
       }
 
       if (seqCanvas.cursorX >= maxWidth
-              || !av.colSel.isVisible(seqCanvas.cursorX))
+              || !av.getColumnSelection().isVisible(seqCanvas.cursorX))
       {
         seqCanvas.cursorX = original;
       }
@@ -335,18 +335,18 @@ public class SeqPanel extends JPanel implements MouseListener,
     {
       seqCanvas.cursorX = 0;
     }
-    else if (seqCanvas.cursorX > av.alignment.getWidth() - 1)
+    else if (seqCanvas.cursorX > av.getAlignment().getWidth() - 1)
     {
-      seqCanvas.cursorX = av.alignment.getWidth() - 1;
+      seqCanvas.cursorX = av.getAlignment().getWidth() - 1;
     }
 
     if (seqCanvas.cursorY < 0)
     {
       seqCanvas.cursorY = 0;
     }
-    else if (seqCanvas.cursorY > av.alignment.getHeight() - 1)
+    else if (seqCanvas.cursorY > av.getAlignment().getHeight() - 1)
     {
-      seqCanvas.cursorY = av.alignment.getHeight() - 1;
+      seqCanvas.cursorY = av.getAlignment().getHeight() - 1;
     }
 
     endEditing();
@@ -366,7 +366,7 @@ public class SeqPanel extends JPanel implements MouseListener,
       }
       if (!av.wrapAlignment)
       {
-        while (seqCanvas.cursorX < av.colSel
+        while (seqCanvas.cursorX < av.getColumnSelection()
                 .adjustForHiddenColumns(av.startRes))
         {
           if (!ap.scrollRight(false))
@@ -374,7 +374,7 @@ public class SeqPanel extends JPanel implements MouseListener,
             break;
           }
         }
-        while (seqCanvas.cursorX > av.colSel
+        while (seqCanvas.cursorX > av.getColumnSelection()
                 .adjustForHiddenColumns(av.endRes))
         {
           if (!ap.scrollRight(true))
@@ -384,7 +384,7 @@ public class SeqPanel extends JPanel implements MouseListener,
         }
       }
     }
-    setStatusMessage(av.alignment.getSequenceAt(seqCanvas.cursorY),
+    setStatusMessage(av.getAlignment().getSequenceAt(seqCanvas.cursorY),
             seqCanvas.cursorX, seqCanvas.cursorY);
 
     seqCanvas.repaint();
@@ -397,12 +397,12 @@ public class SeqPanel extends JPanel implements MouseListener,
 
     if (av.getSelectionGroup() != null)
     {
-      SequenceGroup sg = av.selectionGroup;
+      SequenceGroup sg = av.getSelectionGroup();
       // Find the top and bottom of this group
-      int min = av.alignment.getHeight(), max = 0;
+      int min = av.getAlignment().getHeight(), max = 0;
       for (int i = 0; i < sg.getSize(); i++)
       {
-        int index = av.alignment.findIndex(sg.getSequenceAt(i));
+        int index = av.getAlignment().findIndex(sg.getSequenceAt(i));
         if (index > max)
         {
           max = index;
@@ -447,7 +447,7 @@ public class SeqPanel extends JPanel implements MouseListener,
         sg.getSequences(null).clear();
         for (int i = min; i < max; i++)
         {
-          sg.addSequence(av.alignment.getSequenceAt(i), false);
+          sg.addSequence(av.getAlignment().getSequenceAt(i), false);
         }
       }
     }
@@ -673,7 +673,7 @@ public class SeqPanel extends JPanel implements MouseListener,
 
     tooltipText.setLength(6); // Cuts the buffer back to <html>
 
-    SequenceGroup[] groups = av.alignment.findAllGroups(sequence);
+    SequenceGroup[] groups = av.getAlignment().findAllGroups(sequence);
     if (groups != null)
     {
       for (int g = 0; g < groups.length; g++)
@@ -912,7 +912,7 @@ public class SeqPanel extends JPanel implements MouseListener,
             + sequence.getName());
 
     Object obj = null;
-    if (av.alignment.isNucleotide())
+    if (av.getAlignment().isNucleotide())
     {
       obj = ResidueProperties.nucleotideName.get(sequence.getCharAt(res)
               + "");
@@ -1043,15 +1043,14 @@ public class SeqPanel extends JPanel implements MouseListener,
     boolean fixedColumns = false;
     SequenceGroup sg = av.getSelectionGroup();
 
-    SequenceI seq = av.alignment.getSequenceAt(startseq);
+    SequenceI seq = av.getAlignment().getSequenceAt(startseq);
 
     // No group, but the sequence may represent a group
-    if (!groupEditing && av.hasHiddenRows)
+    if (!groupEditing && av.hasHiddenRows())
     {
-      if (av.hiddenRepSequences != null
-              && av.hiddenRepSequences.containsKey(seq))
+      if (av.isHiddenRepSequence(seq))
       {
-        sg = (SequenceGroup) av.hiddenRepSequences.get(seq);
+        sg = av.getRepresentedSequences(seq);
         groupEditing = true;
       }
     }
@@ -1093,7 +1092,7 @@ public class SeqPanel extends JPanel implements MouseListener,
 
     // Are we editing within a selection group?
     if (groupEditing
-            || (sg != null && sg.getSequences(av.hiddenRepSequences)
+            || (sg != null && sg.getSequences(av.getHiddenRepSequences())
                     .contains(seq)))
     {
       fixedColumns = true;
@@ -1102,13 +1101,12 @@ public class SeqPanel extends JPanel implements MouseListener,
       // but the sequence represents a group
       if (sg == null)
       {
-        if (av.hiddenRepSequences == null
-                || !av.hiddenRepSequences.containsKey(seq))
+        if (av.isHiddenRepSequence(seq))
         {
           endEditing();
           return;
         }
-        sg = (SequenceGroup) av.hiddenRepSequences.get(seq);
+        sg = av.getRepresentedSequences(seq);
       }
 
       fixedLeft = sg.getStartRes();
@@ -1135,7 +1133,7 @@ public class SeqPanel extends JPanel implements MouseListener,
       }
     }
 
-    if (av.hasHiddenColumns)
+    if (av.hasHiddenColumns())
     {
       fixedColumns = true;
       int y1 = av.getColumnSelection().getHiddenBoundaryLeft(startres);
@@ -1165,7 +1163,7 @@ public class SeqPanel extends JPanel implements MouseListener,
 
     if (groupEditing)
     {
-      Vector vseqs = sg.getSequences(av.hiddenRepSequences);
+      Vector vseqs = sg.getSequences(av.getHiddenRepSequences());
       int g, groupSize = vseqs.size();
       SequenceI[] groupSeqs = new SequenceI[groupSize];
       for (g = 0; g < groupSeqs.length; g++)
@@ -1179,9 +1177,9 @@ public class SeqPanel extends JPanel implements MouseListener,
         // If the user has selected the whole sequence, and is dragging to
         // the right, we can still extend the alignment and selectionGroup
         if (sg.getStartRes() == 0 && sg.getEndRes() == fixedRight
-                && sg.getEndRes() == av.alignment.getWidth() - 1)
+                && sg.getEndRes() == av.getAlignment().getWidth() - 1)
         {
-          sg.setEndRes(av.alignment.getWidth() + startres - lastres);
+          sg.setEndRes(av.getAlignment().getWidth() + startres - lastres);
           fixedRight = sg.getEndRes();
         }
 
@@ -1213,19 +1211,19 @@ public class SeqPanel extends JPanel implements MouseListener,
 
         if (!blank)
         {
-          if (sg.getSize() == av.alignment.getHeight())
+          if (sg.getSize() == av.getAlignment().getHeight())
           {
-            if ((av.hasHiddenColumns && startres < av.getColumnSelection()
+            if ((av.hasHiddenColumns() && startres < av.getColumnSelection()
                     .getHiddenBoundaryRight(startres)))
             {
               endEditing();
               return;
             }
 
-            int alWidth = av.alignment.getWidth();
-            if (av.hasHiddenRows)
+            int alWidth = av.getAlignment().getWidth();
+            if (av.hasHiddenRows())
             {
-              int hwidth = av.alignment.getHiddenSequences().getWidth();
+              int hwidth = av.getAlignment().getHiddenSequences().getWidth();
               if (hwidth > alWidth)
               {
                 alWidth = hwidth;
@@ -1282,7 +1280,7 @@ public class SeqPanel extends JPanel implements MouseListener,
         else
         {
           editCommand.appendEdit(EditCommand.INSERT_GAP, groupSeqs,
-                  startres, startres - lastres, av.alignment, true);
+                  startres, startres - lastres, av.getAlignment(), true);
         }
       }
       else
@@ -1298,7 +1296,7 @@ public class SeqPanel extends JPanel implements MouseListener,
         else
         {
           editCommand.appendEdit(EditCommand.DELETE_GAP, groupSeqs,
-                  startres, lastres - startres, av.alignment, true);
+                  startres, lastres - startres, av.getAlignment(), true);
         }
 
       }
@@ -1320,7 +1318,7 @@ public class SeqPanel extends JPanel implements MouseListener,
         else
         {
           editCommand.appendEdit(EditCommand.INSERT_GAP, new SequenceI[]
-          { seq }, lastres, startres - lastres, av.alignment, true);
+          { seq }, lastres, startres - lastres, av.getAlignment(), true);
          }
       }
       else
@@ -1356,7 +1354,7 @@ public class SeqPanel extends JPanel implements MouseListener,
           if (max > 0)
           {
             editCommand.appendEdit(EditCommand.DELETE_GAP, new SequenceI[]
-            { seq }, startres, max, av.alignment, true);
+            { seq }, startres, max, av.getAlignment(), true);
           }
         }
        }else{//insertGap==false AND editSeq==TRUE;
@@ -1371,7 +1369,7 @@ public class SeqPanel extends JPanel implements MouseListener,
             else
             {
               editCommand.appendEdit(EditCommand.INSERT_NUC, new SequenceI[]
-              { seq }, lastres, startres - lastres, av.alignment, true);
+              { seq }, lastres, startres - lastres, av.getAlignment(), true);
              }
        }
       }
@@ -1407,9 +1405,9 @@ public class SeqPanel extends JPanel implements MouseListener,
     }
 
     editCommand.appendEdit(EditCommand.DELETE_GAP, seq, blankColumn, 1,
-            av.alignment, true);
+            av.getAlignment(), true);
 
-    editCommand.appendEdit(EditCommand.INSERT_GAP, seq, j, 1, av.alignment,
+    editCommand.appendEdit(EditCommand.INSERT_GAP, seq, j, 1, av.getAlignment(),
             true);
 
   }
@@ -1417,11 +1415,11 @@ public class SeqPanel extends JPanel implements MouseListener,
   void deleteChar(int j, SequenceI[] seq, int fixedColumn)
   {
 
-    editCommand.appendEdit(EditCommand.DELETE_GAP, seq, j, 1, av.alignment,
+    editCommand.appendEdit(EditCommand.DELETE_GAP, seq, j, 1, av.getAlignment(),
             true);
 
     editCommand.appendEdit(EditCommand.INSERT_GAP, seq, fixedColumn, 1,
-            av.alignment, true);
+            av.getAlignment(), true);
   }
 
   /**
@@ -1466,7 +1464,7 @@ public class SeqPanel extends JPanel implements MouseListener,
   public void mouseClicked(MouseEvent evt)
   {
     SequenceGroup sg = null;
-    SequenceI sequence = av.alignment.getSequenceAt(findSeq(evt));
+    SequenceI sequence = av.getAlignment().getSequenceAt(findSeq(evt));
     if (evt.getClickCount() > 1)
     {
       sg = av.getSelectionGroup();
@@ -1525,7 +1523,7 @@ public class SeqPanel extends JPanel implements MouseListener,
 
     startWrapBlock = wrappedBlock;
 
-    if (av.wrapAlignment && seq > av.alignment.getHeight())
+    if (av.wrapAlignment && seq > av.getAlignment().getHeight())
     {
       JOptionPane.showInternalMessageDialog(Desktop.desktop,
               "Cannot edit annotations in wrapped view.",
@@ -1549,7 +1547,7 @@ public class SeqPanel extends JPanel implements MouseListener,
 
     if (stretchGroup == null)
     {
-      stretchGroup = av.alignment.findGroup(sequence);
+      stretchGroup = av.getAlignment().findGroup(sequence);
 
       if ((stretchGroup != null) && (res > stretchGroup.getStartRes())
               && (res < stretchGroup.getEndRes()))
@@ -1567,7 +1565,7 @@ public class SeqPanel extends JPanel implements MouseListener,
     {
       stretchGroup = null;
 
-      SequenceGroup[] allGroups = av.alignment.findAllGroups(sequence);
+      SequenceGroup[] allGroups = av.getAlignment().findAllGroups(sequence);
 
       if (allGroups != null)
       {
@@ -1676,7 +1674,7 @@ public class SeqPanel extends JPanel implements MouseListener,
       if (stretchGroup.cs instanceof ClustalxColourScheme)
       {
         ((ClustalxColourScheme) stretchGroup.cs).resetClustalX(
-                stretchGroup.getSequences(av.hiddenRepSequences),
+                stretchGroup.getSequences(av.getHiddenRepSequences()),
                 stretchGroup.getWidth());
       }
 
@@ -1721,9 +1719,9 @@ public class SeqPanel extends JPanel implements MouseListener,
       return;
     }
 
-    if (res >= av.alignment.getWidth())
+    if (res >= av.getAlignment().getWidth())
     {
-      res = av.alignment.getWidth() - 1;
+      res = av.getAlignment().getWidth() - 1;
     }
 
     if (stretchGroup.getEndRes() == res)
@@ -1768,7 +1766,7 @@ public class SeqPanel extends JPanel implements MouseListener,
       dragDirection = -1;
     }
 
-    while ((y != oldSeq) && (oldSeq > -1) && (y < av.alignment.getHeight()))
+    while ((y != oldSeq) && (oldSeq > -1) && (y < av.getAlignment().getHeight()))
     {
       // This routine ensures we don't skip any sequences, as the
       // selection is quite slow.
@@ -1873,7 +1871,7 @@ public class SeqPanel extends JPanel implements MouseListener,
           }
 
           if (mouseDragging && (evt.getY() >= getHeight())
-                  && (av.alignment.getHeight() > av.getEndSeq()))
+                  && (av.getAlignment().getHeight() > av.getEndSeq()))
           {
             running = ap.scrollUp(false);
           }
@@ -1926,15 +1924,15 @@ public class SeqPanel extends JPanel implements MouseListener,
       SequenceGroup sgroup = null;
       if (seqsel != null && seqsel.getSize()>0)
       {
-        if (av.alignment == null)
+        if (av.getAlignment() == null)
         {
           jalview.bin.Cache.log.warn("alignviewport av SeqSetId="
                   + av.getSequenceSetId() + " ViewId=" + av.getViewId()
                   + " 's alignment is NULL! returning immediatly.");
           return;
         }
-        sgroup = seqsel.intersect(av.alignment,
-                (av.hasHiddenRows) ? av.hiddenRepSequences : null);
+        sgroup = seqsel.intersect(av.getAlignment(),
+                (av.hasHiddenRows()) ? av.getHiddenRepSequences() : null);
         if ((sgroup == null || sgroup.getSize() == 0)
                 || (colsel == null || colsel.size() == 0))
         {
@@ -1959,29 +1957,29 @@ public class SeqPanel extends JPanel implements MouseListener,
       // so import the new colsel.
       if (colsel == null || colsel.size() == 0)
       {
-        if (av.colSel != null)
+        if (av.getColumnSelection() != null)
         {
-          av.colSel.clear();
+          av.getColumnSelection().clear();
           repaint=true;
         }
       }
       else
       {
         // TODO: shift colSel according to the intersecting sequences
-        if (av.colSel == null)
+        if (av.getColumnSelection() == null)
         {
-          av.colSel = new ColumnSelection(colsel);
+          av.setColumnSelection(new ColumnSelection(colsel));
         }
         else
         {
-          av.colSel.setElementsFrom(colsel);
+          av.getColumnSelection().setElementsFrom(colsel);
         }
       }
       av.isColSelChanged(true);
       repaint = true;
     }
-    if (copycolsel && av.hasHiddenColumns
-            && (av.colSel == null || av.colSel.getHiddenColumns() == null))
+    if (copycolsel && av.hasHiddenColumns()
+            && (av.getColumnSelection() == null || av.getColumnSelection().getHiddenColumns() == null))
     {
       System.err.println("Bad things");
     }
index 3fa00f5..d596183 100755 (executable)
@@ -802,16 +802,16 @@ public class SequenceFetcher extends JPanel implements Runnable
       {
         for (int i = 0; i < al.getHeight(); i++)
         {
-          alignFrame.viewport.alignment.addSequence(al.getSequenceAt(i)); // this
+          alignFrame.viewport.getAlignment().addSequence(al.getSequenceAt(i)); // this
           // also
           // creates
           // dataset
           // sequence
           // entries
         }
-        alignFrame.viewport.setEndSeq(alignFrame.viewport.alignment
+        alignFrame.viewport.setEndSeq(alignFrame.viewport.getAlignment()
                 .getHeight());
-        alignFrame.viewport.alignment.getWidth();
+        alignFrame.viewport.getAlignment().getWidth();
         alignFrame.viewport.firePropertyChange("alignment", null,
                 alignFrame.viewport.getAlignment().getSequences());
       }
index e94fba4..ad704c3 100755 (executable)
@@ -80,7 +80,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
 
   public Color getResidueBoxColour(SequenceI seq, int i)
   {
-    allGroups = av.alignment.findAllGroups(seq);
+    allGroups = av.getAlignment().findAllGroups(seq);
 
     if (inCurrentSequenceGroup(i))
     {
@@ -91,7 +91,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
     }
     else if (av.getShowBoxes())
     {
-      getBoxColour(av.globalColourScheme, seq, i);
+      getBoxColour(av.getGlobalColourScheme(), seq, i);
     }
 
     return resBoxColour;
@@ -205,7 +205,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
         }
         else if (av.getShowBoxes())
         {
-          getBoxColour(av.globalColourScheme, seq, i);
+          getBoxColour(av.getGlobalColourScheme(), seq, i);
         }
 
       }
@@ -328,7 +328,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
           if (currentSequenceGroup.getShowNonconserved()) // todo optimize
           {
             // todo - use sequence group consensus
-            s = getDisplayChar(av.consensus, i, s, '.');
+            s = getDisplayChar(av.getAlignmentConsensusAnnotation(), i, s, '.');
 
           }
 
@@ -343,7 +343,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
           if (av.getColourText())
           {
             getboxColour = true;
-            getBoxColour(av.globalColourScheme, seq, i);
+            getBoxColour(av.getGlobalColourScheme(), seq, i);
 
             if (av.getShowBoxes())
             {
@@ -359,7 +359,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
           {
             if (!getboxColour)
             {
-              getBoxColour(av.globalColourScheme, seq, i);
+              getBoxColour(av.getGlobalColourScheme(), seq, i);
             }
 
             if (resBoxColour.getRed() + resBoxColour.getBlue()
@@ -368,9 +368,9 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
               graphics.setColor(av.textColour2);
             }
           }
-          if (av.showUnconserved)
+          if (av.getShowUnconserved())
           {
-            s = getDisplayChar(av.consensus, i, s, '.');
+            s = getDisplayChar(av.getAlignmentConsensusAnnotation(), i, s, '.');
 
           }
 
index 4cbb985..601bf6d 100755 (executable)
@@ -133,7 +133,7 @@ public class SliderPanel extends GSliderPanel
     conservationSlider.setTitle("Conservation Colour Increment  (" + source
             + ")");
 
-    if (ap.av.alignment.getGroups() != null)
+    if (ap.av.getAlignment().getGroups() != null)
     {
       sp.setAllGroupsCheckEnabled(true);
     }
@@ -209,7 +209,7 @@ public class SliderPanel extends GSliderPanel
 
     PIDSlider.setTitle("Percentage Identity Threshold (" + source + ")");
 
-    if (ap.av.alignment.getGroups() != null)
+    if (ap.av.getAlignment().getGroups() != null)
     {
       pid.setAllGroupsCheckEnabled(true);
     }
@@ -271,7 +271,7 @@ public class SliderPanel extends GSliderPanel
 
     if (allGroupsCheck.isSelected())
     {
-      allGroups = ap.av.alignment.getGroups();
+      allGroups = ap.av.getAlignment().getGroups();
       groupIndex = allGroups.size() - 1;
     }
     else
index ba9a9f9..3ada67e 100644 (file)
@@ -188,12 +188,12 @@ public class TextColourChooser
 
   void setGroupTextColour()
   {
-    if (ap.av.alignment.getGroups() == null)
+    if (ap.av.getAlignment().getGroups() == null)
     {
       return;
     }
 
-    Vector groups = ap.av.alignment.getGroups();
+    Vector groups = ap.av.getAlignment().getGroups();
 
     for (int i = 0; i < groups.size(); i++)
     {
index b62a1c7..b23fbc2 100755 (executable)
@@ -125,7 +125,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
         aps[a].av.setSelectionGroup(selected);
       }
 
-      selected.setEndRes(aps[a].av.alignment.getWidth() - 1);
+      selected.setEndRes(aps[a].av.getAlignment().getWidth() - 1);
       selected.addOrRemove(sequence, true);
     }
   }
@@ -851,7 +851,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
         for (int a = 0; a < aps.length; a++)
         {
           aps[a].av.setSelectionGroup(null);
-          aps[a].av.alignment.deleteAllGroups();
+          aps[a].av.getAlignment().deleteAllGroups();
           aps[a].av.sequenceColours = null;
         }
         colourGroups();
@@ -901,7 +901,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
         }
         else
         {
-          cs = ColourSchemeProperty.getColour(sequences, av.alignment
+          cs = ColourSchemeProperty.getColour(sequences, av.getAlignment()
                   .getWidth(), ColourSchemeProperty.getColourName(av
                   .getGlobalColourScheme()));
         }
@@ -914,7 +914,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
       }
 
       SequenceGroup sg = new SequenceGroup(sequences, null, cs, true, true,
-              false, 0, av.alignment.getWidth() - 1);
+              false, 0, av.getAlignment().getWidth() - 1);
 
       sg.setName("JTreeGroup:" + sg.hashCode());
       sg.setIdColour(col);
@@ -932,7 +932,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
           sg.cs.setConservation(c);
         }
 
-        aps[a].av.alignment.addGroup(sg);
+        aps[a].av.getAlignment().addGroup(sg);
       }
     }
     // notify the panel to redo any group specific stuff.
index a266412..602ded6 100755 (executable)
@@ -255,11 +255,11 @@ public class TreePanel extends GTreePanel
       {
         if (odata == null)
         {
-          tree = new NJTree(av.alignment.getSequencesArray(), newtree);
+          tree = new NJTree(av.getAlignment().getSequencesArray(), newtree);
         }
         else
         {
-          tree = new NJTree(av.alignment.getSequencesArray(), odata,
+          tree = new NJTree(av.getAlignment().getSequencesArray(), odata,
                   newtree);
         }
         if (!tree.hasOriginalSequenceData())
@@ -276,14 +276,14 @@ public class TreePanel extends GTreePanel
         if (av.getSelectionGroup() == null)
         {
           start = 0;
-          end = av.alignment.getWidth();
-          seqs = av.alignment.getSequencesArray();
+          end = av.getAlignment().getWidth();
+          seqs = av.getAlignment().getSequencesArray();
         }
         else
         {
           start = av.getSelectionGroup().getStartRes();
           end = av.getSelectionGroup().getEndRes() + 1;
-          seqs = av.getSelectionGroup().getSequencesInOrder(av.alignment);
+          seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
         }
 
         tree = new NJTree(seqs, seqStrings, type, pwtype, start, end);
@@ -570,7 +570,7 @@ public class TreePanel extends GTreePanel
     AlignmentSorter.sortByTree(av.getAlignment(), tree);
     CommandI undo;
     undo=new OrderCommand("Tree Sort", oldOrder,
-          av.alignment);
+          av.getAlignment());
 
     ap.paintAlignment(true);    
     return undo;
diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java
new file mode 100644 (file)
index 0000000..0cd23de
--- /dev/null
@@ -0,0 +1,1081 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
+ * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * 
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package jalview.viewmodel;
+
+import jalview.analysis.Conservation;
+import jalview.api.AlignCalcManagerI;
+import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.AlignmentView;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.schemes.ClustalxColourScheme;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ResidueProperties;
+import jalview.workers.AlignCalcManager;
+import jalview.workers.ConsensusThread;
+import jalview.workers.ConservationThread;
+import jalview.workers.StrucConsensusThread;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * base class holding visualization and analysis attributes and common logic for an active alignment view displayed in the GUI
+ * @author jimp
+ *
+ */
+public abstract class AlignmentViewport implements AlignViewportI
+{
+  /**
+   * alignment displayed in the viewport. Please use get/setter
+   */
+  protected AlignmentI alignment;
+
+  protected String sequenceSetID;
+
+  private Hashtable hiddenRepSequences;
+
+  protected ColumnSelection colSel = new ColumnSelection();
+
+
+  public boolean autoCalculateConsensus = true;
+
+  protected boolean autoCalculateStrucConsensus = true;
+
+  protected boolean ignoreGapsInConsensusCalculation = false;
+  
+
+  protected ColourSchemeI globalColourScheme = null;
+
+
+  public void setGlobalColourScheme(ColourSchemeI cs)
+  {
+    globalColourScheme = cs;
+  }
+
+  public ColourSchemeI getGlobalColourScheme()
+  {
+    return globalColourScheme;
+  }
+
+
+  protected AlignmentAnnotation consensus;
+
+  protected AlignmentAnnotation strucConsensus;
+
+  protected AlignmentAnnotation conservation;
+
+  protected AlignmentAnnotation quality;
+
+  protected AlignmentAnnotation[] groupConsensus;
+
+  protected AlignmentAnnotation[] groupConservation;
+
+  /** 
+   * results of alignment consensus analysis for visible portion of view 
+   */
+  protected Hashtable[] hconsensus=null;
+
+  /**
+   * results of secondary structure base pair consensus for visible portion of view
+   */
+  protected Hashtable[] hStrucConsensus=null;
+
+  /**
+   * percentage gaps allowed in a column before all amino acid properties should be considered unconserved
+   */
+  int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
+
+
+  public int getConsPercGaps()
+  {
+    return ConsPercGaps;
+  }
+  @Override
+  public void setSequenceConsensusHash(Hashtable[] hconsensus)
+  {
+    this.hconsensus=hconsensus;
+    
+  }
+
+  @Override
+  public Hashtable[] getSequenceConsensusHash()
+  {
+    return hconsensus;
+  }
+
+  @Override
+  public Hashtable[] getRnaStructureConsensusHash()
+  {
+    return hStrucConsensus;
+  }
+  @Override
+  public void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus)
+  {
+    this.hStrucConsensus=hStrucConsensus;
+    
+  }
+  @Override
+  public AlignmentAnnotation getAlignmentQualityAnnot()
+  {
+    return quality;
+  }
+
+  @Override
+  public AlignmentAnnotation getAlignmentConservationAnnotation()
+  {
+    return conservation;
+  }
+  @Override
+  public AlignmentAnnotation getAlignmentConsensusAnnotation()
+  {
+    return consensus;
+  }
+  @Override
+  public AlignmentAnnotation getAlignmentStrucConsensusAnnotation()
+  {
+    return strucConsensus;
+  }
+  
+  protected AlignCalcManagerI calculator=new AlignCalcManager();
+
+  jalview.workers.ConsensusThread consensusThread;
+
+  StrucConsensusThread strucConsensusThread;
+
+
+  private ConservationThread conservationThread;
+
+  /**
+   * trigger update of conservation annotation
+   */
+  public void updateConservation(final AlignmentViewPanel ap)
+  {
+    // see note in mantis : issue number 8585
+    if (alignment.isNucleotide() || conservation == null
+            || !autoCalculateConsensus)
+    {
+      return;
+    }
+    
+    calculator.startWorker(conservationThread=new jalview.workers.ConservationThread(this, ap));
+  }
+
+  /**
+   * trigger update of consensus annotation
+   */
+  public void updateConsensus(final AlignmentViewPanel ap)
+  {
+    // see note in mantis : issue number 8585
+    if (consensus == null || !autoCalculateConsensus)
+    {
+      return;
+    }
+    calculator.startWorker(consensusThread = new ConsensusThread(this, ap));
+  }
+
+  // --------START Structure Conservation
+  public void updateStrucConsensus(final AlignmentViewPanel ap)
+  {
+    // see note in mantis : issue number 8585
+    if (strucConsensus == null || !autoCalculateStrucConsensus)
+    {
+      return;
+    }
+    calculator.startWorker(strucConsensusThread = new StrucConsensusThread(this,ap));
+  }
+
+  public boolean isCalcInProgress()
+  {
+    // TODO generalise to iterate over all calculators associated with av
+    return calculator.isWorking();
+  }
+
+  public boolean isCalculationInProgress(
+          AlignmentAnnotation alignmentAnnotation)
+  {
+    if (!alignmentAnnotation.autoCalculated)
+      return false;
+    if ((calculator.isWorking(consensusThread) && consensus==alignmentAnnotation)
+            || (calculator.isWorking(conservationThread) &&  (conservation==alignmentAnnotation || quality==alignmentAnnotation))
+            || (calculator.isWorking(strucConsensusThread) && strucConsensus==alignmentAnnotation)
+            )
+    {
+      return true;
+    }
+    return false;
+  }
+  @Override
+  public boolean isClosed()
+  {
+    // TODO: check that this isClosed is only true after panel is closed, not before it is fully constructed.
+    return alignment==null;
+  }
+
+  @Override
+  public AlignCalcManagerI getCalcManager()
+  {
+    return calculator;
+  }
+
+  /**
+   * should conservation rows be shown for groups
+   */
+  protected boolean showGroupConservation = false;
+
+  /**
+   * should consensus rows be shown for groups
+   */
+  protected boolean showGroupConsensus = false;
+
+  /**
+   * should consensus profile be rendered by default
+   */
+  protected boolean showSequenceLogo = false;
+  /**
+   * should consensus profile be rendered normalised to row height
+   */
+  protected boolean normaliseSequenceLogo = false;
+  /**
+   * should consensus histograms be rendered by default
+   */
+  protected boolean showConsensusHistogram = true;
+
+  /**
+   * @return the showConsensusProfile
+   */
+  public boolean isShowSequenceLogo()
+  {
+    return showSequenceLogo;
+  }
+
+  /**
+   * @param showSequenceLogo
+   *          the new value
+   */
+  public void setShowSequenceLogo(boolean showSequenceLogo)
+  {
+    if (showSequenceLogo != this.showSequenceLogo)
+    {
+      // TODO: decouple settings setting from calculation when refactoring
+      // annotation update method from alignframe to viewport
+      this.showSequenceLogo = showSequenceLogo;
+      if (consensusThread != null)
+      {
+        consensusThread.updateAnnotation();
+      }
+      if (strucConsensusThread != null)
+      {
+        strucConsensusThread.updateAnnotation();
+      }
+    }
+    this.showSequenceLogo = showSequenceLogo;
+  }
+
+  /**
+   * @param showConsensusHistogram
+   *          the showConsensusHistogram to set
+   */
+  public void setShowConsensusHistogram(boolean showConsensusHistogram)
+  {
+    this.showConsensusHistogram = showConsensusHistogram;
+  }
+
+  /**
+   * @return the showGroupConservation
+   */
+  public boolean isShowGroupConservation()
+  {
+    return showGroupConservation;
+  }
+
+  /**
+   * @param showGroupConservation
+   *          the showGroupConservation to set
+   */
+  public void setShowGroupConservation(boolean showGroupConservation)
+  {
+    this.showGroupConservation = showGroupConservation;
+  }
+
+  /**
+   * @return the showGroupConsensus
+   */
+  public boolean isShowGroupConsensus()
+  {
+    return showGroupConsensus;
+  }
+
+  /**
+   * @param showGroupConsensus
+   *          the showGroupConsensus to set
+   */
+  public void setShowGroupConsensus(boolean showGroupConsensus)
+  {
+    this.showGroupConsensus = showGroupConsensus;
+  }
+
+  /**
+   * 
+   * @return flag to indicate if the consensus histogram should be rendered by
+   *         default
+   */
+  public boolean isShowConsensusHistogram()
+  {
+    return this.showConsensusHistogram;
+  }
+
+  /**
+   * show non-conserved residues only
+   */
+  protected boolean showUnconserved = false;
+
+
+  /**
+   * when set, updateAlignment will always ensure sequences are of equal length
+   */
+  private boolean padGaps = false;
+
+  /**
+   * when set, alignment should be reordered according to a newly opened tree
+   */
+  public boolean sortByTree = false;
+
+  public boolean getShowUnconserved()
+  {
+    return showUnconserved;
+  }
+
+  public void setShowUnconserved(boolean showunconserved)
+  {
+    showUnconserved = showunconserved;
+  }
+
+  /**
+   * @param showNonconserved
+   *          the showUnconserved to set
+   */
+  public void setShowunconserved(boolean displayNonconserved)
+  {
+    this.showUnconserved = displayNonconserved;
+  }
+
+  /**
+   * 
+   * 
+   * @return null or the currently selected sequence region
+   */
+  public SequenceGroup getSelectionGroup()
+  {
+    return selectionGroup;
+  }
+
+  /**
+   * Set the selection group for this window.
+   * 
+   * @param sg
+   *          - group holding references to sequences in this alignment view
+   * 
+   */
+  public void setSelectionGroup(SequenceGroup sg)
+  {
+    selectionGroup = sg;
+  }
+
+  public void setHiddenColumns(ColumnSelection colsel)
+  {
+    this.colSel = colsel;
+    if (colSel.getHiddenColumns() != null)
+    {
+      hasHiddenColumns = true;
+    }
+  }
+
+  public ColumnSelection getColumnSelection()
+  {
+    return colSel;
+  }
+  public void setColumnSelection(ColumnSelection colSel)
+  {
+    this.colSel=colSel;
+  }
+  public Hashtable getHiddenRepSequences()
+  {
+    return hiddenRepSequences;
+  }
+  public void setHiddenRepSequences(Hashtable hiddenRepSequences)
+  {
+    this.hiddenRepSequences = hiddenRepSequences;
+  }
+  protected boolean hasHiddenColumns = false;
+
+  public void updateHiddenColumns()
+  {
+    hasHiddenColumns = colSel.getHiddenColumns() != null;  
+  }
+  
+  protected boolean hasHiddenRows = false;
+  
+  public boolean hasHiddenRows() {
+    return hasHiddenRows;
+  }
+
+  protected SequenceGroup selectionGroup;
+
+  public void setSequenceSetId(String newid)
+  {
+    if (sequenceSetID!=null)
+    {
+      System.err.println("Warning - overwriting a sequenceSetId for a viewport!");
+    }
+    sequenceSetID=new String(newid);
+  }
+  public String getSequenceSetId()
+  {
+    if (sequenceSetID == null)
+    {
+      sequenceSetID = alignment.hashCode() + "";
+    }
+
+    return sequenceSetID;
+  }
+  /**
+   * unique viewId for synchronizing state (e.g. with stored Jalview Project)
+   * 
+   */
+  protected String viewId = null;
+
+  public String getViewId()
+  {
+    if (viewId == null)
+    {
+      viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
+    }
+    return viewId;
+  }
+  public void setIgnoreGapsConsensus(boolean b, AlignmentViewPanel ap)
+  {
+    ignoreGapsInConsensusCalculation = b;
+    if (ap!=null) {updateConsensus(ap);
+    if (globalColourScheme != null)
+    {
+      globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
+              ignoreGapsInConsensusCalculation);
+    }}
+    
+  }
+  private long sgrouphash = -1, colselhash = -1;
+
+  /**
+   * checks current SelectionGroup against record of last hash value, and
+   * updates record.
+   * 
+   * @param b
+   *          update the record of last hash value
+   * 
+   * @return true if SelectionGroup changed since last call (when b is true)
+   */
+  public boolean isSelectionGroupChanged(boolean b)
+  {
+    int hc = (selectionGroup == null || selectionGroup.getSize() == 0) ? -1
+            : selectionGroup.hashCode();
+    if (hc != -1 && hc != sgrouphash)
+    {
+      if (b)
+      {
+        sgrouphash = hc;
+      }
+      return true;
+    }
+    return false;
+  }
+
+  /**
+   * checks current colsel against record of last hash value, and optionally
+   * updates record.
+   * 
+   * @param b
+   *          update the record of last hash value
+   * @return true if colsel changed since last call (when b is true)
+   */
+  public boolean isColSelChanged(boolean b)
+  {
+    int hc = (colSel == null || colSel.size() == 0) ? -1 : colSel
+            .hashCode();
+    if (hc != -1 && hc != colselhash)
+    {
+      if (b)
+      {
+        colselhash = hc;
+      }
+      return true;
+    }
+    return false;
+  }
+
+  public boolean getIgnoreGapsConsensus()
+  {
+    return ignoreGapsInConsensusCalculation;
+  }
+
+  /// property change stuff
+
+  // JBPNote Prolly only need this in the applet version.
+  private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
+          this);
+
+
+  /**
+   * Property change listener for changes in alignment
+   * 
+   * @param listener
+   *          DOCUMENT ME!
+   */
+  public void addPropertyChangeListener(
+          java.beans.PropertyChangeListener listener)
+  {
+    changeSupport.addPropertyChangeListener(listener);
+  }
+
+  /**
+   * DOCUMENT ME!
+   * 
+   * @param listener
+   *          DOCUMENT ME!
+   */
+  public void removePropertyChangeListener(
+          java.beans.PropertyChangeListener listener)
+  {
+    changeSupport.removePropertyChangeListener(listener);
+  }
+
+  /**
+   * Property change listener for changes in alignment
+   * 
+   * @param prop
+   *          DOCUMENT ME!
+   * @param oldvalue
+   *          DOCUMENT ME!
+   * @param newvalue
+   *          DOCUMENT ME!
+   */
+  public void firePropertyChange(String prop, Object oldvalue,
+          Object newvalue)
+  {
+    changeSupport.firePropertyChange(prop, oldvalue, newvalue);
+  }
+
+  // common hide/show column stuff
+  
+
+  public void hideSelectedColumns()
+  {
+    if (colSel.size() < 1)
+    {
+      return;
+    }
+
+    colSel.hideSelectedColumns();
+    setSelectionGroup(null);
+
+    hasHiddenColumns = true;
+  }
+
+  public void hideColumns(int start, int end)
+  {
+    if (start == end)
+    {
+      colSel.hideColumns(start);
+    }
+    else
+    {
+      colSel.hideColumns(start, end);
+    }
+
+    hasHiddenColumns = true;
+  }
+
+  public void showColumn(int col)
+  {
+    colSel.revealHiddenColumns(col);
+    if (colSel.getHiddenColumns() == null)
+    {
+      hasHiddenColumns = false;
+    }
+  }
+
+  public void showAllHiddenColumns()
+  {
+    colSel.revealAllHiddenColumns();
+    hasHiddenColumns = false;
+  }
+
+  
+  // common hide/show seq stuff
+  public void showAllHiddenSeqs()
+  {
+    if (alignment.getHiddenSequences().getSize() > 0)
+    {
+      if (selectionGroup == null)
+      {
+        selectionGroup = new SequenceGroup();
+        selectionGroup.setEndRes(alignment.getWidth() - 1);
+      }
+      Vector tmp = alignment.getHiddenSequences().showAll(
+              hiddenRepSequences);
+      for (int t = 0; t < tmp.size(); t++)
+      {
+        selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
+      }
+
+      hasHiddenRows = false;
+      hiddenRepSequences = null;
+
+      firePropertyChange("alignment", null, alignment.getSequences());
+      // used to set hasHiddenRows/hiddenRepSequences here, after the property changed event
+      sendSelection();
+    }
+  }
+
+  public void showSequence(int index)
+  {
+    Vector tmp = alignment.getHiddenSequences().showSequence(index,
+            hiddenRepSequences);
+    if (tmp.size() > 0)
+    {
+      if (selectionGroup == null)
+      {
+        selectionGroup = new SequenceGroup();
+        selectionGroup.setEndRes(alignment.getWidth() - 1);
+      }
+
+      for (int t = 0; t < tmp.size(); t++)
+      {
+        selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
+      }
+      // JBPNote: refactor: only update flag if we modified visiblity (used to do this regardless) 
+      if (alignment.getHiddenSequences().getSize() < 1)
+      {
+        hasHiddenRows = false;
+      }
+      firePropertyChange("alignment", null, alignment.getSequences());
+      sendSelection();
+    }
+  }
+
+
+  
+  public void hideAllSelectedSeqs()
+  {
+    if (selectionGroup == null || selectionGroup.getSize() < 1)
+    {
+      return;
+    }
+
+    SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
+
+    hideSequence(seqs);
+
+    setSelectionGroup(null);
+  }
+  
+
+  public void hideSequence(SequenceI[] seq)
+  {
+    if (seq != null)
+    {
+      for (int i = 0; i < seq.length; i++)
+      {
+        alignment.getHiddenSequences().hideSequence(seq[i]);
+      }
+      hasHiddenRows = true;
+      firePropertyChange("alignment", null, alignment.getSequences());
+    }
+  }
+
+  public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
+  {
+    int sSize = sg.getSize();
+    if (sSize < 2)
+    {
+      return;
+    }
+
+    if (hiddenRepSequences == null)
+    {
+      hiddenRepSequences = new Hashtable();
+    }
+
+    hiddenRepSequences.put(repSequence, sg);
+
+    // Hide all sequences except the repSequence
+    SequenceI[] seqs = new SequenceI[sSize - 1];
+    int index = 0;
+    for (int i = 0; i < sSize; i++)
+    {
+      if (sg.getSequenceAt(i) != repSequence)
+      {
+        if (index == sSize - 1)
+        {
+          return;
+        }
+
+        seqs[index++] = sg.getSequenceAt(i);
+      }
+    }
+    sg.setSeqrep(repSequence); // note: not done in 2.7applet 
+    sg.setHidereps(true); // note: not done in 2.7applet
+    hideSequence(seqs);
+
+  }
+
+  public boolean isHiddenRepSequence(SequenceI seq)
+  {
+    return hiddenRepSequences != null
+          && hiddenRepSequences.containsKey(seq);
+  }
+  public SequenceGroup getRepresentedSequences(SequenceI seq)
+  {
+    return (SequenceGroup) (hiddenRepSequences == null ? null : hiddenRepSequences.get(seq));
+  }
+
+  public int adjustForHiddenSeqs(int alignmentIndex)
+  {
+    return alignment.getHiddenSequences().adjustForHiddenSeqs(
+            alignmentIndex);
+  }
+
+  // Selection manipulation
+  /**
+   * broadcast selection to any interested parties
+   */
+  public abstract void sendSelection();
+  
+
+  public void invertColumnSelection()
+  {
+    colSel.invertColumnSelection(0, alignment.getWidth());
+  }
+
+
+  /**
+   * This method returns an array of new SequenceI objects derived from the
+   * whole alignment or just the current selection with start and end points
+   * adjusted
+   * 
+   * @note if you need references to the actual SequenceI objects in the
+   *       alignment or currently selected then use getSequenceSelection()
+   * @return selection as new sequenceI objects
+   */
+  public SequenceI[] getSelectionAsNewSequence()
+  {
+    SequenceI[] sequences;
+    // JBPNote: Need to test jalviewLite.getSelectedSequencesAsAlignmentFrom - this was the only caller in the applet for this method
+    // JBPNote: in applet, this method returned references to the alignment sequences, and it did not honour the presence/absence of annotation attached to the alignment (probably!)
+    if (selectionGroup == null)
+    {
+      sequences = alignment.getSequencesArray();
+      AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
+      for (int i = 0; i < sequences.length; i++)
+      {
+        sequences[i] = new Sequence(sequences[i], annots); // construct new
+        // sequence with
+        // subset of visible
+        // annotation
+      }
+    }
+    else
+    {
+      sequences = selectionGroup.getSelectionAsNewSequences(alignment);
+    }
+
+    return sequences;
+  }
+
+
+  /**
+   * get the currently selected sequence objects or all the sequences in the
+   * alignment.
+   * 
+   * @return array of references to sequence objects
+   */
+  public SequenceI[] getSequenceSelection()
+  {
+    SequenceI[] sequences = null;
+    if (selectionGroup != null)
+    {
+      sequences = selectionGroup.getSequencesInOrder(alignment);
+    }
+    if (sequences == null)
+    {
+      sequences = alignment.getSequencesArray();
+    }
+    return sequences;
+  }
+
+
+  /**
+   * This method returns the visible alignment as text, as seen on the GUI, ie
+   * if columns are hidden they will not be returned in the result. Use this for
+   * calculating trees, PCA, redundancy etc on views which contain hidden
+   * columns.
+   * 
+   * @return String[]
+   */
+  public jalview.datamodel.CigarArray getViewAsCigars(
+          boolean selectedRegionOnly)
+  {
+    return new jalview.datamodel.CigarArray(alignment,
+            (hasHiddenColumns ? colSel : null),
+            (selectedRegionOnly ? selectionGroup : null));
+  }
+
+  /**
+   * return a compact representation of the current alignment selection to pass
+   * to an analysis function
+   * 
+   * @param selectedOnly
+   *          boolean true to just return the selected view
+   * @return AlignmentView
+   */
+  public jalview.datamodel.AlignmentView getAlignmentView(
+          boolean selectedOnly)
+  {
+    return getAlignmentView(selectedOnly, false);
+  }
+
+  /**
+   * return a compact representation of the current alignment selection to pass
+   * to an analysis function
+   * 
+   * @param selectedOnly
+   *          boolean true to just return the selected view
+   * @param markGroups
+   *          boolean true to annotate the alignment view with groups on the
+   *          alignment (and intersecting with selected region if selectedOnly
+   *          is true)
+   * @return AlignmentView
+   */
+  public jalview.datamodel.AlignmentView getAlignmentView(
+          boolean selectedOnly, boolean markGroups)
+  {
+    return new AlignmentView(alignment, colSel, selectionGroup,
+            hasHiddenColumns, selectedOnly, markGroups);
+  }
+
+
+  /**
+   * This method returns the visible alignment as text, as seen on the GUI, ie
+   * if columns are hidden they will not be returned in the result. Use this for
+   * calculating trees, PCA, redundancy etc on views which contain hidden
+   * columns.
+   * 
+   * @return String[]
+   */
+  public String[] getViewAsString(boolean selectedRegionOnly)
+  {
+    String[] selection = null;
+    SequenceI[] seqs = null;
+    int i, iSize;
+    int start = 0, end = 0;
+    if (selectedRegionOnly && selectionGroup != null)
+    {
+      iSize = selectionGroup.getSize();
+      seqs = selectionGroup.getSequencesInOrder(alignment);
+      start = selectionGroup.getStartRes();
+      end = selectionGroup.getEndRes() + 1;
+    }
+    else
+    {
+      iSize = alignment.getHeight();
+      seqs = alignment.getSequencesArray();
+      end = alignment.getWidth();
+    }
+
+    selection = new String[iSize];
+    if (hasHiddenColumns)
+    {
+      selection = colSel.getVisibleSequenceStrings(start, end, seqs);
+    }
+    else
+    {
+      for (i = 0; i < iSize; i++)
+      {
+        selection[i] = seqs[i].getSequenceAsString(start, end);
+      }
+
+    }
+    return selection;
+  }
+
+
+  /**
+   * return visible region boundaries within given column range
+   * @param min first column (inclusive, from 0)
+   * @param max last column (exclusive)
+   * @return int[][] range of {start,end} visible positions
+   */
+  public int[][] getVisibleRegionBoundaries(int min, int max)
+  {
+    Vector regions = new Vector();
+    int start = min;
+    int end = max;
+
+    do
+    {
+      if (hasHiddenColumns)
+      {
+        if (start == 0)
+        {
+          start = colSel.adjustForHiddenColumns(start);
+        }
+
+        end = colSel.getHiddenBoundaryRight(start);
+        if (start == end)
+        {
+          end = max;
+        }
+        if (end > max)
+        {
+          end = max;
+        }
+      }
+
+      regions.addElement(new int[]
+      { start, end });
+
+      if (hasHiddenColumns)
+      {
+        start = colSel.adjustForHiddenColumns(end);
+        start = colSel.getHiddenBoundaryLeft(start) + 1;
+      }
+    } while (end < max);
+
+    int[][] startEnd = new int[regions.size()][2];
+
+    regions.copyInto(startEnd);
+
+    return startEnd;
+
+  }
+  /**
+   * @return the padGaps
+   */
+  public boolean isPadGaps()
+  {
+    return padGaps;
+  }
+  /**
+   * @param padGaps the padGaps to set
+   */
+  public void setPadGaps(boolean padGaps)
+  {
+    this.padGaps = padGaps;
+  }
+  /**
+   * apply any post-edit constraints and trigger any calculations needed after an edit has been performed on the alignment 
+   * @param ap
+   */
+  public void alignmentChanged(AlignmentViewPanel ap)
+  {
+    // TODO: test jvLite always pads, and that JVD has configurable padding.
+    if (isPadGaps())
+    {
+      alignment.padGaps();
+    }
+    if (autoCalculateConsensus)
+    {
+      updateConsensus(ap);
+    }
+    if (hconsensus != null && autoCalculateConsensus)
+    {
+      updateConservation(ap);
+    }
+    if (autoCalculateStrucConsensus)
+    {
+      updateStrucConsensus(ap);
+    }
+
+    // Reset endRes of groups if beyond alignment width
+    int alWidth = alignment.getWidth();
+    Vector groups = alignment.getGroups();
+    if (groups != null)
+    {
+      for (int i = 0; i < groups.size(); i++)
+      {
+        SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
+        if (sg.getEndRes() > alWidth)
+        {
+          sg.setEndRes(alWidth - 1);
+        }
+      }
+    }
+
+    if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
+    {
+      selectionGroup.setEndRes(alWidth - 1);
+    }
+
+    resetAllColourSchemes();
+
+    // alignment.adjustSequenceAnnotations();
+  }
+
+  
+  /**
+   * reset scope and do calculations for all applied colourschemes on alignment
+   */
+  void resetAllColourSchemes()
+  {
+    ColourSchemeI cs = globalColourScheme;
+    if (cs != null)
+    {
+      if (cs instanceof ClustalxColourScheme)
+      {
+        ((ClustalxColourScheme) cs).resetClustalX(alignment.getSequences(),
+                alignment.getWidth());
+      }
+
+      cs.setConsensus(hconsensus);
+      if (cs.conservationApplied())
+      {
+        cs.setConservation(Conservation.calculateConservation("All",
+                ResidueProperties.propHash, 3, alignment.getSequences(), 0,
+                alignment.getWidth(), false, getConsPercGaps(), false));
+      }
+    }
+
+    int s, sSize = alignment.getGroups().size();
+    for (s = 0; s < sSize; s++)
+    {
+      SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
+      if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
+      {
+        ((ClustalxColourScheme) sg.cs).resetClustalX(sg
+                .getSequences(hiddenRepSequences), sg.getWidth());
+      }
+      sg.recalcConservation();
+    }
+  }
+
+}