1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2000, 2010 IBM Corporation and others.
|
3
|
* All rights reserved. This program and the accompanying materials
|
4
|
* are made available under the terms of the Eclipse Public License v1.0
|
5
|
* which accompanies this distribution, and is available at
|
6
|
* http://www.eclipse.org/legal/epl-v10.html
|
7
|
*
|
8
|
* Contributors:
|
9
|
* IBM Corporation - initial API and implementation
|
10
|
*******************************************************************************/
|
11
|
package org.eclipse.gef.handles;
|
12
|
|
13
|
import org.eclipse.swt.graphics.Cursor;
|
14
|
|
15
|
import org.eclipse.draw2d.Cursors;
|
16
|
import org.eclipse.draw2d.Locator;
|
17
|
|
18
|
import org.eclipse.gef.DragTracker;
|
19
|
import org.eclipse.gef.GraphicalEditPart;
|
20
|
import org.eclipse.gef.tools.ResizeTracker;
|
21
|
|
22
|
/**
|
23
|
* A Handle used to resize a GraphicalEditPart.
|
24
|
*/
|
25
|
public class ResizeHandle extends SquareHandle {
|
26
|
|
27
|
private int cursorDirection = 0;
|
28
|
|
29
|
/**
|
30
|
* Creates a new ResizeHandle for the given GraphicalEditPart.
|
31
|
* <code>direction</code> is the relative direction from the center of the
|
32
|
* owner figure. For example, <code>SOUTH_EAST</code> would place the handle
|
33
|
* in the lower-right corner of its owner figure. These direction constants
|
34
|
* can be found in {@link org.eclipse.draw2d.PositionConstants}.
|
35
|
*
|
36
|
* @param owner
|
37
|
* owner of the ResizeHandle
|
38
|
* @param direction
|
39
|
* relative direction from the center of the owner figure
|
40
|
*/
|
41
|
public ResizeHandle(GraphicalEditPart owner, int direction) {
|
42
|
setOwner(owner);
|
43
|
setLocator(new RelativeHandleLocator(owner.getFigure(), direction));
|
44
|
setCursor(Cursors.getDirectionalCursor(direction, owner.getFigure()
|
45
|
.isMirrored()));
|
46
|
cursorDirection = direction;
|
47
|
}
|
48
|
|
49
|
/**
|
50
|
* Creates a new ResizeHandle for the given GraphicalEditPart.
|
51
|
*
|
52
|
* @see SquareHandle#SquareHandle(GraphicalEditPart, Locator, Cursor)
|
53
|
*/
|
54
|
public ResizeHandle(GraphicalEditPart owner, Locator loc, Cursor c) {
|
55
|
super(owner, loc, c);
|
56
|
}
|
57
|
|
58
|
/**
|
59
|
* Returns <code>null</code> for the DragTracker.
|
60
|
*
|
61
|
* @return returns <code>null</code>
|
62
|
*/
|
63
|
protected DragTracker createDragTracker() {
|
64
|
return new ResizeTracker(getOwner(), cursorDirection);
|
65
|
}
|
66
|
|
67
|
}
|