Package de.hpi.eworld.observer

Examples of de.hpi.eworld.observer.ObserverNotification


   */
  public void setSimulationEndTime(int simulationEndTime) {
    this.simulationEndTime = simulationEndTime;

    setChanged();
    notifyObservers(new ObserverNotification(NotificationType.simulationTimeRangeChanged));
  }
View Full Code Here


   */
  public void setSimulationStartTime(int simulationStartTime) {
    this.simulationStartTime = simulationStartTime;

    setChanged();
    notifyObservers(new ObserverNotification(NotificationType.simulationTimeRangeChanged));
  }
View Full Code Here

  public int getSimulationLength() {
    return simulationEndTime - simulationStartTime;
  }

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

      hasReachedThreshold = true;
    }

    if (hasReachedThreshold) {
      setChanged();
      notifyObservers(new ObserverNotification(NotificationType.elementChanged, this));
      clearChanged();
    }
  }
View Full Code Here

    this.messageTime = updateCount;
    this.sentCount++;

    if (!wasSendingMessage) {
      setChanged();
      notifyObservers(new ObserverNotification(NotificationType.elementChanged, this));
      clearChanged();
    }
  }
View Full Code Here

    this.receivingMessage = true;
    this.messageTime = updateCount;
    this.receivedCount++;

    setChanged();
    notifyObservers(new ObserverNotification(NotificationType.elementChanged, this));
    clearChanged();
  }
View Full Code Here

   */
  @SuppressWarnings("rawtypes")
  @Override
  public void update(Observable o, Object arg) {
    if (arg instanceof ObserverNotification) {
      ObserverNotification notification = (ObserverNotification) arg;
      NotificationType type = notification.getType();
     
      // dispatch events to methods handling a special event
      switch (type) {
        case itemButtonClicked:
          onItemButtonClicked((AbstractView) notification.getObj1(), (AbstractButton)notification.getObj2());
          break;
        case elementAdded:
          Object element = notification.getObj1();
          if (element instanceof AreaModel) {
            onAreaAdded((AreaModel)element);
          }
          break;
        default:
View Full Code Here

    StatisticsDataManager smm = StatisticsDataManager.getInstance();
    smm.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
         
          if (type.equals(NotificationType.displayInfoBox)) {
            showInfoBox((String) notification.getObj1(), (String) notification.getObj2());
          }
        }
      }
    });
   
    //setAllowedAreas(Qt.DockWidgetArea.RightDockWidgetArea, Qt.DockWidgetArea.LeftDockWidgetArea);
//    setTitle(title);
    tabWidget = new JPanel();
    tabWidget.setMinimumSize(new Dimension(150, 200));
    tabWidget.setMaximumSize(new Dimension(235,9999));

    // statDataWidget
    // ------------------------------------------------------------
    statDataWidget = new JPanel();
    GridBagLayout dataLayout = new GridBagLayout();

    listModel = new DefaultListModel<ListValue>();
    datasetsList = new JList<Object>();
   
    datasetsListPopup = new JPopupMenu();
    datasetsListPopup.addPopupMenuListener(new PopupMenuListener() {
      @Override
      public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
        displayDatasetItem((ListValue) e.getSource());
      }
     
      @Override
      public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {}
     
      @Override
      public void popupMenuCanceled(PopupMenuEvent e) {}
    });
   
    // context actions
    JMenuItem showPropertiesAction = new JMenuItem("Properties");
    showPropertiesAction.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        super.mouseClicked(e);
        showProperties();
      }
    });
    datasetsListPopup.add(showPropertiesAction);
   
    JMenuItem showChartsAction = new JMenuItem("Show charts");
    showChartsAction.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        super.mouseClicked(e);
        showCharts();
      }
    });
    datasetsListPopup.add(showChartsAction);
   
    showOnMapAction = new JMenuItem("Show on map");
    showOnMapAction.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        super.mouseClicked(e);
        initShowOnMap();
      }
    });
    datasetsListPopup.add(showOnMapAction);
   
    JMenuItem showRawAction = new JMenuItem("Open data file");
    showRawAction.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        super.mouseClicked(e);
        showRawData();
      }
    });
    datasetsListPopup.add(showRawAction);
   
    JMenuItem renameSetAction = new JMenuItem("Rename");
    renameSetAction.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        super.mouseClicked(e);
        onRenameDataset();
      }
    });
    datasetsListPopup.add(renameSetAction);
   
    JMenuItem deleteSetAction = new JMenuItem("Remove");
    deleteSetAction.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        super.mouseClicked(e);
        onDeleteDataset();
      }
    });
    datasetsListPopup.add(deleteSetAction);
   
    JMenuItem deleteAllAction = new JMenuItem("Remove all");
    deleteAllAction.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        super.mouseClicked(e);
        onDeleteAllDatasets();
      }
    });
    datasetsListPopup.add(deleteAllAction);

    //datasetsList.setContextMenuPolicy(Qt.ContextMenuPolicy.NoContextMenu);
    datasetsList.addListSelectionListener(new ListSelectionListener() {
      @Override
      public void valueChanged(ListSelectionEvent e) {
        checkBelongingToMap();
      }
    });
   
    statAutoImport = new JCheckBox("Automatically import data");
    statAutoImport.setToolTipText("Import of the SUMO dump data will be triggered automatically when the simulation finishes");
    statAutoImport.setSelected(true);

    final GridBagConstraints datasetsListConstraints = new GridBagConstraints();
    datasetsListConstraints.gridx = 0;
    datasetsListConstraints.gridy = 0;
    datasetsListConstraints.fill = GridBagConstraints.HORIZONTAL;
    dataLayout.setConstraints(datasetsList, datasetsListConstraints);
    mainPanel.add(datasetsList);
   
    final GridBagConstraints statAutoImportConstraints = new GridBagConstraints();
    statAutoImportConstraints.gridx = 1;
    statAutoImportConstraints.gridy = 0;
    statAutoImportConstraints.gridwidth = 1;
    statAutoImportConstraints.fill = GridBagConstraints.HORIZONTAL;
    dataLayout.setConstraints(statAutoImport, statAutoImportConstraints);
    mainPanel.add(statAutoImport);

    statDataWidget.setLayout(dataLayout);


    //simulationDock.set(tabWidget.indexOf(statDataWidget));

    smm.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
         
          if (type.equals(NotificationType.datasetsChanged)) {
            onDatasetsChanged();
          }
        }
      }
    });
   
    smm.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
         
          if (type.equals(NotificationType.datasetsCleared)) {
            onDatasetsCleared();
          }
        }
