bugfix to avoid null pointer exceptions being raised for groups with no colourscheme...
[jalview.git] / src / jalview / appletgui / AnnotationPanel.java
index d4055a5..ec5fbd8 100755 (executable)
@@ -42,14 +42,13 @@ public class AnnotationPanel
   static String COLOUR = "Colour";
   static Color HELIX_COLOUR = Color.red.darker();
   static Color SHEET_COLOUR = Color.green.darker().darker();
-
+  
   Image image;
   Graphics gg;
   FontMetrics fm;
   int imgWidth = 0;
 
   boolean fastPaint = false;
-
   public static int GRAPH_HEIGHT = 40;
 
   boolean MAC = false;
@@ -57,7 +56,6 @@ public class AnnotationPanel
   public AnnotationPanel(AlignmentPanel ap)
   {
     MAC = new jalview.util.Platform().isAMac();
-    
     this.ap = ap;
     av = ap.av;
     setLayout(null);
@@ -648,10 +646,13 @@ public class AnnotationPanel
         if (av.validCharWidth && validRes &&
             (row.annotations[column].displayCharacter!=null && row.annotations[column].displayCharacter.length() > 0))
         {
-          int charOffset = (av.charWidth -
-                            fm.charWidth(row.annotations[column].
-                                         displayCharacter.charAt(
-                                             0))) / 2;
+          int charOffset = (av.getCentreColumnLabels()) ? ((av.charWidth -
+                  fm.charsWidth(row.annotations[column].
+                               displayCharacter.toCharArray(),0,
+                               row.annotations[column].
+                               displayCharacter.length())) / 2)
+                               : (av.charWidth - fm.charWidth(row.annotations[column].
+                                       displayCharacter.charAt(0))) / 2;
 
           if (row.annotations[column].colour == null)
             g.setColor(Color.black);