Skip to main content



      Home
Home » Eclipse Projects » Sirius » Findings node in the path edges
Findings node in the path edges [message #1734025] Fri, 03 June 2016 03:13 Go to next message
Eclipse UserFriend
Hello,

I implement a custom layout provider. I implement a custom algorithm to create edges. Creating edges and sets them each RelativeBendpoint, so that the edge leading the way.

I need to find out whether the road on the edge there is a node, and if so, what position is the node that I could keep the edge another way.

Thanks for any advice.

Martin
Re: Findings node in the path edges [message #1734057 is a reply to message #1734025] Fri, 03 June 2016 07:37 Go to previous messageGo to next message
Eclipse UserFriend
Le 03/06/2016 à 09:13, Martin Jedlicka a écrit :
> Hello,
>
Hi,

> I implement a custom layout provider. I implement a custom algorithm to
> create edges. Creating edges and sets them each RelativeBendpoint, so
> that the edge leading the way.
>
> I need to find out whether the road on the edge there is a node, and if
> so, what position is the node that I could keep the edge another way.

I'm not sure to exactly understand what you want. But the methods
getIntersection of
org.eclipse.sirius.ext.gmf.runtime.editparts.GraphicalHelper class are
maybe a good starting point.

>
> Thanks for any advice.
>
> Martin

Regrds,

--
Laurent Redor - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Findings node in the path edges [message #1734322 is a reply to message #1734057] Tue, 07 June 2016 02:53 Go to previous messageGo to next message
Eclipse UserFriend
I attach the images for a better explanation.

invalid_edges.png
Edge runs through the node, I need to find out over the edge nodes lead I could find another way. Need to know where the edge is what nodes and nodes which have a position.

valid_edges.png
It found a way on the basis of previous findings.

Thanks.

Martin
Re: Findings node in the path edges [message #1734324 is a reply to message #1734322] Tue, 07 June 2016 03:01 Go to previous messageGo to next message
Eclipse UserFriend
Le 07/06/2016 à 08:53, Martin Jedlicka a écrit :
> I attach the images for a better explanation.
>
> invalid_edges.png
> Edge runs through the node, I need to find out over the edge nodes lead I could find another way. Need to know where the edge is what nodes and nodes which have a position.
>
> valid_edges.png
> It found a way on the basis of previous findings.
>
> Thanks.
>
> Martin
>

OK so I as said before, all GraphicalHelper.getIntersection methods [1]
are good starting points. With these methods, you can detect if an edge
is in intersection with a node. You must do that for each edge with all
nodes (other than the source and the target of the edge).

[1]
http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/tree/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/editparts/GraphicalHelper.java#n354

--
Laurent Redor - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Findings node in the path edges [message #1735202 is a reply to message #1734324] Thu, 16 June 2016 06:12 Go to previous messageGo to next message
Eclipse UserFriend
Hi Laurent,

Thank you for your answer, but I do not know exactly what method getIntersection returns.

I thought that returned intersections of edges and nodes that are on the edge, but the result somehow understand.

On the attached figure (intersections.png) shows that the edge intersects the node TST001_U003 left and above. I expected that these points method returns, but the returns do not understand.

Because I want to lead otherwise edge (around node), so I implement custom layout provider, see code below where excerpting node coordinates and intersections.

So what exactly the method returns?

Thanks so much for any advice.

Martin

Output:
source bound: (101, 70), target bound: (101, 70)
source point: (153, 209), target point: (293, 79)
intersections: Option: Point(265.0, 105.0)


Code:
class CustomLayout extends AbstractLayoutProvider {

		private IGraphicalEditPart container;

		public CustomLayout(IGraphicalEditPart container) {
			this.container = container;
		}

		@SuppressWarnings("rawtypes")
		@Override
		public Command layoutEditParts(List selectedObjects, IAdaptable layoutHint) {

			if (selectedObjects.isEmpty()) {
	            return UnexecutableCommand.INSTANCE;
	        }

			for (IGraphicalEditPart graphicalEditPart : Iterables.filter(selectedObjects, IGraphicalEditPart.class)) {

				EObject semanticElement = graphicalEditPart.resolveSemanticElement();

				if (semanticElement instanceof DDiagramElement) {
					View notationView = graphicalEditPart.getNotationView();

					if (notationView instanceof Edge) {
						final Edge edge = (Edge) notationView;
						Bendpoints bendpoints = edge.getBendpoints();

						if (bendpoints instanceof RelativeBendpoints) {
							Connection connection = (Connection) GMFHelper.getGraphicalEditPart(edge).get().getFigure();

							Point sourceRefPoint = connection.getSourceAnchor().getReferencePoint();
							Point targetRefPoint = connection.getTargetAnchor().getReferencePoint();
			                connection.translateToRelative(sourceRefPoint);
			                connection.translateToRelative(targetRefPoint);
			                IFigure sourceFigure = connection.getSourceAnchor().getOwner();
			                IFigure targetFigure = connection.getTargetAnchor().getOwner();

			                System.out.println("source bound: (" + sourceFigure.getBounds().width +", "+ sourceFigure.getBounds().height + "), target bound: (" + targetFigure.getBounds().width + ", " + targetFigure.getBounds().height + ")");
			                System.out.println("source point: (" + sourceRefPoint.x + ", " + sourceRefPoint.y + "), target point: (" + targetRefPoint.x + ", " + targetRefPoint.y + ")");

			                Option<Point> intersections = GraphicalHelper.getIntersection(sourceRefPoint, targetRefPoint, graphicalEditPart, false);
			                System.out.println("intersections: " + intersections);
						}
					}
				}
			}

			return new CompoundCommand();
		}
	}

[Updated on: Fri, 17 June 2016 07:03] by Moderator

Re: Findings node in the path edges [message #1735460 is a reply to message #1734324] Mon, 20 June 2016 00:52 Go to previous messageGo to next message
Eclipse UserFriend
Hi Laurent,

can you please reply to my last post.

Thank you very much.

Martin
Re: Findings node in the path edges [message #1735470 is a reply to message #1735202] Mon, 20 June 2016 03:55 Go to previous message
Eclipse UserFriend
Hi Martin,

I gave you these methods as starting point. I didn't say that it is THE
solution. These methods allow to detect/find an intersection between an
edge and a rectangle.

You have to analyse the code of these methods and to test with your
specific code to correctly understand what they do or how to adapt them
to answer your needs. These methods use other GMF utilities classes. You
also have to look at them (and the associated javadoc). I can't do more
for you in the scope of this forum.

If this is blocking for you, you can contact us at Obeo for consulting &
coaching, or even custom development. See
http://www.obeodesigner.com/sirius for more details on Obeo's offers.

Regards,

Laurent

Le 16/06/2016 à 12:12, Martin Jedlicka a écrit :
> Hello,
>
> Thank you for your answer, but I do not know exactly what method getIntersection returns.
>
> I thought that returned intersections of edges and nodes that are on the edge, but the result somehow understand.
>
> On the attached figure (intersections.png) shows that the edge intersects the node TST001_U003 left and above. I expected that these points method returns, but the returns do not understand.
>
> Because I want to lead otherwise edge (around node), so I implement custom layout provider, see code below where excerpting node coordinates and intersections.
>
> So what exactly the method returns?
>
> Thanks so much for any advice.
>
> Martin
>
> Output:
>
> source bound: (101, 70), target bound: (101, 70)
> source point: (153, 209), target point: (293, 79)
> intersections: Option: Point(265.0, 105.0)
>
>
> Code:
>
> class CustomLayout extends AbstractLayoutProvider {
>
> private IGraphicalEditPart container;
>
> public CustomLayout(IGraphicalEditPart container) {
> this.container = container;
> }
>
> @SuppressWarnings("rawtypes")
> @Override
> public Command layoutEditParts(List selectedObjects, IAdaptable layoutHint) {
>
> if (selectedObjects.isEmpty()) {
> return UnexecutableCommand.INSTANCE;
> }
>
> for (IGraphicalEditPart graphicalEditPart : Iterables.filter(selectedObjects, IGraphicalEditPart.class)) {
>
> EObject semanticElement = graphicalEditPart.resolveSemanticElement();
>
> if (semanticElement instanceof DDiagramElement) {
> View notationView = graphicalEditPart.getNotationView();
>
> if (notationView instanceof Edge) {
> final Edge edge = (Edge) notationView;
> Bendpoints bendpoints = edge.getBendpoints();
>
> if (bendpoints instanceof RelativeBendpoints) {
> Connection connection = (Connection) GMFHelper.getGraphicalEditPart(edge).get().getFigure();
>
> Point sourceRefPoint = connection.getSourceAnchor().getReferencePoint();
> Point targetRefPoint = connection.getTargetAnchor().getReferencePoint();
> connection.translateToRelative(sourceRefPoint);
> connection.translateToRelative(targetRefPoint);
> IFigure sourceFigure = connection.getSourceAnchor().getOwner();
> IFigure targetFigure = connection.getTargetAnchor().getOwner();
>
> System.out.println("source bound: (" + sourceFigure.getBounds().width +", "+ sourceFigure.getBounds().height + "), target bound: (" + targetFigure.getBounds().width + ", " + targetFigure.getBounds().height + ")");
> System.out.println("source point: (" + sourceRefPoint.x + ", " + sourceRefPoint.y + "), target point: (" + targetRefPoint.x + ", " + targetRefPoint.y + ")");
>
> Option<Point> intersections = GraphicalHelper.getIntersection(sourceRefPoint, targetRefPoint, graphicalEditPart, false);
> System.out.println("intersections: " + intersections);
> }
> }
> }
> }
>
> return new CompoundCommand();
> }
> }
>


--
Laurent Redor - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:Highlight edges when selecting a node
Next Topic:Cross Tables examples
Goto Forum:
  


Current Time: Tue Apr 15 01:17:15 EDT 2025

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

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

Back to the top