edu.hws.jcm.draw
Class DrawBorder
java.lang.Object
|
+--edu.hws.jcm.draw.Drawable
|
+--edu.hws.jcm.draw.DrawBorder
- All Implemented Interfaces:
- java.io.Serializable
- public class DrawBorder
- extends Drawable
A DrawBorder object is just a simple border around the edges of its CoordinateRect, with
a specified width, in pixels, and a specified color.
- See Also:
- Serialized Form
Field Summary |
protected java.awt.Color |
color
A non-null Color, giving the color of the bortder. |
protected int |
width
A non-negative integer giving the width of the border in pixels. |
Constructor Summary |
DrawBorder()
Create a black border that is one pixel thick. |
DrawBorder(java.awt.Color color,
int width)
Create a border with the spcified color and width. |
Method Summary |
void |
draw(java.awt.Graphics g,
boolean changed)
Draw the border in the given graphics context. |
java.awt.Color |
getColor()
Get the color of the border. |
int |
getWidth()
Get the width of the border, in pixels. |
void |
setColor(java.awt.Color c)
Set the color of the border to the specified color. |
void |
setWidth(int w)
Set the width of the border to be w pixels. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
color
protected java.awt.Color color
- A non-null Color, giving the color of the bortder.
width
protected int width
- A non-negative integer giving the width of the border in pixels.
DrawBorder
public DrawBorder()
- Create a black border that is one pixel thick.
DrawBorder
public DrawBorder(java.awt.Color color,
int width)
- Create a border with the spcified color and width. If the color is null,
black is used. If the width is less than zero, a width of 1 is used.
A border of width zero is invisible.
getColor
public java.awt.Color getColor()
- Get the color of the border.
setColor
public void setColor(java.awt.Color c)
- Set the color of the border to the specified color. If the color is null, nothing is done.
getWidth
public int getWidth()
- Get the width of the border, in pixels.
setWidth
public void setWidth(int w)
- Set the width of the border to be w pixels. If w is negative,
this is ignored. A border of witdth 0 is invisible.
- Parameters:
w
- the desired width for the border.
draw
public void draw(java.awt.Graphics g,
boolean changed)
- Draw the border in the given graphics context. This is not ordinarily called directly.
- Overrides:
draw
in class Drawable
- Following copied from class:
edu.hws.jcm.draw.Drawable
- Parameters:
g
- The graphics context in which the Drawble is to be drawn. (The drawing
can change the color in g, but should not permanently change font, painting mode, etc.
Thus, every drawable is responsible for setting the color it wants to use.)coordsChanged
- Indicates whether the CoordinateRect has changed.