/** Sets up new coordinates and rotation of all VivaeObjects according to their movement. */ public void moveVivaes() { // for (Active active : actives) { // active.moveComponent(); // } for (Passive passive : passives) { passive.moveComponent(); } for (VivaeController controller : controllers) { controller.moveControlledObject(); } }
/** * Registers a controller to an Active object. If the controller extends KeyboardVivaeController * it also registers it to the parent component as a new KeyListener. * * @param agent The Active the controller will control. * @param controller The controller specifing behavior of the Active object. */ public void registerController(Active agent, VivaeController controller) { controller.setControlledObject(agent); controllers.add(controller); if (agent instanceof Robot && controller instanceof KeyboardVivaeController) { if (parent != null) parent.addKeyListener((KeyboardVivaeController) controller); this.addKeyListener((KeyboardVivaeController) controller); } }
/** * Registers a controller to an Active object. If the controller extends KeyboardVivaeController * it also registers it to the parent component as a new KeyListener. * * @param agent The Active the controller will control. * @param controller The controller specifing behavior of the Active object. */ public void registerController(IRobotInterface agent, VivaeController controller) { controller.setControlledObject(agent); controllers.add(controller); if (agent instanceof VivaeRobotRepresent && controller instanceof KeyboardVivaeController) { if (parent != null) { parent.addKeyListener((KeyboardVivaeController) controller); } this.addKeyListener((KeyboardVivaeController) controller); } }