edu.neu.ccs.gui
Class Borders

java.lang.Object
  extended byedu.neu.ccs.gui.Borders

public class Borders
extends Object

Class Borders redesigns the Java class BorderFactory by providing brief names for many methods in that class and by providing additional convenience methods that do not exist in that class.

In particular, this class provides new methods to create etch and bevel style borders with a levels parameter that controls the border thickness.

Technical Note: Many of the complex borders are made using compounds of MatteBorder objects and so the return types will not match the classic Java border classes.

This class cannot be instantiated.

Since:
2.5.0
Version:
2.5.0

Field Summary
static int ABOVE_BOTTOM
          The int TitledBorder.ABOVE_BOTTOM.
static int ABOVE_TOP
          The int TitledBorder.ABOVE_TOP.
static int BELOW_BOTTOM
          The int TitledBorder.BELOW_BOTTOM.
static int BELOW_TOP
          The int TitledBorder.BELOW_TOP.
static int BOTTOM
          The int TitledBorder.BOTTOM.
static int CENTER
          The int TitledBorder.CENTER.
static Border DEFAULT_LINE_BORDER
          The default line border for a titled border, namely, line(Color.black,2).
static int H_DEFAULT
          The horizontal default for a titled border that we take to be (CENTER) rather than the Java default (LEADING).
static int LEADING
          The int TitledBorder.LEADING.
static int LEFT
          The int TitledBorder.LEFT.
static int RIGHT
          The int TitledBorder.RIGHT.
static int TOP
          The int TitledBorder.TOP.
static int TRAILING
          The int TitledBorder.TRAILING.
static int V_DEFAULT
          The vertical default for a titled border that is (TOP) as in Java.
 
Constructor Summary
private Borders()
          Private constructor to prevent instantiation.
 
Method Summary
static Border bevelLowered()
          Creates a default lowered bevel border.
static Border bevelLowered(Color highlight, Color shadow)
          Creates a lowered bevel border with the given highlight and shadow colors.
static Border bevelLowered(Color highlightOuter, Color highlightInner, Color shadowInner, Color shadowOuter)
          Creates a lowered bevel border with the given outer and inner highlight colors and the given outer and inner shadow colors.
static Border bevelLowered(int levels, Color highlight, Color shadow)
          Creates a lowered bevel border in which the thickness of each edge is equal to the number of levels.
static Border bevelLowered(int levels, Color highlightOuter, Color highlightInner, Color shadowInner, Color shadowOuter)
          Creates a lowered bevel border in which the thickness of each edge is equal to the number of levels.
static Border bevelRaised()
          Creates a default raised bevel border.
static Border bevelRaised(Color highlight, Color shadow)
          Creates a raised bevel border with the given highlight and shadow colors.
static Border bevelRaised(Color highlightOuter, Color highlightInner, Color shadowInner, Color shadowOuter)
          Creates a lowered bevel border with the given outer and inner highlight colors and the given outer and inner shadow colors.
static Border bevelRaised(int levels, Color highlight, Color shadow)
          Creates a raised bevel border in which the thickness of each edge is equal to the number of levels.
static Border bevelRaised(int levels, Color highlightOuter, Color highlightInner, Color shadowInner, Color shadowOuter)
          Creates a raised bevel border in which the thickness of each edge is equal to the number of levels.
static Border compound(Border[] array)
          Returns a compound border constructed from the given array of borders.
static Border compound(Border outer, Border inner)
          Returns a compound border constructed from the given outer and inner borders.
static Border empty()
          Creates an empty border that takes up no space.
static Border empty(int thickness)
          Creates an empty border with the given thickness.
static Border empty(int vgap, int hgap)
          Creates an empty border with the given gaps.
static Border empty(int top, int left, int bottom, int right)
          Creates an empty border with the given parameters.
static Border etchLowered()
          Creates a default lowered etch border.
static Border etchLowered(Color highlight, Color shadow)
          Creates a lowered etch border with the given highlight and shadow colors.
static Border etchLowered(int levels, Color highlight, Color shadow)
          Creates a lowered etch border in which the thickness of each color band is equal to the number of levels.
static Border etchRaised()
          Creates a default raised etch border.
static Border etchRaised(Color highlight, Color shadow)
          Creates a raised etch border with the given highlight and shadow colors.
static Border etchRaised(int levels, Color highlight, Color shadow)
          Creates a raised etch border in which the thickness of each color band is equal to the number of levels.
static Border line()
          Creates a line border with color black and thickness 1.
static Border line(Color color)
          Creates a line border with given color and thickness 1.
static Border line(Color color, int thickness)
          Creates a line border with the given color and thickness.
