Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***********************************************************************
- * Module: ResizeElementCommand.java
- * Author: 13592
- * Purpose: Defines the Class ResizeElementCommand
- ***********************************************************************/
- package model.graph.commands;
- import java.awt.geom.Point2D;
- import view.MainFrame;
- import model.graph.Node;
- public class ResizeElementCommand extends model.genericFunctions.Command {
- private double oldXscale, oldYscale;
- private Point2D oldPosition;
- private Node currentNode;
- private Point2D newPosition;
- private double newXscale, newYscale;
- public ResizeElementCommand(double oldXscale, double oldYscale,
- Point2D oldPosition, Node currentNode) {
- super();
- this.oldXscale = oldXscale;
- this.oldYscale = oldYscale;
- this.oldPosition = oldPosition;
- this.currentNode = currentNode;
- this.newPosition = currentNode.getPosition();
- this.newXscale = currentNode.getScaleX();
- this.newYscale = currentNode.getScaleY();
- }
- public void execute() {
- MainFrame.getInstance().getGraphEditorPanel().getGraphDocumentView()
- .getSelection().removeElement(currentNode);
- currentNode.setPosition(newPosition);
- currentNode.setScaleX(newXscale);
- currentNode.setScaleY(newYscale);
- MainFrame.getInstance().getGraphEditorPanel().getGraphDocumentView()
- .getSelection().addElement(currentNode);
- MainFrame.getInstance().getGraphEditorPanel().repaint();
- }
- public void undo() {
- MainFrame.getInstance().getGraphEditorPanel().getGraphDocumentView()
- .getSelection().removeElement(currentNode);
- currentNode.setPosition(oldPosition);
- currentNode.setScaleX(oldXscale);
- currentNode.setScaleY(oldYscale);
- MainFrame.getInstance().getGraphEditorPanel().getGraphDocumentView()
- .getSelection().addElement(currentNode);
- MainFrame.getInstance().getGraphEditorPanel().repaint();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement