Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Swing / AWT / SWT and the fly likes Polygon lasso drawing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Polygon lasso drawing" Watch "Polygon lasso drawing" New topic

Polygon lasso drawing

Yang Li

Joined: Jan 31, 2007
Posts: 5
I am trying to use Java to implement a feature that is very like to polygon lasso tool in any image processing software, like FireWords, PhotoShop.

Basically, when a user clicks the polygon lasso icon I provided, he is ready to start to draw a polygon lasso. When he clicks anywhere in a drawing area, a dot will show up there; clicks again, a new dot will apprear. There is a solid or arrow between two dots. The last dot must overlap the first dot and it represents the drawing is finished and a polygon will appear; all points are decided by my clicks.

There are several constraints:

1. A user can only click selected times, i.e.: he can only click 5 times. Clicks beyond 5 times will not be accepted (no dot appeared)

2. A user must click selected times, i.e.: he must click 5 times. If he just clicks twice and decides to terminate the drawing, all dots and connected lines will disappear

3. The last dot and the first dot must be overlapped. Please note: As long as two points are very close, say, 2 px, we still say they are overlapped.

4. If the last dot and the first dot does not overlapped, I may choose to accept or not accept the drawing. If I do not accept it, all dots and connected lines will disappear

Any suggestion and/or sample code?

Thank you for your time.
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
I agree. Here's the link:
subject: Polygon lasso drawing
It's not a secret anymore!