• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Scala-Robotics-Simulator / PPS-22-srs / #353

23 Aug 2025 07:35AM UTC coverage: 45.6% (-12.1%) from 57.73%
#353

Pull #52

github

sceredi
fix: close simulation gui at stop
Pull Request #52: feature: implementation of Simulation GUI

6 of 529 new or added lines in 12 files covered. (1.13%)

4 existing lines in 2 files now uncovered.

1114 of 2443 relevant lines covered (45.6%)

6.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

54.82
/src/main/scala/io/github/srs/utils/SimulationDefaults.scala
1
package io.github.srs.utils
2

3
import java.awt.Color
4
import java.util.UUID
5

6
import scala.concurrent.duration.{ DurationInt, FiniteDuration }
7

8
import io.github.srs.model.entity.*
9
import io.github.srs.model.entity.dynamicentity.Robot
10
import io.github.srs.model.entity.dynamicentity.actuator.{ Actuator, Wheel as ActWheel }
11
import io.github.srs.model.entity.dynamicentity.behavior.Policy
12
import io.github.srs.model.entity.dynamicentity.sensor.*
13
import io.github.srs.model.environment.Environment
14

15
object SimulationDefaults:
16

×
17
  object UI:
NEW
18

×
19
    object SimulationViewConstants:
NEW
20
      val IdDisplayLength = 8
×
NEW
21
      val PositionDecimals = 2
×
NEW
22
      val OrientationDecimals = 1
×
NEW
23
      val DefaultRobotInfo = "Select a robot to view details"
×
NEW
24
      val StopConfirmMessage = "Are you sure you want to stop the simulation?\n\nClick Yes to stop, No to continue."
×
NEW
25
      val StopConfirmTitle = "Stop Simulation"
×
NEW
26

×
27
    object Colors:
NEW
28
      @inline private def rgb(r: Int, g: Int, b: Int) = new java.awt.Color(r, g, b)
×
NEW
29
      @inline private def rgba(r: Int, g: Int, b: Int, a: Int) = new java.awt.Color(r, g, b, a)
×
NEW
30
      def backgroundLight: Color = rgb(250, 250, 250)
×
NEW
31
      def backgroundMedium: Color = rgb(245, 245, 245)
×
NEW
32
      def border: Color = rgb(200, 200, 200)
×
NEW
33
      def text: Color = rgb(60, 60, 60)
×
NEW
34
      def obstacleGradientStart: Color = rgb(120, 120, 120)
×
NEW
35
      def obstacleGradientEnd: Color = rgb(80, 80, 80)
×
NEW
36
      def obstacleBorder: Color = rgb(60, 60, 60)
×
NEW
37
      def robotDefault: Color = rgb(100, 150, 255)
×
NEW
38
      def robotDefaultDark: Color = rgb(50, 100, 200)
×
NEW
39
      def robotDefaultBorder: Color = rgb(0, 50, 150)
×
NEW
40
      def robotSelected: Color = rgb(255, 100, 100)
×
NEW
41
      def robotSelectedDark: Color = rgb(200, 50, 50)
×
NEW
42
      def robotSelectedBorder: Color = rgb(150, 0, 0)
×
NEW
43
      def robotShadow: Color = rgba(0, 0, 0, 50)
×
NEW
44
      def lightCenter: Color = rgba(255, 255, 200, 200)
×
NEW
45
      def lightEdge: Color = rgba(255, 140, 0, 80)
×
NEW
46
      def buttonHover: Color = rgb(230, 230, 230)
×
NEW
47
      def buttonPressed: Color = rgb(220, 235, 250)
×
NEW
48

×
49
    end Colors
50

51
    object Fonts:
NEW
52
      val family = "Arial"
×
NEW
53
      val titleSize = 12
×
NEW
54

×
55
    object Spacing:
NEW
56
      val standardPadding = 10
×
NEW
57
      val innerPadding = 5
×
NEW
58
      val componentGap = 10
×
NEW
59

×
60
    object Dimensions:
NEW
61
      val buttonWidth = 150
×
NEW
62
      val buttonHeight = 30
×
NEW
63
      val robotListWidth = 250
×
NEW
64
      val robotListHeight = 300
×
NEW
65
      val infoAreaRows = 6
×
NEW
66
      val infoAreaColumns = 25
×
NEW
67

×
68
    object Strokes:
NEW
69
      val obstacleStroke = 1.5f
×
NEW
70
      val robotShadowStroke = 3f
