Color resBoxColour;\r
Graphics graphics;\r
float transparency = 1.0f;\r
+ FontMetrics fm;\r
+ int charOffset;\r
\r
// The following vector holds the features which are\r
// to be added, in the correct order or rendering\r
if (seq.getDatasetSequence().getSequenceFeatures() == null)\r
return;\r
\r
+ fm = g.getFontMetrics();\r
+\r
if (transparency != 1)\r
{\r
Graphics2D g2 = (Graphics2D) g;\r
AlphaComposite.SRC_OVER, transparency));\r
}\r
\r
- Enumeration e, e2;\r
String type;\r
SequenceFeature sf;\r
- if (featuresDisplayed != null)\r
- {\r
- e = featuresDisplayed.elements();\r
- while(e.hasMoreElements())\r
- {\r
- type = e.nextElement().toString();\r
- e2 = seq.getDatasetSequence().getSequenceFeatures().elements();\r
- while(e2.hasMoreElements())\r
- {\r
- sf = (SequenceFeature) e2.nextElement();\r
- if(!type.equals(sf.getType() ) )\r
- continue;\r
-\r
- if (sf.getBegin() > seq.getEnd())\r
- continue;\r
-\r
- renderFeature(g,seq,\r
- seq.findIndex(sf.getBegin()) - 1,\r
- seq.findIndex(sf.getEnd()) - 1,\r
- type,start,end,x1,y1,width,height);\r
- }\r
- }\r
- }\r
- else\r
+ if (featuresDisplayed == null || featuresDisplayed.size()==0)\r
+ findAllFeatures();\r
+\r
+ Enumeration e = featuresDisplayed.elements(), e2;\r
+\r
+ // Loop through each visible feature\r
+ while (e.hasMoreElements())\r
{\r
- e = seq.getDatasetSequence().getSequenceFeatures().elements();\r
- while (e.hasMoreElements())\r
+\r
+ type = e.nextElement().toString();\r
+ e2 = seq.getDatasetSequence().getSequenceFeatures().elements();\r
+ // loop through all features in sequence to find\r
+ // current feature to render\r
+ while (e2.hasMoreElements())\r
{\r
- sf = (SequenceFeature) e.nextElement();\r
- type = sf.getType();\r
+\r
+ sf = (SequenceFeature) e2.nextElement();\r
+ if (!type.equals(sf.getType()))\r
+ continue;\r
\r
if (sf.getBegin() > seq.getEnd())\r
- {\r
continue;\r
- }\r
\r
- renderFeature(g,seq,\r
- seq.findIndex(sf.getBegin()) - 1,\r
- seq.findIndex(sf.getEnd()) - 1,\r
- type,start,end,x1,y1,width,height);\r
+ if (type.equals("disulfide bond"))\r
+ {\r
+\r
+ renderFeature(g, seq,\r
+ seq.findIndex(sf.getBegin()) - 1,\r
+ seq.findIndex(sf.getBegin()) - 1,\r
+ type, start, end, x1, y1, width, height);\r
+ renderFeature(g, seq,\r
+ seq.findIndex(sf.getEnd()) - 1,\r
+ seq.findIndex(sf.getEnd()) - 1,\r
+ type, start, end, x1, y1, width, height);\r
\r
+ }\r
+ else\r
+ renderFeature(g, seq,\r
+ seq.findIndex(sf.getBegin()) - 1,\r
+ seq.findIndex(sf.getEnd()) - 1,\r
+ type, start, end, x1, y1, width, height);\r
}\r
}\r
\r
- /* while (e.hasMoreElements())\r
- {\r
- SequenceFeature sf=null;\r
- if(featuresDisplayed!=null)\r
- {\r
- e2 = seq.getDatasetSequence().getSequenceFeatures().elements();\r
- type = e.nextElement().toString();\r
- while(e2.hasMoreElements())\r
- {\r
- sf = (SequenceFeature) e2.nextElement();\r
- if(sf.getType().equals(type))\r
- break;\r
- else\r
- sf = null;\r
- }\r
- }\r
- else\r
- {\r
- sf = (SequenceFeature) e.nextElement();\r
- type = sf.getType();\r
- }\r
-\r
- if(sf==null)\r
- continue;\r
-\r
-\r
- if (sf.getBegin() > seq.getEnd())\r
- {\r
- continue;\r
- }\r
-\r
- int fstart = seq.findIndex(sf.getBegin()) - 1;\r
- int fend = seq.findIndex(sf.getEnd()) - 1;\r
-*/\r
-\r
if(transparency!=1.0f)\r
{\r
Graphics2D g2 = (Graphics2D) g;\r
}\r
}\r
\r
+\r
void renderFeature(Graphics g, SequenceI seq,\r
int fstart, int fend, String type, int start, int end, int x1, int y1, int width, int height)\r
{\r
+\r
if (((fstart <= end) && (fend >= start)))\r
{\r
if (fstart < start)\r
\r
if (fend >= end)\r
{\r
- fend = end;\r
+ fend = end;\r
}\r
-\r
- if (fstart == fend)\r
+ for (int i = fstart; i <= fend; i++)\r
{\r
- g.setColor(getColour(type));\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
+ char s = seq.getSequence().charAt(i);\r
+\r
+ if (jalview.util.Comparison.isGap(s))\r
+ {\r
+ continue;\r
+ }\r
+\r
+ g.setColor(getColour(type));\r
+\r
+ g.fillRect( (i - start) * width, y1, width, height);\r
+\r
+ g.setColor(Color.white);\r
+\r
+ charOffset = (width - fm.charWidth(s)) / 2;\r
+ g.drawString(String.valueOf(s),\r
+ charOffset + x1 + (width * (i - start)),\r
+ (y1 + height) - height/5);//pady = height / 5;\r
}\r
- else\r
+ }\r
+ }\r
+\r
+ void findAllFeatures()\r
+ {\r
+ Vector features = new Vector();\r
+ SequenceFeature sf;\r
+ featuresDisplayed = new Vector();\r
+ Enumeration e;\r
+ for (int i = 0; i < av.alignment.getHeight(); i++)\r
+ {\r
+ features = av.alignment.getSequenceAt(i).getDatasetSequence().\r
+ getSequenceFeatures();\r
+ if (features == null)\r
+ continue;\r
+\r
+ e = features.elements();\r
+ while (e.hasMoreElements())\r
+ {\r
+ sf = (SequenceFeature) e.nextElement();\r
+ if (!featuresDisplayed.contains(sf.getType()))\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(getColour(type));\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
+ featuresDisplayed.addElement(sf.getType());\r
}\r
+ }\r
}\r
}\r
\r
featureColours.put("coiled-coil region", new Color(215, 115, 0));\r
featureColours.put("compositionally biased region", new Color(205, 125, 0));\r
featureColours.put("cross-link", new Color(195, 135, 0));\r
- featureColours.put("disulfide bond", new Color(185, 145, 0));\r
+ featureColours.put("disulfide bond", new Color(230,230,0));\r
featureColours.put("DNA-binding region", new Color(175, 155, 0));\r
featureColours.put("domain", new Color(165, 165, 0));\r
featureColours.put("glycosylation site", new Color(155, 175, 0));\r
featureColours.put("mutagenesis site", new Color(95, 235, 45));\r
featureColours.put("non-consecutive residues", new Color(85, 245, 55));\r
featureColours.put("non-terminal residue", new Color(75, 255, 65));\r
- featureColours.put("nucleotide phosphate-binding region",\r
- new Color(65, 245, 75));\r
+ featureColours.put("nucleotide phosphate-binding region",new Color(65, 245, 75));\r
featureColours.put("peptide", new Color(55, 235, 85));\r
featureColours.put("propeptide", new Color(45, 225, 95));\r
featureColours.put("region of interest", new Color(35, 215, 105));\r