static Border line(int thickness)
          Creates a line border with color black and the given thickness.
static Border matte(int thickness, Color color)
          Creates a matte border with the given thickness and color.
static Border matte(int thickness, Icon tileicon)
          Creates a matte border with the given thickness and tileicon.
static Border matte(int vgap, int hgap, Color color)
          Creates a matte border with the given gaps and color.
static Border matte(int vgap, int hgap, Icon tileicon)
          Creates a matte border with the given gaps and tileicon.
static Border matte(int top, int left, int bottom, int right, Color color)
          Creates a matte border with the given parameters.
static Border matte(int top, int left, int bottom, int right, Icon tileicon)
          Creates a matte border with the given parameters.
static Border sandwich(Border center, Border wrap)
          Returns a compound with the given center border in the middle and the wrap border as outer and inner.
static TitledBorder title(String t)
          Returns a TitledBorder using the given parameters.
static TitledBorder title(String t, Border base)
          Returns a TitledBorder using the given parameters.
static TitledBorder title(String t, Border base, Font font, Color fontcolor)
          Returns a TitledBorder using the given parameters.
static TitledBorder title(String t, Font font, Color fontcolor)
          Returns a TitledBorder using the given parameters.
static TitledBorder title(String t, int hPosition, int vPosition)
          Returns a TitledBorder using the given parameters.
static TitledBorder title(String t, int hPosition, int vPosition, Border base)
          Returns a TitledBorder using the given parameters.
static TitledBorder title(String t, int hPosition, int vPosition, Border base, Font font, Color fontcolor)
          Returns a TitledBorder using the given parameters.
static TitledBorder title(String t, int hPosition, int vPosition, Font font, Color fontcolor)
          Returns a TitledBorder using the given parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEFT

public static final int LEFT
The int TitledBorder.LEFT.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
The int TitledBorder.RIGHT.

See Also:
Constant Field Values

CENTER

public static final int CENTER
The int TitledBorder.CENTER.

See Also:
Constant Field Values

LEADING

public static final int LEADING
The int TitledBorder.LEADING.

See Also:
Constant Field Values

TRAILING

public static final int TRAILING
The int TitledBorder.TRAILING.

See Also:
Constant Field Values

H_DEFAULT

public static final int H_DEFAULT
The horizontal default for a titled border that we take to be (CENTER) rather than the Java default (LEADING).

See Also:
Constant Field Values

TOP

public static final int TOP
The int TitledBorder.TOP.

See Also:
Constant Field Values

ABOVE_TOP

public static final int ABOVE_TOP
The int TitledBorder.ABOVE_TOP.

See Also:
Constant Field Values

BELOW_TOP

public static final int BELOW_TOP
The int TitledBorder.BELOW_TOP.

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
The int TitledBorder.BOTTOM.

See Also:
Constant Field Values

ABOVE_BOTTOM

public static final int ABOVE_BOTTOM
The int TitledBorder.ABOVE_BOTTOM.

See Also:
Constant Field Values

BELOW_BOTTOM

public static final int BELOW_BOTTOM
The int TitledBorder.BELOW_BOTTOM.

See Also:
Constant Field Values

V_DEFAULT

public static final int V_DEFAULT
The vertical default for a titled border that is (TOP) as in Java.

See Also:
Constant Field Values

DEFAULT_LINE_BORDER

public static final Border DEFAULT_LINE_BORDER
The default line border for a titled border, namely, line(Color.black,2).

Constructor Detail

Borders

private Borders()
Private constructor to prevent instantiation.

Method Detail

empty

public static Border empty()

Creates an empty border that takes up no space.


empty

public static Border empty(int thickness)

Creates an empty border with the given thickness.

Parameters:
thickness - the border thickness

empty

public static Border empty(int vgap,
                           int hgap)

Creates an empty border with the given gaps.

Parameters:
vgap - the border vertical gap: top and bottom
hgap - the border horizontal gap: left and right

empty

public static Border empty(int top,
                           int left,
                           int bottom,
                           int right)

Creates an empty border with the given parameters.

Parameters:
top - the border top
left - the border left
bottom - the border bottom
right - the border right

matte

public static Border matte(int thickness,
                           Color color)

Creates a matte border with the given thickness and color.

If the color is null, it is set to the color Color.black.

Parameters:
thickness - the border thickness
color - the border color

matte

public static Border matte(int vgap,
                           int hgap,
                           Color color)

Creates a matte border with the given gaps and color.

If the color is null, it is set to the color Color.black.

Parameters:
vgap - the border vertical gap: top and bottom
hgap - the border horizontal gap: left and right
color - the border color

