Skip to main content

[JAVA2D] Click detection

3 replies [Last post]
Anonymous

Hi EveryBody!

I'm trying to do the following:

I have some geometrics objects such as ellipses, rectanglesand
poly-lines instancied and drawn on a canvas, and I need to know when
the user clicks over the lines of one of its.

There is the method called "contains(double x, double y)" but it
checks if the point is inside of some geom object .. I need something
like the Line2D method : " int relativeCCW(double PX, double PY)"
that return 0 when the point lies exactly on the line segment. But I
need to know when it lies on a ellipse , on the lines of a rectangle,
or polyline, or polygon!

I hope I was clear
Please, I realy need help on it!
[]
Danilo

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Ted Hill

Look at Graphics2D.hit()

You can build a small Rectangle centered at the mouse click and see if
it intersects a Shape.

Will this work for you?

-----Original Message-----
From: Discussion list for Java 2D API
[mailto:JAVA2D-INTEREST@JAVA.SUN.COM] On Behalf Of Danilo Costa
Sent: Thursday, August 26, 2004 8:55 AM
To: JAVA2D-INTEREST@JAVA.SUN.COM
Subject: [JAVA2D] Click detection

Hi EveryBody!

I'm trying to do the following:

I have some geometrics objects such as ellipses, rectanglesand
poly-lines instancied and drawn on a canvas, and I need to know when the
user clicks over the lines of one of its.

There is the method called "contains(double x, double y)" but it checks
if the point is inside of some geom object .. I need something
like the Line2D method : " int relativeCCW(double PX, double PY)"
that return 0 when the point lies exactly on the line segment. But I
need to know when it lies on a ellipse , on the lines of a rectangle, or
polyline, or polygon!

I hope I was clear
Please, I realy need help on it!
[]
Danilo

========================================================================
===
To unsubscribe, send email to listserv@java.sun.com and include in the
body of the message "signoff JAVA2D-INTEREST". For general help, send
email to listserv@java.sun.com and include in the body of the message
"help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Thomas Busey

Since we are talking about mice, here is a hard one. I need to be able
to move the position of the cursor on the screen. That is, I need
something like:

SetMouse(258, 234)

which in applications would put this at screen location 258,234. Yes, I
know this breaks all kinds of user interface guidelines, but I really
need it for a psychology experiment. There are lots of java routines
for reading the mouse position, but I need one that will set the mouse
to a new location. Any ideas?

Thanks,

Tom

On Aug 26, 2004, at 9:22 AM, Ted Hill wrote:

> Look at Graphics2D.hit()
>
> You can build a small Rectangle centered at the mouse click and see if
> it intersects a Shape.
>
> Will this work for you?
>
> -----Original Message-----
> From: Discussion list for Java 2D API
> [mailto:JAVA2D-INTEREST@JAVA.SUN.COM] On Behalf Of Danilo Costa
> Sent: Thursday, August 26, 2004 8:55 AM
> To: JAVA2D-INTEREST@JAVA.SUN.COM
> Subject: [JAVA2D] Click detection
>
>
> Hi EveryBody!
>
> I'm trying to do the following:
>
> I have some geometrics objects such as ellipses, rectanglesand
> poly-lines instancied and drawn on a canvas, and I need to know when
> the
> user clicks over the lines of one of its.
>
> There is the method called "contains(double x, double y)" but it
> checks
> if the point is inside of some geom object .. I need something
> like the Line2D method : " int relativeCCW(double PX, double PY)"
> that return 0 when the point lies exactly on the line segment. But I
> need to know when it lies on a ellipse , on the lines of a rectangle,
> or
> polyline, or polygon!
>
> I hope I was clear
> Please, I realy need help on it!
> []
> Danilo
>
> =======================================================================
> =
> ===
> To unsubscribe, send email to listserv@java.sun.com and include in the
> body of the message "signoff JAVA2D-INTEREST". For general help, send
> email to listserv@java.sun.com and include in the body of the message
> "help".
>
> =======================================================================
> ====
> To unsubscribe, send email to listserv@java.sun.com and include in the
> body
> of the message "signoff JAVA2D-INTEREST". For general help, send
> email to
> listserv@java.sun.com and include in the body of the message "help".
>
>
>

Thomas Busey, PhD
Associate Professor
Department of Psychology and Program in Cognitive Science
Indiana University, Bloomington
1101 E. 10th St
Bloomington, IN, 47405
(812) 855-4261
busey@indiana.edu
www.indiana.edu/~busey

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Rob Ross

On Aug 27, 2004, at 7:33 PM, Thomas Busey wrote:

> Since we are talking about mice, here is a hard one. I need to be able
> to move the position of the cursor on the screen. That is, I need
> something like:
>
> SetMouse(258, 234)
>
> which in applications would put this at screen location 258,234. Yes, I
> know this breaks all kinds of user interface guidelines, but I really
> need it for a psychology experiment. There are lots of java routines
> for reading the mouse position, but I need one that will set the mouse
> to a new location. Any ideas?
>
> Thanks,
>
> Tom

look at java.awt.Robot.mouseMove()

Rob Ross, Senior Software Engineer
E! Networks
rross@eentertainment.com
---------------------------------------------------
"Beware of he who would deny you access to information, for in his
heart he dreams himself your master." -- Commissioner Pravin Lal

Rob Ross, Senior Software Engineer
E! Networks
rross@eentertainment.com
---------------------------------------------------
"Beware of he who would deny you access to information, for in his
heart he dreams himself your master." -- Commissioner Pravin Lal

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".