View Javadoc

1   /**********************************************
2    * Copyright (C) 2009 Lukas Laag
3    * This file is part of Vectomatic.
4    * 
5    * Vectomatic is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    * 
10   * Vectomatic is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   * 
15   * You should have received a copy of the GNU General Public License
16   * along with Vectomatic.  If not, see http://www.gnu.org/licenses/
17   **********************************************/
18  package org.vectomatic.client.rep.command;
19  
20  import org.vectomatic.client.rep.RepApplication;
21  import org.vectomatic.client.rep.controller.RepresentationController;
22  import org.vectomatic.common.rpc.Representation;
23  
24  /**
25   * Command to resize the drawing
26   */
27  public class ResizeDrawingCommand extends CommandBase {
28  	private RepresentationController _controller;
29  	private int _width;
30  	private int _height;
31  
32  	public ResizeDrawingCommand(RepApplication app, RepresentationController controller, int width, int height) {
33  		super(app);
34  		_controller = controller;
35  		_width = width;
36  		_height = height;
37  	}
38  
39  	public String getDescription() {
40  		return _app.getConstants().resizeDrawingCommand();
41  	}
42  
43  	public void execute() {
44  		run();
45  	}
46  
47  	public void unexecute() {
48  		run();
49  	}
50  	
51  	private void run() {
52  		Representation rep = _controller.getCurrentRep();
53  		int width = rep.getWidth();
54  		int height = rep.getHeight();
55  		rep.setWidth(_width);
56  		rep.setHeight(_height);
57  		_width = width;
58  		_height = height;
59  	}
60  
61  }