• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is there a getPoints for a Graphics or Graphics2D object

 
john kalaigian
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can retrieve an array of points for a particular Graphics object. I want to be able to do a free hand drawing (of a Region Of Interest) and store that ROI into a database. So I was hoping to be able to access the data from the database either in object form or as a list of x and y points that comprise the Graphics object itself, then all I would have to do is reorient the object propertly in the appropriate corrodinate system. Any thoughts?
 
meera sood
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to retrieve an array of pixels from an image, you can use the pixelgrabber class. i know this is a very very long way of doing it, and there must be a shorter and better way of doing the same thing..but you can try the following.
you can do all your drawing(graphics) on a canvas, convert that into a jpg image, using an encoder, and then grab the pixels from that image into a one-dimensional array and store this array into your database. when you want to retrieve the image, you can draw back the image using the createImage class.
Hope ths helps.
(if you find a better way of doing it...do lemme know )
meera
 
john kalaigian
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry I should have been more clear - my fault - I want to store the polygon points (for freehand ROI) or the points of a bounding rectangle - these are what I'm referring to when I say Graphics object. How do I access the points that comprise them once they are drawn on screen?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like what you need to do is capture the points when the user is drawing the ROI, save the points to the database, retrieve the points from the database, and create a java.awt.Polygon object from them. You wouldn't need to get the points from the object drawn, you would save them in the MouseListener, then have the MouseListener generate the graphics for you.

Here's some exqample code of what I'm talking about...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!