Custom Figures for Connections in Zest [message #889909] |
Wed, 20 June 2012 08:23 |
Saurabh Srivastava 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.
|
|
|
|
Powered by
FUDForum. Page generated in 0.01339 seconds