Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » [zest] Set Text For Ellipse
[zest] Set Text For Ellipse [message #249089] Mon, 01 June 2009 13:16
jeffty is currently offline jefftyFriend
Messages: 2
Registered: July 2009
Junior Member
Am a new user of zest and I want to change the shape of GraphNode to

I tried many times but failed to add text for the ellipse. Now the
GraphNode's shape is changed to ellipse but I can't set text for it.

After that I want to pop up window and show the information of GraphNodes
when user double clicks the GraphNodes and GraphConnection. Unfortunately
I find I can't get the selected Node or Connection directly.

Instead of that I get the GraphLabel and PolylineConnection from
'g.getFigureAt()'. So I should list all of the GraphNodes with
'g.getNodes()' and check their text one by one to find the selected Nodes?

My class looks like:

public class MyGraphNode extends GraphNode {

public MyGraphNode(IContainer graphModel, int style, String text) {
super(graphModel, style, text);

protected IFigure createFigureForModel() {
Ellipse ellipse = new Ellipse();
ellipse.setSize(30, 20);
return ellipse;

public static void main(String[] args) {

Display d = new Display();
Shell shell = new Shell(d);
shell.setLayout(new FillLayout());
shell.setSize(400, 400);
final Graph g = new Graph(shell, SWT.NONE);

g.addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(MouseEvent e) {
Object o = g.getFigureAt(e.x, e.y);

if (o instanceof GraphLabel) {
String labelText = ((GraphLabel) o).getText();

GraphNode n;
for (Object node : g.getNodes()) {
if (((GraphNode) node).getText().equalsIgnoreCase(
labelText)) {
n = (GraphNode) node;

// ....

} else if (o instanceof PolylineConnection) {
// ....

GraphNode n = new MyGraphNode(g, SWT.NONE, "1");
GraphNode n2 = new GraphNode(g, SWT.NONE, "normal");

new GraphConnection(g, SWT.NONE, n, n2);

g.setLayoutAlgorithm(new SpringLayoutAlgorithm(
LayoutStyles.NO_LAYOUT_NODE_RESIZING), true);;
while (!shell.isDisposed()) {
while (!d.readAndDispatch()) {



Thanks in advance.
Previous Topic:Clipping area
Next Topic:Undo Redo retagets never activate for my EditorPart
Goto Forum:

Current Time: Thu Apr 26 06:11:36 GMT 2018

Powered by FUDForum. Page generated in 0.01196 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software