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
Hi,

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 {
	
	@Override
	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:
www.eclipse.org/forums/index.php/m/886620/

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:example GEF
Next Topic:curved connections
Goto Forum:
  


Current Time: Mon Dec 22 09:20:32 GMT 2014

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

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