Customising Edge styles [message #1775211] |
Thu, 26 October 2017 11:13 |
|
Hi,
We are currently trying to customise the style of edges in our editor. Instead of the three line styles (Straight/Tree/Manhattan) provided by Sirius/GMF. We want to implement a edge what is actually a cubic curve. Is there anyway that we could provide an edit part for the edges? Any pointer to that direction is hugely appreciated.
Cheers,
Will
Research Associate
Department of Computer Science
University of York
|
|
|
|
Re: Customising Edge styles [message #1775295 is a reply to message #1775226] |
Fri, 27 October 2017 09:59 |
|
Hi Pierre,
Thanks very much for your response.
We have tried providing cutomised EditParts through the EditPartProviders extension of GMF. As a matter of fact all our shapes need a customised EditPart.
As far as I understand, what you suggested is to create the Edges as they are in the odesign file, and then in the EditPart Provider we look for Edges and return our customised EditPart?
If this is the case, could you please point me to the direction which class to extend? For example, for nodes we extend AbstractNotSelectableShapeNodeEditPart. What of edges?
Cheers,
Ran
Research Associate
Department of Computer Science
University of York
|
|
|
Re: Customising Edge styles [message #1775465 is a reply to message #1775295] |
Mon, 30 October 2017 14:07 |
Pierre Guilet Messages: 250 Registered: June 2017 |
Senior Member |
|
|
Hi,
You have well understood what I suggested.
The class to extend is AbstractDiagramEdgeEditPart.
Regarding your need are you aware of the option "Smoothness" that seems to fit well?
To test it just select an edge and in the "properties view" activate the smoothness in "appearence" tab to have curved edges:
Though this option need to be manually activated for all edges with default mechanism.
So your custom edge part can activate by default this option.
Regards,
Pierre
Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
[Updated on: Mon, 30 October 2017 15:09] Report message to a moderator
|
|
|
Re: Customising Edge styles [message #1776185 is a reply to message #1775465] |
Mon, 13 November 2017 14:05 |
|
Hi Pierre,
Thank you very much for your reply. I have tried the smooth edge, unfortunately it does not meet our requirement.
I have implemented a editpart for the edge. However i have ran into some other problems.
See this is the code for my editpart:
public class EdgeEditPart extends AbstractDiagramEdgeEditPart implements IStyleEditPart{
public EdgeEditPart(View view) {
super(view);
}
public DragTracker getDragTracker(Request request) {
return getParent().getDragTracker(request);
}
@Override
protected Connection createConnectionFigure() {
Figure figure = new EdgePipeConnection();
return (Connection) figure;
}
}
The EdgePipeConnection is a subclass of PolylineConnectionEx, we have tried PolylineConnection but it gives me a IllegalStateException. However, when I tried PolylineConnectionEx, we had this exception:
java.lang.NullPointerException
at org.eclipse.draw2d.Figure.add(Figure.java:149)
at org.eclipse.draw2d.Figure.add(Figure.java:185)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.addChildVisual(AbstractGraphicalEditPart.java:209)
at org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:211)
at org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart.addChild(ConnectionEditPart.java:213)
at org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(AbstractEditPart.java:781)
at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:726)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:644)
at org.eclipse.gef.editparts.AbstractConnectionEditPart.refresh(AbstractConnectionEditPart.java:226)
at org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart.access$1(ConnectionEditPart.java:1)
at org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart$5.run(ConnectionEditPart.java:1127)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
Which is telling me that the parent of the figure is null. Do you have any idea how to solve this please?
Cheers,
Ran
Research Associate
Department of Computer Science
University of York
|
|
|
|
Re: Customising Edge styles [message #1776320 is a reply to message #1776317] |
Wed, 15 November 2017 10:28 |
|
Hi Pierre,
As previously discussed, I provide a EditPartProvider, this is the code of my implmentation:
public class TreeEditPartProvider extends AbstractEditPartProvider {
public TreeEditPartProvider() {
super();
}
@Override
protected Class<?> getNodeEditPartClass(View view) {
if (view.getElement() instanceof CustomStyle) {
CustomStyle customStyle = (CustomStyle) view.getElement();
if (customStyle.getId().equals(TreeEditPart.TREE_EDITPART_ID)) {
return TreeEditPart.class;
}
}
return super.getNodeEditPartClass(view);
}
@Override
protected Class<?> getEdgeEditPartClass(View view) {
if (view.getElement() instanceof DEdge) {
return EdgeEditPart.class;
}
return super.getEdgeEditPartClass(view);
}
}
The EdigeEditPart class:
public class EdgeEditPart extends AbstractDiagramEdgeEditPart implements IStyleEditPart{
public EdgeEditPart(View view) {
super(view);
}
public DragTracker getDragTracker(Request request) {
return getParent().getDragTracker(request);
}
@Override
protected Connection createConnectionFigure() {
Figure figure = new EdgePipeConnection();
return (Connection) figure;
}
}
And the EdgePipeConnection:
public class EdgePipeConnection extends PolylineConnectionEx {
// offset X
private static int OFFSET_X = 70;
// offset Y
private static int OFFSET_Y = 0;
// list of precision points
private List<PrecisionPoint> connectionPoints = new ArrayList<PrecisionPoint>();
// bend x
private int bend_X;
// bend y
private int bend_Y;
// counter for queue entries
private int queueEntries = 0;
...
Here I omit the source code for the EdgePipeConnection as 1) it is a lot and 2) it works in a GEF implementation.
So when I create edges in Sirius I got the aforementioned Exception. Any ideas why?
Thanks very much for your help.
Cheers,
Will
Research Associate
Department of Computer Science
University of York
|
|
|
|
Re: Customising Edge styles [message #1776355 is a reply to message #1776353] |
Wed, 15 November 2017 15:37 |
|
Hi Pierre,
In TreeEditPartProvider, when getEdgeEditPartClass() is called, I provide EdgeEditPart, which in turn creates an EdgePipeConnection.
When EdgePipeConnection extends PolylineConnection, the edge can be drawn, just it is now allowed by Sirius.
When EdgePipeConnection extends PolylineConnectionEx , I had the previous exception.
By when creating an edge, i meant when using a tool from the palette to create an edge between two nodes, that is correct.
Thank you very much for your help.
Cheers,
Will
Research Associate
Department of Computer Science
University of York
|
|
|
|
|
Re: Customising Edge styles [message #1776440 is a reply to message #1776360] |
Thu, 16 November 2017 13:12 |
|
Hi Pierre,
Many thanks for your suggestions. As expected, new issues arise. For the editpart, instead of extending DEdgeEditPart, I extended AbstractExtendableEdgeEditPart, which seems to be the right choice as DEdgeEditPart gives me warnings saying it is not supposed to be extended.
However, I have a ClassCastException after the change:
java.lang.ClassCastException: tree.example.extension.edit.part.EdgePipeConnection cannot be cast to org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramEdgeEditPart$ViewEdgeFigure
at org.eclipse.sirius.diagram.ui.internal.edit.parts.DEdgeEditPart.getPrimaryShape(DEdgeEditPart.java:113)
at org.eclipse.sirius.diagram.ui.graphical.edit.part.specific.AbstractExtendableEdgeEditPart.installRouter(AbstractExtendableEdgeEditPart.java:86)
at org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart.addNotify(ConnectionEditPart.java:1084)
at org.eclipse.gef.editparts.AbstractConnectionEditPart.setParent(AbstractConnectionEditPart.java:268)
at org.eclipse.gef.editparts.AbstractConnectionEditPart.setSource(AbstractConnectionEditPart.java:282)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.addSourceConnection(AbstractGraphicalEditPart.java:260)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refreshSourceConnections(AbstractGraphicalEditPart.java:697)
Any ideas if we can go around this problem?
Cheers,
Will
Research Associate
Department of Computer Science
University of York
|
|
|
Re: Customising Edge styles [message #1776462 is a reply to message #1776440] |
Thu, 16 November 2017 15:24 |
Pierre Guilet Messages: 250 Registered: June 2017 |
Senior Member |
|
|
Hi,
AbstractExtendableEdgeEditPart extends DEdgeEditPart that is internal that is why you have warnings.
So it does not change anything. You should keep DEdgeEditPart
Internal means we can do some changes that will break your code if you use the internal code.
If this is ok for your project you can use it. If you want to industrialize it then you should extend AbstractDiagramEdgeEditPart and add the code that was missing and causing exception and that I gave you in previous message.
In both case you must change the method getPrimaryShape() to return your figure type.
Your figure must also provide label figures like ViewEdgeFigure with methods called by your addFixedChild(EditPart) method (getFigureViewEdgeNameFigure,getFigureViewEndEdgeNameFigure,getFigureViewBeginEdgeNameFigure).
You can just copy the code handling these labels in your figure.
Anyway there is no guarantee that you will not be blocked completely at some point because Sirius architecture does not allow you to do what you seek.
What you are doing is out of the box and can lead to nothing.
Regards,
Pierre
Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
[Updated on: Thu, 16 November 2017 15:26] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.05519 seconds