×
NEW
71

×
72
    object Icons:
NEW
73
      val play = "\u25B6"
×
NEW
74
      val stop = "\u23F9"
×
NEW
75
      val pause = "\u23F8"
×
NEW
76
  end UI
×
77

78
  val duration: Option[Long] = None
79
  val seed: Option[Long] = None
8✔
80
  val debugMode = true
4✔
81
  val binarySearchDurationThreshold: FiniteDuration = 1.microseconds
2✔
82

13✔
83
  object SimulationConfig:
84
    val maxCount = 10_000
×
85

×
86
  object Environment:
87
    val defaultWidth: Int = 10
3✔
88
    val minWidth: Int = 1
8✔
89
    val maxWidth: Int = 500
4✔
90

4✔
91
    val defaultHeight: Int = 10
92
    val minHeight: Int = 1
4✔
93
    val maxHeight: Int = 500
4✔
94

4✔
95
    val defaultEntities: Set[Entity] = Set.empty
96
    val maxEntities: Int = 200
10✔
97

5✔
98
  object StaticEntity:
99

×
100
    object Obstacle:
101
      val defaultId: UUID = UUID.fromString("00000000-0000-0000-0000-000000000000")
3✔
102
      val defaultPosition: Point2D = (0.0, 0.0)
13✔
103
      val defaultOrientation: Orientation = Orientation(0.0)
8✔
104
      val defaultWidth: Double = 1.0
10✔
105
      val defaultHeight: Double = 1.0
4✔
106

5✔
107
    object Light:
108
      val defaultId: UUID = UUID.fromString("00000000-0000-0000-0000-000000000001")
3✔
109
      val defaultPosition: Point2D = (0.0, 0.0)
13✔
110
      val defaultOrientation: Orientation = Orientation(0.0)
8✔
111
      val defaultRadius: Double = 0.05
10✔
112
      val defaultIlluminationRadius: Double = 1.0
4✔
113
      val defaultIntensity: Double = 1.0
4✔
114
      val defaultAttenuation: Double = 1.0
4✔
115

5✔
116
    object Boundary:
117
      val defaultPosition: Point2D = (0.0, 0.0)
3✔
118
      val defaultOrientation: Orientation = Orientation(0.0)
12✔
119
      val defaultWidth: Double = 1.0
10✔
120
      val defaultHeight: Double = 1.0
4✔
121

5✔
122
  end StaticEntity
123

124
  object DynamicEntity:
125
    val zeroSpeed: Double = 0.0
3✔
126
    val minSpeed: Double = -1.0
8✔
127
    val maxSpeed: Double = 1.0
4✔
128
    val halfSpeed: Double = 0.5
4✔
129

5✔
130
    object Actuator:
131

×
132
      object DifferentialWheelMotor:
133
        val defaultWheel: ActWheel = ActWheel()
3✔
134

22✔
135
        object Wheel:
136
          val defaultSpeed: Double = 1.0
3✔
137
          val defaultShape: ShapeType.Circle = ShapeType.Circle(0.1)
8✔
138

7✔
139
    object Sensor:
140

×
141
      object ProximitySensor:
142
        val defaultOffset: Double = 0.0
×
143
        val defaultDistance: Double = 0.5
×
144
        val defaultRange: Double = 5.0
×
145

×
146
    object Robot:
147
      import SimulationDefaults.DynamicEntity.Robot.defaultShape.radius
3✔
148

149
      val defaultMaxRetries = 10
150

6✔
151
      val defaultId: UUID = UUID.fromString("00000000-0000-0000-0000-000000000002")
152
      val defaultPosition: Point2D = (0.0, 0.0)
9✔
153
      val defaultShape: ShapeType.Circle = ShapeType.Circle(0.5)
8✔
154
      val defaultOrientation: Orientation = Orientation(0.0)
6✔
155
      val defaultActuators: Seq[Actuator[Robot]] = Seq.empty
10✔
156
      val defaultSensors: Vector[Sensor[Robot, Environment]] = Vector.empty
11✔
157

10✔
158
      val selectionStroke: Float = 3f
159
      val normalStroke: Float = 1f
2✔
160
      val arrowLengthFactor: Double = 0.6
2✔
161
      val arrowWidthFactor: Double = 0.3
2✔
162
      val minArrowWidth: Float = 2f
2✔
163

