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

Examples of de.hpi.eworld.model.db.data.TrafficLightModel$NodeObserver


      new PolygonEventView(new PolygonEventModel(PolygonEventModel.Type.Rain, 1, null)),
      new PolygonEventView(new PolygonEventModel(PolygonEventModel.Type.Snow, 1, null)),
      new PolygonEventView(new PolygonEventModel(PolygonEventModel.Type.Ice, 1, null)),
      new StreetBarrierView(new RoadSpotModel(RoadSpotModel.Type.Busstop)),
      new StreetBarrierView(new RoadSpotModel(RoadSpotModel.Type.Liftgate)),
      new TrafficLightView(new TrafficLightModel(new NodeModel(0,0))));
    return (List<GraphicsView<EventModel>>) list;
  }
View Full Code Here


    /**
     * Generated using the JET engine and the according template
     */
    List<?> elementList = (List<?>) argument;
    stringBuffer.append(TEXT_1);
    TrafficLightModel trafficLight;
    for (Iterator<?> iter = elementList.iterator(); iter.hasNext();) {
      trafficLight = (TrafficLightModel) iter.next();
      if (trafficLight.getClass().equals(TrafficLightModel.class)) {       
        int noOfOutgoingEdges = (trafficLight.getUsedBy().size() - trafficLight.getNoOfIncomingEdges());
        if (trafficLight.isExported()) {
          int counter;
          stringBuffer.append(TEXT_2);
          stringBuffer.append(trafficLight.getNode().getInternalID());
          stringBuffer.append(TEXT_3);
          stringBuffer.append(trafficLight.getNoOfPhases());
          stringBuffer.append(TEXT_4);
          for (int i = 0; i < trafficLight.getNoOfPhases(); i++) {

            stringBuffer.append(TEXT_5);
            stringBuffer.append(trafficLight.getDurations()[i]);
            stringBuffer.append(TEXT_6);
            Object[] edgeArray = trafficLight.getDefaultLogic().keySet().toArray();
            EdgeModel edge;
            // iterate over each element beginning at the second.
            for(int j=1; j<=edgeArray.length;j++) {
              if (j==edgeArray.length) {
                edge = (EdgeModel)edgeArray[0];
              }
              else {
                edge = (EdgeModel)edgeArray[j];
              }
              List<TrafficLightStateListEntry> tls = trafficLight.getDefaultLogic().get(edge).getStates();
                       
              int lanes = noOfOutgoingEdges + getStraightLanes(edge, trafficLight.getNode());
              // HACK! It seems that edges with more than one 2 lanes need one more traffic light state!
              // Have a closer look at SUMOs netconvert to solve this issue!
              if (edge.getLanes().size()>2) {
                lanes++;
              }
View Full Code Here

    poi = new PointOfInterest(0, 0, 0, "PoI");
    networkView.onModelElementAdded(poi);
    Assert.assertEquals(4, networkView.getGraphModel().items().length);

    // adding a traffic light
    trafficLight = new TrafficLightModel(new NodeModel(0,0));
    networkView.onModelElementAdded(trafficLight);
    Assert.assertEquals(5, networkView.getGraphModel().items().length);
  }
View Full Code Here

        at = currentAttributes.get( "highway");
        if( ( at != null ) && ( at.equals( "traffic_signals" ) ) ) {
         
//          node = new  TrafficLightModel( lat, lon );
          node = new NodeModel(lat,lon);
          modelManager.addModelElement(new TrafficLightModel(node));
          // Do not attempt to do this here because this Trafficlight then has no references to any edge.
          // The created nodes (variable n) will be added later at endDocument()!
          // modelManager.addModelElement( new TrafficLight( lat, lon ) );
          // if you do this, it is added twice
         
        } else if ( ( at != null ) && (at.equals( "bus_stop" ) )) {
          node = new RoadSpotModel(lat, lon, RoadSpotModel.Type.Busstop);
          modelManager.addModelElement(node);
        } else if ( ( at != null ) && (at.equals( "stop" ) )) {
         
          PointOfInterest poi = new PointOfInterest(lat, lon, "stop_sign");
          imported = true;
         
          // this means that POIs are added to the model in any case
          // and the node is added an other time if it is referenced
          // by an edge
          modelManager.addModelElement(poi);
         
          node = new NodeModel( lat, lon );

        } else if ( ( at != null ) && (at.equals( "crossing" ) )) {
//          node = new TrafficLightModel(lat, lon, TrafficLightModel.Crossing);
          node = new NodeModel(lat,lon);
          modelManager.addModelElement(new TrafficLightModel(node,TrafficLightModel.Type.Crossing));
        } else {
       
          at = currentAttributes.get( "name" );
          if( at != null ) {
           
            String label = at;
            if( currentAttributes.get( "railway" ) != null ) {
              label = "Railway Station: " + label;
              node = new NodeModel( lat, lon );
            } else {
              PointOfInterest poi = new PointOfInterest( lat, lon, label );
              imported = true;
             
              // this means that POIs are added to the model in any case
              // and the node is added an other time if it is referenced
              // by an edge
              modelManager.addModelElement(poi);
             
              node = new NodeModel( lat, lon );
            }
           
          } else {
           
            at = currentAttributes.get( "barrier");
            if( ( at != null ) && ( at.equals( "lift_gate" ) ) ) {
//              node = new TrafficLightModel(lat,lon, TrafficLightModel.Lift_Gate);
              node = new NodeModel(lat,lon);
              modelManager.addModelElement(new TrafficLightModel(node,TrafficLightModel.Type.Lift_Gate));
            }
            else if ( ( at != null ) && (at.equals( "gate" ) )) {
              PointOfInterest poi = new PointOfInterest(lat, lon, "gate");
              modelManager.addModelElement(poi);
              node = new NodeModel(lat,lon);
View Full Code Here

    // create traffic lights
    TrafficLightModel[] tl = new TrafficLightModel[2];
    NodeModel[] tln = new NodeModel[2];
    tln[0] = new NodeModel(2.0, 2.0);
    tln[1] = new NodeModel(3.0, 2.0);
    tl[0] = new TrafficLightModel(tln[0]);
    tl[1] = new TrafficLightModel(tln[1]);

    // create street network
    EdgeModel[] e = new EdgeModel[50];

    e[0] = new EdgeModel("edgeModelID", n[0], n[3], w[0], 3, 50, null, null);
View Full Code Here

  private void initializeTrafficLightVisualization() throws IOException
    Collection<ModelElement> allElements = ModelManager.getInstance().getAllModelElements();
    for(ModelElement modelElement: allElements) {
      if(modelElement instanceof TrafficLightModel) {
       
        TrafficLightModel trafficLight = (TrafficLightModel) modelElement;
        if(!trafficLight.isExported())
          continue;
        try {
          int externalID = traciClient.getExternalID(trafficLight);
       
          Map<String, VisualizerTrafficLight> localMap = new HashMap<String, VisualizerTrafficLight>();
          trafficLights.put(externalID, localMap);
         
          for(TrafficLightPhase phase : traciClient.getTrafficLightStatus(externalID)) {
            String precRoadID = new String(phase.getPrecRoad());
            EdgeModel predEdge = trafficLight.findEdgeByID(precRoadID);
           
            Point2D center = predEdge.getToNode().getPosition().projected();
            Point2D prePos = predEdge.getFromNode().getPosition().projected();
            Point2D diff = new Point2D.Double(prePos.getX() - center.getX(), prePos.getY() - center.getY());
            double squareRoot = Math.sqrt(diff.getX() * diff.getX() + diff.getY() * diff.getY());
 
View Full Code Here

    durationsCache = new HashMap<TrafficLightModel, int[]>();

    int hasMoreThanOneIncomingEdge;
    for (ModelElement modelElement : modelManager.getAllModelElements()) {
      if (modelElement.getClass().equals(TrafficLightModel.class)) {
        TrafficLightModel tl = (TrafficLightModel) modelElement;
        List<EdgeModel> edges = tl.getUsedBy();
        hasMoreThanOneIncomingEdge = 0;
        for (EdgeModel edge : edges) {
          if (tl.getNode() == edge.getToNode()) {
            hasMoreThanOneIncomingEdge++;
          }
        }

        if (hasMoreThanOneIncomingEdge > 1) {
          tllCache.put(tl, tl.getDefaultLogic());
          durationsCache.put(tl, tl.getDurations());
          trafficLights.add(tl);
        }
      }
    }
  }
View Full Code Here

      }

      currentTrafficLight = null;
      for (ModelElement modelElement : modelManager.getAllModelElements()) {
        if (modelElement.getClass().equals(TrafficLightModel.class)) {
          TrafficLightModel tl = (TrafficLightModel) modelElement;
          if (tl.getInternalID().equals(newNode)) {
            currentTrafficLight = tl;

            currentIncomingEdges = new ArrayList<EdgeModel>();
            for (EdgeModel edge : tllCache.get(currentTrafficLight)
                .keySet()) {
View Full Code Here

  }

  @Test
  public void testTrafficLightItem() {
    NodeModel nodeModel = new NodeModel(0,0);
    TrafficLightModel trafficLight = new TrafficLightModel(nodeModel);
    AbstractView<Observable> viewObject = AbstractViewFactory.createView(trafficLight);
    Assert.assertNotNull(viewObject);
    Assert.assertTrue(viewObject instanceof AbstractView<?>);
//    trafficLightView trafficLightItem = (TrafficLightView) viewObject;
//    Assert.assertSame(trafficLight, trafficLightItem.getAssociatedElement());
View Full Code Here

    n3 = new NodeModel(3.0,3.0);
    n4 = new NodeModel(4.0,4.0);
   
    tln1 = new NodeModel(123.0123,17.00982);
   
    tl1 = new TrafficLightModel(tln1);
    e1 = new EdgeModel("testModelID", n1,tln1);
    e2 = new EdgeModel("testModelID1", n3,tln1);
    e3 = new EdgeModel("testModelID2", n4,tln1);
    e4 = new EdgeModel("testModelID3", n2,tln1);
   
    tln2 = new NodeModel(1442.0129, 1285.002374);
   
    tl2 = new TrafficLightModel(tln2);
//    tl2.addUsedBy(new EdgeModel(n1,tln2));
    new EdgeModel("testModelID4", n1,tln2);
   
   
  }
View Full Code Here

TOP

Related Classes of de.hpi.eworld.model.db.data.TrafficLightModel$NodeObserver

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.