Class DrawBorder

java.lang.Object
edu.hws.jcm.draw.Drawable
edu.hws.jcm.draw.DrawBorder
All Implemented Interfaces:
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:
  • Field Details

    • color

      protected 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.
  • Constructor Details

    • DrawBorder

      public DrawBorder()
      Create a black border that is one pixel thick.
    • DrawBorder

      public DrawBorder(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 Details

    • getColor

      public Color getColor()
      Get the color of the border.
    • setColor

      public void setColor(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(Graphics g, boolean changed)
      Draw the border in the given graphics context. This is not ordinarily called directly.
      Specified by:
      draw in class 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.)
      changed - Indicates whether the CoordinateRect has changed.