2✔
164
      val stdProximitySensors: Vector[Sensor[Robot, Environment]] = Vector(
165
        ProximitySensor(Orientation(0.0), radius),
6✔
166
        ProximitySensor(Orientation(45.0), radius),
23✔
167
        ProximitySensor(Orientation(90.0), radius),
15✔
168
        ProximitySensor(Orientation(135.0), radius),
15✔
169
        ProximitySensor(Orientation(180.0), radius),
15✔
170
        ProximitySensor(Orientation(225.0), radius),
15✔
171
        ProximitySensor(Orientation(270.0), radius),
15✔
172
        ProximitySensor(Orientation(315.0), radius),
15✔
173
      )
15✔
174

3✔
175
      val stdLightSensors: Vector[Sensor[Robot, Environment]] = Vector(
176
        LightSensor(Orientation(0.0)),
6✔
177
        LightSensor(Orientation(45.0)),
20✔
178
        LightSensor(Orientation(90.0)),
12✔
179
        LightSensor(Orientation(135.0)),
12✔
180
        LightSensor(Orientation(180.0)),
12✔
181
        LightSensor(Orientation(225.0)),
12✔
182
        LightSensor(Orientation(270.0)),
12✔
183
        LightSensor(Orientation(315.0)),
12✔
184
      )
12✔
185
      val defaultPolicy: Policy = Policy.AlwaysForward
3✔
186
    end Robot
5✔
187
  end DynamicEntity
188

189
  object Fields:
190

×
191
    object Simulation:
192
      val self: String = "simulation"
3✔
193
      val duration: String = "duration"
8✔
194
      val seed: String = "seed"
4✔
195

5✔
196
    object Environment:
197
      val self: String = "environment"
3✔
198
      val width: String = "width"
8✔
199
      val height: String = "height"
4✔
200
      val entities: String = "entities"
4✔
201

5✔
202
    object Entity:
203
      val id: String = "id"
3✔
204
      val position: String = "position"
8✔
205
      val x: String = "x"
4✔
206
      val y: String = "y"
2✔
207
      val orientation: String = "orientation"
2✔
208

5✔
209
      object StaticEntity:
210

×
211
        object Obstacle:
212
          val self: String = "obstacle"
3✔
213
          val width: String = "width"
8✔
214
          val height: String = "height"
4✔
215

5✔
216
        object Light:
217
          val self: String = "light"
3✔
218
          val radius: String = "radius"
8✔
219
          val illuminationRadius: String = "illuminationRadius"
4✔
220
          val intensity: String = "intensity"
4✔
221
          val attenuation: String = "attenuation"
4✔
222

5✔
223
      object DynamicEntity:
224

×
225
        object Robot:
226
          val self: String = "robot"
3✔
227
          val radius: String = "radius"
8✔
228
          val speed: String = "speed"
4✔
229
          val withProximitySensors: String = "withProximitySensors"
4✔
230
          val withLightSensors: String = "withLightSensors"
4✔
231
          val behavior: String = "behavior"
4✔
232
    end Entity
5✔
233
  end Fields
234

235
  object Layout:
NEW
236
    val splitPaneWeight: Double = 0.8
×
NEW
237
    val splitPaneLocation: Double = 0.8
×
NEW
238

×
239
  object Frame:
NEW
240
    val minWidth = 800
×
NEW
241
    val minHeight = 600
×
NEW
242
    val prefWidth = 1200
×
NEW
243
    val prefHeight = 720
×
NEW
244
    val splitWeight = 0.8
×
NEW
245
    val canvasBorder: Int = 2
×
NEW
246

×
247
  object Canvas:
NEW
248
    val borderSize = 2
×
NEW
249
    val minZoom = 0.2
×
NEW
250
    val maxZoom = 5.0
×
NEW
251
    val zoomInFactor = 1.2
×
NEW
252
    val zoomOutFactor = 0.8
×
NEW
253
    val desiredLabelPixels = 40.0
×
NEW
254
    val gridStrokeWidth = 1f
×
NEW
255
    val labelDesiredPx: Double = 40.0
×
NEW
256
    val minLightSize: Int = 12
×
NEW
257
    val lightStroke: Float = 2f
×
NEW
258
    val labelBottomOffset: Int = 4
×
NEW
259
    val labelYOffset: Int = 12
×
NEW
260
    val labelXOffset: Int = 2
×
NEW
261

×
262
  object ControlsPanel:
NEW
263
    val startStopButtonText: String = "Start/Stop"
×
NEW
264

×
265
end SimulationDefaults
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc