Package de.hpi.eworld.model.db.data

Examples of de.hpi.eworld.model.db.data.AreaModel


    return simulationTimePanel;
  }
 
  @Override
  public void emitIntervalChanged(int newValue) {
    AreaModel selectedArea = getSelectedArea();
   
    if (selectedArea != null) {
      selectedArea.setVehicleEmitInterval(newValue);
    }
  }
View Full Code Here


    }
  }
 
  @Override
  public void vehicleCountChanged(int newValue) {
    AreaModel selectedArea = getSelectedArea();
   
    if (selectedArea != null) {
      selectedArea.setVehicleCount(newValue);
    }
  }
View Full Code Here

    }
  }
 
  @Override
  public void vehicleTypeChanged(String typeName, boolean enabled) {
    AreaModel selectedArea = getSelectedArea();
   
    if (selectedArea != null) {
      logger.info((enabled ? "Enabling" : "Disabling") + " vehicle type " + typeName + " for " + selectedArea.toString());
     
      if (enabled) {
        selectedArea.addVehicleType(typeName);
      } else {
        selectedArea.removeVehicleType(typeName);
      }
    }
  }
View Full Code Here

    }
  }
 
  @Override
  public void sourceAreaChanged(AreaModel sourceArea, boolean enabled) {
    AreaModel selectedArea = getSelectedArea();
   
    if (selectedArea != null) {
      logger.info((enabled ? "Adding" : "Removing") + " source area " +
          sourceArea.getIdentifier() + " to " + selectedArea.getIdentifier());
     
      if (enabled) {
        sourceArea.addDestinationArea(selectedArea);
      } else {
        sourceArea.removeDestinationArea(selectedArea);
View Full Code Here

    }
  }
 
  @Override
  public void areaNameChanged(String newValue) {
    AreaModel selectedArea = getSelectedArea();
   
    if (selectedArea != null) {
      selectedArea.setIdentifier(newValue);
    }
  }
View Full Code Here

    }
  }
 
  @Override
  public void simulationTimeChanged(int newValue) {
    AreaModel selectedArea = getSelectedArea();
   
    if (selectedArea != null) {
      selectedArea.setSimulationTime(newValue);
    }
  }
View Full Code Here

        if (index == -1) {
          return;
        }
       
        CheckListItem item = (CheckListItem) list.getModel().getElementAt(index);
        AreaModel sourceArea = (AreaModel)item.getData();
       
        synchronized (configChangeListeners) {
          for (AreaConfigurationChangeListener listener : configChangeListeners) {
            listener.sourceAreaChanged(sourceArea, !item.isSelected());
          }
View Full Code Here

    }
  }
 
  private List<AreaModel> getAssociatedSourceAreas() {
    List<AreaModel> sourceAreas = new Vector<AreaModel>();
    AreaModel selectedArea = getSelectedArea();
   
    for (AreaModel currentArea : getAllCurrentSourceAreas()) {
      List<AreaModel> destinationAreas = currentArea.getDestinationAreas();
     
      if (destinationAreas != null && destinationAreas.contains(selectedArea)) {
View Full Code Here

  }

  @Override
  @SuppressWarnings({ "rawtypes", "unchecked" })
  protected List<GraphicsView<AreaModel>> provideAnnotationItems() {
    List list = Arrays.asList(new CircleScenarioView(new AreaModel(
        new CircleLocationModel(), AreaType.START),
        CircleScenarioView.DEFAULT_RADIUS), new CircleScenarioView(
        new AreaModel(new CircleLocationModel(), AreaType.DESTINATION),
        CircleScenarioView.DEFAULT_RADIUS));
    return (List<GraphicsView<AreaModel>>) list;
  }
View Full Code Here

    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();
        if ((area.getAreaType() == AreaType.START) || ((area.getAreaType() == AreaType.DESTINATION) && !startAreaDefined)) {
          if (actualSimulationTime < simulationStartTime) {
            area.setSimulationTime(simulationStartTime);
            adaptedSimulationTimes.add(area);
          } else if (actualSimulationTime > simulationEndTime) {
            area.setSimulationTime(simulationEndTime);
            adaptedSimulationTimes.add(area);
          }
        }
      }

      // generate warnings concerning simulation times
      if (adaptedSimulationTimes.size() > 0) {
        final StringBuffer buffer = new StringBuffer();
        for (final AreaModel area : adaptedSimulationTimes) {
          if (buffer.length() == 0) {
            buffer
                    .append("- the simualion time of the following areas has been adapted, since they are not within the simulation time specified in the time line: ");
          } else {
            buffer.append(", ");
          }
          buffer.append(area.getIdentifier());
        }
        warningList.add(buffer.toString());
      }

      if (warningList.size() > 0) {
View Full Code Here

TOP

Related Classes of de.hpi.eworld.model.db.data.AreaModel

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.