Drawing Rectangles

Published — Edited

The following sections cover the constructor and functions of the RectanglePrinter class.

Links

RectanglePrinter()

This constructor creates a new, reusable RectanglePrinter.

The following example shows that you do not need to create a new instance of the RectanglePrinter class for every rectangle that you print.

setWidth()

This function sets the width, in tiles, of the rectangle that the RectanglePrinter will print.

setHeight()

This function sets the height, in tiles, of the rectangle that the RectanglePrinter will print.

print(TileGrid, Point)

This function prints a rectangle on a TileGrid. The point given is the top-left point/tile of the rectangle.

If two rectangles, of the same RectangleType, overlap when drawn, then the RectanglePrinter will automatically connect the rectangles together using the appropriate connection characters.

printFilled(TileGrid, Point)

This function prints a filled rectangle on a TileGrid. The point given is the top-left point/tile of the rectangle.

setFillChar(int)

This function sets the character used to fill the rectangle, when using the printFilled(TileGrid, Point) function.

setTitle(String)

This function sets the title to be displayed along the top border of the rectangle.

setRectangleType(RectangleType)

This function sets the RectangleType to use when printing the rectangle. A RectangleType defines the top-left, top-right, bottom-left, bottom-right, horizontal, vertical, and other connecting characters used to display a rectangle.

The following image shows a number of the RectangleTypes that you can use.