[Eclipse] GEF Introduction Series (I. draw2d)

Source: Internet
Author: User
Tags requires

About java2d believe that everyone will not be unfamiliar, it is based on the awt/swing two-dimensional graphics processing package, the JDK included with the sample program to show us the java2d very powerful graphics processing capabilities. SWT applications have been downwind in this way before the advent of draw2d, and draw2d, the java2d of the SWT world, has changed the situation.

Many people may not know much about the relationship between GEF and DRAW2D: Some applications use only draw2d and look similar to GEF applications. Why, let's briefly explain:

GEF is a graphical editing framework with standard MVC (Model-view-control) architecture, in which model is designed by ourselves based on the business to provide a mechanism for some kind of model change notification to tell the control layer about changes to the models The control layer is implemented by some Editpart, Editpart is the core component of GEF as a whole, and the mechanism and functions of editpart will be introduced in future posts, and the view layer (in most cases) is the draw2d we are going to say here. Its role is to the model in a graphical way to show to users.

Although GEF can use any graphic package as the view layer, the fact that GEF relies on draw2d is strong. For example: Although the EditPart (Org.eclipse.gef.EditPart) interface does not require the introduction of any draw2d classes, the createfigure of the Abstractgraphicaleditpart class we use most often () method requires that you return the Ifigure type. For this reason, it is not surprising that the GEF SDK simply contains the draw2d package, and that, by the same token, it is possible to master GEF only if you understand draw2d first.

In this way, the questions raised at the outset can be summarized as follows: DRAW2D is a graphics processing package based on SWT that is suitable for use as a view layer for GEF. If an application only needs to display graphics, it is enough to use only draw2d; If the application's model requires editing in a graphical manner, it is best to use the GEF framework.

Now let's see what's in the draw2d, look at the picture below.

Fig. 1 Structure of draw2d

DRAW2D is connected to one of the canvas instances in SWT through a widget called Lightweightsystem (LWS), which is typically the application shell in the canvas application, and more in the GEF application A editor control (Createpartcontrol () method), in which we do not see the presence of LWS, but all the other graphics that can be seen are placed inside it, which form a tree-like hierarchy by the parent-child inclusion relationship.

LWS is the core component of draw2d, which contains three main components: Rootfigure is the root of all graphics in LWS, that is to say, all other shapes are directly or indirectly placed in Rootfigure; Eventdispatcher the various Events are assigned to Rootfigure, and these events are eventually assigned to the appropriate graphics, note that this rootfigure is not the same object as the topmost ifigure in your application, which is invisible and used internally by LWS, which is usually a visible canvas, It is placed directly in the former; Updatemanager is used to redraw the graph, and when canvas is asked to redraw, LWS calls its performupdate () method.

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.