import java.util.*; /** * A scene. * * A scene may contain: * 1) coordinates (class Coordinates) * 2) line segments (class Vector) * 3) scenery (class Scenery) */ public class Scene extends Observable { private Vector _v; /** * The constructor. */ public Scene() { _v = new Vector(); } /** * Scene manipulation. */ public void add(Object o) { _v.addElement(o); } public void remove(Object o) { _v.removeElement(o); } public Enumeration elements() { return _v.elements(); } /** * Apply the supplied transformation. */ public void transform(Transformation tr) { Enumeration enum = _v.elements(); while (enum.hasMoreElements()) { Object obj = enum.nextElement(); if (obj instanceof Scenery) { synchronized (obj) { ((Scenery)obj).transform(tr); } } else if (obj instanceof Vector) { tr.transform(((Vector)obj).elements()); } else if (obj instanceof Coordinates) { tr.transform((Coordinates)obj); } } setChanged(); notifyObservers(); } }