JAL-1553 fixed null pointer exception thrown in SeqCanvas and ScalePanel of jalview...
[jalview.git] / src / jalview / appletgui / SeqCanvas.java
index 34ef556..4b3cd1c 100755 (executable)
@@ -1,26 +1,35 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
  * Copyright (C) 2014 The Jalview Authors
  * 
  * 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.
+ * 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/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.appletgui;
 
-import java.awt.*;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SearchResults;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
 
-import jalview.datamodel.*;
+import java.awt.Color;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Panel;
 
 public class SeqCanvas extends Panel
 {
@@ -508,18 +517,27 @@ public class SeqCanvas extends Panel
   void drawPanel(Graphics g1, int startRes, int endRes, int startSeq,
           int endSeq, int offset)
   {
+
+
     if (!av.hasHiddenColumns())
     {
       draw(g1, startRes, endRes, startSeq, endSeq, offset);
     }
     else
     {
-      java.util.Vector regions = av.getColumnSelection().getHiddenColumns();
+
+
 
       int screenY = 0;
       int blockStart = startRes;
       int blockEnd = endRes;
 
+      if (av.getColumnSelection() != null
+              && av.getColumnSelection().getHiddenColumns() != null)
+      {
+        java.util.Vector regions = av.getColumnSelection()
+                .getHiddenColumns();
+
       for (int i = 0; i < regions.size(); i++)
       {
         int[] region = (int[]) regions.elementAt(i);
@@ -550,7 +568,7 @@ public class SeqCanvas extends Panel
         screenY += blockEnd - blockStart + 1;
         blockStart = hideEnd + 1;
       }
-
+      }
       if (screenY <= (endRes - startRes))
       {
         blockEnd = blockStart + (endRes - startRes) - screenY;
@@ -587,7 +605,7 @@ public class SeqCanvas extends Panel
       sr.drawSequence(nextSeq, av.getAlignment().findAllGroups(nextSeq),
               startRes, endRes, offset + ((i - startSeq) * av.charHeight));
 
-      if (av.showSequenceFeatures)
+      if (av.isShowSequenceFeatures())
       {
         fr.drawSequence(g, nextSeq, startRes, endRes, offset
                 + ((i - startSeq) * av.charHeight));
@@ -644,7 +662,7 @@ public class SeqCanvas extends Panel
 
     if ((group == null) && (av.getAlignment().getGroups().size() > 0))
     {
-      group = (SequenceGroup) av.getAlignment().getGroups().get(0);
+      group = av.getAlignment().getGroups().get(0);
       groupIndex = 0;
     }
 
@@ -801,7 +819,7 @@ public class SeqCanvas extends Panel
           break;
         }
 
-        group = (SequenceGroup) av.getAlignment().getGroups()
+        group = av.getAlignment().getGroups()
                 .get(groupIndex);
       } while (groupIndex < av.getAlignment().getGroups().size());