public boolean removeConversation(Conversation conversation) {
    boolean removed = false;

    if (conversation instanceof ConversationData) {
      if (this.conversations.contains(conversation)) {
        this.conversations.remove(conversation);
        this.hiddenConversations.add((ConversationData) conversation);
        removed = true;
        this.activeConversation = this.conversations.isEmpty() ? null : this.conversations.get(0);
      }
    } else if (conversation instanceof MultiConversationData) {
      if (this.multiConversations.contains(conversation)) {
        this.multiConversations.remove(conversation);
        this.hiddenMultiConversations.add((MultiConversationData) conversation);
        removed = true;
        this.activeConversation =
            this.multiConversations.isEmpty() ? null : this.multiConversations.get(0);
      }
    }

    super.setChanged();
    super.notifyObservers();

    return removed;
  }
  public void addHiddenConversation(Conversation conversation) {
    if (conversation instanceof ConversationData) {
      if (!this.hiddenConversations.contains(conversation)) {
        this.hiddenConversations.add((ConversationData) conversation);
        if (this.conversations.contains(conversation)) {
          this.conversations.remove(conversation);
          if (this.conversations.size() < 1) {
            this.activeConversation = null;
          }
        }
      }
    } else if (conversation instanceof MultiConversationData) {
      if (!this.hiddenMultiConversations.contains(conversation)) {
        this.hiddenMultiConversations.add((MultiConversationData) conversation);
        if (this.multiConversations.contains(conversation)) {
          this.multiConversations.remove(conversation);
          if (multiConversations.size() < 1) {
            this.activeConversation = null;
          }
        }
      }
    }

    super.setChanged();
    super.notifyObservers();

    return;
  }
  public void run(double duration) {
    double endtime = _currentTime + duration;

    while ((!empty()) && (_head.next.waketime <= endtime)) {
      _currentTime = _head.next.waketime;
      dequeue().run();
      super.setChanged();
      super.notifyObservers();
    }
    _currentTime = endtime;
  }
Exemplo n.º 4
0
  /**
   * Sets whether adjustable participates in adjustment synchronization or not
   *
   * @param adjustable the adjustable
   */
  protected void setParticipatingInSynchronizedScrolling(
      Adjustable adjustable, boolean isParticipating) {
    CheckParameterUtil.ensureParameterNotNull(adjustable, "adjustable");
    if (!synchronizedAdjustables.contains(adjustable))
      throw new IllegalStateException(
          tr(
              "Adjustable {0} not registered yet. Cannot set participation in synchronized adjustment.",
              adjustable));

    enabledMap.put(adjustable, isParticipating);
    observable.notifyObservers();
  }
  public void removeAllConversations() {
    this.conversations.clear();
    this.hiddenConversations.clear();
    this.hiddenMultiConversations.clear();
    this.multiConversations.clear();
    this.activeConversation = null;

    super.setChanged();
    super.notifyObservers();

    return;
  }
  public void setActiveConversation(Conversation activeConversation) {
    this.activeConversation = activeConversation;
    if (this.isHidden(this.activeConversation)) {
      this.activateConversation(this.activeConversation);
    } else {
      // Only notify if not calling activeConversation because
      // it also notifies
      super.setChanged();
      super.notifyObservers();
    }

    return;
  }
Exemplo n.º 7
0
  public void setRule(Syntax syntax, Rule rule) {
    this.syntax = syntax;

    if (this.rule != null) {
      for (Node node : getNodes().toArray(new Node[getNodes().size()])) removeNodeWithEdges(node);
    }
    this.rule = rule;
    if (this.rule != null) populate(rule.node);

    layout();
    hoverProvider.unsetHovering(this);
    ruleObservable.notifyObservers(rule);
  }
Exemplo n.º 8
0
  public synchronized void redrawCurrentImage() {
    if (verbose) {
      System.out.println("redrawCurrentImage called");
      System.out.flush();
    }
    synchronized (redrawLock) {
      scheduled = false;
      drawing = true;
    }
    if (verbose) {
      System.out.println("redraw lock taken");
      System.out.flush();
    }

    Graphics2D G = bufferEnvImage.createGraphics();
    Color myClearColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);
    G.setColor(myClearColor);
    G.setBackground(myClearColor);
    G.clearRect(0, 0, bufferEnvImage.getWidth(), bufferEnvImage.getHeight());

    /*
     * Cycle through SelfUpdatingVizComponents (e.g., CarOnMountainComponent for mountain car) and
     * call getProductionImage(), which calls render()(?).
     */
    for (int i = 0; i < theRenderObjects.size(); i++) {
      RenderObject thisRunner = theRenderObjects.get(i);
      Dimension position = makeLocationForVizComponent(i);
      G.drawImage(thisRunner.getProductionImage(), position.width, position.height, null);
    }

    // Make generated image official as productionEnvImage
    BufferedImage tmpImage = productionEnvImage;
    productionEnvImage = bufferEnvImage;
    bufferEnvImage = tmpImage;

    synchronized (redrawLock) {
      lastDrawTime = System.currentTimeMillis();
      drawing = false;
    }

    if (verbose) {
      System.out.println("redraw finished. parentPanel: " + parentPanel.getClass().getSimpleName());
      System.out.flush();
    }
    parentPanel.receiveNotificationVizChanged();
    super.notifyObservers(productionEnvImage);
  }
  public void activateConversation(Conversation conversation) {

    if (this.hiddenConversations.contains(conversation)) {
      this.conversations.add((ConversationData) conversation);
      this.hiddenConversations.remove(conversation);
    } else if (this.hiddenMultiConversations.contains(conversation)) {
      this.multiConversations.add((MultiConversationData) conversation);
      this.hiddenMultiConversations.remove(conversation);
    } else {
      throw new IllegalArgumentException();
    }

    super.setChanged();
    super.notifyObservers();

    return;
  }
