2 Replies Latest reply: Jun 28, 2011 10:31 PM by s3a RSS

    Need help with algorithm for my paint program

      I was making a paint program with using a BufferedImage where the user draws to the BufferedImage and then I draw the BufferedImage onto the class I am extending JPanel with. I want the user to be able to use an undo feature via ctrl+z and I also want them to be able to update what kind of paper they're writing on live: a) blank paper b) graph paper c) lined paper. I cannot see how to do this by using BufferedImages. Is there something I'm missing or must I do it another way? I am trying to avoid the other way because it seems too demanding on the computer but if this is not do-able then I guess I must but I feel I should ask you guys if what I am doing is logical or monstrous.

      What I am planning to do is make a LinkedList that has the following 4 parameters:
      1) previous Point
      2) current Point
      3) current Color
      4) boolean connectPrevious

      which means that the program would basically draw the instantaneous line using the two points and color specified in paintComponent(Graphics g). The boolean value is for ctrl+z (undo) purposes. I am also planning to use a background thread to eliminate repeated entries in the LinkedList except for the last 25 components of the LinkedList (that number might change in practice).

      What do you guys think?

      Any input would be greatly appreciated!
      Thanks in advance!