/*
 * @(#)Halo.java  2.4.0   12 August 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 edu.neu.ccs.codec.*;
import edu.neu.ccs.console.*;
import edu.neu.ccs.filter.*;
import edu.neu.ccs.parser.*;
import edu.neu.ccs.pedagogy.*;
import edu.neu.ccs.util.*;

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.font.*;
import java.util.*;
import java.text.*;
import java.math.*;
import javax.swing.*;
import java.lang.reflect.*;

/**
 * <p>A wrapper class for one <code>Object</code> viewed as a
 * <code>Component</code> that uses a <code>CenterLayout</code>
 * and provides positive border insets.</p>
 *
 * @author  Richard Rasala
 * @version 2.4.0
 * @since 2.2
 */
public class Halo extends DisplayPanel
{   
    /**
     * The default inset used to wrap the given object in the panel;
     * its value is 2.
     */
    public static final int DEFAULT_INSET = 2;
    
    /**
     * The minimum inset used to wrap the given object in the panel;
     * its value is 1.
     */
    public static final int MINIMUM_INSET = 1;
    
    
    /**
     * Constructs a wrapper for the object using the default inset.
     *
     * @param object the object to be wrapped
     * @see #Halo(Object, int, int)
     * @see DisplayPanel#makeComponent(Object)
     * @since 2.2
     */
    public Halo(Object object) {
        this(object, DEFAULT_INSET, DEFAULT_INSET);
    }
    
    
    /**
     * Constructs a wrapper for the object using the given insets or
     * the minimum inset if the given x and y insets are too small.
     *
     * @param object the object to be wrapped
     * @param xInset the inset to be used on the left and right sides
     * @param yInset the inset to be used on the top and bottom sides
     * @see #Halo(Object)
     * @see DisplayPanel#makeComponent(Object)
     * @since 2.2
     */
    public Halo(Object object, int xInset, int yInset) {
        setLayout(new CenterLayout());
        
        if (xInset < MINIMUM_INSET)
            xInset = MINIMUM_INSET;
        
        if (yInset < MINIMUM_INSET)
            yInset = MINIMUM_INSET;
        
        setBorder(
            BorderFactory.createEmptyBorder
                (yInset, xInset, yInset, xInset));
        
        addObject(object);
    }
    
}
