shape selection tests

I

Ian Stanley

hi,
back again and revisiting an old problem from months ago(still stuck)
I need a way to test what type of shape is selected and set further
behaviour accordingly. eg if rectangle selected, then change its color to
red, circle blue etc.
The main problem is that once the shapes are rotated or scaled the usual
rules(from what I can gather) do not apply. The general path takes over. I
have looked at the path iterator but am not sure how to use it.
The only shapes I am interested in are: rectangle, triangle, line, square or
circle.
has anyone a suggestion how to test if a mouse click occurs over one of
these which determines what type of shape is selected. If the click is over
a number of shapes then the last one is tested - I have started to try and
test using the bounds somehow- dicovered is too tricky(below)
Thanking you in advance
Ian

public Shape hitTest(int x, int y)
{
for (int i = 0; i < v.size(); i++){
Shape s = (Shape)v.elementAt(i);
if (s.contains(x,y) ){
int wid = s.getBounds().width;
int hei = s.getBounds().height;
... ... ...
return s;
}
}
return null;
}
 
A

Alex Hunsley

Ian said:
hi,
back again and revisiting an old problem from months ago(still stuck)
I need a way to test what type of shape is selected and set further
behaviour accordingly. eg if rectangle selected, then change its color to
red, circle blue etc.
[snip rest]

Can you post, or make available, the entire code? It would be much
easider to help then.
 
S

Sudsy

Ian said:
hi,
back again and revisiting an old problem from months ago(still stuck)
I need a way to test what type of shape is selected and set further
behaviour accordingly. eg if rectangle selected, then change its color to
red, circle blue etc.
The main problem is that once the shapes are rotated or scaled the usual
rules(from what I can gather) do not apply. The general path takes over. I
have looked at the path iterator but am not sure how to use it.
The only shapes I am interested in are: rectangle, triangle, line, square or
circle.
has anyone a suggestion how to test if a mouse click occurs over one of
these which determines what type of shape is selected. If the click is over
a number of shapes then the last one is tested - I have started to try and
test using the bounds somehow- dicovered is too tricky(below)
Thanking you in advance
Ian

One of the best references I've read regarding these concepts is
"Principles of Interactive Computer Graphics". And if this doesn't
mark me as an old-timer then consider that this book doesn't even
have an ISBN!
It covers (nicely) raster graphics, edge detection and determining
whether a point is contained within a shape. And it sounds as
though you need a good reference such as this for what you're
trying to achieve.
IOW, I don't think c.l.j.p is the appropriate newsgroup for your
queries.
 
D

David Postill

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

<snip />

| One of the best references I've read regarding these concepts is
| "Principles of Interactive Computer Graphics". And if this doesn't
| mark me as an old-timer then consider that this book doesn't even
| have an ISBN!

Hmmmm. My copy is handy ... yes it does. ISBN 0-07-046338-7

Mine is the second edition though...

<davidp />

- --
David Postill

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.3 - not licensed for commercial use: www.pgp.com
Comment: Get key from pgpkeys.mit.edu:11370

iQA/AwUBP7z0vnxp7q1nhFwUEQKNXACeIfTFj12gMy1p0IITBo8tRU3o9MgAoPtX
HkBAFePRrsvQ+0QOWZcWR4HX
=JIL4
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,835
Latest member
lila30

Latest Threads

Top