/*\r
* Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * Copyright (C) 2006 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
int imgHeight = 0;\r
boolean fastPaint = false;\r
java.util.Vector searchResults;\r
+ FontMetrics fm;\r
+ AnnotationLabels labels = null;\r
+ AnnotationPanel ap;\r
+ Font idfont;\r
\r
/**\r
* Creates a new IdCanvas object.\r
{\r
setLayout(new BorderLayout());\r
this.av = av;\r
- PaintRefresher.Register(this, av.alignment);\r
+ PaintRefresher.Register(this, av.getSequenceSetId());\r
}\r
\r
/**\r
*/\r
public void drawIdString(Graphics2D gg, SequenceI s, int i, int starty, int ypos)\r
{\r
+ int xPos = 0;\r
+ int panelWidth = getWidth();\r
int charHeight = av.charHeight;\r
\r
if ((searchResults != null) && searchResults.contains(s))\r
gg.setColor(Color.white);\r
}\r
else if ((av.getSelectionGroup() != null) &&\r
- av.getSelectionGroup().getSequences(false).contains(s))\r
+ av.getSelectionGroup().getSequences(null).contains(s))\r
{\r
gg.setColor(Color.lightGray);\r
gg.fillRect(0, ((i - starty) * charHeight) + ypos, getWidth(),\r
}\r
else\r
{\r
- gg.setColor(s.getColor());\r
+ gg.setColor(av.getSequenceColour(s));\r
gg.fillRect(0, ((i - starty) * charHeight) + ypos, getWidth(),\r
charHeight);\r
gg.setColor(Color.black);\r
}\r
\r
+ if (av.rightAlignIds)\r
+ {\r
+ xPos = panelWidth - fm.stringWidth(\r
+ s.getDisplayId(av.getShowJVSuffix())\r
+ ) - 4;\r
+ }\r
\r
gg.drawString( s.getDisplayId(av.getShowJVSuffix()),\r
- 0, (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5));\r
+ xPos, (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5));\r
\r
if (av.hasHiddenRows && av.showHiddenMarkers)\r
drawMarker(i, starty, ypos);\r
}\r
\r
gg = (Graphics2D) image.getGraphics();\r
+\r
//Fill in the background\r
gg.setColor(Color.white);\r
gg.fillRect(0, 0, getWidth(), imgHeight);\r
*/\r
void drawIds(int starty, int endy)\r
{\r
- Font italic = new Font(av.getFont().getName(), Font.ITALIC,\r
+ if(av.seqNameItalics)\r
+ idfont = new Font(av.getFont().getName(), Font.ITALIC,\r
av.getFont().getSize());\r
+ else\r
+ idfont = av.getFont();\r
\r
- gg.setFont(italic);\r
+ gg.setFont(idfont);\r
+ fm = gg.getFontMetrics();\r
\r
if (av.antiAlias)\r
gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\r
maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;\r
\r
int annotationHeight = 0;\r
- AnnotationLabels labels = null;\r
+\r
\r
if(av.showAnnotation)\r
{\r
- AnnotationPanel ap = new AnnotationPanel(av);\r
+ if (ap == null)\r
+ ap = new AnnotationPanel(av);\r
+\r
annotationHeight = ap.adjustPanelHeight();\r
- labels = new AnnotationLabels(av);\r
+ if (labels == null)\r
+ labels = new AnnotationLabels(av);\r
}\r
\r
int hgap = av.charHeight;\r
{\r
for (int i = starty; i < alheight; i++)\r
{\r
+ SequenceI s = av.alignment.getSequenceAt(i);\r
if (av.hasHiddenRows)\r
{\r
- setHiddenFont(i);\r
+ setHiddenFont(s);\r
}\r
else\r
- gg.setFont(italic);\r
+ gg.setFont(idfont);\r
\r
- SequenceI s = av.alignment.getSequenceAt(i);\r
drawIdString(gg, s, i, 0, ypos);\r
}\r
\r
- if(labels!=null)\r
+ if(labels!=null && av.showAnnotation)\r
{\r
gg.translate(0, ypos+(alheight * av.charHeight));\r
labels.drawComponent(gg, getWidth());\r
gg.translate(0, -ypos-(alheight * av.charHeight));\r
}\r
-\r
-\r
}\r
}\r
else\r
{\r
+ //No need to hang on to labels if we're not wrapped\r
+ labels = null;\r
+\r
//Now draw the id strings\r
+ int panelWidth = getWidth();\r
+ int xPos = 0;\r
\r
+ SequenceI sequence;\r
//Now draw the id strings\r
for (int i = starty; i < endy; i++)\r
{\r
+ sequence = av.alignment.getSequenceAt(i);\r
+\r
+ if(sequence==null)\r
+ continue;\r
+\r
if (av.hasHiddenRows)\r
{\r
- setHiddenFont(i);\r
+ setHiddenFont(sequence);\r
}\r
\r
// Selected sequence colours\r
if ( (searchResults != null) &&\r
- searchResults.contains(av.alignment.getSequenceAt(i)))\r
+ searchResults.contains(sequence))\r
{\r
currentColor = Color.black;\r
currentTextColor = Color.white;\r
}\r
else if ( (av.getSelectionGroup() != null) &&\r
- av.getSelectionGroup().getSequences(false).contains(\r
- av.alignment.getSequenceAt(i)))\r
+ av.getSelectionGroup().getSequences(null).contains(\r
+ sequence))\r
{\r
currentColor = Color.lightGray;\r
currentTextColor = Color.black;\r
}\r
else\r
{\r
- currentColor = av.alignment.getSequenceAt(i).getColor();\r
+ currentColor = av.getSequenceColour(sequence);\r
currentTextColor = Color.black;\r
}\r
\r
\r
gg.setColor(currentTextColor);\r
\r
- String string = av.alignment.getSequenceAt(i).getDisplayId( av.getShowJVSuffix());\r
+ String string = sequence.getDisplayId( av.getShowJVSuffix());\r
\r
- gg.drawString(string, 0,\r
+\r
+ if(av.rightAlignIds)\r
+ {\r
+ xPos = panelWidth - fm.stringWidth(string) - 4;\r
+ }\r
+\r
+ gg.drawString(string, xPos,\r
(((i - starty) * av.charHeight) + av.charHeight) -\r
(av.charHeight / 5));\r
\r
\r
void drawMarker(int i, int starty, int yoffset)\r
{\r
- int hiddenIndex = av.adjustForHiddenSeqs(i);\r
- int lastIndex = av.adjustForHiddenSeqs(i - 1);\r
- int nextIndex = av.adjustForHiddenSeqs(i + 1);\r
+\r
+ SequenceI [] hseqs = av.alignment.getHiddenSequences().hiddenSequences;\r
+ //Use this method here instead of calling hiddenSeq adjust\r
+ //3 times.\r
+ int hSize = hseqs.length;\r
+\r
+ int hiddenIndex = i;\r
+ int lastIndex = i - 1;\r
+ int nextIndex = i + 1;\r
+\r
+ for(int j=0; j<hSize; j++)\r
+ {\r
+ if (hseqs[j] != null)\r
+ {\r
+ if(j-1<hiddenIndex)\r
+ hiddenIndex++;\r
+ if(j-1<lastIndex)\r
+ lastIndex++;\r
+ if(j-1<nextIndex)\r
+ nextIndex++;\r
+ }\r
+ }\r
\r
boolean below = (hiddenIndex > lastIndex + 1);\r
- boolean above = (nextIndex>hiddenIndex+1);\r
+ boolean above = (nextIndex > hiddenIndex+1);\r
+\r
\r
gg.setColor(Color.blue);\r
if(below)\r
}\r
}\r
\r
- void setHiddenFont(int i)\r
+ void setHiddenFont(SequenceI seq)\r
{\r
- Font italic = new Font(av.getFont().getName(), Font.ITALIC,\r
- av.getFont().getSize());\r
Font bold = new Font(av.getFont().getName(), Font.BOLD,\r
av.getFont().getSize());\r
\r
- if (av.alignment.getSequenceAt(i).getHiddenSequences() != null)\r
+\r
+ if (av.hiddenRepSequences!=null &&\r
+ av.hiddenRepSequences.containsKey(seq))\r
gg.setFont(bold);\r
else\r
- gg.setFont(italic);\r
+ gg.setFont(idfont);\r
}\r
\r
/**\r