-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathVCase.java
More file actions
132 lines (115 loc) · 3.96 KB
/
VCase.java
File metadata and controls
132 lines (115 loc) · 3.96 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*****************************************************************************
* SysML 2 Pilot Implementation, PlantUML Visualization
* Copyright (c) 2021 Mgnite Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of theGNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
*
* Contributors:
* Hisashi Miyashita, Mgnite Inc.
*
*****************************************************************************/
package org.omg.sysml.plantuml;
import java.util.List;
import org.omg.sysml.lang.sysml.ActionUsage;
import org.omg.sysml.lang.sysml.CaseUsage;
import org.omg.sysml.lang.sysml.Membership;
import org.omg.sysml.lang.sysml.Namespace;
import org.omg.sysml.lang.sysml.ObjectiveMembership;
import org.omg.sysml.lang.sysml.RequirementUsage;
import org.omg.sysml.lang.sysml.SubjectMembership;
import org.omg.sysml.lang.sysml.Succession;
import org.omg.sysml.lang.sysml.TransitionUsage;
import org.omg.sysml.lang.sysml.Type;
import org.omg.sysml.plantuml.SysML2PlantUMLStyle.StyleRelSwitch;
import org.omg.sysml.plantuml.SysML2PlantUMLStyle.StyleSwitch;
public class VCase extends VMixed {
private static final SysML2PlantUMLStyle style
= new SysML2PlantUMLStyle
("VCase",
null,
"",
new StyleSwitch(new StyleRelSwitch() {
@Override
public String caseSuccession(Succession s) {
return " ..> ";
}
@Override
public String caseTransitionUsage(TransitionUsage tu) {
return " ..> ";
}
}, null));
@Override
protected SysML2PlantUMLStyle getStyle() {
return style;
}
@Override
protected VTree newVTree(Namespace namespace, Membership membership) {
return new VCase(this, namespace, membership);
}
private String addAction(Type typ) {
String name = extractTitleName(typ);
int id = addRecLine(name, typ, true);
addSpecializations(id, typ);
VCaseMembers v = new VCaseMembers(this);
v.processCase(typ);
return "";
}
@Override
public String caseObjectiveMembership(ObjectiveMembership om) {
RequirementUsage ru = om.getOwnedObjectiveRequirement();
String name = ru.getName();
if ("obj".equals(name)) name = null;
VRequirement vr = new VRequirement(this);
List<VTree> subtrees = processCompartment(vr, ru);
int id = -1;
if (subtrees != null || name != null) {
if (name == null) {
id = addPUMLLine(ru, "comp usage ", " <U+00AB>objective<U+00BB> ", "");
} else {
id = addPUMLLine(ru, "comp usage ", name, " <<objective>> ");
}
processSubtrees(vr, subtrees);
}
addSpecializations(id, ru);
return "";
}
@Override
public String caseSubjectMembership(SubjectMembership sm) {
addSubjectMembership(sm, false);
return "";
}
@Override
public String caseActionUsage(ActionUsage au) {
return addAction(au);
}
@Override
public String caseCaseUsage(CaseUsage cu) {
// We MUST override VMixed.caseCaseUsage()
return addAction(cu);
}
VCase(Visitor vt, Namespace namespace, Membership membership) {
super(vt, namespace, membership);
}
VCase(VCaseMembers vt) {
super(vt);
}
public VCase(VMixed vt) {
super(vt);
}
public VCase() {
super();
}
}