Search in sources :

Example 1 with AddAction

use of com.willwinder.ugs.nbp.designer.actions.AddAction in project Universal-G-Code-Sender by winder.

the class CreateRectangleControl method createEntity.

private void createEntity() {
    double startX = Math.min(startPosition.getX(), endPosition.getX());
    double endX = Math.max(startPosition.getX(), endPosition.getX());
    double startY = Math.min(startPosition.getY(), endPosition.getY());
    double endY = Math.max(startPosition.getY(), endPosition.getY());
    Rectangle rectangle = new Rectangle(startX, startY);
    rectangle.setWidth(endX - startX);
    rectangle.setHeight(endY - startY);
    AddAction addAction = new AddAction(controller, rectangle);
    addAction.actionPerformed(new ActionEvent(this, 0, ""));
    controller.addEntity(rectangle);
}
Also used : ActionEvent(java.awt.event.ActionEvent) Rectangle(com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle) AddAction(com.willwinder.ugs.nbp.designer.actions.AddAction)

Example 2 with AddAction

use of com.willwinder.ugs.nbp.designer.actions.AddAction in project Universal-G-Code-Sender by winder.

the class CreateEllipseControl method createEntity.

private void createEntity() {
    double startX = Math.min(startPosition.getX(), endPosition.getX());
    double endX = Math.max(startPosition.getX(), endPosition.getX());
    double startY = Math.min(startPosition.getY(), endPosition.getY());
    double endY = Math.max(startPosition.getY(), endPosition.getY());
    Ellipse ellipse = new Ellipse(startX, startY);
    ellipse.setSize(new Size(endX - startX, endY - startY));
    AddAction addAction = new AddAction(controller, ellipse);
    addAction.actionPerformed(new ActionEvent(this, 0, ""));
    controller.addEntity(ellipse);
}
Also used : Ellipse(com.willwinder.ugs.nbp.designer.entities.cuttable.Ellipse) Size(com.willwinder.ugs.nbp.designer.model.Size) ActionEvent(java.awt.event.ActionEvent) AddAction(com.willwinder.ugs.nbp.designer.actions.AddAction)

Example 3 with AddAction

use of com.willwinder.ugs.nbp.designer.actions.AddAction in project Universal-G-Code-Sender by winder.

the class CreateTextControl method createEntity.

private void createEntity() {
    double startX = Math.min(startPosition.getX(), endPosition.getX());
    double startY = Math.min(startPosition.getY(), endPosition.getY());
    Text text = new Text(startX, startY);
    AddAction addAction = new AddAction(controller, text);
    addAction.actionPerformed(new ActionEvent(this, 0, ""));
    controller.addEntity(text);
    controller.setTool(Tool.SELECT);
    controller.getSelectionManager().addSelection(text);
}
Also used : ActionEvent(java.awt.event.ActionEvent) Text(com.willwinder.ugs.nbp.designer.entities.cuttable.Text) AddAction(com.willwinder.ugs.nbp.designer.actions.AddAction)

Example 4 with AddAction

use of com.willwinder.ugs.nbp.designer.actions.AddAction in project Universal-G-Code-Sender by winder.

the class Controller method addEntity.

public void addEntity(Entity s) {
    AddAction add = new AddAction(this, s);
    add.execute();
    undoManager.addAction(add);
}
Also used : AddAction(com.willwinder.ugs.nbp.designer.actions.AddAction)

Example 5 with AddAction

use of com.willwinder.ugs.nbp.designer.actions.AddAction in project Universal-G-Code-Sender by winder.

the class Controller method addEntities.

public void addEntities(List<Entity> s) {
    AddAction add = new AddAction(this, s);
    add.execute();
    undoManager.addAction(add);
}
Also used : AddAction(com.willwinder.ugs.nbp.designer.actions.AddAction)

Aggregations

AddAction (com.willwinder.ugs.nbp.designer.actions.AddAction)5 ActionEvent (java.awt.event.ActionEvent)3 Ellipse (com.willwinder.ugs.nbp.designer.entities.cuttable.Ellipse)1 Rectangle (com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle)1 Text (com.willwinder.ugs.nbp.designer.entities.cuttable.Text)1 Size (com.willwinder.ugs.nbp.designer.model.Size)1