views:

123

answers:

2

Hey,

I need to simulate a fairly complex water piping system (2D) in Java. I need to be able to show the flow of water through some pipes when some others are blocked. What toolkit/APIs can I use? I am a newbie to graphics programming. Kindly advice.

Thanks DC

A: 

Java has a 2D API that you could use. You can read about it in this trail. Also, this tutorial could be helpful.

kgiannakakis
+2  A: 

What do you mean by a 'fairly complex water piping system'? Are you planning to implement a pipeline network simulator? If so, you should not tackle this problem as a graphics problem, but rather as a simulation problem: first you need to write a simulator that calculates the dynamics of your model, then you can worry about showing the model behavior to the user.

Anyway, this can be tricky as well -- first you should decide which data from the running simulator you actually require for the visualization (I presume you want to do an online visualization, i.e. visualize the data at runtime, with the simulator running in an extra thread?). Then you need to record this data, e.g. by using the Observer pattern. Actually displaying the pipeline network and its current state might be easy when you use a tool for graph layout, such as JUNG (though you might already have spatial information on every node, in which case you might still be able to leverage a graph library's components for graph display and animation). I used Batik for declarative SVG animation a couple of years ago, and was quite pleased with its simplicity -- but of course you might want to have more control over the actual animation, especially if you are interested in the computer graphics aspects of the problem.

__roland__