Examples of ModelManager


Examples of de.hpi.eworld.core.ModelManager

   * This method checks if all model elements that were created actaully exist in the model
   */
  @Test
  public void testModelContent() {
    initTestCase();
    ModelManager mm = ModelManager.getInstance();
    Collection<ModelElement> mmAllModelElements = mm.getAllModelElements();
    Assert.assertEquals(allModelElements.size(), mmAllModelElements.size());
    for(ModelElement e : allModelElements) {
      Assert.assertEquals(true, mmAllModelElements.contains(e));
    }
  }
View Full Code Here

Examples of de.hpi.eworld.core.ModelManager

   * This test checks that it is impossible to add a model element that already exists in the model
   */
  @Test
  public void testAddRefused() {
    initTestCase();
    ModelManager mm = ModelManager.getInstance();
    for(ModelElement e : allModelElements) {
      Assert.assertEquals(false, mm.addModelElement(e));
    }
  }
View Full Code Here

Examples of de.hpi.eworld.core.ModelManager

   * number of model elements
   */
  @Test
  public void testSaveLoad() {
    initTestCase();
    ModelManager mm = ModelManager.getInstance();
    PersistenceManager.getInstance().saveToFile(DIR_SAVE + "out.ewd");
    mm.clearModel();
    Assert.assertEquals(0,mm.getAllModelElements().size());
   
    mm.clearModel();
   
    PersistenceManager.getInstance().loadFromFile(DIR_SAVE + "out.ewd");
    compareModels(allModelElements, mm.getAllModelElements());
  }
View Full Code Here

Examples of de.hpi.eworld.core.ModelManager

   */
  @Ignore // test takes forever, ignore it for now
  @Test
  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();
    }
    mm.deleteObserver(mmmu);
    PersistenceManager.getInstance().saveToFile(DIR_SAVE + "out.ewd");
    mm.clearModel();
    Assert.assertEquals(0,mm.getAllModelElements().size());

    PersistenceManager.getInstance().loadFromFile(DIR_SAVE + "out.ewd");
    compareModels(mmmu.getModelElements(), mm.getAllModelElements());
  }
View Full Code Here

Examples of de.hpi.eworld.core.ModelManager

   * the simulationstatistic plugin
   */
  @Test
  public void testInternalIDs(){
    initTestCase();
    ModelManager mm = ModelManager.getInstance();
   
    // map all edges of the current map to their ids
    Map<String, EdgeModel> edges = new HashMap<String, EdgeModel>();
    for (ModelElement element : allModelElements) {
      //for all ways
      if (element instanceof WayModel) {
        WayModel way = (WayModel) element;
        //store all edges
        for (EdgeModel edge: way.getBackwardEdges()){
          edges.put(edge.getInternalID(), edge);
        }
        for (EdgeModel edge: way.getForwardEdges()){
          edges.put(edge.getInternalID(), edge);
        }
      }
    }
   
    //check if internal ids are the same
    for (ModelElement element : mm.getAllModelElements()){
      //for all ways
      if (element instanceof WayModel) {
        WayModel way = (WayModel) element;
        //store all edges
        for (EdgeModel edge: way.getBackwardEdges()){
          Assert.assertEquals(
              edge.getId(),
              edges.get(edge.getInternalID()).getId());
        }
        for (EdgeModel edge: way.getForwardEdges()){
          Assert.assertEquals(
              edge.getId(),
              edges.get(edge.getInternalID()).getId());
        }
      }
    }
   
    PersistenceManager.getInstance().saveToFile(DIR_SAVE + "out.ewd");
    mm.clearModel();
    Assert.assertEquals(0,mm.getAllModelElements().size());
   
    mm.clearModel();
   
    PersistenceManager.getInstance().loadFromFile(DIR_SAVE + "out.ewd");
   
    //check again if internal ids are the same
    for (ModelElement element : mm.getAllModelElements()){
      //for all ways
      if (element instanceof WayModel) {
        WayModel way = (WayModel) element;
        //store all edges
        for (EdgeModel edge: way.getBackwardEdges()){
View Full Code Here

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

Examples of de.hpi.eworld.core.ModelManager

    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

Examples of de.hpi.eworld.core.ModelManager

    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

Examples of de.hpi.eworld.core.ModelManager

    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

Examples of de.hpi.eworld.core.ModelManager

      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
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.