blob: d1a05d1677c8f1ef0c72ea68406b69a8fcb462a4 (
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/*****************************************************************************
* Copyright (c) 2017 CEA LIST, ALL4TEC and others.
*
* 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:
* Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.figure.edge;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.PolylineDecoration;
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel;
/**
* {@link PapyrusEdgeFigure} for references.
*
* @author Mickael ADAM
* @since 3.1
*/
public final class ReferenceEdgeFigure extends PapyrusEdgeFigure {
/**
* Creates a new DashEdgeFigure.
*/
public ReferenceEdgeFigure() {
super();
setArrow(true);
setupDefaultStyle();
createContents();
}
/**
* Dashes used to paint line.
*/
private final int[] dashes = new int[10];
/**
* use to if the arrow will be displayed
*/
protected boolean arrow = false;
/**
* The name label.
*/
private WrappingLabel nameLabel;
/**
* Get the name label.
*/
public WrappingLabel getEdgeLabel() {
return nameLabel;
}
/**
* use to display the arrow of the edge
*
* @param arrow
* true if the arrow will be displayed
*/
public void setArrow(final Boolean arrow) {
this.arrow = arrow;
}
/**
* Create the content.
*/
protected void createContents() {
nameLabel = new PapyrusWrappingLabel();
nameLabel.setText("");//$NON-NLS-1$
this.add(nameLabel);
}
/**
* Resets the style of this figure to its default implementation
*/
@Override
public void resetStyle() {
setupDefaultStyle();
}
/**
* Sets initial Style for the figure. It does not give any special Color for
* Background and Foreground. This is the style used for classic arrows:
* ------>
* This method should not be overridden as it defines the default style for the arrow.
* Instead, custom styles should be defined by overriding the resetStyle method.
*/
protected final void setupDefaultStyle() {
if (arrow) {
PolylineDecoration dec = new PolylineDecoration();
dec.setScale(15, 5);
dec.setLineWidth(1);
this.setTargetDecoration(dec);
} else {
this.setTargetDecoration(null);
} // arrow at target endpoint
this.setLineStyle(Graphics.LINE_CUSTOM); // line drawing style
// set dashes
for (int i = 0; i < 10; i++) {
dashes[i] = 5;
}
setLineDash(dashes);
}
}
|