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
80
81
82
|
/*****************************************************************************
* Copyright (c) 2005, 2018 AIRBUS FRANCE, CEA LIST, EclipseSource and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* David Sciamma (Anyware Technologies),
* Mathieu Garcia (Anyware Technologies),
* Jacques Lescot (Anyware Technologies),
* Thomas Friol (Anyware Technologies),
* Nicolas Lalevee (Anyware Technologies) - initial API and implementation
* EclipseSource - Bug 536638
*
****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.figures;
import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.Graphics;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
import org.eclipse.papyrus.uml.diagram.sequence.anchors.AnchorConstants;
import org.eclipse.papyrus.uml.diagram.sequence.anchors.CenterAnchor;
import org.eclipse.uml2.uml.DestructionOccurrenceSpecification;
/**
* Figure for a {@link DestructionOccurrenceSpecification}. It is drawn as an X centered over a Lifeline body
*/
public class DestructionEventFigure extends DefaultSizeNodeFigure {
private int lineWidth = 1;
/**
* Constructor <!-- begin-user-doc --> <!-- end-user-doc -->
*/
public DestructionEventFigure() {
super(40, 40);
}
/**
* The stop is a cross
*
* @see org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics)
*/
@Override
protected void paintFigure(Graphics graphics) {
super.paintFigure(graphics);
graphics.pushState();
graphics.setLineWidth(2);
graphics.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height);
graphics.drawLine(bounds.x, bounds.y + bounds.height, bounds.x + bounds.width, bounds.y);
graphics.popState();
}
@Override
public void setLineWidth(int w) {
if ((lineWidth == w) || (w < 0)) {
return;
}
lineWidth = w;
repaint();
}
/**
* @see org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure#getConnectionAnchor(java.lang.String)
*
* @param terminal
* @return
*/
@Override
public ConnectionAnchor getConnectionAnchor(String terminal) {
if (AnchorConstants.CENTER_TERMINAL.equals(terminal)) {
return new CenterAnchor(this);
}
return super.getConnectionAnchor(terminal);
}
}
|