Back to index

moin  1.9.0~rc2
ToggleGridCommand.java
Go to the documentation of this file.
00001 /*
00002  * @(#)ToggleGridCommand.java 5.1
00003  *
00004  */
00005 
00006 package CH.ifa.draw.standard;
00007 
00008 import java.util.*;
00009 import java.awt.Point;
00010 import CH.ifa.draw.util.Command;
00011 import CH.ifa.draw.framework.*;
00012 
00016 public class ToggleGridCommand extends Command {
00017 
00018     private DrawingView fView;
00019     private Point fGrid;
00020 
00027     public ToggleGridCommand(String name, DrawingView view, Point grid) {
00028         super(name);
00029         fView = view;
00030         fGrid = new Point(grid.x, grid.y);
00031     }
00032 
00033     public void execute() {
00034         PointConstrainer grid = fView.getConstrainer();
00035         if (grid != null) {
00036             fView.setConstrainer(null);
00037         }
00038         else {
00039             fView.setConstrainer(new GridConstrainer(fGrid.x, fGrid.y));
00040         }
00041     }
00042 }
00043 
00044