package lawyer;
import java.awt.*;
import java.util.*;
/**
*
This class creates and maintains the Panel for the display of the brief
* for the lesson. Once a BriefPanel has been created and added to a
* Container, you simply use displayPage(int page)
to do all of
* the painting.
*
* @author David Danks
* @version 1.0; July 24, 1998
* @see LessonManager
*/
public class BriefPanel extends Panel {
/** @serial */
protected String[][] text;
/** @serial */
protected String[][][] options;
/** @serial */
protected int width;
/** @serial */
protected int height;
/** @serial */
protected int MARGIN = 20;
/** @serial */
protected int INSET = 5;
/** @serial */
protected Checkbox[] opts;
/** @serial */
protected FontMetrics fm;
/** @serial */
protected int TOP = 35;
/** @serial */
protected int current;
/**
* This constructor does all of the text wrapping for the given height and
* width, and sets up the constant display characteristics.
*
* @param text An array of arrays of Strings to be displayed, in the form
* String[page_of_text][line_of_text].
* @param options A three-dimensional array of Strings for the options, in
* the form String[page_of_options][choice][line_of_choice].
* The choices should begin at index 1.
* @param f The font in which the text should be displayed.
* @param maxWidth The maximum available width for the Panel
* @param maxHeight The maximum available height for the Panel
*/
public BriefPanel(String[][] text, String[][][] options, Font f,
int maxWidth, int maxHeight) {
setFont(f);
fm = getFontMetrics(getFont());
width = maxWidth;
height = maxHeight;
this.text = wrapText(text);
this.options = wrapOptions(options);
// now do the page setup
setLayout(null);
setBackground(Color.yellow);
}
/**
* Puts the checkboxes in the right place on the page, and then calls repaint
* to add the lines and surrounding text.
*
* @param page The page number to be displayed (starting at 0)
*/
public void displayPage(int page) {
removeAll();
current = page;
CheckboxGroup cbg = new CheckboxGroup();
opts = new Checkbox[options[page].length];
int yOff = TOP + (text[page].length+1)*fm.getHeight();
for (int i=0; i