Ejemplo n.º 1
0
  /**
   * 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.");
      }
    }
  }
Ejemplo n.º 2
0
 /**
  * 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);
   }
 }
Ejemplo n.º 3
0
 public void setParent(Component parent) {
   this.parent = parent;
   this.isVisible = false;
   if (parent == null) {
     this.isVisible = false;
   } else {
     parent.addKeyListener(this);
   }
 }
Ejemplo n.º 4
0
 /**
  * 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);
   }
 }
Ejemplo n.º 5
0
  /**
   * 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);
    }
  }