+ AlignViewport av;\r
+ Color resBoxColour;\r
+ float transparency = 1.0f;\r
+ FontMetrics fm;\r
+ int charOffset;\r
+\r
+ Hashtable featureColours = new Hashtable();\r
+\r
+\r
+ // A higher level for grouping features of a\r
+ // particular type\r
+ Hashtable featureGroups = null;\r
+\r
+ // This is actually an Integer held in the hashtable,\r
+ // Retrieved using the key feature type\r
+ Object currentColour;\r
+\r
+ String [] renderOrder;\r
+\r
+ boolean newFeatureAdded = false;\r
+\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
+ public void transferSettings(FeatureRenderer fr)\r
+ {\r
+ renderOrder = fr.renderOrder;\r
+ featureGroups = fr.featureGroups;\r
+ featureColours = fr.featureColours;\r
+ transparency = fr.transparency;\r
+ }\r
+\r
+ BufferedImage offscreenImage;\r
+ boolean offscreenRender = false;\r
+ public Color findFeatureColour(Color initialCol, SequenceI seq, int res)\r
+ {\r
+ int seqindex = av.alignment.findIndex(seq);\r
+\r
+ return new Color( findFeatureColour (initialCol.getRGB(),\r
+ seqindex, res ));\r
+ }\r
+\r
+ /**\r
+ * This is used by the Molecule Viewer to get the accurate colour\r
+ * of the rendered sequence\r
+ */\r
+ public int findFeatureColour(int initialCol, int seqIndex, int column)\r
+ {\r
+ if(!av.showSequenceFeatures)\r
+ return initialCol;\r
+\r
+ if(seqIndex!=lastSequenceIndex)\r
+ {\r
+ lastSequence = av.alignment.getSequenceAt(seqIndex);\r
+ lastSequenceIndex = seqIndex;\r
+ sequenceFeatures = lastSequence.getDatasetSequence().getSequenceFeatures();\r
+ if(sequenceFeatures==null)\r
+ return initialCol;\r
+\r
+ sfSize = sequenceFeatures.length;\r
+ }\r
+\r
+ if(jalview.util.Comparison.isGap(lastSequence.getCharAt(column)))\r
+ return Color.white.getRGB();\r
+\r
+\r
+ //Only bother making an offscreen image if transparency is applied\r
+ if(transparency!=1.0f && offscreenImage==null)\r
+ {\r
+ offscreenImage = new BufferedImage(1,1,BufferedImage.TYPE_INT_ARGB);\r
+ }\r
+\r
+ currentColour = null;\r
+\r
+ offscreenRender = true;\r
+\r
+ if(offscreenImage!=null)\r
+ {\r
+ offscreenImage.setRGB(0,0,initialCol);\r
+ drawSequence(offscreenImage.getGraphics(),\r
+ lastSequence,\r
+ column,column,0);\r
+\r
+ return offscreenImage.getRGB(0,0);\r
+ }\r
+ else\r
+ {\r
+ drawSequence(null,\r
+ lastSequence,\r
+ lastSequence.findPosition(column),\r
+ -1, -1);\r
+\r
+ if (currentColour == null)\r
+ return initialCol;\r
+ else\r
+ return ((Integer)currentColour).intValue();\r
+ }\r
+\r
+\r
+ }\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
+ // String type;\r
+ // SequenceFeature sf;\r
+ int lastSequenceIndex=-1;\r
+ SequenceI lastSequence;\r
+ SequenceFeature [] sequenceFeatures;\r
+ int sfSize, sfindex, spos, epos;\r
+\r
+ public void drawSequence(Graphics g, SequenceI seq,\r
+ int start, int end, int y1)\r