import jalview.analysis.*;\r
public class IdCanvas extends JPanel\r
{\r
- protected Image img;\r
- protected Graphics2D gg;\r
-\r
- protected int imgWidth;\r
- protected int imgHeight;\r
-\r
protected AlignViewport av;\r
\r
public boolean paintFlag = false;\r
PaintRefresher.Register(this);\r
}\r
\r
- public void drawIdString(Graphics g,SequenceI ds,int i, int starty, int ypos) {\r
+ public void drawIdString(Graphics gg,SequenceI ds,int i, int starty, int ypos) {\r
int charHeight = av.getCharHeight();\r
\r
if (av.getSelection().contains(ds)) {\r
\r
}\r
\r
- public void paintComponent(Graphics g) {\r
+ public void paintComponent(Graphics gg) {\r
AlignmentI da = av.getAlignment();\r
int charHeight = av.getCharHeight();\r
- Font f = av.getFont();\r
-\r
- if (img == null ||\r
- imgWidth != getWidth() ||\r
- imgHeight != getHeight() ||\r
- paintFlag == true) {\r
-\r
- imgWidth = getWidth();\r
- imgHeight = getHeight();\r
-\r
- if (imgWidth <= 0 ) {\r
- imgWidth = 700;\r
- }\r
- if (imgHeight <= 0 ) {\r
- imgHeight = 500;\r
- }\r
-\r
- img = createImage(imgWidth,imgHeight);\r
-\r
-\r
- gg = (Graphics2D)img.getGraphics();\r
- gg.setColor(Color.white);\r
- gg.fillRect(0,0,imgWidth,imgHeight);\r
-\r
- gg.setFont(f);\r
-\r
- paintFlag = false;\r
-\r
- }\r
-\r
+ gg.setFont(av.getFont());\r
\r
//Fill in the background\r
gg.setColor(Color.white);\r
- gg.fillRect(0,0,imgWidth,imgHeight);\r
+ gg.fillRect(0,0,getWidth(),getHeight());\r
\r
Color currentColor = Color.white;\r
Color currentTextColor = Color.black;\r
int starty = av.getStartSeq();\r
int endy = av.getEndSeq();\r
\r
-\r
-\r
if (av.getWrapAlignment())\r
{\r
starty = starty%av.getChunkHeight();\r
}\r
\r
}\r
- } else {\r
-\r
- //Now draw the id strings\r
- for (int i = starty; i < endy; i++)\r
+ } else\r
{\r
\r
- // Selected sequence colours\r
- if (av.getSelection().contains(da.getSequenceAt(i)))\r
+ //Now draw the id strings\r
+ for (int i = starty; i < endy; i++)\r
{\r
- currentColor = Color.gray;\r
+ // Selected sequence colours\r
+ if (av.getSelection().contains(da.getSequenceAt(i)))\r
+ {\r
+ currentColor = Color.gray;\r
currentTextColor = Color.black;\r
- }\r
- else\r
- {\r
- currentColor = da.getSequenceAt(i).getColor();\r
- currentTextColor = Color.black;\r
- }\r
-\r
- gg.setColor(currentColor);\r
-\r
+ }\r
+ else\r
+ {\r
+ currentColor = da.getSequenceAt(i).getColor();\r
+ currentTextColor = Color.black;\r
+ }\r
\r
+ gg.setColor(currentColor);\r
\r
- gg.fillRect(0,\r
- AlignmentUtil.getPixelHeight(starty,i,charHeight),\r
+ gg.fillRect(0,\r
+ AlignmentUtil.getPixelHeight(starty, i, charHeight),\r
getWidth(),\r
charHeight);\r
\r
- gg.setColor(currentTextColor);\r
-\r
- String string = da.getSequenceAt(i).getDisplayId();\r
-\r
- gg.drawString(string,0,AlignmentUtil.getPixelHeight(starty,i,charHeight) + charHeight- (charHeight/5));\r
- }\r
+ gg.setColor(currentTextColor);\r
+ String string = da.getSequenceAt(i).getDisplayId();\r
+ gg.drawString(string, 0,\r
+ AlignmentUtil.getPixelHeight(starty, i, charHeight) +\r
+ charHeight - (charHeight / 5));\r
+ }\r
}\r
\r
- g.drawImage(img,0,0,this);\r
}\r
\r
\r
\r
public class ScaleCanvas extends JPanel {\r
\r
- Image img;\r
- Graphics gg;\r
-\r
- int imgWidth;\r
- int imgHeight;\r
int xoffset;\r
\r
public static final int HEIGHT = 30;\r
}\r
\r
// scalewidth will normally be screenwidth,\r
- public void drawScale(Graphics g, int startx, int endx, int scaleWidth)\r
+ public void drawScale(Graphics gg, int startx, int endx, int scaleWidth)\r
{\r
\r
double charWidth = av.getCharWidth();\r
\r
- if (img == null ||\r
- imgWidth != scaleWidth ||\r
- imgHeight != getHeight() ||\r
- paintFlag == true) {\r
-\r
- imgWidth = scaleWidth;\r
- imgHeight = getHeight();\r
- img = createImage(imgWidth,imgHeight);\r
-\r
- gg = img.getGraphics();\r
- gg.setColor(Color.white);\r
- gg.fillRect(0,0,imgWidth,imgHeight);\r
-\r
-\r
-\r
- paintFlag = false;\r
- }\r
gg.setFont(av.getFont());\r
\r
//Fill in the background\r
\r
gg.setColor(Color.white);\r
- gg.fillRect(0,0,imgWidth,imgHeight);\r
+ gg.fillRect(0,0,scaleWidth, HEIGHT);\r
\r
int resWidth = endx - startx + 1;\r
\r
}\r
\r
\r
- g.drawImage(img,0,0,this);\r
-\r
}\r
\r
public Dimension getMinimumSize() {\r