public List<Input> getInputs() { List<Input> inputs = Lists.newArrayList(); for (InputState input : getInputStates()) { inputs.add(input.getInput()); } return inputs; }
/** * 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; }
/** 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); } }
@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)); } }
/** @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); }
/** @return true if the input controller wants to receive a space character, false otherwise. */ public boolean wantsSpace() { return currentState.wantsSpace(); }
/** @return Returns the current command or null if there is no current command. */ public CommandFactory getCurrentFactory() { return currentState.getCurrentFactory(); }
private void changeState(InputState newState) { currentState = newState; changeContext(newState.getContextId()); }
/** Cancels the current factory and sets the current factory as selection. */ public void cancelCurrentFactory() { String message = currentState.cancel(); changeState(currentState.getNext()); printInInterpreter(message); }