From: amwaterhouse Date: Fri, 19 Nov 2004 17:22:47 +0000 (+0000) Subject: doesn't create an image for drawing, important for printing X-Git-Tag: Release_2_0~903 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=51605ff0b3c81ba5894348745596b5038d905ffb;p=jalview.git doesn't create an image for drawing, important for printing --- diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index c1df12d..67c3dca 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -8,12 +8,6 @@ import jalview.datamodel.*; import jalview.analysis.*; public class IdCanvas extends JPanel { - protected Image img; - protected Graphics2D gg; - - protected int imgWidth; - protected int imgHeight; - protected AlignViewport av; public boolean paintFlag = false; @@ -29,7 +23,7 @@ public class IdCanvas extends JPanel PaintRefresher.Register(this); } - public void drawIdString(Graphics g,SequenceI ds,int i, int starty, int ypos) { + public void drawIdString(Graphics gg,SequenceI ds,int i, int starty, int ypos) { int charHeight = av.getCharHeight(); if (av.getSelection().contains(ds)) { @@ -48,43 +42,14 @@ public class IdCanvas extends JPanel } - public void paintComponent(Graphics g) { + public void paintComponent(Graphics gg) { AlignmentI da = av.getAlignment(); int charHeight = av.getCharHeight(); - Font f = av.getFont(); - - if (img == null || - imgWidth != getWidth() || - imgHeight != getHeight() || - paintFlag == true) { - - imgWidth = getWidth(); - imgHeight = getHeight(); - - if (imgWidth <= 0 ) { - imgWidth = 700; - } - if (imgHeight <= 0 ) { - imgHeight = 500; - } - - img = createImage(imgWidth,imgHeight); - - - gg = (Graphics2D)img.getGraphics(); - gg.setColor(Color.white); - gg.fillRect(0,0,imgWidth,imgHeight); - - gg.setFont(f); - - paintFlag = false; - - } - + gg.setFont(av.getFont()); //Fill in the background gg.setColor(Color.white); - gg.fillRect(0,0,imgWidth,imgHeight); + gg.fillRect(0,0,getWidth(),getHeight()); Color currentColor = Color.white; Color currentTextColor = Color.black; @@ -93,8 +58,6 @@ public class IdCanvas extends JPanel int starty = av.getStartSeq(); int endy = av.getEndSeq(); - - if (av.getWrapAlignment()) { starty = starty%av.getChunkHeight(); @@ -157,42 +120,39 @@ public class IdCanvas extends JPanel } } - } else { - - //Now draw the id strings - for (int i = starty; i < endy; i++) + } else { - // Selected sequence colours - if (av.getSelection().contains(da.getSequenceAt(i))) + //Now draw the id strings + for (int i = starty; i < endy; i++) { - currentColor = Color.gray; + // Selected sequence colours + if (av.getSelection().contains(da.getSequenceAt(i))) + { + currentColor = Color.gray; currentTextColor = Color.black; - } - else - { - currentColor = da.getSequenceAt(i).getColor(); - currentTextColor = Color.black; - } - - gg.setColor(currentColor); - + } + else + { + currentColor = da.getSequenceAt(i).getColor(); + currentTextColor = Color.black; + } + gg.setColor(currentColor); - gg.fillRect(0, - AlignmentUtil.getPixelHeight(starty,i,charHeight), + gg.fillRect(0, + AlignmentUtil.getPixelHeight(starty, i, charHeight), getWidth(), charHeight); - gg.setColor(currentTextColor); - - String string = da.getSequenceAt(i).getDisplayId(); - - gg.drawString(string,0,AlignmentUtil.getPixelHeight(starty,i,charHeight) + charHeight- (charHeight/5)); - } + gg.setColor(currentTextColor); + String string = da.getSequenceAt(i).getDisplayId(); + gg.drawString(string, 0, + AlignmentUtil.getPixelHeight(starty, i, charHeight) + + charHeight - (charHeight / 5)); + } } - g.drawImage(img,0,0,this); } diff --git a/src/jalview/gui/ScaleCanvas.java b/src/jalview/gui/ScaleCanvas.java index 4a0bd2a..7e4b617 100755 --- a/src/jalview/gui/ScaleCanvas.java +++ b/src/jalview/gui/ScaleCanvas.java @@ -5,11 +5,6 @@ import javax.swing.*; public class ScaleCanvas extends JPanel { - Image img; - Graphics gg; - - int imgWidth; - int imgHeight; int xoffset; public static final int HEIGHT = 30; @@ -28,34 +23,17 @@ public class ScaleCanvas extends JPanel { } // scalewidth will normally be screenwidth, - public void drawScale(Graphics g, int startx, int endx, int scaleWidth) + public void drawScale(Graphics gg, int startx, int endx, int scaleWidth) { double charWidth = av.getCharWidth(); - if (img == null || - imgWidth != scaleWidth || - imgHeight != getHeight() || - paintFlag == true) { - - imgWidth = scaleWidth; - imgHeight = getHeight(); - img = createImage(imgWidth,imgHeight); - - gg = img.getGraphics(); - gg.setColor(Color.white); - gg.fillRect(0,0,imgWidth,imgHeight); - - - - paintFlag = false; - } gg.setFont(av.getFont()); //Fill in the background gg.setColor(Color.white); - gg.fillRect(0,0,imgWidth,imgHeight); + gg.fillRect(0,0,scaleWidth, HEIGHT); int resWidth = endx - startx + 1; @@ -116,8 +94,6 @@ public class ScaleCanvas extends JPanel { } - g.drawImage(img,0,0,this); - } public Dimension getMinimumSize() {