Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2006

Tip: Looking for answers? Try searching our database.

Draw pointable / pickable lines, etc, how to?

Thread view: 
Kevin - 26 Feb 2006 22:45 GMT
Hello,
I am wondering what is the best way to this common GUI task:

Draw some rectangles, lines, pies, etc (say, in a JPanel). Make sure
these things are "pointable" and "pickable": when mouse is moved over
it, we can press mouse key to "pick up" it and drag it around, etc.

Previously in some early school homework projects, I just stored the
locations for each of them in an array. For example, for a line, I
stored its starting and ending (x, y) points. For a rectangle, I stored
its 4 corner points (x,y). In listener for mouse move (or click, drag)
in JPanel, I got the current mouse's position, and checked each item in
the above array to see if the mouse was in any of them. This worked ok
with not too many lines or rectangles. And it did not use too much
memory also since only several integers needed to be saved for each
line or rectangle, etc.

Any idea of better method? (in terms of efficiency, for example, we may
have 10000 rectangels and 50000 lines. And of course we need it for
real time when user moves the mouse around).

Thanks. :-)
Kevin - 26 Feb 2006 22:52 GMT
By the way, I think one way is to make each line / rectangle / pie etc
an object. But that sounds like not efficient if we have many of them.
Right? And also I am not sure how to do it.
Richard Wheeldon - 27 Feb 2006 19:12 GMT
> I am wondering what is the best way to this common GUI task:
>
> Draw some rectangles, lines, pies, etc (say, in a JPanel). Make sure
> these things are "pointable" and "pickable": when mouse is moved over
> it, we can press mouse key to "pick up" it and drag it around, etc.

Moreover, can someone recommend some sort of framework/toolset/api for
doing this as easily as possible ? I have a need to do something very
similar,

Richard


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.