matte

public static Border matte(int top,
                           int left,
                           int bottom,
                           int right,
                           Color color)

Creates a matte border with the given parameters.

If the color is null, it is set to the color Color.black.

Parameters:
top - the border top
left - the border left
bottom - the border bottom
right - the border right
color - the border color

matte

public static Border matte(int thickness,
                           Icon tileicon)

Creates a matte border with the given thickness and tileicon.

If the tileicon is null, it is replaced by the color Color.black.

Parameters:
thickness - the border thickness
tileicon - the border tileicon

matte

public static Border matte(int vgap,
                           int hgap,
                           Icon tileicon)

Creates a matte border with the given gaps and tileicon.

If the tileicon is null, it is replaced by the color Color.black.

Parameters:
vgap - the border vertical gap: top and bottom
hgap - the border horizontal gap: left and right
tileicon - the border tileicon

matte

public static Border matte(int top,
                           int left,
                           int bottom,
                           int right,
                           Icon tileicon)

Creates a matte border with the given parameters.

If the tileicon is null, it is replaced by the color Color.black.

Parameters:
top - the border top
left - the border left
bottom - the border bottom
right - the border right
tileicon - the border tileicon

line

public static Border line()

Creates a line border with color black and thickness 1.


line

public static Border line(Color color)

Creates a line border with given color and thickness 1.

If the color is null, it is set to the color Color.black.

Parameters:
color - the border color

line

public static Border line(int thickness)

Creates a line border with color black and the given thickness.

Parameters:
thickness - the border thickness

line

public static Border line(Color color,
                          int thickness)

Creates a line border with the given color and thickness.

If the color is null, it is set to the color Color.black.

Note that the effect of this method is the same as:

   matte(thickness, color)

but the parameters are in the opposite order.

Parameters:
color - the border color
thickness - the border thickness

etchLowered

public static Border etchLowered()

Creates a default lowered etch border.


etchLowered

public static Border etchLowered(Color highlight,
                                 Color shadow)

Creates a lowered etch border with the given highlight and shadow colors.

If either color is null, returns a default lowered etch border.

Parameters:
highlight - the highlight color
shadow - the shadow color

etchLowered

public static Border etchLowered(int levels,
                                 Color highlight,
                                 Color shadow)

Creates a lowered etch border in which the thickness of each color band is equal to the number of levels.

Since each etch edge has 2 color bands, the thickness of each edge is 2*levels.

The north and west edges are set up as follows:

The south and east edges are set up as follows:

Note that these color settings are the opposite of those for a raised border.

It is an error if levels is not at least 1 or if either color is null. In that case, a default lowered etch border is returned.

Parameters:
levels - the number of levels in each color band
highlight - the highlight color
shadow - the shadow color

etchRaised

public static Border etchRaised()

Creates a default raised etch border.


etchRaised

public static Border etchRaised(Color highlight,
                                Color shadow)

Creates a raised etch border with the given highlight and shadow colors.

If either color is null, returns a default raised etch border.

Parameters:
highlight - the highlight color
shadow - the shadow color

etchRaised

public static Border etchRaised(int levels,
                                Color highlight,
                                Color shadow)

Creates a raised etch border in which the thickness of each color band is equal to the number of levels.

Since each etch edge has 2 color bands, the thickness of each edge is 2*levels.

The north and west edges are set up as follows:

The south and east edges are set up as follows:

Note that these color settings are the opposite of those for a lowered border.

It is an error if levels is not at least 1 or if either color is null. In that case, a default raised etch border is returned.

Parameters:
levels - the number of levels in each color band
highlight - the highlight color
shadow - the shadow color

bevelLowered

public static Border bevelLowered()

Creates a default lowered bevel border.


bevelLowered

public static Border bevelLowered(Color highlight,
                                  Color shadow)

Creates a lowered bevel border with the given highlight and shadow colors.

If either color is null, returns a default lowered bevel border.

Parameters:
highlight - the highlight color
shadow - the shadow color

bevelLowered

public static Border bevelLowered(Color highlightOuter,
                                  Color highlightInner,
                                  Color shadowInner,
                                  Color shadowOuter)

Creates a lowered bevel border with the given outer and inner highlight colors and the given outer and inner shadow colors.

If any color is null, returns a default lowered bevel border.

The parameter order outer-inner-inner-outer is different from that used in the Java class BorderFactory for similar methods.

Parameters:
highlightOuter - the outer highlight color
highlightInner - the inner highlight color
shadowInner - the inner shadow color
shadowOuter - the outer shadow color

bevelLowered

