KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nightlabs > editor2d > handle > RotateHandleKit


1 /* *****************************************************************************
2  * NightLabs Editor2D - Graphical editor framework *
3  * Copyright (C) 2004-2005 NightLabs - http://NightLabs.org *
4  * Project author: Daniel Mazurek <Daniel.Mazurek [at] nightlabs [dot] org> *
5  * *
6  * This library is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin St, Fifth Floor, *
20  * Boston, MA 02110-1301 USA *
21  * *
22  * Or get it online : *
23  * http://www.gnu.org/copyleft/lesser.html *
24  * *
25  * *
26  ******************************************************************************/

27
28 package org.nightlabs.editor2d.handle;
29
30 import java.util.Iterator JavaDoc;
31 import java.util.List JavaDoc;
32
33 import org.eclipse.draw2d.PositionConstants;
34 import org.eclipse.gef.GraphicalEditPart;
35 import org.eclipse.gef.Handle;
36
37 import org.nightlabs.editor2d.edit.AbstractDrawComponentEditPart;
38
39 public class RotateHandleKit
40 {
41
42   public RotateHandleKit() {
43     super();
44   }
45
46   public static void addHandles(List JavaDoc selectedEditParts, List JavaDoc handles)
47   {
48     int counter = 0;
49     for (Iterator JavaDoc it = selectedEditParts.iterator(); it.hasNext(); ) {
50       GraphicalEditPart editPart = (GraphicalEditPart) it.next();
51       if (editPart instanceof AbstractDrawComponentEditPart)
52         createRotateHandles((AbstractDrawComponentEditPart)editPart, handles);
53     }
54     
55     handles.add(createRotateCenterHandle(selectedEditParts));
56   }
57   
58   protected static Handle createRotateCenterHandle(List JavaDoc editParts)
59   {
60     RotateCenterHandle handle = new RotateCenterHandle(editParts);
61     return handle;
62   }
63   
64 // protected static void createHandles(GraphicalEditPart owner, List handles)
65
protected static void createRotateHandles(AbstractDrawComponentEditPart owner, List JavaDoc handles)
66   {
67     handles.add(createRotateHandle(owner, PositionConstants.NORTH_WEST));
68     handles.add(createRotateHandle(owner, PositionConstants.NORTH_EAST));
69     handles.add(createRotateHandle(owner, PositionConstants.SOUTH_EAST));
70     handles.add(createRotateHandle(owner, PositionConstants.SOUTH_WEST));
71     
72 // handles.add(createRotateCenterHandle(owner));
73

74 // handles.add(createShearHandle(owner, PositionConstants.NORTH));
75
// handles.add(createShearHandle(owner, PositionConstants.WEST));
76
// handles.add(createShearHandle(owner, PositionConstants.SOUTH));
77
// handles.add(createShearHandle(owner, PositionConstants.EAST));
78
}
79   
80   protected static Handle createRotateHandle(AbstractDrawComponentEditPart owner, int direction)
81   {
82     RotateHandle handle = new RotateHandle(owner, direction);
83     return handle;
84   }
85   
86   protected static Handle createShearHandle(AbstractDrawComponentEditPart owner, int direction)
87   {
88     ShearHandle handle = new ShearHandle(owner, direction);
89     return handle;
90   }
91 }
92
Popular Tags