Eclipse Draw2d
2.1

Eclipse Draw2d API Specification

Introduction to Draw2d Draw2d is a lightweight widget system that is hosted on an SWT Composite.

See:
          Description

Packages
org.eclipse.draw2d Most of the Draw2d classes and interfaces reside in this base package.
org.eclipse.draw2d.geometry This package contains useful geometry related classes, such as Rectangle and Point.
org.eclipse.draw2d.parts This package contains some complex parts used with Draw2d.
org.eclipse.draw2d.text  
org.eclipse.draw2d.widgets  

 

Introduction to Draw2d

Draw2d is a lightweight widget system that is hosted on an SWT Composite.  A Draw2d instance consists of an SWT Composite, a Lightweight System, and its contents: figures.  Figures are the building blocks for Draw2d.  Here is how "Hello World" translates into a draw2d program:

Listing for "Hello World"
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.SWT;

import org.eclipse.draw2d.*;
import org.eclipse.draw2d.geometry.*;

public class HelloWorld {
	public static void main(String args[]){
		Shell shell = new Shell();
		shell.open();
		shell.setText("Draw2d Hello World");
		LightweightSystem lws = new LightweightSystem(shell);
		IFigure label = new Label("Hello World");
		lws.setContents(label);
		Display display = Display.getDefault();
		while (!shell.isDisposed ()) {
			if (!display.readAndDispatch ())
				display.sleep ();
		}
	}
}

Running this will result in:

What's going on?

The LightweightSystem is the "glue" for Draw2d.  You provide the SWT composite and the root of the figure hierarchy that you want rendered, and the LightweightSystem sets up the rest with default values.  "The rest" consists of an EventDispatcher, which handles SWT events and dispatches them to figures , and an UpdateManager, which handles layout and repaint requests from the figures in that system.

 

More Examples

Demo2
This example shows basic use of a layout manager and how to create some of the provided figures.
 
  Demo3
This example demonstrates button use and the dynamic laying out of figures.  It also shows how to use a ScrollPane
Demo 4
This example demonstrates the usage of a Connection Figure.   It demonstrates how to decorate the connection, and simple routing support.
 

 


Eclipse Draw2d
2.1

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.