View Full Code Here

   
    networkView.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
         
          if (type.equals(NotificationType.endBatchProcess)) {
            onBatchEnded();
          }
        }
      }
    });
   
    networkView.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
         
          if (type.equals(NotificationType.startBatchProcess)) {
            visualizeWidget.stopShowOnMap();
          }
        }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Override
  public void update(Observable o, 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.
      switch (type) {
      case startBatchProcess:
        onBatchProcessStarted();
        break;
      case endBatchProcess:
        onBatchProcessEnded((Boolean) notification.getObj1(), (Boolean) notification.getObj2());
        break;
      case modelCleared:
        onModelCleared();
        break;
      case elementAdded:
        onModelElementAdded((ModelElement) notification.getObj1());
        break;
      case elementChanged:
        final Object transportedObject = notification.getObj1();
        if (transportedObject instanceof ModelElement) {
          onModelElementChanged((ModelElement) transportedObject);
        } else {
          onVolatileModelElementChanged((VolatileModelElement) transportedObject);
        }
        break;
      case elementRemoved:
        onModelElementRemoved((ModelElement) notification.getObj1());
        break;
      case volatileModelElementAdded:
        onVolatileModelElementAdded((VolatileModelElement) notification.getObj1());
        break;
      case volatileModelElementRemoved:
        onVolatileModelElementRemoved((VolatileModelElement) notification.getObj1());
        break;

      case itemHoverEntered:
        onViewItemHoverEntered((AbstractView<ModelElement>) notification.getObj1());
        break;
      case itemHoverLeft:
        onViewItemHoverLeft();
        break;
      case itemClicked:
        if (notification.getObj1() instanceof AbstractView) {
          onViewItemClicked((AbstractView<ModelElement>) notification.getObj1());
        } else {
          logger.error(type + " notification from object which is not a descendant of AbstractView");
        }
        break;
      case itemMouseReleased:
        if (notification.getObj1() instanceof AbstractView) {
          onItemMouseReleased((AbstractView<ModelElement>) notification.getObj1());
        } else {
          logger.error(type + " notification from object which is not a descendant of AbstractView");
        }
        break;
      case itemMousePressed:
        if (notification.getObj1() instanceof AbstractView) {
          onItemMousePressed((AbstractView<ModelElement>) notification.getObj1());
        } else {
          logger.error(type + " notification from object which is not a descendant of AbstractView");
        }
        break;
      case freeSpaceClicked:
        onFreeSpaceClicked();
        break;
      case freeSpacePressed:
        onFreeSpacePressed((MouseEvent) notification.getObj1());
        break;
      case freeSpaceDragged:
        onFreeSpaceDragged((MouseEvent) notification.getObj1());
        break;
      case freeSpaceReleased:
        onFreeSpaceReleased((MouseEvent) notification.getObj1());
        break;
      case itemDoubleClicked:
        if (notification.getObj1() instanceof AbstractView) {
          onViewItemDoubleClicked((AbstractView<ModelElement>) notification.getObj1());
        } else {
          logger.error(type + " notification from object which is not a descendant of AbstractView");
        }
        break;
      case itemButtonClicked:
        if (notification.getObj1() instanceof AbstractView) {
          final AbstractView<ModelElement> item = (AbstractView<ModelElement>) notification.getObj1();
          onItemButtonClicked(item, (AbstractButton) notification.getObj2());
        } else {
          logger.error(type + " notification from object which is not a descendant of AbstractView");
        }
        break;
      default:
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.