Skip to content

Commit df50b7c

Browse files
committed
added some safety locks
1 parent 7c1ca6f commit df50b7c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

  • src/main/java/com/marginallyclever/makelangelo/turtle

src/main/java/com/marginallyclever/makelangelo/turtle/Turtle.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ public Rectangle2D.Double getBounds() {
301301
Point2d top = new Point2d(-Double.MAX_VALUE, -Double.MAX_VALUE);
302302
Point2d bottom = new Point2d(Double.MAX_VALUE, Double.MAX_VALUE);
303303

304+
lock();
304305
int hits = 0;
305306
for (var cl : strokeLayers) {
306307
for (var line : cl.getAllLines()) {
@@ -313,6 +314,7 @@ public Rectangle2D.Double getBounds() {
313314
}
314315
}
315316
}
317+
unlock();
316318

317319
if (hits == 0) {
318320
bottom.set(0, 0);
@@ -328,6 +330,7 @@ public Rectangle2D.Double getBounds() {
328330
* @param sy the y-axis scale factor.
329331
*/
330332
public void scale(double sx, double sy) {
333+
lock();
331334
for (var cl : strokeLayers) {
332335
for (var line : cl.getAllLines()) {
333336
for (var point : line.getAllPoints()) {
@@ -336,6 +339,7 @@ public void scale(double sx, double sy) {
336339
}
337340
}
338341
}
342+
unlock();
339343
}
340344

341345
/**
@@ -344,6 +348,7 @@ public void scale(double sx, double sy) {
344348
* @param dy relative move y
345349
*/
346350
public void translate(double dx, double dy) {
351+
lock();
347352
for (var cl : strokeLayers) {
348353
for (var line : cl.getAllLines()) {
349354
for (var point : line.getAllPoints()) {
@@ -352,6 +357,7 @@ public void translate(double dx, double dy) {
352357
}
353358
}
354359
}
360+
unlock();
355361
}
356362

357363
/**
@@ -363,6 +369,7 @@ public void rotate(double degrees) {
363369
double c = Math.cos(r);
364370
double s = Math.sin(r);
365371

372+
lock();
366373
for (var cl : strokeLayers) {
367374
for (var line : cl.getAllLines()) {
368375
for (var point : line.getAllPoints()) {
@@ -373,6 +380,7 @@ public void rotate(double degrees) {
373380
}
374381
}
375382
}
383+
unlock();
376384
}
377385

378386
/**

0 commit comments

Comments
 (0)