FileDocCategorySizeDatePackage
BlockCanvas.javaAPI DocExample915Sun Mar 28 19:08:48 BST 1999None

BlockCanvas

public class BlockCanvas extends Canvas

Fields Summary
CharacterBlock
block
int
charWidth
int
charHeight
int
hgap
int
vgap
Constructors Summary
public BlockCanvas()


    
    setFont(new Font("Monospaced", Font.BOLD, 12));
  
Methods Summary
public CharacterBlockgetBlock()

    return block;
  
public voidpaint(java.awt.Graphics g)


    char[] charsOnPage = block.getCharactersInBlock(); 
    int charsPerRow = (getSize().width - 2*hgap)/charWidth;
    if (charsPerRow <= 0) charsPerRow = 1; 
    
    for (int i = 0; i < charsOnPage.length; i++) {
      int x = i % charsPerRow; 
      int y = i / charsPerRow + 1;
      g.drawChars(charsOnPage, i, 1, hgap + charWidth*x, vgap + charHeight*y);    
    }

  
public voidsetBlock(CharacterBlock block)

    this.block = block;  
    this.repaint();