Examples of ObserverNotification


Examples of de.hpi.eworld.observer.ObserverNotification

  public void setDistance(double distance) {
    boolean changed = (this.distance != distance);
    this.distance = distance;
    if(changed) {
      this.setChanged();
      this.notifyObservers(new ObserverNotification(NotificationType.elementChanged, this));
      this.clearChanged();
    }
  }
View Full Code Here

Examples of de.hpi.eworld.observer.ObserverNotification

  public void setLength(double length) {
    boolean changed = (this.length != length);
    this.length = length;
    if(changed) {
      this.setChanged();
      this.notifyObservers(new ObserverNotification(NotificationType.elementChanged, this));
      this.clearChanged();
    }
  }
View Full Code Here

Examples of de.hpi.eworld.observer.ObserverNotification

   *            a {@link ObserverNotification} of the network view
   */
  @Override
  public void update(Observable o, Object arg) {
    if (arg instanceof ObserverNotification) {
      final ObserverNotification notification = (ObserverNotification) arg;
      final NotificationType type = notification.getType();

      switch (type) {
        case itemClicked:
          Object item = notification.getObj1();
          if (item instanceof WayView) {
            onWayClicked((WayView) item);
 
          } else {
            clearSelection();
View Full Code Here

Examples of de.hpi.eworld.observer.ObserverNotification

   * the models and removed when they got removed from the selection.
   */
  @Override
  public void update(Observable o, Object arg) {
    if (arg instanceof ObserverNotification) {
      final ObserverNotification notification = (ObserverNotification) arg;
      final NotificationType type = notification.getType();

      switch (type) {
        case itemClicked:
          clearSelection();
 
          Object item = notification.getObj1();
          if (item instanceof StreetBarrierView) {
            RoadSpotModel roadSpot = (RoadSpotModel) ((StreetBarrierView) item)
                .getModelElement();
            if (roadSpot.getEventType() == Type.School) {
              SchoolModel school = (SchoolModel) roadSpot;
View Full Code Here

Examples of de.hpi.eworld.observer.ObserverNotification

   * 2nd reason: import progress has changed
   * 3rd reason: import was canceled or failed in another way
   */
  @Override
  public void update(Observable o, Object arg) {
    final ObserverNotification notification = (ObserverNotification) arg;

    if (notification.getType() == NotificationType.done) {
      mDialog.setImporting(false);
      // set status bar text
      final int size = ModelManager.getInstance().getAllModelElements().size();
      MainStatusBar.getInstance().showMessage(
        "OSM import successful. Map size: "
        +String.valueOf(size)
        +" elements",
        10000
      );
      mDialog.getProgressDialog().setLabelText("Import complete!");
      mDialog.getProgressDialog().setButtonText("Ok");
      mDialog.getProgressDialog().setVisible(false);
      mDialog.closeDialog();
    } else if (notification.getType() == NotificationType.progress) {
      mDialog.getProgressDialog().setProgressValue(
        new Integer(notification.getObj1().toString())
      );
    } else if (notification.getType() == NotificationType.nothing) {
      mDialog.getProgressDialog().setVisible(false);
      mDialog.closeDialog();
    } else if (notification.getType() == NotificationType.failed) {
      mDialog.setImporting(false);
      Logger.getLogger(this.getClass()).error("Import of OSM data failed!");

      mDialog.getProgressDialog().setVisible(false);
      mDialog.closeDialog();

      JOptionPane.showMessageDialog(
        mDialog.getParent(),
        "Import of OSM data failed! "
        +(String) notification.getObj1(),
        "Import failed",
        JOptionPane.ERROR_MESSAGE
      );
    } else {
      log.error("Unknown event occured: " + notification.getType());
    }
  }
View Full Code Here

Examples of de.hpi.eworld.observer.ObserverNotification

  }

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

      switch (notificationType) {
        case itemClicked:
          Object item = notification.getObj1();
          if (item instanceof StreetBarrierView) {
            RoadSpotModel roadSpot = (RoadSpotModel) ((StreetBarrierView) item)
                .getModelElement();
            if (roadSpot.getEventType() == roadSpotType) {
              descriptionModel.setMappingKey(roadSpot);
View Full Code Here

Examples of de.hpi.eworld.observer.ObserverNotification

   *            a {@link ObserverNotification} of the network view
   */
  @Override
  public void update(Observable o, Object arg) {
    if (arg instanceof ObserverNotification) {
      final ObserverNotification notification = (ObserverNotification) arg;
      final NotificationType type = notification.getType();
      final CardLayout propertyPaneLayout = (CardLayout) propertyPane
          .getLayout();

      switch (type) {
        case itemClicked:
          Object item = notification.getObj1();
          if (item instanceof WayView) {
            propertyPaneLayout.show(propertyPane, edgePaneName);
 
          } else if (item instanceof StreetBarrierView) {
            RoadSpotModel roadSpot = (RoadSpotModel) ((StreetBarrierView) item)
View Full Code Here

Examples of de.hpi.eworld.observer.ObserverNotification

      traciClient.init(socket);
      initializeTrafficLightVisualization();
      traciClient.subscribeToSimulationValues(); //<-new
      log.info("Connection to TraCi Client established. Starting simulation.");
      for (int i = 1; i < this.simulateUntil; i++) {
        this.notifyObservers(new ObserverNotification(NotificationType.simulationStepping, i));
        while (pause) {
          Thread.sleep(1000);
          // if user pressed stop, proceed.
          if (cancelSim)
            break;
          if (oneStep) {
            oneStep = false;
            break;
          }
        }
        if (cancelSim) {
          try {
            traciClient.closeConnection();
          } catch (IOException e) {
            log.error(e);
          }
          this.notifyObservers(new ObserverNotification(NotificationType.simulationCancel));
          return; // stop simulation
        }
        // simulate next step

        try {
          movements = traciClient.simulateTrafficUntil(i, readOnly);
          updateVehicles(movements);
          updateTrafficLights();
        } catch (Exception e) {
          this.notifyObservers(new ObserverNotification(NotificationType.simulationError, e));
          return;
        }
       
        Thread.sleep(this.simulationStepTime);
      }
View Full Code Here

Examples of de.hpi.eworld.observer.ObserverNotification

  public void testSaveLoad_Imported() {
    Osm2Model converter = new Osm2Model();
    ModelManager mm = ModelManager.getInstance();
    ModelManagerMockUp mmmu = ModelManagerMockUp.getInstance();
    mm.addObserver(mmmu);
    mm.notifyObservers(new ObserverNotification(NotificationType.elementAdded));
    try {
      converter.parseFile(new FileInputStream("./resources/rostock.osm"));
    }
    catch (Exception xcp) {
      xcp.printStackTrace();
View Full Code Here

Examples of de.hpi.eworld.observer.ObserverNotification

        return false;
      }

      this.setChanged();
      this.logger.info("Map was successfully converted to SUMO format.");
      this.notifyObservers(new ObserverNotification(NotificationType.sumoFilesSavedTo, path_name));

      return true;
    } else {
      this.logger.error("Either filename or path not defined.");
      return false;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.