/** * Arena consturctor. * * @param parent The component where the arena will be displayed in. */ public Arena(Component parent) { super(); this.parent = parent; this.isVisible = false; if (parent == null) { this.isVisible = false; } else { parent.addKeyListener(this); } FrictionBuffer get = frictionBufferCache.get(this.svgFileName); if (get == null) { // if not in cache, create new instance and frictionBuffer = new FrictionBuffer(this); frictionBufferCache.put(this.svgFileName, frictionBuffer); if (DEBUG_FRICTION_CACHE) { System.out.println( "Cached friction buffer not found, I have created new instance and cached it."); } } else { frictionBuffer = get; if (DEBUG_FRICTION_CACHE) { System.out.println("Cached friction buffer found."); } } }
/** * 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); } }
public void setParent(Component parent) { this.parent = parent; this.isVisible = false; if (parent == null) { this.isVisible = false; } else { parent.addKeyListener(this); } }
/** * 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); } }
/** * Arena consturctor. * * @param parent The component where the arena will be displayed in. */ public Arena(Component parent) { super(); this.parent = parent; this.isVisible = false; if (parent == null) { this.isVisible = false; } else { parent.addKeyListener(this); } }