Math2mat

/home/ythoma/docs/math2mat/svn/wp1/framework/m2mGUI/src/m2m/frontend/dynamicview/editpolicies/EditBendPointPolicy.java

Go to the documentation of this file.
00001 
00016 package m2m.frontend.dynamicview.editpolicies;
00017 
00018 import m2m.frontend.dynamicview.commands.CreateBendpointCommand;
00019 import m2m.frontend.dynamicview.commands.DeleteBendpointCommand;
00020 import m2m.frontend.dynamicview.commands.MoveBendpointCommand;
00021 
00022 import org.eclipse.draw2d.geometry.Point;
00023 import org.eclipse.gef.commands.Command;
00024 import org.eclipse.gef.editpolicies.BendpointEditPolicy;
00025 import org.eclipse.gef.requests.BendpointRequest;
00026 
00027 
00028 public class EditBendPointPolicy extends BendpointEditPolicy
00029 { 
00034         protected Command getMoveBendpointCommand(BendpointRequest request) 
00035         {
00036                 MoveBendpointCommand com = new MoveBendpointCommand();
00037 
00038                 /* Get the referenced point of source ans target anchor of the connection */
00039                 Point p = request.getLocation();
00040                 Point ref1 = getConnection().getSourceAnchor().getReferencePoint();
00041                 Point ref2 = getConnection().getTargetAnchor().getReferencePoint();
00042                 
00043                 /* Initialisation of the command with the request and referenced points */
00044                 com.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2));
00045                 com.setConnection((m2m.frontend.dynamicview.model.Connection)request.getSource().getModel());
00046                 com.setIndex(request.getIndex());
00047                 
00048                 return com;
00049         }
00050         
00051         
00056         @Override
00057         protected Command getCreateBendpointCommand(BendpointRequest request) 
00058         {
00059                 CreateBendpointCommand com = new CreateBendpointCommand();
00060                 
00061                 /* Get the referenced point of source ans target anchor of the connection */
00062                 Point p = request.getLocation();
00063                 Point ref1 = getConnection().getSourceAnchor().getReferencePoint();
00064                 Point ref2 = getConnection().getTargetAnchor().getReferencePoint();
00065                 
00066                 /* Initialisation of the command  with the request and referenced points */
00067                 com.setIndex(request.getIndex());
00068                 com.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2));
00069                 com.setConnection((m2m.frontend.dynamicview.model.Connection)request.getSource().getModel());
00070                 
00071                 return com;
00072         }
00073 
00074         
00079         @Override
00080         protected Command getDeleteBendpointCommand(BendpointRequest request) 
00081         {
00082                 /* Creation and initialisation of the command  with the request */
00083                 DeleteBendpointCommand com = new DeleteBendpointCommand();
00084                 com.setIndex(request.getIndex());
00085                 com.setConnection((m2m.frontend.dynamicview.model.Connection)request.getSource().getModel());
00086                 
00087                 return com;
00088         }
00089 }
 All Classes Namespaces Files Functions Variables Enumerations