Class LineBorder

All Implemented Interfaces:
Border

public class LineBorder extends AbstractBorder
Provides for a line border with sides of equal widths.
  • Constructor Details

    • LineBorder

      public LineBorder(Color color, int width, int style)
      Constructs a LineBorder with the specified color and of the specified width and style.
      Parameters:
      color - The color of the border.
      width - The width of the border in pixels.
      style - The style of the border. For the list of valid values, see Graphics
      Since:
      3.5
    • LineBorder

      public LineBorder(Color color, int width)
      Constructs a LineBorder with the specified color and of the specified width.
      Parameters:
      color - The color of the border.
      width - The width of the border in pixels.
      Since:
      2.0
    • LineBorder

      public LineBorder(Color color)
      Constructs a LineBorder with the specified color and a width of 1 pixel.
      Parameters:
      color - The color of the border.
      Since:
      2.0
    • LineBorder

      public LineBorder(int width)
      Constructs a black LineBorder with the specified width.
      Parameters:
      width - The width of the border in pixels.
      Since:
      2.0
    • LineBorder

      public LineBorder()
      Constructs a default black LineBorder with a width of one pixel.
      Since:
      2.0
  • Method Details

    • getColor

      public Color getColor()
      Returns the line color of this border.
      Returns:
      The line color of this border
    • getInsets

      public Insets getInsets(IFigure figure)
      Returns the space used by the border for the figure provided as input. In this border all sides always have equal width.
      Parameters:
      figure - The figure this border belongs to
      Returns:
      This border's insets
    • getWidth

      public int getWidth()
      Returns the line width of this border.
      Returns:
      The line width of this border
    • isOpaque

      public boolean isOpaque()
      Returns true since this border is opaque. Being opaque it is responsible to fill in the area within its boundaries.
      Specified by:
      isOpaque in interface Border
      Overrides:
      isOpaque in class AbstractBorder
      Returns:
      true since this border is opaque
      See Also:
    • paint

      public void paint(IFigure figure, Graphics graphics, Insets insets)
      Description copied from interface: Border
      Paints the border. The border should paint inside figure's IFigure.getBounds(), inset by the parameter insets. The border generally should not paint inside its own insets. More specifically, Border b should paint inside the rectangle: figure.getBounds().getCropped(insets) and outside of the rectangle: figure.getBounds().getCropped(insets).getCropped(getInsets()) where inside is defined as Rectangle.contains(int, int).
      Parameters:
      figure - The figure this border belongs to
      graphics - The graphics object used for painting
      insets - The insets
      See Also:
    • setColor

      public void setColor(Color color)
      Sets the line color for this border.
      Parameters:
      color - The line color
    • setWidth

      public void setWidth(int width)
      Sets the line width for this border.
      Parameters:
      width - The line width
    • getStyle

      public int getStyle()
      Returns the line style for this border.
      Returns:
      The line style for this border
      Since:
      3.5
    • setStyle

      public void setStyle(int style)
      Sets the line type of this border.
      Parameters:
      style - For the list of valid values, see Graphics
      Since:
      3.5