Package edu.hws.jcm.draw
Class DrawBorder
java.lang.Object
edu.hws.jcm.draw.Drawable
edu.hws.jcm.draw.DrawBorder
- All Implemented Interfaces:
Serializable
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Color
A non-null Color, giving the color of the bortder.protected int
A non-negative integer giving the width of the border in pixels. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a black border that is one pixel thick.DrawBorder
(Color color, int width) Create a border with the spcified color and width. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Draw the border in the given graphics context.getColor()
Get the color of the border.int
getWidth()
Get the width of the border, in pixels.void
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
-
Field Details
-
color
A non-null Color, giving the color of the bortder. -
width
protected int widthA non-negative integer giving the width of the border in pixels.
-
-
Constructor Details
-
DrawBorder
public DrawBorder()Create a black border that is one pixel thick. -
DrawBorder
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 Details
-
getColor
Get the color of the border. -
setColor
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
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.
-