Java DTV API 1.3
18-Nov-2009

com.sun.dtv.lwuit.plaf
Class Border

java.lang.Object
  extended by com.sun.dtv.lwuit.plaf.Border

public class Border
extends Object

Base class that allows us to render a border for a component, a border is drawn before the component and is drawn within the padding region of the component. It is the responsibility of the component not to draw outside of the border line.

This class can be extended to provide additional border types and custom made border types.

A border can optionally paint the background of the component, this depends on the border type and is generally required for rounded borders that "know" the area that should be filled.


Constructor Summary
Border()
           
 
Method Summary
static Border createBevelLowered()
          Creates a lowered bevel border with default colors, highlight is derived from the component and shadow is a plain dark color.
static Border createBevelLowered(Color highlightOuter, Color highlightInner, Color shadowOuter, Color shadowInner)
          Creates a raised bevel border with the given colors.
static Border createBevelRaised()
          Creates a lowered bevel border with default colors, highlight is derived from the component and shadow is a plain dark color.
static Border createBevelRaised(Color highlightOuter, Color highlightInner, Color shadowOuter, Color shadowInner)
          Creates a raised bevel border with the given colors.
static Border createEmpty()
          Creates an empty border, this is useful where we don't want a border for a component but want a focus border etc...
static Border createEtchedLowered()
          Creates a lowered etched border with default colors, highlight is derived from the component and shadow is a plain dark color.
static Border createEtchedLowered(Color highlight, Color shadow)
          Creates a raised etched border with the given colors.
static Border createEtchedRaised()
          Creates a lowered etched border with default colors, highlight is derived from the component and shadow is a plain dark color.
static Border createEtchedRaised(Color highlight, Color shadow)
          Creates a raised etched border with the given colors.
static Border createImageBorder(Image top, Image topLeft, Image background)
          The given images are tiled appropriately across the matching side of the border, rotated and placed as expected in the four corners.
static Border createImageBorder(Image top, Image bottom, Image left, Image right, Image topLeft, Image topRight, Image bottomLeft, Image bottomRight, Image background)
          The given images are tiled appropriately across the matching side of the border and placed as expected in the four corners.
static Border createLineBorder(int thickness)
          Creates a line border that uses the color of the component foreground for drawing.
static Border createLineBorder(int thickness, Color color)
          Creates a line border that uses the given color for the component.
 Border createPressedVersion()
          When applied to buttons borders produce a version that reverses the effects of the border providing a pressed feel.
static Border createRoundBorder(int arcWidth, int arcHeight)
          Creates a rounded corner border that uses the color of the component foreground for drawing.
static Border createRoundBorder(int arcWidth, int arcHeight, Color color)
          Creates a rounded border that uses the given color for the component.
static Border getDefaultBorder()
          Gets the default border to the given value.
static Border getEmpty()
          Returns an empty border, this is mostly useful for overriding components that have a border by default.
 Border getFocusedInstance()
          Returns the focused version of the border if one is installed.
 Border getPressedInstance()
          Returns the pressed version of the border if one is set by the user.
 boolean isBackgroundPainter()
          Returns true if installing this border will override the painting of the component background.
 void paint(Graphics g, Component c)
          Draws the border for the given component, this method is called before a call to background painting is made.
 void paintBorderBackground(Graphics g, Component c)
          Has effect when the border demands responsibility for background painting normally the painter will perform this work but in this case the border might do it instead.
static void setDefaultBorder(Border border)
          Sets the default border to the given value.
 void setFocusedInstance(Border focused)
          Allows us to define a border that will act as the focused version of this border.
 void setPressedInstance(Border pressed)
          Allows us to define a border that will act as the pressed version of this border.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Border

public Border()
Method Detail

getEmpty

public static Border getEmpty()
Returns an empty border, this is mostly useful for overriding components that have a border by default.

Returns:
a border than draws nothing

createEmpty

public static Border createEmpty()
Creates an empty border, this is useful where we don't want a border for a component but want a focus border etc...

Returns:
a border than draws nothing

createImageBorder

public static Border createImageBorder(Image top,
                                       Image bottom,
                                       Image left,
                                       Image right,
                                       Image topLeft,
                                       Image topRight,
                                       Image bottomLeft,
                                       Image bottomRight,
                                       Image background)
The given images are tiled appropriately across the matching side of the border and placed as expected in the four corners. The background image is optional and it will be tiled in the background if necessary.

By default this border does not override background unless a background image is specified.

Parameters:
top - the Image for the top side
bottom - the Image for the bottom side
left - the Image for the left side
right - the Image for the right side
topLeft - the Image for the top left corner
topRight - the Image for the top right corner
bottomLeft - the Image for the bottom left corner
bottomRight - the Image for the bottom right corner
background - the Image for the background
Returns:
new border instance

createImageBorder

public static Border createImageBorder(Image top,
                                       Image topLeft,
                                       Image background)
The given images are tiled appropriately across the matching side of the border, rotated and placed as expected in the four corners. The background image is optional and it will be tiled in the background if necessary.

By default this border does not override background unless a background image is specified.

Notice that this version of the method is potentially much more efficient since images are rotated internally and this might save quite a bit of memory!

The top and topLeft images must be square! The width and height of these images must be equal otherwise rotation won't work as you expect.

Parameters:
top - the Image for the top side
topLeft - the Image for the top left corner
background - the Image for the background
Returns:
new border instance

createLineBorder

public static Border createLineBorder(int thickness)
Creates a line border that uses the color of the component foreground for drawing.

Parameters:
thickness - thickness of the border in pixels
Returns:
new border instance

