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.draw2d;
|
12
|
|
13
|
import java.util.Iterator;
|
14
|
|
15
|
import org.eclipse.draw2d.geometry.Rectangle;
|
16
|
|
17
|
/**
|
18
|
* A Layer that can extend in all 4 directions.
|
19
|
*/
|
20
|
public class FreeformLayer extends Layer implements FreeformFigure {
|
21
|
|
22
|
private FreeformHelper helper = new FreeformHelper(this);
|
23
|
|
24
|
/**
|
25
|
* @see IFigure#add(IFigure, Object, int)
|
26
|
*/
|
27
|
public void add(IFigure child, Object constraint, int index) {
|
28
|
super.add(child, constraint, index);
|
29
|
helper.hookChild(child);
|
30
|
}
|
31
|
|
32
|
/**
|
33
|
* @see FreeformFigure#addFreeformListener(FreeformListener)
|
34
|
*/
|
35
|
public void addFreeformListener(FreeformListener listener) {
|
36
|
addListener(FreeformListener.class, listener);
|
37
|
}
|
38
|
|
39
|
/**
|
40
|
* @see FreeformFigure#fireExtentChanged()
|
41
|
*/
|
42
|
public void fireExtentChanged() {
|
43
|
Iterator iter = getListeners(FreeformListener.class);
|
44
|
while (iter.hasNext())
|
45
|
((FreeformListener) iter.next()).notifyFreeformExtentChanged();
|
46
|
}
|
47
|
|
48
|
/**
|
49
|
* Overrides to do nothing.
|
50
|
*
|
51
|
* @see Figure#fireMoved()
|
52
|
*/
|
53
|
protected void fireMoved() {
|
54
|
}
|
55
|
|
56
|
/**
|
57
|
* @see FreeformFigure#getFreeformExtent()
|
58
|
*/
|
59
|
public Rectangle getFreeformExtent() {
|
60
|
return helper.getFreeformExtent();
|
61
|
}
|
62
|
|
63
|
/**
|
64
|
* @see Figure#primTranslate(int, int)
|
65
|
*/
|
66
|
public void primTranslate(int dx, int dy) {
|
67
|
bounds.x += dx;
|
68
|
bounds.y += dy;
|
69
|
}
|
70
|
|
71
|
/**
|
72
|
* @see IFigure#remove(IFigure)
|
73
|
*/
|
74
|
public void remove(IFigure child) {
|
75
|
helper.unhookChild(child);
|
76
|
super.remove(child);
|
77
|
}
|
78
|
|
79
|
/**
|
80
|
* @see FreeformFigure#removeFreeformListener(FreeformListener)
|
81
|
*/
|
82
|
public void removeFreeformListener(FreeformListener listener) {
|
83
|
removeListener(FreeformListener.class, listener);
|
84
|
}
|
85
|
|
86
|
/**
|
87
|
* @see FreeformFigure#setFreeformBounds(Rectangle)
|
88
|
*/
|
89
|
public void setFreeformBounds(Rectangle bounds) {
|
90
|
helper.setFreeformBounds(bounds);
|
91
|
}
|
92
|
|
93
|
}
|