GPL license added
[jalview.git] / src / jalview / gui / FeatureRenderer.java
index d21b39e..1dd434d 100755 (executable)
@@ -1,3 +1,22 @@
+/*\r
+* Jalview - A Sequence Alignment Editor and Viewer\r
+* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+*\r
+* This program is free software; you can redistribute it and/or\r
+* modify it under the terms of the GNU General Public License\r
+* as published by the Free Software Foundation; either version 2\r
+* of the License, or (at your option) any later version.\r
+*\r
+* This program is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+* GNU General Public License for more details.\r
+*\r
+* You should have received a copy of the GNU General Public License\r
+* along with this program; if not, write to the Free Software\r
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
+*/\r
+\r
 package jalview.gui;\r
 \r
 import jalview.datamodel.*;\r
@@ -5,7 +24,7 @@ import jalview.schemes.*;
 import java.awt.*;\r
 import java.util.*;\r
 \r
-public class FeatureRenderer implements RendererI\r
+public class FeatureRenderer\r
 {\r
   AlignViewport av;\r
 \r
@@ -20,13 +39,16 @@ public class FeatureRenderer implements RendererI
   }\r
 \r
 \r
-  public void drawSequence(Graphics g,SequenceI seq,SequenceGroup [] sg, int start, int end, int x1, int y1, int width, int height, Vector pid, int seqnum)\r
+  public void drawSequence(Graphics g,SequenceI seq,SequenceGroup [] sg, int start, int end, int x1, int y1, int width, int height)\r
   {\r
     Vector features = seq.getSequenceFeatures();\r
     Enumeration e = features.elements();\r
     while( e.hasMoreElements() )\r
     {\r
       SequenceFeature sf = (SequenceFeature)e.nextElement();\r
+      if(sf.getStart()>seq.getEnd())\r
+        continue;\r
+\r
       int fstart = seq.findIndex(sf.getStart())-1;\r
       int fend = seq.findIndex(sf.getEnd())-1;\r
 \r
@@ -52,20 +74,21 @@ public class FeatureRenderer implements RendererI
         {\r
           for (int i = fstart; i <= fend; i++)\r
           {\r
-           try{\r
-             g.setColor(Color.blue);\r
+            char s = seq.getSequence().charAt(i);\r
+            if( jalview.util.Comparison.isGap(s) )\r
+              continue;\r
+\r
+            g.setColor(Color.blue);\r
             g.fillRect( (i-start) * width, y1, width, height);\r
 \r
             g.setColor(Color.white);\r
-            char s = seq.getSequence().charAt(i);\r
+\r
             FontMetrics fm = g.getFontMetrics();\r
             int charOffset = (width - fm.charWidth(s)) / 2;\r
             int pady = height / 5;\r
             g.drawString(String.valueOf(s),\r
                          charOffset + x1 + width * (i-start),\r
                          y1 + height - pady);\r
-\r
-           }catch(Exception ex){System.out.println(i+" "+fstart+" "+fend+" " +sf.getDescription()+" "+seq.getName()+" "+seq.getLength()); }\r
           }\r
         }\r
       }\r