Search in sources :

Example 1 with CityTrafficLight

use of il.ac.technion.cs.yp.btw.citysimulation.CityTrafficLight in project BTW by TechnionYearlyProject.

the class MapGraphics method createCircles.

/**
 * @author: shay
 * @date: 20/1/18
 * creating the array of circles, each circle for a traffic light.
 * @param trafficLights - trafficlights in the map
 */
// TODO: change the color according to real time loads.
private void createCircles(Set<CityTrafficLight> trafficLights) {
    int x = 0;
    for (CityTrafficLight currTrafficLight : trafficLights) {
        Point point = calculateTrafficLightLocation(currTrafficLight);
        Circle circle = new Circle(point.getCoordinateX(), point.getCoordinateY(), 0.0001);
        if (currTrafficLight.getState() == CityTrafficLight.TrafficLightState.GREEN)
            circle.setFill(Color.GREEN);
        else
            circle.setFill(Color.RED);
        circle.setOnMouseClicked(event -> {
            System.out.println(currTrafficLight.getName());
        });
        circles.add(new Pair(circle, currTrafficLight.getName()));
        x++;
    }
}
Also used : Circle(javafx.scene.shape.Circle) Point(il.ac.technion.cs.yp.btw.classes.Point) CityTrafficLight(il.ac.technion.cs.yp.btw.citysimulation.CityTrafficLight) Point(il.ac.technion.cs.yp.btw.classes.Point) Pair(javafx.util.Pair)

Aggregations

CityTrafficLight (il.ac.technion.cs.yp.btw.citysimulation.CityTrafficLight)1 Point (il.ac.technion.cs.yp.btw.classes.Point)1 Circle (javafx.scene.shape.Circle)1 Pair (javafx.util.Pair)1