feat(ui): add box selection feature

- Selection: add addAll() method for bulk shape addition
- Controller: box selection with mouse drag on empty space
- ShapeDraftman: drawSelectionBox() for rubber-band rendering
- ShapesView: currentSelectionBox field and setter
This commit is contained in:
2026-03-26 23:54:46 +01:00
parent 3a6f98455a
commit b0e3428696
4 changed files with 128 additions and 22 deletions

View File

@@ -135,7 +135,7 @@ public class ShapeDraftman implements ShapeVisitor {
if ((selAttrs != null) && (selAttrs.selected)){
Rectangle bounds = s.getBounds();
this.g2d.setColor(Color.RED);
int handleSize = 5;
int handleSize = 10;
this.g2d.drawRect(bounds.x - handleSize, bounds.y - handleSize, handleSize, handleSize);
this.g2d.drawRect(bounds.x + bounds.width, bounds.y + bounds.height, handleSize, handleSize);
if (resizeMode) {
@@ -149,4 +149,14 @@ public class ShapeDraftman implements ShapeVisitor {
}
}
public void drawSelectionBox(Rectangle box) {
if (box == null) return;
g2d.setXORMode(Color.WHITE);
g2d.setColor(Color.BLUE);
g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER, 1, new float[]{4, 4}, 0));
g2d.drawRect(box.x, box.y, box.width, box.height);
g2d.setPaintMode();
}
}