I currently have an program in Java that simulates railway movements. Essentially, trains arrive on platforms, pick up and drop off passengers, and then proceed, respecting signalling where possible. However, currently this only exists in the program's state, and there is no actual graphical view of all of this happening.
It would be much more useful if one could see a diagram of the railway track and where trains were on it. To do this, everything now has to have (x, y) coordinates in respect of the JPanel so that they can be drawn. There are probably other useful fields and methods that would be useful in terms of depicting the current state.
I see two principal options:
Just throwing everything into the original classes. However, I don't like this since it's not a property of a train that it exists at (2, 3) on an arbitrary JPanel, that just happens to be a representation.
Creating a "Visualizer" class for every class that needs to be drawn, so there would be a TrainVisualizer class, a PlatformVisualizer class, etc. The problem with this is that every time I create something, I basically have to create both the original thing (i.e. the Train), and the visualizer. This seems distinctly unideal.
What would be the best way of adding this on to the existing program?