Formatted source
[jalview.git] / src / jalview / gui / FeatureRenderer.java
index 1dd434d..e80d01a 100755 (executable)
@@ -1,35 +1,34 @@
 /*\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
+ * 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
 package jalview.gui;\r
 \r
-import jalview.datamodel.*;\r
-import jalview.schemes.*;\r
-import java.awt.*;\r
 import java.util.*;\r
 \r
+import java.awt.*;\r
+\r
+import jalview.datamodel.*;\r
+\r
 public class FeatureRenderer\r
 {\r
   AlignViewport av;\r
-\r
   SequenceGroup currentSequenceGroup = null;\r
-  SequenceGroup [] allGroups = null;\r
+  SequenceGroup[] allGroups = null;\r
   Color resBoxColour;\r
   Graphics graphics;\r
 \r
@@ -38,48 +37,60 @@ public class FeatureRenderer
     this.av = av;\r
   }\r
 \r
-\r
-  public void drawSequence(Graphics g,SequenceI seq,SequenceGroup [] sg, int start, int end, int x1, int y1, int width, int height)\r
+  public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg,\r
+                           int start, int end, int x1, int y1, int width,\r
+                           int height)\r
   {\r
     Vector features = seq.getSequenceFeatures();\r
     Enumeration e = features.elements();\r
-    while( e.hasMoreElements() )\r
+\r
+    while (e.hasMoreElements())\r
     {\r
-      SequenceFeature sf = (SequenceFeature)e.nextElement();\r
-      if(sf.getStart()>seq.getEnd())\r
+      SequenceFeature sf = (SequenceFeature) e.nextElement();\r
+\r
+      if (sf.getStart() > seq.getEnd())\r
+      {\r
         continue;\r
+      }\r
 \r
-      int fstart = seq.findIndex(sf.getStart())-1;\r
-      int fend = seq.findIndex(sf.getEnd())-1;\r
+      int fstart = seq.findIndex(sf.getStart()) - 1;\r
+      int fend = seq.findIndex(sf.getEnd()) - 1;\r
 \r
-      if(   (fstart<=end && fend>=start)  )\r
+      if ( ( (fstart <= end) && (fend >= start)))\r
       {\r
-        if(fstart<0) // fix for if the feature we have starts before the sequence start,\r
-          fstart = 0;// but the feature end is still valid!!\r
+        if (fstart < 0)\r
+        { // fix for if the feature we have starts before the sequence start,\r
+          fstart = 0; // but the feature end is still valid!!\r
+        }\r
 \r
-        if(fstart==fend)\r
+        if (fstart == fend)\r
         {\r
           g.setColor(Color.red);\r
-          g.fillRoundRect( (fstart - start) * width, y1, width, height, 4,4);\r
+          g.fillRoundRect( (fstart - start) * width, y1, width,\r
+                          height, 4, 4);\r
           g.setColor(Color.white);\r
 \r
           char s = seq.getSequence().charAt(fstart);\r
           FontMetrics fm = g.getFontMetrics();\r
-          int charOffset =  (width - fm.charWidth(s))/2;\r
-          int pady = height/5;\r
-          g.drawString(String.valueOf(s), charOffset + x1 + width * (fstart - start), y1 + height - pady);\r
-\r
+          int charOffset = (width - fm.charWidth(s)) / 2;\r
+          int pady = height / 5;\r
+          g.drawString(String.valueOf(s),\r
+                       charOffset + x1 + (width * (fstart - start)),\r
+                       (y1 + height) - pady);\r
         }\r
         else\r
         {\r
           for (int i = fstart; i <= fend; i++)\r
           {\r
             char s = seq.getSequence().charAt(i);\r
-            if( jalview.util.Comparison.isGap(s) )\r
+\r
+            if (jalview.util.Comparison.isGap(s))\r
+            {\r
               continue;\r
+            }\r
 \r
             g.setColor(Color.blue);\r
-            g.fillRect( (i-start) * width, y1, width, height);\r
+            g.fillRect( (i - start) * width, y1, width, height);\r
 \r
             g.setColor(Color.white);\r
 \r
@@ -87,13 +98,11 @@ public class FeatureRenderer
             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
+                         charOffset + x1 + (width * (i - start)),\r
+                         (y1 + height) - pady);\r
           }\r
         }\r
       }\r
-\r
     }\r
-   }\r
-\r
+  }\r
 }\r