Exemplo n.º 10
0
 @Override
 public void notifyObservers() {
   setChanged();
   super.notifyObservers();
 }
Exemplo n.º 11
0
 @Override
 public void notifyObservers(Object arg) {
   super.setChanged();
   super.notifyObservers(arg);
 }
Exemplo n.º 12
0
  /** Run the simulation for <code>duration</code> model seconds. */
  public void run(int duration) {
    _agents = new ArrayList<Agent>();
    setup(builder, rows, columns);
    _animator = builder.getAnimator();
    super.addObserver(_animator);
    if (_disposed) throw new IllegalStateException();

    // print out lights and roads.
    for (int i = 0; i < duration; i++) {
      _time++;

      // go through road sources and see if a car needs to be added
      for (int k = 0; k < _sources.size(); k++) {
        if (_time % _sources.get(k).getGeneration() == 0) {
          if (_sources.get(k).forGridLock() > 0) {
            Car car = new Car();
            car.setRoad(_sources.get(k));
            _cars.add(car);
            _agents.add(car);
            _sources.get(k).accept(car);
          }
        }
      }

      Agent[] agents_copy = _agents.toArray(new Agent[0]);
      for (Agent a : agents_copy) {
        a.run(_time);

        if (a instanceof Car) {

          // MOVE THE CARS IF THEY'RE OFF ROADS
          _index = _roads.indexOf((((Car) a).getRoad()));

          // if its on a sink
          if (((Car) a).getKill() == true) {
            _agents.remove(a);
            _roads.get(_index).removeCar((Car) a);
          }
          // if its gone off a road, but its not a sink
          else if (((Car) a).getPosition() < 0) {

            // can't move if the light is red
            Road road = _roads.get(_index);

            // all about stopping for the lights
            if (road.getPattern().equals("RH")
                && intersections[road.getX()][road.getY()].getColorEW().equals(Color.RED)) {
              ((Car) a).setPosition((int) (MP.roadLength - ((Car) a).getLength()));
              ((Car) a).stop(true);
            } else if (road.getPattern().equals("RV")
                && intersections[road.getX()][road.getY()].getColorNS().equals(Color.RED)) {
              ((Car) a).setPosition((int) (MP.roadLength - ((Car) a).getLength()));
              ((Car) a).stop(true);
            } else if (road.getPattern().equals("AH")
                && intersections[road.getX()][road.getY() - 1].getColorEW().equals(Color.RED)) {
              ((Car) a).setPosition((int) (MP.roadLength - ((Car) a).getLength()));
              ((Car) a).stop(true);
            } else if (road.getPattern().equals("AV")
                && intersections[road.getX() - 1][road.getY()].getColorNS().equals(Color.RED)) {
              ((Car) a).setPosition((int) (MP.roadLength - ((Car) a).getLength()));
              ((Car) a).stop(true);
            } else {
              // check for road block
              // don't go over the array size
              if ((_index + 1) < _roads.size()) {
                if (_roads.get(_index + 1).forGridLock() > 0) {
                  _roads.get(_index).removeCar(a);
                  ((Car) a).setPosition(0);
                  _index++;

                  _roads.get(_index).accept((Car) a);
                  ((Car) a).setRoad(_roads.get(_index));
                }
              }
            }
          }
        }
      }
      super.setChanged();
      super.notifyObservers();
    }
  }
Exemplo n.º 13
0
  @Override
  public void notifyObservers(Object arg) {

    if (shuffleObservers) shuffleObservers();
    super.notifyObservers(arg);
  }
Exemplo n.º 14
0
  public void forceUpdate() {
    super.setChanged();
    super.notifyObservers();

    return;
  }
 @Override
 public void notifyObservers() {
   observable.notifyObservers();
 }
 @Override
 public void notifyObservers(Object arg) {
   observable.notifyObservers(arg);
 }
Exemplo n.º 17
0
 private void measurementChanged(WeatherCondition weatherCondition) {
   super.setChanged();
   ;
   super.notifyObservers(weatherCondition);
 }
Exemplo n.º 18
0
 /** Notify observers. */
 private void notifyObservers() {
   if (observable != null) {
     observable.notifyObservers(this);
   }
 }
Exemplo n.º 19
0
 public Object remove(Object key) {
   Object obj = super.remove(key);
   _observable.notifyObservers(obj);
   return obj;
 }
Exemplo n.º 20
0
 public void notify(Identifier ident) {
   Observable obs = observables.get(ident);
   if (obs != null) {
     obs.notifyObservers();
   }
 }
 @Override
 public void notifyObservers(Object data) {
   setChanged();
   super.notifyObservers(data);
 }
Exemplo n.º 22
0
  /**
   * 通知更新方法,请在子类中需要通知观察者的地方调用此方法
   *
   * @param data
   */
  protected void updateChange(UpdateMessage message) {

    super.setChanged();
    super.notifyObservers(message);
  }