/*
* (c) Copyright 2004 by Heng Yuan
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* ITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cookxml.cookswing.helper;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.MatteBorder;
import cookxml.core.interfaces.Helper;
/**
* Helper class for constructing a MatteBorder object.
*
* @cxhelper javax.swing.border.MatteBorder
*
* @author Heng Yuan
* @version $Id: MatteBorderHelper.java 215 2007-06-06 03:59:41Z coconut $
* @since CookSwing 1.0
*/
public class MatteBorderHelper implements Helper
{
/** The border insets top part. */
public int top = -1;
/** The border insets left part. */
public int left = -1;
/** The border insets bottom part. */
public int bottom = -1;
/** The border insets right part. */
public int right = -1;
/** The border insets. */
public Insets insets;
/** The color of the border, same as the color attribute. */
public Color matteColor;
/** The icon for the border. */
public Icon tileIcon;
/** The color of the border. */
public void setColor (Color color)
{
matteColor = color;
}
public Object getFinalObject ()
{
if (matteColor == null && tileIcon == null)
return null;
if (top >= 0 && left >= 0 && bottom >= 0 && right >= 0)
{
if (matteColor != null)
return BorderFactory.createMatteBorder (top, left, bottom, right, matteColor);
return BorderFactory.createMatteBorder (top, left, bottom, right, tileIcon);
}
if (insets != null)
{
if (matteColor != null)
return new MatteBorder (insets, matteColor);
return new MatteBorder (insets, tileIcon);
}
if (tileIcon != null)
return new MatteBorder (tileIcon);
return null;
}
/**
* Set the icon for the border.
*
* @param icon
* the icon object for the border.
*/
public void add (Icon icon)
{
tileIcon = icon;
}
/**
* Set the color for the border.
*
* @param color
* The color for the border.
*/
public void add (Color color)
{
matteColor = color;
}
/**
* Set the insets for the border.
* @param insets
* the border insets.
*/
public void add (Insets insets)
{
this.insets = insets;
}
}