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 org.eclipse.draw2d.geometry.Point;
|
14
|
|
15
|
/**
|
16
|
* A transparent figure intended to be added exclusively to a
|
17
|
* {@link LayeredPane}, who has the responsibilty of managing its layers.
|
18
|
*/
|
19
|
public class Layer extends Figure {
|
20
|
|
21
|
/**
|
22
|
* Overridden to implement transparent behavior.
|
23
|
*
|
24
|
* @see IFigure#containsPoint(int, int)
|
25
|
*
|
26
|
*/
|
27
|
public boolean containsPoint(int x, int y) {
|
28
|
if (isOpaque())
|
29
|
return super.containsPoint(x, y);
|
30
|
Point pt = Point.SINGLETON;
|
31
|
pt.setLocation(x, y);
|
32
|
translateFromParent(pt);
|
33
|
x = pt.x;
|
34
|
y = pt.y;
|
35
|
for (int i = 0; i < getChildren().size(); i++) {
|
36
|
IFigure child = (IFigure) getChildren().get(i);
|
37
|
if (child.containsPoint(x, y))
|
38
|
return true;
|
39
|
}
|
40
|
return false;
|
41
|
}
|
42
|
|
43
|
/**
|
44
|
* Overridden to implement transparency.
|
45
|
*
|
46
|
* @see IFigure#findFigureAt(int, int, TreeSearch)
|
47
|
*/
|
48
|
public IFigure findFigureAt(int x, int y, TreeSearch search) {
|
49
|
if (!isEnabled())
|
50
|
return null;
|
51
|
if (isOpaque())
|
52
|
return super.findFigureAt(x, y, search);
|
53
|
|
54
|
IFigure f = super.findFigureAt(x, y, search);
|
55
|
if (f == this)
|
56
|
return null;
|
57
|
return f;
|
58
|
}
|
59
|
|
60
|
}
|