Using ConnectionTool
ConnectionTool is an implementation of the Prototype design pattern. ConnectionTool can be parameterised to create any kind of ConnectionFigure. To create the tool call the ConnectionTool constructor and pass into it an instance (the Prototype) of the type of ConnectionFigure you want to create.
protected
void createTools(Panel palette){
super.createTools(palette);
... define other tools here
ConnectionTool connectionTool = new connectionTool(new LineConnection());
//add a button to the toolbar that represents the tool
}
Tools are represented in the applications GUI as a button.
The ConnectionTool automatically provides the behaviour for setting the end points of a connection (i.e. when the tool is selected, using the mouse click on a figure to start the connection then drag the mouse to another figure to end the connection).