SequenceGroup currentSequenceGroup = null;\r
SequenceGroup[] allGroups = null;\r
Graphics graphics;\r
- float transparency = .4f;\r
\r
// The following vector holds the features which are\r
// to be added, in the correct order or rendering\r
\r
Color currentColour = null;\r
\r
+ boolean drawText = true;\r
+ FontMetrics fm;\r
+ int charOffset;\r
+\r
/**\r
* Creates a new FeatureRenderer object.\r
*\r
{\r
this.av = av;\r
initColours();\r
- String version = System.getProperty("java.version");\r
- if (version.indexOf("1.1") == 0)\r
- highlightTransparent = false;\r
-\r
}\r
\r
- boolean highlightTransparent = true;\r
+ //boolean highlightTransparent = true;\r
/**\r
* DOCUMENT ME!\r
*\r
public void drawSequence(Graphics g, SequenceI seq,\r
int start, int end, int x1, int y1, int width, int height)\r
{\r
+ fm = g.getFontMetrics();\r
\r
if(seq.getSequenceFeatures()==null)\r
return;\r
else\r
e = seq.getSequenceFeatures().elements();\r
\r
- if(highlightTransparent)\r
- {\r
- // MyGraphics.SetTransparency(g, transparency);\r
- }\r
-\r
\r
while (e.hasMoreElements())\r
{\r
continue;\r
}\r
\r
- int fstart = seq.findIndex(sf.getBegin()) - 1;\r
- int fend = seq.findIndex(sf.getEnd()) - 1;\r
-\r
- if (((fstart <= end) && (fend >= start)))\r
+ if (type.equals("disulfide bond"))\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
- currentColour = getColour(type);\r
- g.setColor(currentColour);\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
- currentColour = getColour(type);\r
- g.setColor(currentColour);\r
-\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
+ 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
+\r
+ void renderFeature(Graphics g, SequenceI seq,\r
+ int fstart, int fend, String type, int start, int end,\r
+ int x1, int y1, int width, int height)\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
+ 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
- if (highlightTransparent)\r
+ currentColour = getColour(type);\r
+\r
+ g.setColor(currentColour);\r
+\r
+ g.fillRect( (i - start) * width, y1, width, height);\r
+\r
+ if (drawText)\r
{\r
- // MyGraphics.SetTransparency(g, 1.0f);\r
+ g.setColor(Color.white);\r
+ charOffset = (width - fm.charWidth(s)) / 2;\r
+ g.drawString(String.valueOf(s),\r
+ charOffset + x1 + (width * (i - start)),\r
+ (y1 + height) - height / 5);\r
}\r
+ }\r
+ }\r
}\r
\r
-\r
Image offscreen;\r
Frame nullframe;\r
public Color findFeatureColour(Color initialCol, SequenceI seq, int i)\r
featureColours.put(featureType, col);\r
}\r
\r
- public void setTransparency(float value)\r
+ /* public void setTransparency(float value)\r
{\r
transparency = value;\r
}\r
public float getTransparency()\r
{\r
return transparency;\r
- }\r
+ }*/\r
\r
public void setFeaturePriority(Object [][] data)\r
{\r
// The feature table will display high priority\r
// features at the top, but theses are the ones\r
// we need to render last, so invert the data\r
- featuresDisplayed = new Vector();\r
+ if(featuresDisplayed!=null)\r
+ featuresDisplayed.removeAllElements();\r
+ else\r
+ featuresDisplayed = new Vector();\r
+\r
for(int i=data.length-1; i>-1; i--)\r
{\r
String type = data[i][0].toString();\r
sr.graphics = nullFrame.getGraphics();\r
sr.renderGaps( false );\r
fr = new FeatureRenderer(av);\r
- fr.transparency = ap.seqPanel.seqCanvas.getFeatureRenderer().transparency;\r
- fr.featuresDisplayed = ap.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed;\r
+ fr.drawText = false;\r
+\r
\r
\r
// scale the initial size of overviewpanel to shape of alignment\r
return;\r
}\r
\r
+ if (av.showSequenceFeatures)\r
+ fr.featuresDisplayed = ap.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed;\r
+\r
+\r
resizing = true;\r
\r
if ( (getSize().width > 0) && (getSize().height > 0))\r
float sampleRow = (float) alheight / (float) sequencesHeight;\r
\r
int lastcol=-1, lastrow=-1;\r
- Color color = Color.white;\r
- for (int col = 0; col < width; col++)\r
+ Color color = Color.yellow;\r
+ int row, col;\r
+ for (col = 0; col < width; col++)\r
{\r
- for (int row = 0; row < sequencesHeight; row++)\r
+ for (row = 0; row < sequencesHeight; row++)\r
{\r
if((int)(col*sampleCol) == lastcol && (int)(row*sampleRow)==lastrow)\r
{\r
- mg.setColor(color);\r
- mg.fillRect(col,row,1,1);\r
+ mg.drawLine(col, row, col, row);\r
continue;\r
}\r
\r
+ if (av.conservation != null)\r
+ {\r
+ mg.translate(col, sequencesHeight);\r
+ ap.annotationPanel.drawGraph(mg, av.conservation,\r
+ (int) (sampleCol) + 1,\r
+ graphHeight,\r
+ (int) (col * sampleCol),\r
+ (int) (col * sampleCol) + 1);\r
+ mg.translate( -col, -sequencesHeight);\r
+ }\r
+\r
lastrow = (int)(row*sampleRow);\r
lastcol = (int)(col*sampleCol);\r
\r
{\r
color = sr.findSequenceColour(av.alignment.getSequenceAt(lastrow), lastcol);\r
\r
+\r
if (av.showSequenceFeatures)\r
color = fr.findFeatureColour(color,\r
- av.alignment.getSequenceAt(lastrow),\r
+ av.alignment.getSequenceAt(lastrow),\r
lastcol);\r
}\r
\r
-\r
mg.setColor(color);\r
- mg.fillRect(col,row,1,1);\r
+ mg.drawLine(col,row,col,row);\r
\r
- if (av.conservation != null)\r
- {\r
- mg.translate(col, sequencesHeight);\r
- ap.annotationPanel.drawGraph(mg, av.conservation,\r
- (int) (sampleCol) + 1,\r
- graphHeight,\r
- (int) (col * sampleCol),\r
- (int) (col * sampleCol) + 1);\r
- mg.translate(-col, -sequencesHeight);\r
- }\r
}\r
}\r
\r
+\r
System.gc();\r
\r
resizing = false;\r