package lawyer; import java.awt.*; import java.util.*; /** *
This class displays as much of its text on each page as possible. * Note: It does the text-wrapping and page-fitting at the beginning, so * subsequent resizings will not have an effect. This dynamic "re-fitting" * is something I would like to add to the code.
* * @author David Danks * @version 0.9; July 24, 1998 * @see LessonManager */ public class TextCanvas extends Canvas { /** @serial */ protected String[][] text; /** @serial */ protected int xMax; /** @serial */ protected int yMax; /** @serial */ protected int dialog = 0; /** @serial */ protected Font boldFont; /** @serial */ protected Font plainFont; /** @serial */ protected int INSET = 5; /** * Creates the TextCanvas, and does all of the text-wrapping and page-fitting. * * @param text A two-dimensional String array of the text to be displayed, * in the format String[individual's_speech][line_of_speech] * @param f The font in which to display the text * @height width The maximum width available for the TextCanvas * @height height The maximum height available for the TextCanvas */ public TextCanvas(String[][] text, Font f, int width, int height) { this.setFont(f); this.text = setText(text, width, height); plainFont = getFont(); boldFont = new Font(getFont().getName(), Font.BOLD, getFont().getSize()); xMax = getWidestString(); yMax = getTallestSection(); } /** * Draws all of the text on the Canvas, putting the names in bold. */ public void paint(Graphics g) { g.translate(INSET, 0); g.setFont(boldFont); for (int i=0; i