Search
Brush and Pen Classes

Brush Classes

JDiagram defines classes that encapsulate the Paint and Stroke classes of Java. There are four brush classes that inherit the abstract Brush class, namely HatchBrush, GradientBrush, SolidBrush and TextureBrush.

HatchBrush allows filling the interiors of objects with a hatch pattern. Supported patterns are exposed as members of the HatchStyle class.

The GradientBrush class provides a gradient brush which paints the interior of objects starting with one color and gradually changing to another color by interpolating the RGB values of the two colors. His getColor1 method gets the first gradient color, and getColor2 gets second gradient color. The getAngle method gets the gradient orientation angle.

The SolidBrush class represents a brush for painting the interior of objects with a single color. His getColor method gets the color that fills the interior of objects.

The TextureBrush class defines a brush that fills the interior of objects with a texture pattern. The getTexture and setTexture methods allow specifying a texture pattern.

A brush is assigned to an item by calling the setBrush method. To set the diagram's background brush, perform the setBackBrush method. The setLinkBrush method assigns a default brush to new links.

The Pen Class

The Pen class allows specifying the pen for items, shapes, table nodes, links, and container frame lines. To get and/or set the pen color, use the getColor and/or setColor methods. The getWidth and setWidth methods enable indicating the width of the lines drawn with the pen.

To assign a pen to an item, call the setPen method. The setLinkPen method allows assigning the default pen to new links.

To set the default pen that should be assigned to new nodes, call the setShapePen method.

The setTablePen method allows specifying the pen for TableNode objects.

Use the setBoundsPen method to assign the pen for drawing the diagram bounds.

The Diagram.setContainerHighlightPen and ContainerNode.setHighlightPen methods set the Pen for drawing the container frame lines when an item is dragged over the container.