Skip to content

Commit

Permalink
Fixed regression problem with rotation setting not working (winder#2563)
Browse files Browse the repository at this point in the history
  • Loading branch information
breiler authored Jun 29, 2024
1 parent 9c7865a commit 131327f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ public void setRotation(double rotation) {
children.forEach(entity -> entity.rotate(center, deltaRotation));
}
groupRotation += deltaRotation;
notifyEvent(new EntityEvent(this, EventType.ROTATED));
invalidateBounds();
notifyEvent(new EntityEvent(this, EventType.ROTATED));
}

public final List<Entity> getAllChildren() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public int getSpindleSpeed() {
}

@Override
public void setSpindleSpeed(int Speed) {
this.spindleSpeed = Math.abs(Speed);
public void setSpindleSpeed(int speed) {
this.spindleSpeed = Math.abs(speed);
notifyEvent(new EntityEvent(this, EventType.SETTINGS_CHANGED));
}

Expand Down Expand Up @@ -196,6 +196,7 @@ public List<EntitySetting> getSettings() {
EntitySetting.POSITION_Y,
EntitySetting.WIDTH,
EntitySetting.HEIGHT,
EntitySetting.ROTATION,
EntitySetting.CUT_TYPE,
EntitySetting.START_DEPTH,
EntitySetting.TARGET_DEPTH,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.willwinder.ugs.nbp.designer.entities.cuttable;

import com.willwinder.ugs.nbp.designer.entities.EntitySetting;
import com.willwinder.ugs.nbp.designer.entities.EventType;
import com.willwinder.ugs.nbp.designer.model.Size;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

import static org.junit.Assert.*;
import java.util.concurrent.atomic.AtomicBoolean;

public class RectangleTest {

Expand All @@ -15,4 +19,35 @@ public void setSize() {
assertEquals(30, rectangle.getSize().getHeight(), 0.1);
}

@Test
public void setRotation() {
Rectangle rectangle = new Rectangle(1, 1);
assertEquals(0, rectangle.getRotation(), 0.1);
rectangle.setRotation(10);
assertEquals(10, rectangle.getRotation(), 0.1);
}

@Test
public void setRotationShouldDispatchRotationEvent() {
AtomicBoolean triggeredEvent = new AtomicBoolean(false);
Rectangle rectangle = new Rectangle(1, 1);
rectangle.addListener(entityEvent -> {
if (entityEvent.getType() == EventType.ROTATED) {
triggeredEvent.set(true);
}
});
rectangle.setRotation(10);
assertTrue(triggeredEvent.get());
}

@Test
public void getSettings() {
Rectangle rectangle = new Rectangle(1, 1);
assertTrue(rectangle.getSettings().contains(EntitySetting.ANCHOR));
assertTrue(rectangle.getSettings().contains(EntitySetting.WIDTH));
assertTrue(rectangle.getSettings().contains(EntitySetting.HEIGHT));
assertTrue(rectangle.getSettings().contains(EntitySetting.POSITION_X));
assertTrue(rectangle.getSettings().contains(EntitySetting.POSITION_Y));
assertTrue(rectangle.getSettings().contains(EntitySetting.ROTATION));
}
}

0 comments on commit 131327f

Please sign in to comment.