java - Swing: detect mouse move on generalpath -


i'm drawing splines using generalpath follow:

generalpath path = new generalpath(); path.moveto(x0, y0); path.curveto(x0 + 100, y0, x1 - 100, y1, x1, y1); ((graphics2d) g).draw(path); 

basically, draws spline looks cable, or wire, between point (x0;y0) , point (x1;y1).

p0 --      \       \        `-- p1 

the drawing okay, detect when mouse moves hover spline. problem contains(point) method not seems want. returns true if point inside area between spline , direct line between (x0;y0) , (x1;y1).

in example above, return true whole "stars" area:

p0 -----------      *********\          ******\              ***\                 *\*                    \*******                     `------------- p1 

but want detect when point located on spline.

is there way achieve want ?

any ideas appreciated !

edit: found explanation of problem in documentation, not me find solution:

the contains , intersects methods consider interior of shape area encloses if filled. means these methods consider unclosed shapes implicitly closed purpose of determining if shape contains or intersects rectangle or if shape contains point.

just curveto starting point. it's going really, hard user exactly on curve!


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -