use of com.willwinder.ugs.nbp.designer.logic.Controller in project Universal-G-Code-Sender by winder.
the class SettingsTopComponent method componentOpened.
@Override
protected void componentOpened() {
super.componentOpened();
removeAll();
Controller controller = CentralLookup.getDefault().lookup(Controller.class);
add(new SelectionSettingsPanel(controller));
}
use of com.willwinder.ugs.nbp.designer.logic.Controller in project Universal-G-Code-Sender by winder.
the class EntitiesTreeTopComponent method componentOpened.
@Override
protected void componentOpened() {
super.componentOpened();
removeAll();
Controller controller = CentralLookup.getDefault().lookup(Controller.class);
add(new JScrollPane(new EntitiesTree(controller)));
}
use of com.willwinder.ugs.nbp.designer.logic.Controller in project Universal-G-Code-Sender by winder.
the class UgsSaveCookie method save.
@Override
public void save() {
Controller controller = CentralLookup.getDefault().lookup(Controller.class);
if (controller == null) {
throw new IllegalStateException("Couldn't find an instance of the drawing controller");
}
try {
boolean valid = dataObject.getPrimaryFile().getFileSystem().isValid();
} catch (FileStateInvalidException e) {
e.printStackTrace();
}
UgsDesignWriter writer = new UgsDesignWriter();
writer.write(new File(dataObject.getPrimaryFile().getPath()), controller);
dataObject.setModified(false);
}
use of com.willwinder.ugs.nbp.designer.logic.Controller in project Universal-G-Code-Sender by winder.
the class MoveControlTest method moveShouldMoveWhenDraggedAndReleasedTarget.
@Test
public void moveShouldMoveWhenDraggedAndReleasedTarget() {
Rectangle rectangle = new Rectangle();
rectangle.setWidth(10);
rectangle.setHeight(10);
rectangle.move(new Point2D.Double(10, 10));
SelectionManager selectionManager = new SelectionManager();
selectionManager.addSelection(rectangle);
Controller controller = new Controller(selectionManager, new SimpleUndoManager());
MoveControl target = new MoveControl(controller);
target.onEvent(new MouseEntityEvent(target, EventType.MOUSE_PRESSED, new Point2D.Double(10, 10), new Point2D.Double(10, 10)));
target.onEvent(new MouseEntityEvent(target, EventType.MOUSE_DRAGGED, new Point2D.Double(10, 10), new Point2D.Double(11, 11)));
target.onEvent(new MouseEntityEvent(target, EventType.MOUSE_DRAGGED, new Point2D.Double(10, 10), new Point2D.Double(12, 12)));
target.onEvent(new MouseEntityEvent(target, EventType.MOUSE_DRAGGED, new Point2D.Double(10, 10), new Point2D.Double(11, 11)));
target.onEvent(new MouseEntityEvent(target, EventType.MOUSE_RELEASED, new Point2D.Double(10, 10), new Point2D.Double(11, 11)));
Assert.assertEquals(11, rectangle.getPosition().getX(), 0.1);
Assert.assertEquals(11, rectangle.getPosition().getY(), 0.1);
}
use of com.willwinder.ugs.nbp.designer.logic.Controller in project Universal-G-Code-Sender by winder.
the class MoveControlTest method moveShouldMoveEntitiesWhenParentIsScaled.
@Test
public void moveShouldMoveEntitiesWhenParentIsScaled() {
EntityGroup entityGroup = new EntityGroup();
entityGroup.applyTransform(AffineTransform.getScaleInstance(0.1, 0.1));
Rectangle rectangle = new Rectangle();
rectangle.setWidth(10);
rectangle.setHeight(10);
entityGroup.addChild(rectangle);
SelectionManager selectionManager = new SelectionManager();
selectionManager.addSelection(rectangle);
Assert.assertEquals(0, selectionManager.getPosition().getX(), 0.1);
Assert.assertEquals(0, selectionManager.getPosition().getY(), 0.1);
Controller controller = new Controller(selectionManager, new SimpleUndoManager());
MoveControl target = new MoveControl(controller);
target.onEvent(new MouseEntityEvent(target, EventType.MOUSE_PRESSED, new Point2D.Double(10, 10), new Point2D.Double(10, 10)));
target.onEvent(new MouseEntityEvent(target, EventType.MOUSE_DRAGGED, new Point2D.Double(10, 10), new Point2D.Double(11, 11)));
target.onEvent(new MouseEntityEvent(target, EventType.MOUSE_DRAGGED, new Point2D.Double(10, 10), new Point2D.Double(12, 12)));
target.onEvent(new MouseEntityEvent(target, EventType.MOUSE_DRAGGED, new Point2D.Double(10, 10), new Point2D.Double(20, 20)));
target.onEvent(new MouseEntityEvent(target, EventType.MOUSE_RELEASED, new Point2D.Double(10, 10), new Point2D.Double(20, 20)));
Assert.assertEquals(10, rectangle.getPosition().getX(), 0.1);
Assert.assertEquals(10, rectangle.getPosition().getY(), 0.1);
}
Aggregations