Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » GEF5 MVC Draw polygon
GEF5 MVC Draw polygon [message #1780274] Fri, 19 January 2018 14:26 Go to next message
Kyle Girard is currently offline Kyle GirardFriend
Messages: 12
Registered: March 2012
Junior Member
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 14:01 Go to previous message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 230
Registered: March 2015
Senior Member
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
Previous Topic:Drawing Graph on top of background image
Next Topic:how to test view in GEF MVC
Goto Forum:
  


Current Time: Fri May 10 22:27:57 GMT 2024

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

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

Back to the top