Package de.hpi.eworld.core

Examples of de.hpi.eworld.core.ModelManager


   *
   * @author Thomas Beyhl
   */
  @Override
  public void run() {
    ModelManager manager = ModelManager.getInstance();
    manager.setChanged();
    manager.notifyObservers(new ObserverNotification(NotificationType.startBatchProcess));
    manager.clearChanged();
   
    Collection<ModelElement> allElements = ModelManager.getInstance().getAllModelElements();
    int totalNumber = allElements.size();
    if(totalNumber == 0) totalNumber = 1;
    int i = 0;
   
    for(ModelElement m : allElements)
    { 
      if(progressDialog.wasCanceled()) break;

      m.setChanged();
      m.notifyObservers(new ObserverNotification(NotificationType.elementChanged, m));
      m.clearChanged();
      i++;

      int progress = (int)i * 100 / totalNumber;
      this.setChanged();
      this.notifyObservers(new ObserverNotification(NotificationType.progress,
                              progress));
      this.clearChanged();
    }
   
    manager.setChanged();
    manager.notifyObservers(new ObserverNotification(NotificationType.endBatchProcess, true, false));
    manager.clearChanged();
   
    this.setChanged();
    if(progressDialog.wasCanceled()) {
      this.notifyObservers(new ObserverNotification(NotificationType.failed));
    }
View Full Code Here


    return areaIdentifierField;
  }
 
  protected JComponent prepareSimulationTimeInput() {
    JPanel simulationTimePanel = new JPanel();
    ModelManager modelManager = ModelManager.getInstance();

    simulationTimePanel.setLayout(new BoxLayout(simulationTimePanel, BoxLayout.LINE_AXIS));
   
    simulationTimeSliderValue = new JTextField(String.valueOf(DEFAULT_SIMULATION_TIME));
    simulationTimeSliderValue.setToolTipText(TOOLTIP_SIMULATION_TIME);
   
    simulationTimeSliderValue.repaint();
   
    simulationTimeSliderValue.setPreferredSize(
        new Dimension(40, simulationTimeSliderValue.getPreferredSize().height));
   
    simulationTimeSlider = new JSlider(
        JSlider.HORIZONTAL,
        modelManager.getSimulationStartTime(),
        modelManager.getSimulationEndTime(),
        DEFAULT_SIMULATION_TIME);
   
    simulationTimeSlider.setPreferredSize(new Dimension(80, simulationTimeSlider.getPreferredSize().height));
   
    simulationTimeSlider.setToolTipText(TOOLTIP_SIMULATION_TIME);
View Full Code Here

    graphView.getGraphEventListener().initFreeSpace(this);
    this.graphCoordinateConverter = new GraphCoordinateConverter(graphView);
    initializeDragAndDrop();

    // register as model listener
    final ModelManager mManager = ModelManager.getInstance();
    mManager.addObserver(this);

    if (null != plugin) {
      plugin.provideObservable().addObserver(this);
    }
  }
View Full Code Here

    controller.centerMap();
    progressDialog.setVisible(false);
    if (osmDefaultValues == true) {
      JOptionPane.showMessageDialog(null, "The OSM files misses some lane/speed information, used default values.", "OSM default values", JOptionPane.INFORMATION_MESSAGE);
    }
    ModelManager mm = ModelManager.getInstance();
    mm.addPOIsToWays();
    mm.setChanged();
    progressDialog = null;
    controller.fireNotifyObservers(new ObserverNotification(NotificationType.endBatchProcess));
  }
