JAL-2388 Renamed viewport position props to viewport ranges
[jalview.git] / src / jalview / gui / AlignViewport.java
index 39217e5..11321eb 100644 (file)
@@ -41,14 +41,17 @@ import jalview.datamodel.SearchResultsI;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
+import jalview.renderer.ResidueShader;
+import jalview.schemes.ColourSchemeI;
 import jalview.schemes.ColourSchemeProperty;
+import jalview.schemes.ResidueColourScheme;
 import jalview.schemes.UserColourScheme;
-import jalview.structure.CommandListener;
 import jalview.structure.SelectionSource;
 import jalview.structure.StructureSelectionManager;
 import jalview.structure.VamsasSource;
 import jalview.util.MessageManager;
 import jalview.viewmodel.AlignmentViewport;
+import jalview.viewmodel.ViewportRanges;
 import jalview.ws.params.AutoCalcSetting;
 
 import java.awt.Container;
@@ -61,7 +64,6 @@ import java.util.List;
 import java.util.Vector;
 
 import javax.swing.JInternalFrame;
-import javax.swing.JOptionPane;
 
 /**
  * DOCUMENT ME!
@@ -70,7 +72,7 @@ import javax.swing.JOptionPane;
  * @version $Revision: 1.141 $
  */
 public class AlignViewport extends AlignmentViewport implements
-        SelectionSource, CommandListener
+        SelectionSource
 {
   Font font;
 
@@ -236,10 +238,7 @@ public class AlignViewport extends AlignmentViewport implements
 
   void init()
   {
-    this.startRes = 0;
-    this.endRes = alignment.getWidth() - 1;
-    this.startSeq = 0;
-    this.endSeq = alignment.getHeight() - 1;
+    ranges = new ViewportRanges(this.alignment);
     applyViewProperties();
 
     String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
@@ -284,28 +283,27 @@ public class AlignViewport extends AlignmentViewport implements
     initAutoAnnotation();
     String colourProperty = alignment.isNucleotide() ? Preferences.DEFAULT_COLOUR_NUC
             : Preferences.DEFAULT_COLOUR_PROT;
-    String propertyValue = Cache.getProperty(colourProperty);
-    if (propertyValue == null)
+    String schemeName = Cache.getProperty(colourProperty);
+    if (schemeName == null)
     {
-      // fall back on this property for backwards compatibility
-      propertyValue = Cache.getProperty(Preferences.DEFAULT_COLOUR);
+      // only DEFAULT_COLOUR available in Jalview before 2.9
+      schemeName = Cache.getDefault(Preferences.DEFAULT_COLOUR,
+              ResidueColourScheme.NONE);
     }
-    if (propertyValue != null)
-    {
-      globalColourScheme = ColourSchemeProperty.getColour(alignment,
-              propertyValue);
+    ColourSchemeI colourScheme = ColourSchemeProperty.getColourScheme(
+            alignment, schemeName);
+    residueShading = new ResidueShader(colourScheme);
 
-      if (globalColourScheme instanceof UserColourScheme)
-      {
-        globalColourScheme = UserDefinedColours.loadDefaultColours();
-        ((UserColourScheme) globalColourScheme).setThreshold(0,
-                isIgnoreGapsConsensus());
-      }
+    if (colourScheme instanceof UserColourScheme)
+    {
+      residueShading = new ResidueShader(
+              UserDefinedColours.loadDefaultColours());
+      residueShading.setThreshold(0, isIgnoreGapsConsensus());
+    }
 
-      if (globalColourScheme != null)
-      {
-        globalColourScheme.setConsensus(hconsensus);
-      }
+    if (residueShading != null)
+    {
+      residueShading.setConsensus(hconsensus);
     }
   }
 
@@ -383,7 +381,6 @@ public class AlignViewport extends AlignmentViewport implements
     super.setViewStyle(settingsForView);
     setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
             viewStyle.getFontSize()), false);
-
   }
 
   /**
@@ -918,7 +915,7 @@ public class AlignViewport extends AlignmentViewport implements
 
     // TODO if we want this (e.g. to enable reload of the alignment from file),
     // we will need to add parameters to the stack.
-    // if (!protocol.equals(AppletFormatAdapter.PASTE))
+    // if (!protocol.equals(DataSourceType.PASTE))
     // {
     // alignFrame.setFileName(file, format);
     // }