defining regions in bitmap (java) -


i have graphics application in java, made of many different shapes (lines, circles, arcs, etc, drawn via graphics.drawline(), drawarc()... methods). create mouse-over events on many, if not of drawn objects.

what thinking store sort of bitmap metadata in it, , use figure out object mouse over. there way in java? (looping through objects per mouse move doesn't seem viable).

thanks,

john

key-color solution

(moved comment)

  • create off-screen graphics buffer (like bufferedimage), same size subject image.
  • draw objects buffer. each object 1 own color. depending on object count can optimize image buffer: example use 8-bit graphics.
  • read resulting image buffer pixel (example java - pixel array image). determine pixel color @ current mouse position, , map color index (or rgb value) source object.

pros:

  • the solution "pixel-accurate": object boundaries exact - pixel pixel.
  • easy solve overlapping objects problem. draw them @ desired order.
  • object complexity not limited. theoretically bitmaps possible.

cons:

  • to move 1 object, complete off-screen buffer must repainted
  • number of objects can limited when using low-bit image buffer

Comments