• Post Reply Bookmark Topic Watch Topic
  • New Topic

polygon editor  RSS feed

 
Anna Amatus
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi all,

I need to create a swing utility to draw and manipulate polygons (both regular and irregular).
Quite simple stuff, create the polygon by mouse click on the vertices positions on the screen + move, delete and add vertices.
Before starting from scratch I was wondering if there are some library or free code that I can start from.

Thanks!
Anna.
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There probably is but I don't know about it.

You can set up a mouse listener on your panel which records the location of the click and adds it to a path. A GeneralPath object might be useful.
 
Tim Moores
Saloon Keeper
Posts: 3512
77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JGraphX might fit that bill.
 
Rob Camick
Ranch Hand
Posts: 2756
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Creating the Polygon is easy. You just use the MouseListener and add Points to a Polygon class.

Manipulating the Points will be more difficult. It will be hard to click on the exact Point of the Vertex so you will need to probably write an algorithm to find the closest Point to where the mouse is clicked in order to do the manipulations.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!