public static Border bevelLowered(int levels,
                                  Color highlight,
                                  Color shadow)

Creates a lowered bevel border in which the thickness of each edge is equal to the number of levels.

The north and west edges are set up as follows:

The south and east edges are set up as follows:

Note that these color settings are the opposite of those for a raised border.

It is an error if levels is not at least 1 or if either color is null. In that case, a default bevel border is returned.

Parameters:
levels - the thickness of each edge
highlight - the highlight color
shadow - the shadow color

bevelLowered

public static Border bevelLowered(int levels,
                                  Color highlightOuter,
                                  Color highlightInner,
                                  Color shadowInner,
                                  Color shadowOuter)

Creates a lowered bevel border in which the thickness of each edge is equal to the number of levels.

The north and west edges are set up as follows:

The color smoothly interpolates from shadowOuter on the outside to shadowInner on the inside.

The south and east edges are set up as follows:

The color smoothly interpolates from highlightOuter on the outside to highlightInner on the inside.

Note that these color settings are the opposite of those for a raised border.

It is an error if levels is not at least 2 or if any color is null. In that case, a default bevel border is returned.

The parameter order outer-inner-inner-outer is different from that used in the Java class BorderFactory for similar methods.

Parameters:
levels - the thickness of each edge
highlightOuter - the outer highlight color
highlightInner - the inner highlight color
shadowInner - the inner shadow color
shadowOuter - the outer shadow color

bevelRaised

public static Border bevelRaised()

Creates a default raised bevel border.


bevelRaised

public static Border bevelRaised(Color highlight,
                                 Color shadow)

Creates a raised bevel border with the given highlight and shadow colors.

If either color is null, returns a default raised bevel border.

Parameters:
highlight - the highlight color
shadow - the shadow color

bevelRaised

public static Border bevelRaised(Color highlightOuter,
                                 Color highlightInner,
                                 Color shadowInner,
                                 Color shadowOuter)

Creates a lowered bevel border with the given outer and inner highlight colors and the given outer and inner shadow colors.

If any color is null, returns a default lowered bevel border.

The parameter order outer-inner-inner-outer is different from that used in the Java class BorderFactory for similar methods.

Parameters:
highlightOuter - the outer highlight color
highlightInner - the inner highlight color
shadowInner - the inner shadow color
shadowOuter - the outer shadow color

bevelRaised

public static Border bevelRaised(int levels,
                                 Color highlight,
                                 Color shadow)

Creates a raised bevel border in which the thickness of each edge is equal to the number of levels.

The north and west edges are set up as follows:

The south and east edges are set up as follows:

Note that these color settings are the opposite of those for a lowered border.

It is an error if levels is not at least 1 or if either color is null. In that case, a default bevel border is returned.

Parameters:
levels - the thickness of each edge
highlight - the highlight color
shadow - the shadow color

bevelRaised

public static Border bevelRaised(int levels,
                                 Color highlightOuter,
                                 Color highlightInner,
                                 Color shadowInner,
                                 Color shadowOuter)

Creates a raised bevel border in which the thickness of each edge is equal to the number of levels.

The north and west edges are set up as follows:

The color smoothly interpolates from highlightOuter on the outside to highlightInner on the inside.

The south and east edges are set up as follows:

The color smoothly interpolates from shadowOuter on the outside to shadowInner on the inside.

Note that these color settings are the opposite of those for a lowered border.

It is an error if levels is not at least 2 or if any color is null. In that case, a default bevel border is returned.

The parameter order outer-inner-inner-outer is different from that used in the Java class BorderFactory for similar methods.

Parameters:
levels - the thickness of each edge
highlightOuter - the outer highlight color
highlightInner - the inner highlight color
shadowInner - the inner shadow color
shadowOuter - the outer shadow color

title

public static TitledBorder title(String t)

Returns a TitledBorder using the given parameters.

If t is null, it is set to an empty string.

The title is centered in the top position.

A title is inserted into an existing border. This constructor uses a default line border of thickness 2 in black.

Parameters:
t - the title string

title

public static TitledBorder title(String t,
                                 Border base)

Returns a TitledBorder using the given parameters.

If t is null, it is set to an empty string.

The title is centered in the top position.

A title is inserted into an existing border. If the base is non-null that border is used; otherwise a default line border is used. We have changed the default line border to a line border of thickness 2 in black. The Java default is of thickness 1 and is in a pale blue that is almost invisible.

Parameters:
t - the title string
base - the base border in which to place the title

title

public static TitledBorder title(String t,
                                 Font font,
                                 Color fontcolor)

Returns a TitledBorder using the given parameters.

If t is null, it is set to an empty string.

