Advertisement
nex036ara

resize

Dec 29th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.91 KB | None | 0 0
  1. /***********************************************************************
  2.  * Module:  ResizeElementCommand.java
  3.  * Author:  13592
  4.  * Purpose: Defines the Class ResizeElementCommand
  5.  ***********************************************************************/
  6.  
  7. package model.graph.commands;
  8.  
  9. import java.awt.geom.Point2D;
  10.  
  11. import view.MainFrame;
  12.  
  13. import model.graph.Node;
  14.  
  15. public class ResizeElementCommand extends model.genericFunctions.Command {
  16.     private double oldXscale, oldYscale;
  17.     private Point2D oldPosition;
  18.    
  19.     private Node currentNode;
  20.  
  21.     private Point2D newPosition;
  22.     private double newXscale, newYscale;
  23.    
  24.    
  25.    
  26.     public ResizeElementCommand(double oldXscale, double oldYscale,
  27.             Point2D oldPosition, Node currentNode) {
  28.         super();
  29.         this.oldXscale = oldXscale;
  30.         this.oldYscale = oldYscale;
  31.         this.oldPosition = oldPosition;
  32.  
  33.         this.currentNode = currentNode;
  34.         this.newPosition = currentNode.getPosition();
  35.         this.newXscale = currentNode.getScaleX();
  36.         this.newYscale = currentNode.getScaleY();
  37.     }
  38.  
  39.     public void execute() {
  40.  
  41.        
  42.         MainFrame.getInstance().getGraphEditorPanel().getGraphDocumentView()
  43.                 .getSelection().removeElement(currentNode);
  44.  
  45.         currentNode.setPosition(newPosition);
  46.         currentNode.setScaleX(newXscale);
  47.         currentNode.setScaleY(newYscale);
  48.  
  49.         MainFrame.getInstance().getGraphEditorPanel().getGraphDocumentView()
  50.                 .getSelection().addElement(currentNode);
  51.         MainFrame.getInstance().getGraphEditorPanel().repaint();
  52.        
  53.     }
  54.  
  55.     public void undo() {
  56.  
  57.         MainFrame.getInstance().getGraphEditorPanel().getGraphDocumentView()
  58.                 .getSelection().removeElement(currentNode);
  59.  
  60.         currentNode.setPosition(oldPosition);
  61.         currentNode.setScaleX(oldXscale);
  62.         currentNode.setScaleY(oldYscale);
  63.        
  64.         MainFrame.getInstance().getGraphEditorPanel().getGraphDocumentView()
  65.                 .getSelection().addElement(currentNode);
  66.         MainFrame.getInstance().getGraphEditorPanel().repaint();
  67.  
  68.     }
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement