Beispiel #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.");
      }
    }
  }
Beispiel #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);
   }
 }
Beispiel #3
0
 public void setParent(Component parent) {
   this.parent = parent;
   this.isVisible = false;
   if (parent == null) {
     this.isVisible = false;
   } else {
     parent.addKeyListener(this);
   }
 }
Beispiel #4
0
 private void componentAdded(Component comp) {
   comp.addKeyListener(keyHandler);
   if (comp instanceof Container) {
     Container cont = (Container) comp;
     cont.addContainerListener(this);
     Component[] comps = cont.getComponents();
     for (Component comp1 : comps) componentAdded(comp1);
   }
 }
Beispiel #5
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);
   }
 }
Beispiel #6
0
  /**
   * Adds default interactions to the specified component.
   *
   * @param comp component
   * @param win parent window
   */
  public static void addInteraction(final Component comp, final Window win) {
    comp.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseEntered(final MouseEvent e) {
            focus(comp);
          }
        });

    if (win instanceof BaseXDialog) {
      // add default keys
      final BaseXDialog d = (BaseXDialog) win;
      comp.addKeyListener(
          new KeyAdapter() {
            @Override
            public void keyPressed(final KeyEvent e) {
              final Object s = e.getSource();
              if (s instanceof BaseXCombo && ((BaseXCombo) s).isPopupVisible()) return;

              // do not key close dialog if button or editor is focused
              if (ENTER.is(e) && !(s instanceof BaseXButton || s instanceof TextPanel)) {
                d.close();
              } else if (ESCAPE.is(e)) {
                // do not cancel dialog if search bar is opened
                boolean close = true;
                if (s instanceof TextPanel) {
                  final SearchBar bar = ((TextPanel) s).getSearch();
                  close = bar == null || !bar.deactivate(true);
                }
                if (close) d.cancel();
              }
            }
          });
      return;
    }

    if (win instanceof GUI) {
      comp.addKeyListener(globalShortcuts((GUI) win));
    } else {
      throw Util.notExpected("Reference to main window expected.");
    }
  }
Beispiel #7
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);
    }
  }
  /**
   * Constructor.
   *
   * @param eventSource source of the mouse and key events which will be translated into scripting
   *     language commands. Such a typical source is e.g. the VNC viewer panel.
   */
  public RecordingModule(
      MainFrame frame, Component eventSource, ScriptManager scriptManager, UserConfiguration cfg) {
    this.cfg = cfg;
    this.scriptManager = scriptManager;
    readOnly = cfg.getBoolean("rfb.readOnly").booleanValue();

    fb = (DesktopViewer) eventSource;
    fb.removeMouseListener(fb);
    eventSource.addMouseListener(this);
    fb.addMouseListener(fb);
    eventSource.addMouseMotionListener(this);
    eventSource.addMouseWheelListener(this);
    eventSource.addKeyListener(this);

    client = scriptManager.getClient();
    if (client != null) {
      client.addServerListener(this);
    }

    //        scriptManager.addMouseInputListener(this);
    //        scriptManager.addKeyListener(this);

    // Number of archived events
    //        events.setSize(EVENT_VECTOR_SIZE);

    // Populate the reversed keycode->keyname Map
    Map t = Utils.getKeyCodeTable();
    Iterator e = t.keySet().iterator();
    Object o;
    while (e.hasNext()) {
      o = e.next();
      keyCodes.put(t.get(o), o);
    }
    cfg.addConfigurationListener(this);
    scriptManager.addScriptListener(this);
    configurationChanged(null);
  }