Package 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
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 edu.hws.jcm.draw.Drawable
getVisible, needsRedraw, setOwnerData, setVisible
-
-
-
-
Constructor Detail
-
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.
-
-
Method Detail
-
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.- Specified by:
draw
in classDrawable
- 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.)changed
- Indicates whether the CoordinateRect has changed.
-
-