GEF5 MVC Draw polygon [message #1780274] |
Fri, 19 January 2018 09:26  |
Eclipse User |
|
|
|
I have written an basic editor which allows me to put pre-defined shapes on the graph, rectangle, ellipse etc. But I now want user to be able to draw a polygon shape.
So a couple of things, I'm assuming that I have to create a Model Object for the viewer to store the points that user clicks, but how do I draw the polygon? What kinda of visual and policies do I need? I'm assuming I have to draw a polyline somehow until the polygon is completed in which case I can then create a polygon node in my graph... just need a nudge in the right direction to figure out this interactive drawing part using the mvc framework...
Also since polygons must be simple how to prevent user from creating a intersecting polygon?
|
|
|
Re: GEF5 MVC Draw polygon [message #1785410 is a reply to message #1780274] |
Fri, 13 April 2018 10:01  |
Eclipse User |
|
|
|
Hi Kyle,
yes you do need a model representation for your polygon.
W.r.t. the visualisation, you can have a part that specifies JavaFX Group as its visual to be able to put any visuals in there. Apart from that, you could also use GeometryNode<IGeometry> or Path, i.e. you have some options for the visual.
You will need to implement a couple of handlers for the interaction, e.g. AddPolygonPointOnClickHandler. I would suggest that your model object allows any number of points, so that you can create the model object with the initial click and just trust the synchronisation for creating the corresponding content part.
W.r.t. restricting the polygons to be simple, you can check for intersections between the polygon sides. The GEF Geometry API is capable of doing so, e.g. firstSegment.getIntersections(secondSegment) returns an array of points of intersection.
h2h
Matthias
|
|
|
Powered by
FUDForum. Page generated in 0.03931 seconds