The title is centered in the top position.

A title is inserted into an existing border. This constructor uses a default line border of thickness 2 in black.

The font and fontcolor may be supplied or left as null to accept defaults.

Parameters:
t - the title string
font - the title font
fontcolor - the title font color

title

public static TitledBorder title(String t,
                                 Border base,
                                 Font font,
                                 Color fontcolor)

Returns a TitledBorder using the given parameters.

If t is null, it is set to an empty string.

The title is centered in the top position.

A title is inserted into an existing border. If the base is non-null that border is used; otherwise a default line border is used. We have changed the default line border to a line border of thickness 2 in black. The Java default is of thickness 1 and is in a pale blue that is almost invisible.

The font and fontcolor may be supplied or left as null to accept defaults.

Parameters:
t - the title string
base - the base border in which to place the title
font - the title font
fontcolor - the title font color

title

public static TitledBorder title(String t,
                                 int hPosition,
                                 int vPosition)

Returns a TitledBorder using the given parameters.

If t is null, it is set to an empty string.

The valid values for hPosition are:

The valid values for vPosition are:

If either hPosition or vPosition are invalid, they are set to the corresponding default.

The constants listed above are defined in the Java class TitledBorder except for the default constants. All constants are redefined in this class and the defaults are added as specified above.

A title is inserted into an existing border. This constructor uses a default line border of thickness 2 in black.

Parameters:
t - the title string
hPosition - the horizontal position
vPosition - the vertical position

title

public static TitledBorder title(String t,
                                 int hPosition,
                                 int vPosition,
                                 Border base)

Returns a TitledBorder using the given parameters.

If t is null, it is set to an empty string.

The valid values for hPosition are:

The valid values for vPosition are:

If either hPosition or vPosition are invalid, they are set to the corresponding default.

The constants listed above are defined in the Java class TitledBorder except for the default constants. All constants are redefined in this class and the defaults are added as specified above.

A title is inserted into an existing border. If the base is non-null that border is used; otherwise a default line border is used. We have changed the default line border to a line border of thickness 2 in black. The Java default is of thickness 1 and is in a pale blue that is almost invisible.

Parameters:
t - the title string
hPosition - the horizontal position
vPosition - the vertical position
base - the base border in which to place the title

title

public static TitledBorder title(String t,
                                 int hPosition,
                                 int vPosition,
                                 Font font,
                                 Color fontcolor)

Returns a TitledBorder using the given parameters.

If t is null, it is set to an empty string.

The valid values for hPosition are:

The valid values for vPosition are:

If either hPosition or vPosition are invalid, they are set to the corresponding default.

The constants listed above are defined in the Java class TitledBorder except for the default constants. All constants are redefined in this class and the defaults are added as specified above.

A title is inserted into an existing border. This constructor uses a default line border of thickness 2 in black.

The font and fontcolor may be supplied or left as null to accept defaults.

Parameters:
t - the title string
hPosition - the horizontal position
vPosition - the vertical position
font - the title font
fontcolor - the title font color

title

public static TitledBorder title(String t,
                                 int hPosition,
                                 int vPosition,
                                 Border base,
                                 Font font,
                                 Color fontcolor)

Returns a TitledBorder using the given parameters.

If t is null, it is set to an empty string.

The valid values for hPosition are:

The valid values for vPosition are:

If either hPosition or vPosition are invalid, they are set to the corresponding default.

The constants listed above are defined in the Java class TitledBorder except for the default constants. All constants are redefined in this class and the defaults are added as specified above.

A title is inserted into an existing border. If the base is non-null that border is used; otherwise a default line border is used. We have changed the default line border to a line border of thickness 2 in black. The Java default is of thickness 1 and is in a pale blue that is almost invisible.

The font and fontcolor may be supplied or left as null to accept defaults.

Parameters:
t - the title string
hPosition - the horizontal position
vPosition - the vertical position
base - the base border in which to place the title
font - the title font
fontcolor - the title font color

compound

public static Border compound(Border outer,
                              Border inner)

Returns a compound border constructed from the given outer and inner borders.

If either border is null, the other border is returned directly.

Parameters:
outer - the outer border
inner - the inner border

compound

public static Border compound(Border[] array)

Returns a compound border constructed from the given array of borders.

The initial border in the array will be the outermost border in the compound.

The sequence of array elements is viewed as outermost to innermost.

Parameters:
array - an array of borders to compound

sandwich

public static Border sandwich(Border center,
                              Border wrap)

Returns a compound with the given center border in the middle and the wrap border as outer and inner.

Parameters:
center - the border in the middle
wrap - the border to wrap as both outer and inner