Package com.dcaiti.eworld.visualizer.simulation.models

Examples of com.dcaiti.eworld.visualizer.simulation.models.TrafficLight


        else
          addedRoadsideUnit.setHidden(false);
      }
    }
    else if (arg instanceof TrafficLight) {
      TrafficLight addedTrafficLight = (TrafficLight) arg;

      String id = addedTrafficLight.getID();
      String type = addedTrafficLight.getPrettyName();
      Double latitude = GlobalPosition.from(Point2DUtils.convertPoint(addedTrafficLight.getPosition()))
          .getLatitude();
      Double longitude = GlobalPosition.from(Point2DUtils.convertPoint(addedTrafficLight.getPosition()))
          .getLongitude();
      String speed = "N/A";
      String direction = "N/A";
      String coveredDistance = "N/A";
      String communicationCount = addedTrafficLight.getSentCount() + "/" + addedTrafficLight.getReceivedCount();

      Object[] addedData = new Object[] { id, type, latitude, longitude, speed, direction, coveredDistance,
          communicationCount };

      // Add a new model to the table
      if (!modelsToRows.containsKey(addedTrafficLight.getID())) {
        tableModel.addRow(addedData);
        modelsToRows.put(addedTrafficLight.getID(), tableModel.getRowCount() - 1);
        tableModel.setValueAt(true, modelsToRows.get(addedTrafficLight.getID()), columns.get("Annotation"));
        tableModel.setValueAt(true, modelsToRows.get(addedTrafficLight.getID()), columns.get("Radius"));
        tableModel.setValueAt(false, modelsToRows.get(addedTrafficLight.getID()), columns.get("Destination"));
        tableModel.setValueAt(false, modelsToRows.get(addedTrafficLight.getID()), columns.get("V2X-Tracing"));
        tableModel.setValueAt(false, modelsToRows.get(addedTrafficLight.getID()), columns.get("Hide"));
        updateGlobalSettings(modelsToRows.get(addedTrafficLight.getID()),
            modelsToRows.get(addedTrafficLight.getID()));
      }
      // Modify an existing model in the table
      else {
        tableModel.setValueAt(id, modelsToRows.get(addedTrafficLight.getID()), columns.get("ID"));
        tableModel.setValueAt(type, modelsToRows.get(addedTrafficLight.getID()), columns.get("Type"));
        tableModel.setValueAt(latitude, modelsToRows.get(addedTrafficLight.getID()), columns.get("Latitude"));
        tableModel.setValueAt(longitude, modelsToRows.get(addedTrafficLight.getID()), columns.get("Longitude"));
        tableModel.setValueAt(communicationCount, modelsToRows.get(addedTrafficLight.getID()),
            columns.get("# Sent/Received"));

        Boolean displayAnnotations = (Boolean) tableModel.getValueAt(
            modelsToRows.get(addedTrafficLight.getID()), columns.get("Annotation"));
        if (displayAnnotations)
          addedTrafficLight.setDisplayingAnnotations(true);
        else
          addedTrafficLight.setDisplayingAnnotations(false);

        Boolean displayRadius = (Boolean) tableModel.getValueAt(modelsToRows.get(addedTrafficLight.getID()),
            columns.get("Radius"));
        if (displayRadius)
          addedTrafficLight.setDisplayingRadius(true);
        else
          addedTrafficLight.setDisplayingRadius(false);

        Boolean displayDestination = (Boolean) tableModel.getValueAt(
            modelsToRows.get(addedTrafficLight.getID()),
            columns.get("Destination"));
        if (displayDestination)
          addedTrafficLight.setDisplayingDestination(true);
        else
          addedTrafficLight.setDisplayingDestination(false);

        Boolean v2xTracing = (Boolean) tableModel.getValueAt(modelsToRows.get(addedTrafficLight.getID()),
            columns.get("V2X-Tracing"));
        if (v2xTracing)
          addedTrafficLight.setV2XTracing(true);
        else
          addedTrafficLight.setV2XTracing(false);

        Boolean hidden = (Boolean) tableModel.getValueAt(modelsToRows.get(addedTrafficLight.getID()),
            columns.get("Hide"));
        if (hidden)
          addedTrafficLight.setHidden(true);
        else
          addedTrafficLight.setHidden(false);
      }
    }
  }