createLineBorder

public static Border createLineBorder(int thickness,
                                      Color color)
Creates a line border that uses the given color for the component.

Parameters:
thickness - thickness of the border in pixels
color - the color for the border
Returns:
new border instance

createRoundBorder

public static Border createRoundBorder(int arcWidth,
                                       int arcHeight)
Creates a rounded corner border that uses the color of the component foreground for drawing. Due to technical issues (lack of shaped clipping) performance and memory overhead of round borders can be low if used with either a bgImage or translucency!

This border overrides any painter used on the component and would ignore such a painter.

Parameters:
arcWidth - the horizontal diameter of the arc at the four corners.
arcHeight - the vertical diameter of the arc at the four corners.
Returns:
new border instance

createRoundBorder

public static Border createRoundBorder(int arcWidth,
                                       int arcHeight,
                                       Color color)
Creates a rounded border that uses the given color for the component. Due to technical issues (lack of shaped clipping) performance and memory overhead of round borders can be low if used with either a bgImage or translucency!

This border overrides any painter used on the component and would ignore such a painter.

Parameters:
arcWidth - the horizontal diameter of the arc at the four corners.
arcHeight - the vertical diameter of the arc at the four corners.
color - the color for the border
Returns:
new border instance

createEtchedLowered

public static Border createEtchedLowered()
Creates a lowered etched border with default colors, highlight is derived from the component and shadow is a plain dark color.

Returns:
new border instance

createEtchedLowered

public static Border createEtchedLowered(Color highlight,
                                         Color shadow)
Creates a raised etched border with the given colors.

Parameters:
highlight - color RGB value
shadow - color RGB value
Returns:
new border instance

createEtchedRaised

public static Border createEtchedRaised()
Creates a lowered etched border with default colors, highlight is derived from the component and shadow is a plain dark color.

Returns:
new border instance

createEtchedRaised

public static Border createEtchedRaised(Color highlight,
                                        Color shadow)
Creates a raised etched border with the given colors.

Parameters:
highlight - color RGB value
shadow - color RGB value
Returns:
new border instance

isBackgroundPainter

public boolean isBackgroundPainter()
Returns true if installing this border will override the painting of the component background.

Returns:
true if it is a background painter, false otherwise

createBevelLowered

public static Border createBevelLowered()
Creates a lowered bevel border with default colors, highlight is derived from the component and shadow is a plain dark color.

Returns:
new border instance

createBevelLowered

public static Border createBevelLowered(Color highlightOuter,
                                        Color highlightInner,
                                        Color shadowOuter,
                                        Color shadowInner)
Creates a raised bevel border with the given colors.

Parameters:
highlightOuter - RGB of the outer edge of the highlight area
highlightInner - RGB of the inner edge of the highlight area
shadowOuter - RGB of the outer edge of the shadow area
shadowInner - RGB of the inner edge of the shadow area
Returns:
new border instance

createBevelRaised

public static Border createBevelRaised()
Creates a lowered bevel border with default colors, highlight is derived from the component and shadow is a plain dark color.

Returns:
new border instance

createBevelRaised

public static Border createBevelRaised(Color highlightOuter,
                                       Color highlightInner,
                                       Color shadowOuter,
                                       Color shadowInner)
Creates a raised bevel border with the given colors.

Parameters:
highlightOuter - RGB of the outer edge of the highlight area
highlightInner - RGB of the inner edge of the highlight area
shadowOuter - RGB of the outer edge of the shadow area
shadowInner - RGB of the inner edge of the shadow area
Returns:
new border instance

setPressedInstance

public void setPressedInstance(Border pressed)
Allows us to define a border that will act as the pressed version of this border.

Parameters:
pressed - a border that will be returned by the pressed version method
See Also:
getPressedInstance()

setFocusedInstance

public void setFocusedInstance(Border focused)
Allows us to define a border that will act as the focused version of this border.

Parameters:
focused - a border that will be returned by the focused version method
See Also:
getFocusedInstance()

getFocusedInstance

public Border getFocusedInstance()
Returns the focused version of the border if one is installed.

Returns:
the focused version of the border if one is installed
See Also:
setFocusedInstance(com.sun.dtv.lwuit.plaf.Border)

getPressedInstance

public Border getPressedInstance()
Returns the pressed version of the border if one is set by the user.

Returns:
the pressed version of the border if one is set by the user
See Also:
setPressedInstance(com.sun.dtv.lwuit.plaf.Border)

createPressedVersion

public Border createPressedVersion()
When applied to buttons borders produce a version that reverses the effects of the border providing a pressed feel.

Returns:
a border that will make the button feel pressed

paintBorderBackground

public void paintBorderBackground(Graphics g,
                                  Component c)
Has effect when the border demands responsibility for background painting normally the painter will perform this work but in this case the border might do it instead.

Parameters:
g - graphics context to draw onto
c - component whose border should be drawn

paint

public void paint(Graphics g,
                  Component c)
Draws the border for the given component, this method is called before a call to background painting is made.

Parameters:
g - graphics context to draw onto
c - component whose border should be drawn

setDefaultBorder

public static void setDefaultBorder(Border border)
Sets the default border to the given value.

Parameters:
border - new border value
See Also:
getDefaultBorder()

getDefaultBorder

public static Border getDefaultBorder()
Gets the default border to the given value.

Returns:
the default border to the given value
See Also:
setDefaultBorder(com.sun.dtv.lwuit.plaf.Border)

Java DTV API 1.3
18-Nov-2009

Copyright © 2008-2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.