KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > editor2d > handle > RotateCenterHandle


1 /**
2  * <p> Project: com.nightlabs.editor2d </p>
3  * <p> Copyright: Copyright (c) 2004 </p>
4  * <p> Company: NightLabs GmbH (Germany) </p>
5  * <p> Creation Date: 13.04.2005 </p>
6  * <p> Author: Daniel Mazurek </p>
7 **/

8 package com.nightlabs.editor2d.handle;
9
10 import java.util.List JavaDoc;
11
12 import org.eclipse.draw2d.Graphics;
13 import org.eclipse.draw2d.geometry.Rectangle;
14 import org.eclipse.gef.DragTracker;
15
16 import com.nightlabs.editor2d.custom.EditorCursors;
17 import com.nightlabs.editor2d.edit.AbstractDrawComponentEditPart;
18 import com.nightlabs.editor2d.tools.RotateCenterTracker;
19
20
21 public class RotateCenterHandle
22 extends EditorAbstractHandle
23 {
24   protected List JavaDoc editParts;
25   public RotateCenterHandle(List JavaDoc editParts)
26   {
27     super();
28     if (editParts.size() == 1) {
29       setLocator(new RotateCenterLocator((AbstractDrawComponentEditPart)editParts.get(0)));
30     } else {
31       setLocator(new MultipleCenterLocator(editParts));
32       multiple = true;
33     }
34     setOwner((AbstractDrawComponentEditPart)editParts.get(0));
35     setCursor(EditorCursors.CROSS);
36   }
37
38   protected DragTracker createDragTracker() {
39     return new RotateCenterTracker((AbstractDrawComponentEditPart)getOwner());
40   }
41   
42   public void paintFigure(Graphics g)
43   {
44     Rectangle r = getBounds();
45     r.shrink(1, 1);
46     try {
47       g.fillOval(r);
48       g.drawOval(r);
49 // g.drawLine(r.x + r.width/2, r.y, r.x + r.width/2, r.y + r.height);
50
// g.drawLine(r.x, r.y + r.height/2, r.x + r.width, r.y + r.height/2);
51
} finally {
52       //We don't really own rect 'r', so fix it.
53
r.expand(1, 1);
54     }
55   }
56   
57   protected boolean multiple = false;
58   public boolean isMultiple() {
59     return multiple;
60   }
61 }
62
Popular Tags