Package de.hpi.eworld.observer

Examples of de.hpi.eworld.observer.ObserverNotification


  public void convertWaysToEdges() {
    convertWaysToEdges = true;
  }

  public synchronized void update(Observable o, Object arg) {
    ObserverNotification notification = (ObserverNotification)arg;
   
    if(notification.getType() == NotificationType.elementAdded) {
      this.addModelElement((ModelElement)notification.getObj1());
    }
  } 
View Full Code Here


      EWorld2sumoMenu sumoMenu = sumoExp.getMenu();
      sumoMenu.provideObservable().addObserver(this);
      this.dispose();
    } else {
      // otherwise, do nothing since sumo is already running somewhere
      this.notifyObservers(new ObserverNotification(NotificationType.configFinished, simSettings));
      dispose();
    }
  }
View Full Code Here

  public void update(Observable arg0, Object arg1) {
    this.simSettings.setSumoCfgFile(((ObserverNotification) arg1).getObj1().toString());
    Object observerNotification = ((ObserverNotification) arg1).getObj2();
    this.simSettings.setSumoOffsetX(((double[]) observerNotification)[0]);
    this.simSettings.setSumoOffsetY(((double[]) observerNotification)[1]);
    this.notifyObservers(new ObserverNotification(NotificationType.configFinished, simSettings));
    this.dispose();
    }
View Full Code Here

  @Override
  public void update(final Observable o, final Object arg) {
    if (arg instanceof ObserverNotification) {
      // cast notification and type.
      final ObserverNotification notification = (ObserverNotification) arg;
      final NotificationType type = notification.getType();

      // we're going to make some assumptions about the class of some
      // objects returned from the notification. those might be wrong,
      // hence the try/catch with ClassCastException.
      try {
View Full Code Here

  }

  @Override
  public void update(final Observable o, final Object arg) {
    if (arg instanceof ObserverNotification) {
      final ObserverNotification notification = (ObserverNotification) arg;
      final NotificationType type = notification.getType();
      try {
        if (type.equals(NotificationType.loadFromFile)) {
          final PersistenceProviderInterface plugin = (PersistenceProviderInterface) notification.getObj1();
          final Collection<?> items = (Collection<?>) notification.getObj2();
          if (this == plugin) {
            loadFromFile(items);
          }
        } else if (type.equals(NotificationType.clearModel)) {
          final PersistenceProviderInterface plugin = (PersistenceProviderInterface) notification.getObj1();
          if (this == plugin) {
            clearModel();
          }
        }
        if (type.equals(NotificationType.saveToFile)) {
          final PersistenceProviderInterface plugin = (PersistenceProviderInterface) notification.getObj1();
          @SuppressWarnings("unchecked")
          final Collection<Object> items = (Collection<Object>) notification.getObj2();
          if (this == plugin) {
            saveToFile(items);
          }
        }
      } catch (final ClassCastException e) {
View Full Code Here

        t = new Thread(infoLog);
        t.start();

      } catch (IOException e) {
        log.error("Error while trying to create sumo process", e);
        this.notifyObservers(new ObserverNotification(NotificationType.simulationError, e));
        return;
      }
      log.info("Sumo started successfully.");
    }
View Full Code Here

  /**
   * SLOT that is called upon simulation error
   * @param e
   */
  private void handleSimulationException(Exception e) {
    this.notifyObservers(new ObserverNotification(NotificationType.simulationError, e));
  }
View Full Code Here

  /**
   * SLOT that is called upon simulation stepping
   * @param i
   */
  private void handleSimulationStepping(Integer i) {
    this.notifyObservers(new ObserverNotification(NotificationType.simulationStepping, i));
  }
View Full Code Here

  public void update(final Observable o, final Object arg) {

    if (arg instanceof ObserverNotification) {

      // cast notification and type.
      final ObserverNotification notification = (ObserverNotification) arg;
      final NotificationType type = notification.getType();

      logger.debug("Received notification: " + type.toString());
      switch (type) {
        case simulationError:
          handleSimulationException((Exception) notification.getObj1());
          break;
        case simulationStepping:
          handleSimulationStepping((Integer) notification.getObj1());
          break;
        default:
          break;
      }
View Full Code Here

    // now ask for each registered plugin to deliver their data
    for (final String pluginName : plugins.keySet()) {
      final Collection<Object> coll = new ArrayList<Object>();
      setChanged();
      notifyObservers(new ObserverNotification(NotificationType.saveToFile, plugins.get(pluginName), coll));
      clearChanged();

      // if the plugin has data...
      if (coll.size() > 0) {
View Full Code Here

TOP

Related Classes of de.hpi.eworld.observer.ObserverNotification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.