Eclipse Draw2d
2.1

org.eclipse.draw2d
Class TitleBarBorder

java.lang.Object
  |
  +--org.eclipse.draw2d.AbstractBorder
        |
        +--org.eclipse.draw2d.AbstractLabeledBorder
              |
              +--org.eclipse.draw2d.TitleBarBorder
All Implemented Interfaces:
Border, LabeledBorder

public class TitleBarBorder
extends AbstractLabeledBorder

Border provides a title bar on the Figure for which this is the border of. Generally used in conjunction with other borders to create window-like effects. Also provides for alignment of the text in the bar.

See Also:
FrameBorder

Field Summary
 
Fields inherited from class org.eclipse.draw2d.AbstractBorder
tempRect
 
Constructor Summary
TitleBarBorder()
          Constructs a TitleBarBorder with its label set to the name of this class.
TitleBarBorder(String s)
          Constructs a TitleBarBorder with its label set to the passed String.
 
Method Summary
protected  Insets calculateInsets(IFigure figure)
          Calculates and returns the Insets for this border.
protected  Color getBackgroundColor()
          Returns the background Color of this TitleBarBorder.
protected  Insets getPadding()
          Returns this TitleBarBorder's padding.
 int getTextAlignment()
          Returns the alignment of the text in the title bar.
 boolean isOpaque()
          Returns true if the Border completely fills the region defined in paint(IFigure, Graphics, Insets).
 void paint(IFigure figure, Graphics g, Insets insets)
          Paints the border.
 void setBackgroundColor(Color color)
          Sets the background color of the area within the boundaries of this border.
 void setPadding(Insets pad)
          Sets the padding space of this TitleBarBorder to the passed value.
 void setPadding(int all)
          Sets the padding space to be applied on all sides of the border.
 void setTextAlignment(int align)
          Sets the alignment of the text in the title bar.
 
Methods inherited from class org.eclipse.draw2d.AbstractLabeledBorder
getFont, getInsets, getLabel, getPreferredSize, getTextColor, getTextExtents, invalidate, setFont, setLabel, setTextColor
 
Methods inherited from class org.eclipse.draw2d.AbstractBorder
getPaintRectangle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TitleBarBorder

public TitleBarBorder()
Constructs a TitleBarBorder with its label set to the name of this class.

Since:
2.0

TitleBarBorder

public TitleBarBorder(String s)
Constructs a TitleBarBorder with its label set to the passed String.

Parameters:
s - Text of the label.
Since:
2.0
Method Detail

calculateInsets

protected Insets calculateInsets(IFigure figure)
Calculates and returns the Insets for this border.

Specified by:
calculateInsets in class AbstractLabeledBorder
Parameters:
figure - Figure on which Insets calculations are based.
Returns:
The calculated Insets.
Since:
2.0

getBackgroundColor

protected Color getBackgroundColor()
Returns the background Color of this TitleBarBorder.

Since:
2.0

getPadding

protected Insets getPadding()
Returns this TitleBarBorder's padding. Padding provides spacing along the sides of the TitleBarBorder.

Returns:
The Insets representing the space along the sides of the TitleBarBorder. Default value is no padding along all sides.
Since:
2.0

getTextAlignment

public int getTextAlignment()
Returns the alignment of the text in the title bar. Values permitted are as defined in the PositionConstants interface.

Returns:
Alignment of the text as an integer.
Since:
2.0
See Also:
PositionConstants, setTextAlignment(int)

isOpaque

public boolean isOpaque()
Description copied from interface: Border
Returns true if the Border completely fills the region defined in Border.paint(IFigure, Graphics, Insets).

Specified by:
isOpaque in interface Border
Overrides:
isOpaque in class AbstractBorder
Returns:
true if this border is opaque

paint

public void paint(IFigure figure,
                  Graphics g,
                  Insets insets)
Description copied from interface: Border
Paints the border. The border should paint inside figure's IFigure.getBounds(), inset by the parameter insets. The border generally should not paint inside its own insets. More specifically, Border b should paint inside the rectangle: figure.getBounds().getCropped(insets) and outside of the rectangle: figure.getBounds().getCropped(insets).getCropped(getInsets()) where inside is defined as Rectangle.contains(int, int).

Parameters:
figure - The figure this border belongs to
g - The graphics object used for painting
insets - The insets

setBackgroundColor

public void setBackgroundColor(Color color)
Sets the background color of the area within the boundaries of this border. This is required as this border takes responsibility for filling up the region, as TitleBarBorders are always opaque.

Parameters:
color - Color of the backround.
Since:
2.0
See Also:
isOpaque()

setPadding

public void setPadding(int all)
Sets the padding space to be applied on all sides of the border. Default value is no padding on all sides.

Parameters:
all - Value of the padding on all sides.
Since:
2.0

setPadding

public void setPadding(Insets pad)
Sets the padding space of this TitleBarBorder to the passed value. Default value is no padding on all sides.

Parameters:
pad - Specific values of padding set to specific sides.
Since:
2.0

setTextAlignment

public void setTextAlignment(int align)
Sets the alignment of the text in the title bar. Values can be as defined in the PositionConstants interface.

Parameters:
align - Value of the alignment.
Since:
2.0
See Also:
PositionConstants, getTextAlignment()

Eclipse Draw2d
2.1

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.