Ejemplo n.º 1
0
  /**
   * Update whether a named signal source is active.
   *
   * @param name signal's name (not null)
   * @param sourceIndex index of the signal source (key or button) which is being updated
   * @param newState true if the source is active; false is the source is inactive
   */
  private void update(String name, int sourceIndex, boolean newState) {
    Indices status = statusMap.get(name);
    if (status == null) {
      logger.log(Level.WARNING, "Unknown signal: {0}", MyString.quote(name));
      return;
    }
    logger.log(
        Level.INFO, "name = {0}, newState = {1}", new Object[] {MyString.quote(name), newState});

    status.addRemove(sourceIndex, newState);
  }
Ejemplo n.º 2
0
  /**
   * Test whether the named signal is active.
   *
   * @param name signal's name (not null)
   * @return true if any of the signal's sources is active; false if all of the signal's sources are
   *     inactive
   */
  public boolean test(String name) {
    assert name != null;

    Indices status = statusMap.get(name);
    if (status == null) {
      logger.log(
          Level.WARNING,
          "Testing a signal which has not yet been added: {0}.",
          MyString.quote(name));
      status = new Indices();
      statusMap.put(name, status);
    }
    boolean result = !status.isEmpty();
    return result;
  }