001package myproject.model;
002
003import myproject.util.Animator;
004
005/**
006 * An interface for building a {@link Animator} for this {@link Model}.
007 */
008public interface AnimatorBuilder {
009        /**
010         *  Returns the {@link Animator}.
011         *  This method may be called only once; subsequent calls throw an
012         *  {@link IllegalStateException}.
013         */
014        public Animator getAnimator();
015        /**
016         *  Add the {@link Light} to the display at position <code>i,j</code>.
017         */
018        public void addLight(Light d, int i, int j);
019        /**
020         *  Add the horizontal {@link Road} to the display, west of position <code>i,j</code>.
021         *  If <code>eastToWest</code> is true, then road position 0 is the eastmost position.
022         *  If <code>eastToWest</code> is false, then road position 0 is the westmost position.
023         */
024        public void addHorizontalRoad(Road l, int i, int j, boolean eastToWest);
025        /**
026         *  Add the vertical {@link Road} to the display, north of position <code>i,j</code>.
027         *  If <code>southToNorth</code> is true, then road position 0 is the southmost position.
028         *  If <code>southToNorth</code> is false, then road position 0 is the northmost position.
029         */
030        public void addVerticalRoad(Road l, int i, int j, boolean southToNorth);
031}
032
033/**
034 * Null object for {@link AnimatorBuilder}.
035 */
036class NullAnimatorBuilder implements AnimatorBuilder {
037        public Animator getAnimator() { return new NullAnimator(); }
038        public void addLight(Light d, int i, int j) { }
039        public void addHorizontalRoad(Road l, int i, int j, boolean eastToWest) { }
040        public void addVerticalRoad(Road l, int i, int j, boolean southToNorth) { }
041}
042
043/**
044 * Null object for {@link Animator}.
045 */
046class NullAnimator implements Animator {
047        public void update(java.util.Observable o, Object arg) { }
048        public void dispose() { }
049}