Ejemplo n.º 1
0
  public List<Input> getInputs() {
    List<Input> inputs = Lists.newArrayList();

    for (InputState input : getInputStates()) {
      inputs.add(input.getInput());
    }

    return inputs;
  }
Ejemplo n.º 2
0
  /**
   * Set the current command to the specified command and execute it.
   *
   * @param factory The command to be executed.
   * @return The message that should be printed.
   */
  public String setCurrentFactory(CommandFactory factory) {

    if (factory == null) {
      cancelCurrentFactory();
      return null;
    }
    return currentState.setCurrentFactory(factory);
  }
  public Map<Input, Map<ClusterEntity, InputState>> loadAllInputStatesByInput() {
    Map<ClusterEntity, List<InputState>> inputStatesByNode = loadAllInputStatesByEntity();
    Map<Input, Map<ClusterEntity, InputState>> result = Maps.newHashMap();

    for (Map.Entry<ClusterEntity, List<InputState>> nodeEntry : inputStatesByNode.entrySet()) {
      for (InputState inputState : nodeEntry.getValue()) {
        Input input = inputState.getInput();
        if (result.get(input) == null) {
          Map<ClusterEntity, InputState> inputStateMap = Maps.newHashMap();
          result.put(input, inputStateMap);
        }

        result.get(input).put(nodeEntry.getKey(), inputState);
      }
    }

    return result;
  }
Ejemplo n.º 4
0
  /** Receives the text and interpretes it. */
  public void receiveText(String text) {

    String returnValue = ""; // $NON-NLS-1$
    String trimmedText = text.trim();

    boolean shouldHandleNext;
    do {
      String receivedText = currentState.receiveText(trimmedText);
      if (receivedText != null) {
        returnValue += receivedText;
      }
      shouldHandleNext = currentState.nextShouldHandle();
      changeState(currentState.getNext());
    } while (shouldHandleNext);

    if (returnValue != null && !returnValue.trim().equals("")) { // $NON-NLS-1$
      printInInterpreter(returnValue);
    }
  }
Ejemplo n.º 5
0
  @Override
  public void touchDragged(InputEvent event, float x, float y, int pointer) {
    super.touchDragged(event, x, y, pointer);

    if (selecting) {
      selectionBox.set(
          Math.min(x, selectionBoxPivot.x),
          Math.min(y, selectionBoxPivot.y),
          Math.abs(x - selectionBoxPivot.x),
          Math.abs(y - selectionBoxPivot.y));
      Service.eventQueue().enqueue(new Event(EventName.SELECTING, selectionBox));
    }
  }
Ejemplo n.º 6
0
  /** @param drawing True if the interpreter is enabled, false otherwise. */
  public void setDrawing(Drawing drawing) {

    Controller controller = br.org.archimedes.Utils.getController();
    if (!controller.isThereActiveDrawing()) {
      controller.setActiveDrawing(drawing);
    } else if (this.getCurrentFactory() == null || this.getCurrentFactory().isDone()) {
      controller.setActiveDrawing(drawing);
      controller.deselectAll();
    }

    changeState(currentState.changedDrawing(drawing));
    setChanged();
    notifyObservers(drawing);
  }
Ejemplo n.º 7
0
  /** @return true if the input controller wants to receive a space character, false otherwise. */
  public boolean wantsSpace() {

    return currentState.wantsSpace();
  }
Ejemplo n.º 8
0
  /** @return Returns the current command or null if there is no current command. */
  public CommandFactory getCurrentFactory() {

    return currentState.getCurrentFactory();
  }
Ejemplo n.º 9
0
  private void changeState(InputState newState) {

    currentState = newState;
    changeContext(newState.getContextId());
  }
Ejemplo n.º 10
0
  /** Cancels the current factory and sets the current factory as selection. */
  public void cancelCurrentFactory() {

    String message = currentState.cancel();
    changeState(currentState.getNext());
    printInInterpreter(message);
  }