com.abstractics.utils.converter
Class ConverterBorder
java.lang.Object
com.abstractics.utils.converter.ConverterBorder
- All Implemented Interfaces:
- ObjectConverter
- public class ConverterBorder
- extends java.lang.Object
- implements ObjectConverter
Converts the given object into a String via the toString()
method and then converts the String into a
javax.swing.border.Border
object. Border types are determined
by the text left of a colon in the String.
matte border type is used for a simple line or graphic border. There
are two versions: matte which uses a color, and matteimage
which uses an image.
BorderFactory.createMatteBorder(int, int, int, int, java.awt.Color)
Examples:
- matte:5 = Black line border, thickness of 5
- matte:5,blue = Blue line border, thickness of 5
- matte:2,#FFC782 = Color with RGB #FFC782 line border, thickness of 2
- matte:5,10,5,10,red = Red line border with size 5, 10, 5, and 10 in the
top, right, bottom, and left respectively
- matte:5,10,blue = Blue line border with size 5 on top and bottom, and
size 10 on left and right
- matteimage:10,file:/images/image.gif = Matte border filled with the
image and a uniform 10 pixels all around
With colors and images, the text that follows the last comma in the String is
first sent through the Converter
utility to resolve a color/image.
bevel and bevelsoft border types are used to create Beveled
borders, with the latter resulting in a
javax.swing.border.SoftBevelBorder
object. Raised/Lowered must
be specified, followed by inner/outer highlight/shadow if needed. See
BorderFactory.createBevelBorder(int, java.awt.Color, java.awt.Color, java.awt.Color, java.awt.Color)
Examples:
- bevel:raised = Creates a beveled border of the specified type, using
brighter shades of the component's current background color for highlighting,
and darker shading for shadows.
- bevel:lowered,blue,#C7C7B1 = Creates a beveled border of the specified
type, using the specified highlight and shadow colors (respectively).
- bevel:raised,red,blue,yellow,green = Creates a beveled border of the
specified type, using the specified colors for highlight outer, highlight
inner, shadow outer, and shadow inner (respectively).
etched border type is used for to create Etched borders.
Raised/Lowered must be specified, followed by highlight/shadow if needed.
BorderFactory.createEtchedBorder(int, java.awt.Color, java.awt.Color)
Examples:
- etched:raised = Creates a etched border of the specified type, using the
component's current background color for highlighting and shading.
- etched:lowered,blue,#C7C7B1 = Creates a etched border of the specified
type, using the specified highlight and shadow colors (respectively).
empty border type is used for to create an empty space border.
BorderFactory.createEmptyBorder(int, int, int, int)
Examples:
- empty:5 = thickness of 5
- empty:5,10,5,10 = thickness of 5, 10, 5, and 10 in the top, right,
bottom, and left respectively
compound border type is used to create Compound borders where you can
combine two other borders into a single border.
BorderFactory.createCompoundBorder(javax.swing.border.Border, javax.swing.border.Border)
Compund borders allow the user to specify two borders to combine together, an
outside and an inside border. Examples:
- compound:[matte:5,blue][empty:10] = compound border with an outside
border that is a Matte border, and an inside border that is an empty border
- compound:[matte:5][compound:[empty:10][matte:5]] = borders can be nested
as far as necessary. This example has a compound border with an outside
border that is a Matte border, and an inside border that is another compound
border.
- Version:
- $Id: ConverterBorder.java,v 1.3 2006/03/15 05:37:30 andyman99 Exp $
- Author:
- Andrew Lawrence, Copyright 2006 Abstractics, L.L.C., Licensed under the Apache
License, Version 2.0
- See Also:
ConverterInsets
,
ConverterColor
,
ConverterImageIcon
Method Summary |
java.lang.Object |
convert(java.lang.Object obj,
java.util.Locale locale)
Converts to a Border, using the obj.toString() to parse
from |
java.lang.Class |
getClassToConvertTo()
Returns javax.swing.Border |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ConverterBorder
public ConverterBorder()
getClassToConvertTo
public java.lang.Class getClassToConvertTo()
- Returns
javax.swing.Border
- Specified by:
getClassToConvertTo
in interface ObjectConverter
- Returns:
- The class that this converter converts to
- See Also:
com.abstractics.xmlpanel.utils.stringtoobject.ObjectConverter#getClassToConvertTo()
convert
public java.lang.Object convert(java.lang.Object obj,
java.util.Locale locale)
throws ObjectConverterException
- Converts to a Border, using the
obj.toString()
to parse
from
- Specified by:
convert
in interface ObjectConverter
- Parameters:
obj
- Object to be converted. Guaranteed not to be null and not to
already be an instanceof the Class returned by
ObjectConverter.getClassToConvertTo()
. Those conditions are checked
before the converter is even called.locale
- The locale that is asking for the conversion. This may or may
not be necessary for the conversion.
- Returns:
- The converted object - should NEVER return anything that is not
an instanceof the class returned by
ObjectConverter.getClassToConvertTo()
- Throws:
ObjectConverterException
- Throw this exception if the string cannot be converted, for
whatever reason.- See Also:
com.abstractics.xmlpanel.utils.stringtoobject.ObjectConverter#convert(Object)