DiagramLinks-s consist of series of straight or Bezier segments and arrowhead shapes. The link and arrowhead shapes, and also color attributes and text can be customized as detailed below: Customizing the shape of a linkYour link can be straight or curved and can have one or more segments. Call DiagramLink.setShape to change the shape. It takes as an argument one of the LinkShape enumeration values:
The link can further be customized by changing its control points - they specify the position of the link. The number of control points depends on the LinkShape: Bezier links have four control points per segment. Each straight segment has two control points. Adjacent segments share a control point. The following code sets three control points of a polyline link which has two segments:
Customizing the arrowheadsEach link can start and end with a shape. The shape at the start is called BaseShape, the shape at the end is called HeadShape. The methods that set the shapes are setBaseShape and setHeadShape. They take as argument either the Shape to set or a string that identifies it:
The Shape identifiers are also exposed as static members of the Shapes class. Choosing colorsThe shapes at the head and base are filled with HeadBrush and BaseBrush. To access them use setHeadBrush and setBaseBrush as shown below:
Setting textUse setText to set a label of your link, setFont specifies the font. Here is an example how to do this:
|