This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Saving of freehand drawing coordination...

 
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!!
 
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...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!