/*
 * @(#)TextBounds.java    2.4.0   25 May 2005
 *
 * Copyright 2005
 * 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 java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
import java.awt.font.*;

/**
 * <P>The <CODE>TextBounds</CODE> class defines an interface that specifies
 * how to compute accurate bounds for a <CODE>TextPaintable</CODE>.</P>
 *
 * <P>The <CODE>TextBounds</CODE> class also defines static objects that
 * implement the interface it defines.</P>
 *
 * <P>The <CODE>TextBounds</CODE> class cannot be instantiated.</P>
 *
 * <p>In 2.4.0, this class was updated to be consistent with
 * refinements to the <code>Paintable</code> interface.</p>
 *
 * @author  Richard Rasala
 * @version 2.4.0
 * @since   2.3
 */
public class TextBounds
{
    /** Private constructor to prevent instantiation. */
    private TextBounds() {}
    
    
    /**
     * <P>The <CODE>Strategy</CODE> interface defines the call-back method
     * needed to compute accurate bounds for a <CODE>TextPaintable</CODE>.</P>
     */
    public interface Strategy {
        XRect getBounds2D(TextPaintable paintable);
    }
    
    
    /**
     * <P>The <CODE>TIGHT</CODE> <CODE>Strategy</CODE> produces tight bounds on
     * the <CODE>TextPaintable</CODE> by calling the method
     * <CODE>getTightBounds</CODE>.</P>
     */
    public static TextBounds.Strategy TIGHT =
        new TextBounds.Strategy() {
            public XRect getBounds2D(TextPaintable paintable) {
                if (paintable == null)
                    return new XRect();
                
                return paintable.getTightBounds();
            }
        };
    
    
    /**
     * <P>The <CODE>LOOSE</CODE> <CODE>Strategy</CODE> produces loose bounds on
     * the <CODE>TextPaintable</CODE> by calling the method
     * <CODE>getLooseBounds</CODE>.</P>
     */
    public static TextBounds.Strategy LOOSE =
        new TextBounds.Strategy() {
            public XRect getBounds2D(TextPaintable paintable) {
                if (paintable == null)
                    return new XRect();
                
                return paintable.getLooseBounds();
            }
        };
    
}
