Two Laptop Bag
The moose likes Swing / AWT / SWT and the fly likes Erasing Scribbles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Erasing Scribbles" Watch "Erasing Scribbles" New topic

Erasing Scribbles

Eric Chang
Ranch Hand

Joined: Jan 27, 2004
Posts: 113
So let's say I have a Java application that allows for the drawing of scribbles. However, the way I store the scribbles in memory is by turning the scribble into line segments and storing the two points of each line segment (thereby not actually storing every single pixel coordinate into memory).
Now, I have to be able to erase that scribble...does anyone have any fancy ideas on how this can be done within Java that is efficient. I've thought about turning the scribble back into it's pixel-by-pixel form and working from there, but it seems like the refreshing and redrawing of it is pretty inefficient and quite flickery.
I'm open to suggestions from those that might have a much better idea on this than I do.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10836

I see two approaches to this

1) Remove the line segment(s) which were "erased"
2) If the user is provided an "eraser" whenever he updates the canvas (draw/erase) etc, update the line segments

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
jQuery in Action, 3rd edition
subject: Erasing Scribbles
It's not a secret anymore!