Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some small designer fixes #2467

Merged
merged 3 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ This file is part of Universal Gcode Sender (UGS).
*/
package com.willwinder.ugs.nbp.designer;

import static com.willwinder.ugs.nbp.designer.DesignerMain.PROPERTY_IS_STANDALONE;
import org.apache.commons.lang3.StringUtils;

import java.awt.geom.Point2D;
import java.text.ParseException;

import static com.willwinder.ugs.nbp.designer.DesignerMain.PROPERTY_IS_STANDALONE;

/**
* @author Joacim Breiler
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ public void setTransform(AffineTransform transform) {
@Override
public void move(Point2D deltaMovement) {
try {
transform.preConcatenate(AffineTransform.getTranslateInstance(deltaMovement.getX(), deltaMovement.getY()));
notifyEvent(new EntityEvent(this, EventType.MOVED));
if( deltaMovement.distance(new Point2D.Double(0d, 0d)) > 0) {
transform.preConcatenate(AffineTransform.getTranslateInstance(deltaMovement.getX(), deltaMovement.getY()));
notifyEvent(new EntityEvent(this, EventType.MOVED));
}
} catch (Exception e) {
throw new EntityException("Could not make inverse transform of point", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public void rotate(double angle) {
groupRotation += angle;
Point2D center = getCenter();
getAllChildren().forEach(entity -> entity.rotate(center, angle));
invalidateBounds();
notifyEvent(new EntityEvent(this, EventType.ROTATED));
} catch (Exception e) {
throw new EntityException("Couldn't set the rotation", e);
Expand All @@ -81,8 +82,8 @@ public void rotate(Point2D center, double angle) {
try {
groupRotation += angle;
getAllChildren().forEach(entity -> entity.rotate(center, angle));
notifyEvent(new EntityEvent(this, EventType.ROTATED));
invalidateBounds();
notifyEvent(new EntityEvent(this, EventType.ROTATED));
} catch (Exception e) {
throw new EntityException("Couldn't set the rotation", e);
}
Expand Down Expand Up @@ -170,8 +171,8 @@ public void applyTransform(AffineTransform transform) {
public void move(Point2D deltaMovement) {
try {
applyTransform(AffineTransform.getTranslateInstance(deltaMovement.getX(), deltaMovement.getY()));
notifyEvent(new EntityEvent(this, EventType.MOVED));
invalidateBounds();
notifyEvent(new EntityEvent(this, EventType.MOVED));
} catch (Exception e) {
throw new EntityException("Could not make inverse transform of point", e);
}
Expand Down Expand Up @@ -328,14 +329,14 @@ public void scale(double sx, double sy) {
child.scale(sx, sy);
child.setPosition(new Point2D.Double(originalPosition.getX() + (relativePosition.getX() * sx), originalPosition.getY() + (relativePosition.getY() * sy)));
});
notifyEvent(new EntityEvent(this, EventType.RESIZED));
invalidateBounds();
notifyEvent(new EntityEvent(this, EventType.RESIZED));
}

@Override
public void onEvent(EntityEvent entityEvent) {
notifyEvent(entityEvent);
invalidateBounds();
notifyEvent(entityEvent);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This file is part of Universal Gcode Sender (UGS).
import com.willwinder.ugs.nbp.designer.model.Size;
import com.willwinder.universalgcodesender.uielements.helpers.ThemeColors;

import java.awt.*;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;

Expand Down Expand Up @@ -95,6 +95,9 @@ private void createEntity() {
Ellipse ellipse = new Ellipse(startX, startY);
ellipse.setSize(new Size(endX - startX, endY - startY));
controller.addEntity(ellipse);

controller.setTool(Tool.SELECT);
controller.getSelectionManager().addSelection(ellipse);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ public void onEvent(EntityEvent entityEvent) {
if (entityEvent instanceof MouseEntityEvent) {
MouseEntityEvent mouseEntityEvent = (MouseEntityEvent) entityEvent;
if (mouseEntityEvent.getType() == EventType.MOUSE_PRESSED) {
controller.addEntity(new Point(mouseEntityEvent.getStartMousePosition().getX(), mouseEntityEvent.getStartMousePosition().getY()));

Point point = new Point(mouseEntityEvent.getStartMousePosition().getX(), mouseEntityEvent.getStartMousePosition().getY());
controller.addEntity(point);
controller.setTool(Tool.SELECT);
controller.getSelectionManager().addSelection(point);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This file is part of Universal Gcode Sender (UGS).
import com.willwinder.ugs.nbp.designer.logic.Tool;
import com.willwinder.universalgcodesender.uielements.helpers.ThemeColors;

import java.awt.*;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

Expand Down Expand Up @@ -95,6 +95,9 @@ private void createEntity() {
rectangle.setWidth(endX - startX);
rectangle.setHeight(endY - startY);
controller.addEntity(rectangle);

controller.setTool(Tool.SELECT);
controller.getSelectionManager().addSelection(rectangle);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ This file is part of Universal Gcode Sender (UGS).
import com.willwinder.ugs.nbp.designer.logic.Controller;
import com.willwinder.ugs.nbp.designer.logic.ControllerFactory;

import java.awt.*;
import java.awt.Cursor;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ This file is part of Universal Gcode Sender (UGS).
import com.willwinder.ugs.nbp.designer.entities.Entity;

import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Ellipse2D;

/**
Expand Down
Loading