Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Custom Figures for Connections in Zest(How can we add our own Custom Connection Figures in a Graph using Zest)
Custom Figures for Connections in Zest [message #889909] Wed, 20 June 2012 08:23 Go to next message
Saurabh Srivastava is currently offline Saurabh SrivastavaFriend
Messages: 7
Registered: June 2012
Junior Member

I am new to Zest, though I have worked significantly in Draw2d. I have made Custom Figures and Connections using Draw2d. Since now I am building a Graph Drawing Application, Zest seems to be an obvious Choice.

Coming to the Point,I have a Label Provider for my Application, which implements IFigureProvider Interface. I made two Custom Classes, one each for creating Node Figures and Connection Figures. However, the method getFigure gets called only for Nodes and not Connections. Any idea how I can achieve that? My Label Provider is as follows:

package viewer;

import model.MyConnection;
import model.MyNode;

import org.eclipse.draw2d.IFigure;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.zest.core.viewers.EntityConnectionData;
import org.eclipse.zest.core.viewers.IFigureProvider;

import figure.NodeFigure;

public class ZestLabelProvider extends LabelProvider implements IFigureProvider {
	public String getText(Object element) {
		if (element instanceof MyNode) {
			MyNode myNode = (MyNode) element;
			return myNode.getName();
		// Not called with the IGraphEntityContentProvider
		if (element instanceof MyConnection) {
			MyConnection myConnection = (MyConnection) element;
			return myConnection.getLabel();

		if (element instanceof EntityConnectionData) {
			EntityConnectionData test = (EntityConnectionData) element;
			return "";
		throw new RuntimeException("Wrong type: "
				+ element.getClass().toString());

	public IFigure getFigure(Object element) {
		IFigure figure = null;
		if(element instanceof MyNode) {
			figure = new NodeFigure((MyNode)element);
			figure.setSize(-1, -1);
		//Doesn't get Called
		/*else if(element instanceof MyConnection) {
			figure = new ConnectionFigure();
			figure.setSize(-1, -1);
		return figure;

I have already seen the topic:

But that is not what I want to do. I am sure there's a better way for this. Looking for a reply.
Re: Custom Figures for Connections in Zest [message #891491 is a reply to message #889909] Mon, 25 June 2012 05:28 Go to previous message
Saurabh Srivastava is currently offline Saurabh SrivastavaFriend
Messages: 7
Registered: June 2012
Junior Member
Any Help or even Hints would be valuable.
Previous Topic:Zest Bug - Small Nodes
Next Topic:Integrate tree drawing algorithm in GEF editor?
Goto Forum:

Current Time: Mon Jun 25 02:20:27 GMT 2018

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

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

Back to the top