Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1bcde8b27dffd98411c51be7ddea53278482e914 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*****************************************************************************
 * Copyright (c) 2008 CEA LIST.
 *
 *    
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.figure.node;

import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;

/**
 * this figure is used to display at the good positionn acnhor on the
 * packageable element
 * 
 * @author PT202707
 * 
 */
public class PackageNodePlateFigure extends DefaultSizeNodeFigure {

	// @unused
	public PackageNodePlateFigure(Dimension defSize) {
		super(defSize);
		// TODO Auto-generated constructor stub
	}

	public PackageNodePlateFigure(int width, int height) {
		super(width, height);
		// TODO Auto-generated constructor stub
	}

	/**
	 * Gets the package figure, it's a child of PackageNodePlateFigure
	 * 
	 * @return the package figure
	 */
	public PackageFigure getPackageFigure() {
		if(getChildren().size() > 0 && getChildren().get(0) instanceof PackageFigure) {
			return (PackageFigure)getChildren().get(0);

		}
		return null;
	}

	// This returns as the anchoring area only the central line
	@Override
	public PointList getPolygonPoints() {
		PointList points = new PointList(5);
		Rectangle anchorableRectangle = getHandleBounds();
		points.addPoint(anchorableRectangle.x, anchorableRectangle.y);

		PackageFigure packageFigure = getPackageFigure();

		if(packageFigure != null) {
			// take in account the header of the package
			points.addPoint(anchorableRectangle.x + packageFigure.getHeader().width, anchorableRectangle.y);
			points.addPoint(anchorableRectangle.x + packageFigure.getHeader().width, anchorableRectangle.y + packageFigure.getHeader().height);
			points.addPoint(anchorableRectangle.x + anchorableRectangle.width, anchorableRectangle.y + packageFigure.getHeader().height);
		}// no header
		else {
			points.addPoint(anchorableRectangle.x + anchorableRectangle.width, anchorableRectangle.y);
		}

		points.addPoint(anchorableRectangle.x + anchorableRectangle.width, anchorableRectangle.y + anchorableRectangle.height);
		points.addPoint(anchorableRectangle.x, anchorableRectangle.y + anchorableRectangle.height);
		points.addPoint(anchorableRectangle.x, anchorableRectangle.y);
		return points;
	}

}

Back to the top