Examples of ModelManager


Examples of de.hpi.eworld.core.ModelManager

    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

Examples of de.hpi.eworld.core.ModelManager

   * 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

Examples of de.hpi.eworld.core.ModelManager

   * @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

Examples of de.hpi.eworld.core.ModelManager

    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

Examples of de.hpi.eworld.core.ModelManager

  @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

Examples of de.hpi.eworld.core.ModelManager

    filename = this.netField.getText();
    routeFilename = this.routeField.getText();
    includeTL = trafficLightsCheckBox.isSelected();
    withRoutes = routeFileCheckBox.isSelected();
 
    ModelManager model = ModelManager.getInstance();
   
    progressDialog = new ProgressDialog(this,
        "Loading SUMO file...",
        new CancelListener(this));
View Full Code Here

Examples of de.hpi.eworld.core.ModelManager

   *
   * At this time, there is no map loaded so no {@link CityModel} object is
   * created yet. This happens when a map is imported.
   */
  private CityPropertyModels() {
    ModelManager modelManager = ModelManager.getInstance();
    modelManager.addObserver(this);
  }
View Full Code Here

Examples of de.hpi.eworld.core.ModelManager

   * Creates a new {@code CityModel} instance, adds it to the
   * {@code ModelManager} and connects the number models to this new instance.
   */
  private void createCity() {
    CityModel city = new CityModel();
    ModelManager modelManager = ModelManager.getInstance();
    modelManager.addModelElement(city);

    carPersonRelationModel.clear();
    carPersonRelationModel.add(city);
    carPreferenceModel.clear();
    carPreferenceModel.add(city);
View Full Code Here

Examples of de.hpi.eworld.core.ModelManager

  public void buildeWorldStructure() {
    HashMap<String, NodeModel> eNodes = new HashMap<String, NodeModel>();
    HashMap<String, TrafficLightModel> eTrafficLights = new HashMap<String, TrafficLightModel>();
    HashMap<String, WayModel> eWays = new HashMap<String, WayModel>();

    ModelManager model = ModelManager.getInstance();
   
    model.clearModel();

    model.setChanged();
    model.notifyObservers(new ObserverNotification(NotificationType.startBatchProcess));
    model.clearChanged();
   
    for(String id : nodes.keySet()) {
      MyNode n = nodes.get(id);
      NodeModel newNode = new NodeModel(n.lat, n.lon);
      if (n.isTrafficLight){
        TrafficLightModel trafficLight = new TrafficLightModel(newNode);
        eTrafficLights.put(id, trafficLight);
      }
//      if (n.isTrafficLight)
//        newNode = new TrafficLightModel(n.lat, n.lon);
//      else
//        newNode = new NodeModel(n.lat, n.lon);
      eNodes.put(id, newNode);
      model.addModelElement(newNode);
    }
   
    for(Entry<String, MyEdge> edgePair : edges.entrySet()) {
      MyEdge e = edgePair.getValue();
      EdgeModel newEdge = new EdgeModel(edgePair.getKey(), eNodes.get(e.first), eNodes.get(e.second));
     
      for(int i=0; i<e.nolanes; i++) {
        newEdge.addLane(new LaneModel());
      }
     
      model.addModelElement(newEdge);
      if (eWays.keySet().contains(e.second + "|" + e.first)) {
        eWays.get(e.second+"|"+e.first).addBackwardEdge(newEdge);
        newEdge.setComplementaryEdge(eWays.get(e.second+"|"+e.first).getFirstForwardEdge());
        eWays.get(e.second+"|"+e.first).getFirstForwardEdge().setComplementaryEdge(newEdge);
        newEdge.setParentWay(eWays.get(e.second+"|"+e.first));
      } else {
        WayModel newWay = new WayModel("");
        newWay.addForwardEdge(newEdge);
        newEdge.setParentWay(newWay);
        eWays.put(e.first+"|"+e.second, newWay);
        model.addModelElement(newWay);
      }
    }
   
    model.setChanged();
    model.notifyObservers(new ObserverNotification(NotificationType.endBatchProcess, true, false));
    model.clearChanged();
  }
View Full Code Here

Examples of org.protege.editor.core.ModelManager

   */
  private void getAllLoadedReasoners(){
    config.loadRemoteReasonerConfiguration();
   
    ReasonerRegistry registry = HeraklesManager.getReasonerRegistry();
    ModelManager modelManager = workspace.getEditorKit().getModelManager();
    if(modelManager instanceof OWLModelManager){
      OWLOntologyManager manager = ((OWLModelManager)modelManager).getOWLOntologyManager();
     
      Set<String> types = config.getRemoteReasonerTypes();
     
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.