implement resize feature
This commit is contained in:
@@ -13,12 +13,16 @@ public class ShapeDraftman implements ShapeVisitor {
|
||||
private static final ColorAttributes DEFAULT_COLOR_ATTRIBUTES =
|
||||
new ColorAttributes(false, true, Color.BLACK, Color.BLACK);
|
||||
private final Graphics2D g2d;
|
||||
|
||||
private boolean resizeMode;
|
||||
|
||||
public ShapeDraftman(Graphics graph) {
|
||||
this.g2d = (Graphics2D) graph;
|
||||
}
|
||||
|
||||
public void setResizeMode(boolean resizeMode) {
|
||||
this.resizeMode = resizeMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitRectangle(SRectangle rect) {
|
||||
Rectangle r = rect.getBounds();
|
||||
@@ -129,8 +133,17 @@ public class ShapeDraftman implements ShapeVisitor {
|
||||
if ((selAttrs != null) && (selAttrs.selected)){
|
||||
Rectangle bounds = s.getBounds();
|
||||
this.g2d.setColor(Color.RED);
|
||||
this.g2d.drawRect(bounds.x - 5, bounds.y - 5, 5, 5);
|
||||
this.g2d.drawRect(bounds.x + bounds.width, bounds.y + bounds.height, 5, 5);
|
||||
int handleSize = 5;
|
||||
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) {
|
||||
this.g2d.drawRect(bounds.x + bounds.width, bounds.y - handleSize, handleSize, handleSize);
|
||||
this.g2d.drawRect(bounds.x - handleSize, bounds.y + bounds.height, handleSize, handleSize);
|
||||
this.g2d.drawRect(bounds.x + bounds.width / 2 - handleSize / 2, bounds.y - handleSize, handleSize, handleSize);
|
||||
this.g2d.drawRect(bounds.x + bounds.width / 2 - handleSize / 2, bounds.y + bounds.height, handleSize, handleSize);
|
||||
this.g2d.drawRect(bounds.x - handleSize, bounds.y + bounds.height / 2 - handleSize / 2, handleSize, handleSize);
|
||||
this.g2d.drawRect(bounds.x + bounds.width, bounds.y + bounds.height / 2 - handleSize / 2, handleSize, handleSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user