-/*\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
-import jalview.schemes.*;\r
-import java.awt.*;\r
-import java.util.*;\r
-\r
-public class FeatureRenderer\r
-{\r
- AlignViewport av;\r
-\r
- SequenceGroup currentSequenceGroup = null;\r
- SequenceGroup [] allGroups = null;\r
- Color resBoxColour;\r
- Graphics graphics;\r
-\r
- public FeatureRenderer(AlignViewport av)\r
- {\r
- 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
- {\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
- 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
-\r
- if(fstart==fend)\r
- {\r
- g.setColor(Color.red);\r
- g.fillRoundRect( (fstart - start) * width, y1, width, 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
- }\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
- continue;\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
-\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;
+
+/**
+ * A class that manages drawing of sequence features for the Swing gui
+ */
+public class FeatureRenderer
+ extends jalview.renderer.seqfeatures.FeatureRenderer
+{
+ 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);
+ }
+ }
+}