Corrects incorrect calls to ViewportRanges.setEndSeq()
[jalview.git] / src / jalview / gui / FeatureRenderer.java
old mode 100755 (executable)
new mode 100644 (file)
index 8a94a89..0553fef
-/*\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
-\r
-import java.awt.*;\r
-\r
-import java.util.*;\r
-\r
-\r
-/**\r
- * DOCUMENT ME!\r
- *\r
- * @author $author$\r
- * @version $Revision$\r
- */\r
-public class FeatureRenderer\r
-{\r
-    AlignViewport av;\r
-    SequenceGroup currentSequenceGroup = null;\r
-    SequenceGroup[] allGroups = null;\r
-    Color resBoxColour;\r
-    Graphics graphics;\r
-\r
-    /**\r
-     * Creates a new FeatureRenderer object.\r
-     *\r
-     * @param av DOCUMENT ME!\r
-     */\r
-    public FeatureRenderer(AlignViewport av)\r
-    {\r
-        this.av = av;\r
-    }\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param g DOCUMENT ME!\r
-     * @param seq DOCUMENT ME!\r
-     * @param sg DOCUMENT ME!\r
-     * @param start DOCUMENT ME!\r
-     * @param end DOCUMENT ME!\r
-     * @param x1 DOCUMENT ME!\r
-     * @param y1 DOCUMENT ME!\r
-     * @param width DOCUMENT ME!\r
-     * @param height DOCUMENT ME!\r
-     */\r
-    public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg,\r
-        int start, int end, int x1, int y1, int width, int height)\r
-    {\r
-        Vector features = seq.getSequenceFeatures();\r
-        Enumeration e = features.elements();\r
-\r
-        while (e.hasMoreElements())\r
-        {\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
-\r
-            if (((fstart <= end) && (fend >= start)))\r
-            {\r
-                if (fstart < start)\r
-                { // fix for if the feature we have starts before the sequence start,\r
-                    fstart = start; // but the feature end is still valid!!\r
-                }\r
-\r
-                if (fend >= end)\r
-                {\r
-                    fend = end;\r
-                }\r
-\r
-                if (fstart == fend)\r
-                {\r
-                    g.setColor(Color.red);\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),\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
-\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
-\r
-                        g.setColor(Color.white);\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
-                }\r
-            }\r
-        }\r
-    }\r
-}\r
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ 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.
+ *  
+ * 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/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.gui;
+
+import java.awt.Color;
+
+/**
+ * DOCUMENT ME!
+ * 
+ * @author $author$
+ * @version $Revision$
+ */
+public class FeatureRenderer
+        extends jalview.renderer.seqfeatures.FeatureRenderer
+{
+  Color resBoxColour;
+
+  AlignmentPanel ap;
+
+  /**
+   * Creates a new FeatureRenderer object
+   * 
+   * @param alignPanel
+   */
+  public FeatureRenderer(AlignmentPanel alignPanel)
+  {
+    super(alignPanel.av);
+    this.ap = alignPanel;
+    if (alignPanel.getSeqPanel() != null
+            && alignPanel.getSeqPanel().seqCanvas != null
+            && alignPanel.getSeqPanel().seqCanvas.fr != null)
+    {
+      transferSettings(alignPanel.getSeqPanel().seqCanvas.fr);
+    }
+  }
+}