View Full Code Here

      new EnvironmentEventModel(EnvironmentEventModel.Type.Snow, 0, el);
   
    ///////////////////////////////////
    // run restore test
   
    ModelManager mm = ModelManager.getInstance();
   
    //make sure the model is empty before we add anything
    mm.clearModel();
   
    mm.addModelElement(re1);
    mm.addModelElement(re2);
    mm.addModelElement(re3);
    mm.addModelElement(re4);
    mm.addModelElement(re5);
    mm.addModelElement(re6);
    mm.addModelElement(ee1);
    mm.addModelElement(ee2);
    mm.addModelElement(ee3);
   
    //save it to an ewd file
    PersistenceManager.getInstance().saveToFile(EWD_FILE);
   
    //fine, now lets restore the saved objects
    mm.clearModel();
    PersistenceManager.getInstance().loadFromFile(EWD_FILE);
   
    Collection<ModelElement> modelElements = mm.getAllModelElements();
    Assert.assertEquals(9, modelElements.size());

    //cleanup
    Assert.assertTrue(FileSysUtils.deleteFile(EWD_FILE));
  }
View Full Code Here

    add(Box.createHorizontalGlue());
    observable = new ObservableWrapper();
  }

  private void addItems() {
    ModelManager modelManager = ModelManager.getInstance();
    modelManager.addObserver(this);

    exportButton = EXPORT.createJButton();
    add(exportButton);
    exportButton.setEnabled(!modelManager.isEmpty());
   
    startButton = PLAY.createJButton();
    startButton.setEnabled(!modelManager.isEmpty());
    add(startButton);
   
    stopButton = STOP.createJButton();
    stopButton.setEnabled(false);
    add(stopButton);
View Full Code Here

   * Saves the model element to an ewd file via ModelManager.saveToFile and
   * Loads it afterwards to check if all attributes are restored correctly
   */
  @Test
  public void testSaveAndRestore() {
    ModelManager modelManager = ModelManager.getInstance();
    modelManager.clearModel();

    // save
    modelManager.addModelElement(pos1);

    PersistenceManager.getInstance().saveToFile(EWD_FILE);

    // restore
    modelManager.clearModel();
    PersistenceManager.getInstance().loadFromFile(EWD_FILE);
    for (ModelElement modelElement : modelManager.getAllModelElements()) {
      GlobalPosition restoredPos1 = (GlobalPosition)modelElement;
      Assert.assertEquals(pos1.getLatitude(), restoredPos1.getLatitude(), 0.0001);
    }

    // cleanup
View Full Code Here

   * @author Gerald Toepper
   * @param toggled
   *            Indicates whether the scenarios export button was toggled.
   */
  private void onScenariosCheck(final boolean toggled) {
    final ModelManager modelManager = ModelManager.getInstance();
    final Collection<ModelElement> elements = modelManager.getAllModelElements();

    boolean startAreaDefined = false;
    boolean destinationAreaDefined = false;
    final List<String> startAreasWithNoDestinationAreas = new ArrayList<String>();
    final List<String> areasWithNoUnderlyingEdges = new ArrayList<String>();

    final List<AreaModel> areas = new ArrayList<AreaModel>();
    for (final ModelElement element : elements) {
      if (element instanceof AreaModel) {
        final AreaModel area = (AreaModel) element;
        areas.add(area);
        if (area.getAreaType() == AreaType.START) {
          startAreaDefined = true;
          final List<AreaModel> destinationAreas = area.getDestinationAreas();
          if ((destinationAreas == null) || (destinationAreas.size() == 0)) {
            startAreasWithNoDestinationAreas.add(area.getIdentifier());
          }
        } else {
          destinationAreaDefined = true;
        }
        final List<EdgeModel> edges = area.getLocation().getEdges();
        if ((edges == null) || (edges.size() == 0)) {
          areasWithNoUnderlyingEdges.add(area.getIdentifier());
        }
      }
    }

    // generate error list
    final List<String> errorList = new ArrayList<String>();

    // check whether a start and a destination area is defined
    if (!startAreaDefined && !destinationAreaDefined) {
      errorList.add("- no area defined (at least one start area or one destination area)");
    }
    // check whether all start areas have destination areas defined in case
    // destination areas exist
    if ((startAreasWithNoDestinationAreas.size() > 0) && destinationAreaDefined) {
      final StringBuffer buffer = new StringBuffer();
      for (final String startArea : startAreasWithNoDestinationAreas) {
        if (buffer.length() == 0) {
          buffer.append("- the following start areas have no destination area: ");
        } else {
          buffer.append(", ");
        }
        buffer.append(startArea);
      }
      errorList.add(buffer.toString());
    }
    // check whether all areas have underlying edges
    if (areasWithNoUnderlyingEdges.size() > 0) {
      final StringBuffer buffer = new StringBuffer();
      for (final String area : areasWithNoUnderlyingEdges) {
        if (buffer.length() == 0) {
          buffer.append("- the following areas have no underlying edges: ");
        } else {
          buffer.append(", ");
        }
        buffer.append(area);
      }
      errorList.add(buffer.toString());
    }

    if (errorList.size() > 0) {
      // generate error string
      final StringBuffer errorBuffer = new StringBuffer("The following errors occured:");
      for (final String error : errorList) {
        errorBuffer.append("\n").append(error);
      }

      // create message box
      JOptionPane.showMessageDialog(this, errorBuffer.toString(), "Errors in scenarios-config", JOptionPane.WARNING_MESSAGE);
      scenariosCheckBox.setSelected(false);
      return;
    } else if (scenariosCheckBox.isSelected()) {
      // generate warning list
      final List<String> warningList = new ArrayList<String>();

      // check simulation times
      final int simulationStartTime = modelManager.getSimulationStartTime();
      final int simulationEndTime = modelManager.getSimulationEndTime();

      final List<AreaModel> adaptedSimulationTimes = new ArrayList<AreaModel>();

      for (final AreaModel area : areas) {
        final int actualSimulationTime = area.getSimulationTime();
View Full Code Here

    QLabel periodLabel = new QLabel("Emit interval:");
    QLabel repnoLabel = new QLabel("Replication number:");

    idText = new QLineEdit("Trip" + new Random().nextInt());
    depTimeSpin = new QSpinBox();
    ModelManager mm = ModelManager.getInstance();
    depTimeSpin.setMinimum(mm.getSimulationStartTime());
    depTimeSpin.setMaximum(mm.getSimulationEndTime());
    fromEdgeEdit = new QLineEdit();
    fromEdgeEdit.setEnabled(false);
    fromEdgeSelectButton = new QPushButton("Select");
    fromEdgeSelectButton.pressed.connect(this, "onFromNodeSelect()");
    toEdgeEdit = new QLineEdit();
View Full Code Here

  @Test
  public void additionalInfoRetrievalTest() {
    //setup testcase
    ArrayList<ModelElement> allElements = TestCaseUtil
        .createSampleTestcase();
    ModelManager mm = ModelManager.getInstance();
    mm.clearModel();

    StatisticsDataManager smm = StatisticsDataManager.getInstance();
    smm.clear();
    EdgeModel testEdge = null;

    // create 2 dummy models
    StatDataset model1 = new StatDataset();
    model1.setBelongsToCurrentMap(true);
    StatInterval interval1 = new StatInterval("int1", 0, 100);
    model1.addInterval(interval1);
    StatDataset model2 = new StatDataset();
    model2.setBelongsToCurrentMap(true);
    StatInterval interval2 = new StatInterval("int2", 0, 100);
    model2.addInterval(interval2);

    for (ModelElement element : allElements) {
      if (element instanceof WayModel) {
        WayModel way = (WayModel) element;
        //add way to ModelManager
        mm.addModelElement(way);
       
        List<EdgeModel> edges = way.getBackwardEdges();
        edges.addAll(way.getForwardEdges());
        for (EdgeModel edge : edges) {
          // for each edge in the testcase add a StatEdge to the dummy
View Full Code Here

TOP

Related Classes of de.hpi.eworld.core.ModelManager

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.