public static int randomColor() { int r = (int) (Math.random() * 256); int g = (int) (Math.random() * 256); int b = (int) (Math.random() * 256); return color(r, g, b); }
private void initGraphicSettings() { initGraphicConfigFieldsFromProperties(); resetScaleAndOffset(); for (final RoadSegment roadSegment : roadNetwork) { roadSegment.roadMapping().setRoadColor(roadColor.getRGB()); } for (String vehicleTypeLabel : simulator.getVehiclePrototypeLabels()) { final Color color = new Color(Colors.randomColor()); LOG.info("set color for vehicle label={}", vehicleTypeLabel); labelColors.put(vehicleTypeLabel, color); } backgroundPicture = readBackgroundImage(backgroundPicturePath); }
public Vehicle(String label, LongitudinalModelBase longitudinalModel, VehiclePrototypeConfiguration vehInput, @Nullable LaneChangeModel lcModel) { Preconditions.checkNotNull(longitudinalModel); Preconditions.checkNotNull(vehInput); this.label = label; dimensions = new VehicleDimensions(vehInput.getLength(), vehInput.getWidth()); this.maxDeceleration = vehInput.getMaximumDeceleration(); id = nextId++; randomFix = MyRandom.nextDouble(); initialize(); this.longitudinalModel = longitudinalModel; physQuantities = new PhysicalQuantities(this); this.laneChangeModel = lcModel; if (laneChangeModel != null) { laneChangeModel.initialize(this); } // needs to be > 0 to avoid lane-changing over 2 lanes in one update // step assert FINITE_LANE_CHANGE_TIME_S > 0; this.color = Colors.randomColor(); trafficLightApproaching = new TrafficLightApproaching(); inhomogeneity = new InhomogeneityAdaption(); userData = new VehicleUserData(); }