[Eclipse] GEF Getting Started series (V, talking about layout)

Source: Internet
Author: User

While many GEF applications use connections (Connection), there are applications that do not need to be connected to express relationships, and the project we are currently working on is one such example. In such applications, the relationship between model objects is mainly expressed by the inclusion of graphs, so most of them are one-to-many relationships.

Figure 1 GEF applications that do not use connections

First of all, a brief description of our project, the project needs a graphical model editor, the main function is in a table with three rows n columns to add/remove nodes, nodes can be dragged between different cells, you can merge adjacent nodes, table columns can be added or subtracted, drag and so on. Since the tables provided by Swt/jface are difficult to implement, we have chosen to use GEF development, and it seems to be working well (see figure below), and here is a brief introduction to some of the problems associated with graphics and layout during implementation.

Before you start, consider the structure of the model. Since draw2d only provides very limited layout, such as Toolbarlayout, FlowLayout and Xylayout, and does not have a gridlayout, the entire table cannot be used as a editpart, Instead, you should think of each column as a editpart (because there are more operations on the column than the row, so you don't use the row as Editpart) to implement the drag of the column. In addition, as can be seen from the requirements, each node is contained in a column, but a closer look will find that the node is not directly contained in the column, but rather that there is a single Cell object as the middle bridge, that is, each column contains a fixed three cells, each cell can contain any node. Through the above analysis, our model, editpart and figure should have been preliminarily formed, see the following table:

  model editpart figure
canvas diagram diagrampart columns column columnpart columnfigure
cell c Ell cellfigure
node node nodepart nodefigure

The top to bottom of a table is a relationship, which is a one-to-many relationship, and the following illustration shows these relationships in simple terms:

Figure 2 Graph contains diagram

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.