//[skeleton1.
import java.io.*;

/**
 * An encapsulation of a paragraph in a document
 *
 * This is used in an example of event bubbling
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class Paragraph extends AbstractDocumentElement
{
    private Section      parent;    
    private String       pointSize, style;


    /**
     * Default Constructor
     */
    public Paragraph()
    {
       super();
       pointSize = null;
       style     = null;       
       parent    = null;       
    }


    /**
     * Get the parent of this EventHandler
     *
     * @return  The parent
     */
    public EventHandler getParent()
    {
       return parent;       
    }
//]skeleton1.
//[handlers.

    /**
     * Handle a font size change event
     *
     * @param pointSize    The new font size (e.g., 12)
     */
    protected boolean handleSizeChange(String pointSize)
    {
	this.pointSize = pointSize;
        return true;        
    }


    /**
     * Handle a font style change event
     *
     * @param style    The new font style (e.g., Italic)
     */
    protected boolean handleStyleChange(String style)
    {
	this.style = style;
        return true;        
    }
//]handlers.


    /**
     * Print this Paragraph
     *
     * @param out   The PrintStream to use
     */
    public void print(PrintStream  out)
    {
	out.println("Size: "+pointSize+"\tStyle: "+style);
    }


//[skeleton2.

    /**
     * Set the parent of this Paragraph
     *
     * Note: In this example, a Paragraph must be in a Section.
     * This could be relaxed.
     */
    public void setParent(Section s)
    {
       parent = s;       
    }
}
//]skeleton2.
