use of com.willwinder.ugs.nbp.designer.entities.EntityGroup in project Universal-G-Code-Sender by winder.
the class EntityTreeUtils method getSelectedPaths.
public static List<TreePath> getSelectedPaths(Controller controller, Entity entity, List<Entity> currentTreePath) {
ArrayList<TreePath> result = new ArrayList<>();
if (controller.getSelectionManager().isSelected(entity)) {
List<Entity> entities = new ArrayList<>(currentTreePath);
entities.add(entity);
result.add(new TreePath(entities.toArray(new Entity[0])));
}
if (entity instanceof EntityGroup) {
List<Entity> newCurrentTreePath = new ArrayList<>(currentTreePath);
newCurrentTreePath.add(entity);
result.addAll(((EntityGroup) entity).getChildren().stream().flatMap(e -> getSelectedPaths(controller, e, newCurrentTreePath).stream()).collect(Collectors.toList()));
}
return result;
}
use of com.willwinder.ugs.nbp.designer.entities.EntityGroup in project Universal-G-Code-Sender by winder.
the class EntityGroupV1 method toInternal.
@Override
public Entity toInternal() {
EntityGroup entityGroup = new EntityGroup();
children.stream().map(EntityV1::toInternal).forEach(entityGroup::addChild);
entityGroup.setName(getName());
return entityGroup;
}
use of com.willwinder.ugs.nbp.designer.entities.EntityGroup in project Universal-G-Code-Sender by winder.
the class MultiplyDialog method stateChanged.
@Override
public void stateChanged(ChangeEvent e) {
entityGroup.removeAll();
EntityGroup selection = new EntityGroup();
selection.addAll(controller.getSelectionManager().getSelection().stream().map(Entity::copy).collect(Collectors.toList()));
for (int x = 0; x < (int) xCountSpinner.getValue(); x++) {
for (int y = 0; y < (int) yCountSpinner.getValue(); y++) {
if (x >= 1 || y >= 1) {
EntityGroup clone = (EntityGroup) selection.copy();
Point2D position = clone.getPosition();
double newX = position.getX() + (x * clone.getSize().getWidth()) + (x * (int) xSpacingSpinner.getValue());
double newY = position.getY() + (y * clone.getSize().getHeight()) + (y * (int) ySpacingSpinner.getValue());
clone.setPosition(new Point2D.Double(newX, newY));
entityGroup.addAll(clone.getChildren());
}
}
}
controller.getDrawing().repaint();
}
use of com.willwinder.ugs.nbp.designer.entities.EntityGroup in project Universal-G-Code-Sender by winder.
the class FlipHorizontallyAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
SelectionManager selectionManager = controller.getSelectionManager();
if (!selectionManager.getSelection().isEmpty()) {
List<Entity> entities = selectionManager.getSelection();
EntityGroup entityGroup = new EntityGroup();
entityGroup.addAll(entities);
UndoableFlipHorizontallyAction undoableAction = new UndoableFlipHorizontallyAction(controller.getDrawing(), entityGroup);
controller.getUndoManager().addAction(undoableAction);
undoableAction.execute();
}
}
use of com.willwinder.ugs.nbp.designer.entities.EntityGroup in project Universal-G-Code-Sender by winder.
the class FlipVerticallyAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
SelectionManager selectionManager = controller.getSelectionManager();
if (!selectionManager.getSelection().isEmpty()) {
List<Entity> entities = selectionManager.getSelection();
EntityGroup entityGroup = new EntityGroup();
entityGroup.addAll(entities);
UndoableFlipVerticallyAction undoableAction = new UndoableFlipVerticallyAction(controller.getDrawing(), entityGroup);
controller.getUndoManager().addAction(undoableAction);
undoableAction.execute();
}
}
Aggregations