This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I need to determine where on screen to display a window so that it does not overlap any other places on the screen where vital content is being displayed. The vital content could be displayed in multiple places and the window should be as close to some pre-determined point on the screen.
For example. I have a facsimile of a form on the left hand side being displayed in a window. On the right hand side of the screen is an image being displayd in the window. The user runs a query on database and a screen pops up displaying matches. When this screen pops up, I want it as close to the center as the screen as possible. However, it must not overlap either the fields on the form they're currently searching on, and it must not overlap the location on the image where that field is shown (say the image is a scan of a medical form). How do I determine the location closest to the center of the screen that will not overlap with either of the two areas?
Keep in mind that these two areas aren't static, they're dynamic, they will be changing. My initial approach has been to get a Shape for each area on the screen that shouldn't be overlapped. I theorize that, from these shapes, I should be able to subtract them from the initial screen area and come up with a new shape that is essentially the inverse and consequently could be called my 'useable area'. From this, I would know where I'm 'allowed' to put the window and calculate the location closest to point x (in the above example it was the center of the screen).
I'm having a great deal of difficulty taking this from an abstract concept to putting it into code. Any and all help is appreciated. Keep in mind that the size of the window I'm displaying is dynamic and so are the shape, size, and locations (and even the number of them) that aren't allowed to be overlapped. The point we try and get closest to would be something the user sets, but for our purposes we can just assume it's the center of the screen (after all if we solve it for point x being the center of the screen we've solved it no matter where point x is).
I hope I've explained it clearly enough. On the most basic level the problem is this: you have a screen, you need to display a shape of some sort on that screen such that it does not overlap with any other shapes on that screen and is closest to a given point as possible.
Help? [ June 14, 2005: Message edited by: Ken Blair ]