1 8 package com.nightlabs.editor2d.handle; 9 10 import java.util.List ; 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 editParts; 25 public RotateCenterHandle(List 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 } finally { 52 r.expand(1, 1); 54 } 55 } 56 57 protected boolean multiple = false; 58 public boolean isMultiple() { 59 return multiple; 60 } 61 } 62 | Popular Tags |