View Full Code Here


      setChanged();
      notifyObservers(ObserverNotifications.roadsideUnitRemoved);

      return;
    }
    TrafficLight removedTrafficLight = trafficLights.get(id);
    if (removedTrafficLight != null) {
      System.out.println("tl");
      networkViewPlugin.removeVolatileModelElement(trafficLights.get(id));
      trafficLights.remove(id);
      updateCounter();
View Full Code Here

      setChanged();
      notifyObservers(ObserverNotifications.messageSent);

      return;
    }
    TrafficLight sendingTrafficLight = trafficLights.get(id);
    if (sendingTrafficLight != null) {
      sendingTrafficLight.sendMessage(messageID, ipSegments, destinationLatitude, destinationLongitude,
          destinationRadius);
      updateCounter();
      if (SimulationSettings.getInstance().isShowingStatusBarSteps()) {
        if (ipSegments == null)
          ipSegments = new byte[] { 0, 0, 0, 0 };
View Full Code Here

      setChanged();
      notifyObservers(ObserverNotifications.messageReceived);

      return;
    }
    TrafficLight receivingTrafficLight = trafficLights.get(id);
    if (receivingTrafficLight != null) {
      receivingTrafficLight.receiveMessage(messageID);
      updateCounter();
      if (SimulationSettings.getInstance().isShowingStatusBarSteps()) {
        MainStatusBar.getInstance().showMessage(
            "Traffic Light is receiving a messsage [id: " + id + "] [message id: "
                + Integer.toString(messageID) + "]");
View Full Code Here

  private void addTrafficLight(final String id, final double latitude,
      final double longitude) {
    Runnable worker = new Runnable() {
      @Override
      public synchronized void run() {
        TrafficLight addedTrafficLight = new TrafficLight(id,
            Utilities.project(latitude, longitude));
        modelController.addTrafficLight(addedTrafficLight);

        if (simulationSettings.isBuffering()) {
          simulationBuffer.add(
              VisualizationConstants.CMD_ADDTL,
              new TrafficLight(id, Utilities.project(latitude,
                  longitude)));
        }

        if (sync)
          try {
View Full Code Here

                .setDestinationRadius(destinationRadius);
            simulationBuffer.add(
                VisualizationConstants.CMD_SENDV2X,
                sendingRoadsideUnit);
          } else if (modelController.getTrafficLight(id) != null) {
            TrafficLight sendingTrafficLight = new TrafficLight(
                modelController.getTrafficLight(id).getID(),
                modelController.getTrafficLight(id)
                    .getPosition());
            sendingTrafficLight.setSentMessageID(messageID);
            sendingTrafficLight.setIPSegments(ipSegments);
            sendingTrafficLight
                .setDestinationLatitude(destinationLatitude);
            sendingTrafficLight
                .setDestinationLongitude(destinationLongitude);
            sendingTrafficLight
                .setDestinationRadius(destinationRadius);
            simulationBuffer.add(
                VisualizationConstants.CMD_SENDV2X,
                sendingTrafficLight);
          }
View Full Code Here

            receivingRoadsideUnit.setReceivedMessageID(messageID);
            simulationBuffer.add(
                VisualizationConstants.CMD_RECVV2X,
                receivingRoadsideUnit);
          } else if (modelController.getTrafficLight(id) != null) {
            TrafficLight receivingTrafficLight = new TrafficLight(
                modelController.getTrafficLight(id).getID(),
                modelController.getTrafficLight(id)
                    .getPosition());
            receivingTrafficLight.setReceivedMessageID(messageID);
            simulationBuffer.add(
                VisualizationConstants.CMD_RECVV2X,
                receivingTrafficLight);
          }
        }
View Full Code Here

    else if (model instanceof RoadsideUnit) {
      RoadsideUnit addedRoadsideUnit = (RoadsideUnit) model;
      buffer.add(new SimulationStep<Byte, VolatileModelElement>(command, addedRoadsideUnit));
    }
    else if (model instanceof TrafficLight) {
      TrafficLight addedTrafficLight = (TrafficLight) model;
      buffer.add(new SimulationStep<Byte, VolatileModelElement>(command, addedTrafficLight));
    }
  }
View Full Code Here

   */
  private void addTrafficLight(final TrafficLight addedTrafficLight) throws IOException {
    Runnable worker = new Runnable() {
      @Override
      public synchronized void run() {
        TrafficLight addedTrafficLightClone = new TrafficLight(addedTrafficLight.getID(),
            addedTrafficLight.getPosition());
        modelController.addTrafficLight(addedTrafficLightClone);
      }
    };
    try {
View Full Code Here

              sendingRoadsideUnit.getSentMessageID(), sendingRoadsideUnit.getIPSegments(),
              sendingRoadsideUnit.getDestinationLatitude(),
              sendingRoadsideUnit.getDestinationLongitude(), sendingRoadsideUnit.getDestinationRadius());
        }
        else if (model instanceof TrafficLight) {
          TrafficLight sendingTrafficLight = (TrafficLight) model;
          modelController.sendNetworkMessage(sendingTrafficLight.getID(),
              sendingTrafficLight.getSentMessageID(), sendingTrafficLight.getIPSegments(),
              sendingTrafficLight.getDestinationLatitude(),
              sendingTrafficLight.getDestinationLongitude(), sendingTrafficLight.getDestinationRadius());
        }
      }
    };
    try {
      if (EventQueue.isDispatchThread()) {
View Full Code Here

TOP

Related Classes of com.dcaiti.eworld.visualizer.simulation.models.TrafficLight

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.