Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Saving of freehand drawing coordination...  RSS feed

 
MJ Seah
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Do anyone of you have any idea how can i save my X and Y value coordination in a text file? I am currently doing a freehand drawing. i need to know how to save the coordination when i draw.

For example when i draw from point A to Point B, the moment i click on my mouse, it should be able to capture the coordination i am at and when i started to drag, every drag i do, automatically it capture the coordination and save it into a file. This process repeats until i stop drawing.

I will be required to have a save button to save my drawing and load it as when i want it. is there anyway i can do that??? Please enlighten me!!!

Thank You!!
 
Tanveer Rameez
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. use a bufferedimage
2. take its graphics object and draw the freehand on that grahics (g.drawLine...)
3. use imageIO in java 1.4.2 to save it JPG format and you can load that image.
4. however if you want to save only the coordinates, then first collect the coordinates in a Vector orany collection class. then save the Vector maybe using serialization, or you can use a simple text file to save the coordinates. To load the image, you can read the coordinates from the file and draw the lines accordingly.
 
MJ Seah
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thanks for the reply...

I would like to save just the coordinates...

do u have a set of coding for me to refer to? Thank you... waiting for your reply again...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!