Previous posts have said how to use the layout, which was focused on Toolbarlayout and FlowLayout (collectively orderedlayout), and many applications use a layout that allows you to drag the child graph freely, called xylayout in GEF, And this kind of application will probably need to create some connecting lines between the graphs, such as the scene shown in the following picture. The presence of the connection increases the complexity of the model to some extent, and the refresh of the connector is also a concern of GEF, which focuses on the implementation of such applications, and specifically discusses the implementation of the expand/collapse (expand/collapse) feature.
Figure 1 Application using Xylayout
Or from the beginning of the model, when using Xylayout, the model corresponding to each child graph maintains its own coordinates and dimension information, which introduces some member variables that are unrelated to the actual business in the model. To solve this problem, we typically have all model elements that need to have these interface information inherited from an abstract class such as node, which provides variables such as point, dimension, and Getter/setter methods:
public class Node extends Element implements IPropertySource {
protected Point location = new Point(0, 0);//位置
protected Dimension size = new Dimension(100, 150);//尺寸
protected String name = "Node";//标签
protected List outputs = new ArrayList(5);//节点作为起点的连接
protected List inputs = new ArrayList(5);//节点作为终点的连接
…
}