Tidy up group size after alignmentChanged
[jalview.git] / src / jalview / gui / IdCanvas.java
index 571cf52..32cbfb5 100755 (executable)
@@ -53,7 +53,7 @@ public class IdCanvas extends JPanel
     {\r
         setLayout(new BorderLayout());\r
         this.av = av;\r
-        PaintRefresher.Register(this, av.alignment);\r
+        PaintRefresher.Register(this, av.getSequenceSetId());\r
     }\r
 \r
     /**\r
@@ -280,9 +280,15 @@ public class IdCanvas extends JPanel
         {\r
           //Now draw the id strings\r
 \r
+            SequenceI sequence;\r
             //Now draw the id strings\r
             for (int i = starty; i < endy; i++)\r
             {\r
+              sequence = av.alignment.getSequenceAt(i);\r
+\r
+              if(sequence==null)\r
+                continue;\r
+\r
               if (av.hasHiddenRows)\r
               {\r
                 setHiddenFont(i);\r
@@ -290,21 +296,21 @@ public class IdCanvas extends JPanel
 \r
                 // Selected sequence colours\r
                 if ( (searchResults != null) &&\r
-                    searchResults.contains(av.alignment.getSequenceAt(i)))\r
+                    searchResults.contains(sequence))\r
                 {\r
                   currentColor = Color.black;\r
                   currentTextColor = Color.white;\r
                 }\r
                 else if ( (av.getSelectionGroup() != null) &&\r
                          av.getSelectionGroup().getSequences(false).contains(\r
-                             av.alignment.getSequenceAt(i)))\r
+                             sequence))\r
                 {\r
                   currentColor = Color.lightGray;\r
                   currentTextColor = Color.black;\r
                 }\r
                 else\r
                 {\r
-                  currentColor = av.alignment.getSequenceAt(i).getColor();\r
+                  currentColor = sequence.getColor();\r
                   currentTextColor = Color.black;\r
                 }\r
 \r
@@ -315,7 +321,7 @@ public class IdCanvas extends JPanel
 \r
                 gg.setColor(currentTextColor);\r
 \r
-                String string = av.alignment.getSequenceAt(i).getDisplayId( av.getShowJVSuffix());\r
+                String string = sequence.getDisplayId( av.getShowJVSuffix());\r
 \r
                 gg.drawString(string, 0,\r
                     (((i - starty) * av.charHeight) + av.charHeight) -\r
@@ -331,12 +337,32 @@ public class IdCanvas extends JPanel
 \r
     void drawMarker(int i, int starty, int yoffset)\r
     {\r
-      int hiddenIndex = av.adjustForHiddenSeqs(i);\r
-      int lastIndex = av.adjustForHiddenSeqs(i - 1);\r
-      int nextIndex = av.adjustForHiddenSeqs(i + 1);\r
+\r
+      SequenceI [] hseqs = av.alignment.getHiddenSequences().hiddenSequences;\r
+      //Use this method here instead of calling hiddenSeq adjust\r
+      //3 times.\r
+      int hSize = hseqs.length;\r
+\r
+      int hiddenIndex = i;\r
+      int lastIndex = i - 1;\r
+      int nextIndex = i + 1;\r
+\r
+      for(int j=0; j<hSize; j++)\r
+      {\r
+        if (hseqs[j] != null)\r
+        {\r
+          if(j-1<hiddenIndex)\r
+            hiddenIndex++;\r
+          if(j-1<lastIndex)\r
+            lastIndex++;\r
+          if(j-1<nextIndex)\r
+            nextIndex++;\r
+        }\r
+      }\r
 \r
       boolean below = (hiddenIndex > lastIndex + 1);\r
-      boolean above = (nextIndex>hiddenIndex+1);\r
+      boolean above = (nextIndex > hiddenIndex+1);\r
+\r
 \r
         gg.setColor(Color.blue);\r
         if(below)\r
@@ -375,7 +401,9 @@ public class IdCanvas extends JPanel
       Font bold = new Font(av.getFont().getName(), Font.BOLD,\r
                            av.getFont().getSize());\r
 \r
-      if (av.alignment.getSequenceAt(i).getHiddenSequences() != null)\r
+\r
+      if (av.alignment.getSequenceAt(i)!=null\r
+          && av.alignment.getSequenceAt(i).getHiddenSequences() != null)\r
         gg.setFont(bold);\r
       else\r
         gg.setFont(italic);\r