/* @(#)PaintableSequenceComposite.java   2.6.0   7 June 2007
 *
 * Copyright 2007
 * College of Computer and Information Science
 * Northeastern University
 * Boston, MA  02115
 *
 * The Java Power Tools software may be used for educational
 * purposes as long as this copyright notice is retained intact
 * at the top of all source files.
 *
 * To discuss possible commercial use of this software, 
 * contact Richard Rasala at Northeastern University, 
 * College of Computer and Information Science,
 * 617-373-2462 or rasala@ccs.neu.edu.
 *
 * The Java Power Tools software has been designed and built
 * in collaboration with Viera Proulx and Jeff Raab.
 *
 * Should this software be modified, the words "Modified from 
 * Original" must be included as a comment below this notice.
 *
 * All publication rights are retained.  This software or its 
 * documentation may not be published in any media either
 * in whole or in part without explicit permission.
 *
 * This software was created with support from Northeastern 
 * University and from NSF grant DUE-9950829.
 */

package edu.neu.ccs.gui;

import edu.neu.ccs.*;
import edu.neu.ccs.util.*;

import java.awt.*;
import java.awt.geom.*;

import javax.swing.*;
import java.beans.*;

/**
 * <p>The class <code>PaintableSequenceComposite</code> is a base
 * class for the construction of <code>Paintable</code> classes.
 * Although the class is not abstract, nothing useful can be done
 * with it directly.</p>
 *
 * <p>A derived class can control exactly what is inserted into the
 * internal <code>PaintableSequence</code> via the protected access
 * method <code>getPaintableSequence()</code> but this sequence is
 * not visible to a public caller.  Thus, all features of a
 * <code>PaintableSequence</code> are available to a derived class
 * without public exposure of this implementation.</p>
 *
 * <p>In 2.3.5, the class was refactored to be consistent with
 * the new <code>Paintable</code> interface and
 * the new <code>AbstractPaintable</code> class.
 *
 * <p>In 2.4.0, this class was updated to be consistent with
 * refinements to the <code>Paintable</code> interface.</p>
 *
 * <p>In 2.6.0, this class was refactored to directly extend
 * <code>AbstractPaintable</code>.  This implementation is much
 * easier and also has the advantages of the <code>Tile</code>
 * wrapper class, namely, this class maintains mutator data
 * independent of the internal paintable sequence.  This turned
 * out to be critical in the definition of a new derived class
 * <code>MultiLineTextPaintable</code>.  In effect, this class
 * is now a wrapper class similar to <code>Tile</code> but what
 * is wrapped is an internal paintable sequence not a paintable
 * supplied by the caller.</p>
 * 
 * <p>Since the internal paintable sequence is not available to a
 * normal caller, this class provides methods to permit the caller
 * to set or get the background paint and background tile of that
 * sequence.  This may be useful for certain effects.</p>
 *
 * @author  Richard Rasala
 * @version 2.6.0
 * @since   2.3.2
 * @see     Tile
 * @see     MultiLineTextPaintable
 */
public class PaintableSequenceComposite
    extends AbstractPaintable
{
    /** The internal paintable sequence. */
    private PaintableSequence sequence = new PaintableSequence();
    
    
    /**
     * <p>Returns the internal paintable sequence for use by a
     * derived class.</p>
     *
     * @return the internal paintable sequence
     */
    protected PaintableSequence getPaintableSequence() {
        return sequence;
    }
    
    
    /**
     * <p>Implements <code>originalPaint</code> on this object
     * by calling <code>paint</code>
     * on the internal paintable sequence.</p>
     */
    public void originalPaint(Graphics g) {
        sequence.paint(g);
    }
    
    
    /**
     * <p>Implements <code>getActualBounds2D</code> on this object
     * by calling <code>getBounds2D</code>
     * on the internal paintable sequence.</p>
     */
    public XRect getActualBounds2D() {
        return sequence.getBounds2D();
    }
    
    
    /**
     * <p>Implements <code>originalContains</code> on this object
     * by calling <code>contains</code>
     * on the internal paintable sequence.</p>
     */
    public boolean originalContains(double x, double y) {
        return sequence.contains(x, y);
    }
    
    
    /**
     * <p>Sets the background paint of the internal paintable
     * sequence.</p>
     * 
     * @param paint the inner background paint to set
     */
    public void setInnerBackgroundPaint(Paint paint) {
        sequence.setBackgroundPaint(paint);
    }
    
    
    /**
     * <p>Gets the background paint of the internal paintable
     * sequence.</p>
     */
    public Paint getInnerBackgroundPaint() {
        return sequence.getBackgroundPaint();
    }
    
    
    /**
     * <p>Clears the background paint of the internal paintable
     * sequence.</p>
     */
    public void clearInnerBackgroundPaint() {
        sequence.clearBackgroundPaint();
    }
    
    
    /**
     * <p>Sets the background tile of the internal paintable
     * sequence.</p>
     * 
     * <p>The object passed should be a paintable or be
     * convertible to a paintable via the method
     * <code>ComponentFactory.makePaintable</code>.</p>
     * 
     * @param object the background tile object
     */
    public void setInnerBackgroundTile(Object object) {
        sequence.setBackgroundTile(object);
    }
    
    
    /**
     * <p>Gets the background tile of the internal paintable
     * sequence.</p>
     */
    public Paintable getInnerBackgroundTile() {
        return sequence.getBackgroundTile();
    }
    
    
    /**
     * <p>Clears the background tile of the internal paintable
     * sequence.</p>
     */
    public void clearInnerBackgroundTile() {
        sequence.clearBackgroundTile();
    }
    
    
    /**
     * <p>Clears both the background paint and the background tile
     * of the internal paintable sequence.</p>
     */
    public void clearBothInnerBackgrounds() {
        sequence.clearBothBackgrounds();
    }
    
}
