views:

283

answers:

1

I have made a very basic paint brush application in java.

I want to enhance this application to be shared across users on the internet so that we can simultaneously share the instance and work collaboratively on the paint screen. [i got this idea form the doodle work env in yahoo messenger]

I am not sure if this would be acheived by networking? (Like we make a chat application.) i.e in a chat application two users work on the same screen and chat.

But instead I have a paintboard and two users will send messages to draw on the screen.

But I really cant think how to go about the architecuture of this application. Any hints, pointers or design links will be a great help.

Thanks

+2  A: 
  1. Make a text protocol describing any action the user may do with your app. E.g.

    • Set foreground color to red, e.g. "SetForegroundColorChange(RED)"

    • Set brush shape to B1: "SetBrushShape(B1)"

    • Put a dot of current color/shape at coordinates X,Y: "Paint(X,Y)"

    • Erase dot at coordinates X, Y (hopefully no more examples needed)

    • Re-size document

    • New document

    • ... etc

  2. The app architecture would be:

    • GUI event handler, which converts GUI events into protocol commands, and sends protocol commands to two places, the protocol handler AND network communicator

    • Protocol handler, which reads protocol commands (given to it by GUI event handler OR network communicator's listener), and calls appropriate application method, e.g. 'changeForegroundColor("red")' for the first example message above.

    • Network communicator, consisting of sender (which merely sends protocol commands from your app's GUI event handler on to other apps, in exactly the same way chat client would, and a listener that accepts protocol commands over the network from other apps, again in exactly the same way chat client would, and sends those commands to protocol handler.

You also need to figure out some way to handle concurrency issues (e.g. two apps both drawing different-colored dots in the same place at the same time).

Hope this is clear enough.

NOTE: This answer assumes you know how to write a basic chat application and merely wish to know how to apply that skill to shared paint app. If I inferred this incorrectly from your post, you would also need to learn how to make a basic chat app to use architecture below, which is usually covered in aby basic Java Networking (or just Java) textbook/class, so I won't write that one out.

DVK
thanks i have a better picture now. Am sure this will help me get started.
krisp