sears.search.gui
Class PillShape

java.lang.Object
  extended by sears.search.gui.PillShape
All Implemented Interfaces:
java.lang.Cloneable, GPShape

public class PillShape
extends java.lang.Object
implements GPShape, java.lang.Cloneable


A PillShape is a rounded bordered rectangle with text inside.


Field Summary
protected static java.awt.Composite ALPHA_COMPOSITE
           
protected static float BORDER_STROKE
          stroke use for line limit
protected static float DECAY
           
protected static int EXPANDED
           
protected static int EXPANDED_HEIGHT
          expanded height factor
protected static int EXPANDED_WIDTH
          expanded width factor
protected static java.awt.Color PILL_BACKGROUND_COLOR
          pill background color
protected static java.awt.Color PILL_FOREGROUND_COLOR
          pill foreground color
protected static int ROUNDED_ARC
          arc factor, use or the rounded rectangle
protected static java.awt.Stroke STROKE
           
 
Constructor Summary
PillShape(java.awt.Font font, java.awt.Rectangle bounds, java.lang.String text)
          Creates a new instance of PillShape by passing ...
 
Method Summary
protected  java.lang.Object clone()
          Calls the super method and catch the clone exception if occurs.
 java.awt.Color getBackground()
          Gets the background color
 java.awt.Shape getBounds()
          Returns a RoundRectangle2D object, represents the real bounds of this shape
protected  PillShape getClone()
          Gets a clone of the PillShape object
 java.awt.Color getForeground()
          Gets the foreground color
 PillShape getPillInstance(java.awt.Font newFont, java.awt.Rectangle newBounds, java.lang.String newText, java.awt.Point newLocation)
          Gets an instance of the object with a new data set
Optimization...
 void paint(java.awt.Graphics2D gr)
          Paint the GPShape using the graphics context given in parameters
 void setBackground(java.awt.Color background)
          Sets the background color for the pill
 void setForeground(java.awt.Color foreground)
          Sets the foreground color for the pill
Foreground color is used for the text inside and pill's border
 void translate(int x, int y)
          Translates the GPShape object to the new given coordinates.
 void translate(java.awt.Point point)
          Translates the GPShape object to the new given point location.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXPANDED

protected static final int EXPANDED
See Also:
Constant Field Values

EXPANDED_HEIGHT

protected static final int EXPANDED_HEIGHT
expanded height factor

See Also:
Constant Field Values

EXPANDED_WIDTH

protected static final int EXPANDED_WIDTH
expanded width factor

See Also:
Constant Field Values

DECAY

protected static final float DECAY
See Also:
Constant Field Values

ROUNDED_ARC

protected static final int ROUNDED_ARC
arc factor, use or the rounded rectangle

See Also:
Constant Field Values

BORDER_STROKE

protected static final float BORDER_STROKE
stroke use for line limit

See Also:
Constant Field Values

PILL_FOREGROUND_COLOR

protected static final java.awt.Color PILL_FOREGROUND_COLOR
pill foreground color


PILL_BACKGROUND_COLOR

protected static final java.awt.Color PILL_BACKGROUND_COLOR
pill background color


STROKE

protected static final java.awt.Stroke STROKE

ALPHA_COMPOSITE

protected static final java.awt.Composite ALPHA_COMPOSITE
Constructor Detail

PillShape

public PillShape(java.awt.Font font,
                 java.awt.Rectangle bounds,
                 java.lang.String text)
Creates a new instance of PillShape by passing ...

WARNING:
This class is a beta class, so there's some limitation:
The parameter bounds must be the bounds of the text string
There's no control of any sort about this coherence, so use at your own risk.

Parameters:
font - the font
bounds - the text bounds
text - the text
Throws:
java.lang.NullPointerException - if at least one of the given parameters is null
Method Detail

setBackground

public void setBackground(java.awt.Color background)
Sets the background color for the pill

Parameters:
background - the background color, if null the default background color will be used

setForeground

public void setForeground(java.awt.Color foreground)
Sets the foreground color for the pill
Foreground color is used for the text inside and pill's border

Parameters:
foreground - the foreground color, if null the default foreground color will be used

getForeground

public java.awt.Color getForeground()
Gets the foreground color

Returns:
the foreground color

getBackground

public java.awt.Color getBackground()
Gets the background color

Returns:
the foreground color

getBounds

public java.awt.Shape getBounds()
Returns a RoundRectangle2D object, represents the real bounds of this shape

Specified by:
getBounds in interface GPShape
Returns:
the shape bounds
See Also:
GPShape.getBounds()

paint

public void paint(java.awt.Graphics2D gr)
Description copied from interface: GPShape
Paint the GPShape using the graphics context given in parameters

Specified by:
paint in interface GPShape
Parameters:
gr - the graphics context

translate

public void translate(int x,
                      int y)
Description copied from interface: GPShape
Translates the GPShape object to the new given coordinates.

Specified by:
translate in interface GPShape
Parameters:
x - the new x coordinates.
y - the new y coordinates.

translate

public void translate(java.awt.Point point)
Description copied from interface: GPShape
Translates the GPShape object to the new given point location.

Specified by:
translate in interface GPShape
Parameters:
point - the new point location

clone

protected java.lang.Object clone()
Calls the super method and catch the clone exception if occurs.
The result of catching exception is that a null object could be returned

Overrides:
clone in class java.lang.Object
Returns:
a clone Object or null if the super method failed to clone the object
See Also:
Object.clone()

getClone

protected PillShape getClone()
Gets a clone of the PillShape object

Returns:
a PillShape object or null if clone() method failed

getPillInstance

public PillShape getPillInstance(java.awt.Font newFont,
                                 java.awt.Rectangle newBounds,
                                 java.lang.String newText,
                                 java.awt.Point newLocation)
Gets an instance of the object with a new data set
Optimization...

Parameters:
newFont - the font to associate to the pill
newBounds - the text bounds
newText - the text
newLocation - the pill location
Returns:
a Pill object