import java.applet.*; import java.awt.*; public class randcnvs extends Canvas { private int PaintSeq; private Image LogoImg; private Dimension dimCnvs; public randcnvs() { dimCnvs = new Dimension(); PaintSeq = 0; LogoImg = null; } /* Set the Image to be used as a logo */ public void SetLogoImage(Image i) { LogoImg = i; } /* Return the smallest square inside the canvas, this area is the one we actually do the painting inside */ public Dimension GetDrawSize() { return dimCnvs; // TEMPORARY } /* Draw a string centered in the canvas at the given y-height */ private void CentreString(String s, int y, Graphics g) { FontMetrics fm = g.getFontMetrics(); int logolen = fm.stringWidth(s); g.drawString(s,(dimCnvs.width-logolen)/2,y); } /* On paint we reset the drawing canvas to its original logo */ public void paint(Graphics g) { dimCnvs = size(); int iw = LogoImg.getWidth(this); int ih = LogoImg.getHeight(this); g.setColor(Color.black); g.fillRect(0,0,dimCnvs.width,dimCnvs.height); g.drawImage(LogoImg,(dimCnvs.width-iw)/2,(dimCnvs.height-ih)/2,iw,ih,Color.white,this); // Centered //g.drawImage(LogoImg,0,0,dimCnvs.width,dimCnvs.height,Color.white,this); // Full Window g.setColor(Color.yellow); CentreString("Version: 1.14 Date: 26-Jan-98 Author: Greg Keogh",dimCnvs.height-20,g); ++PaintSeq; } }