Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a2bf5e7d3852730be5c1400e43f869ce1ccaff96 (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
<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="InitFlowLayoutGenerator"
	imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.*"%>
<%
GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
final FlowLayout gmfLayout = (FlowLayout) argsBundle.getLayout();
final String layouterVarName = argsBundle.getManagerVariableName();

class AlignmentConverter {
	public String convert(Alignment alignment){
		if (alignment == null){
			alignment = Alignment.BEGINNING_LITERAL;
		}
		switch (alignment.getValue()){
			case Alignment.BEGINNING : 
				return "ALIGN_LEFTTOP";
			case Alignment.END :
				return "ALIGN_RIGHTBOTTOM";
			case Alignment.FILL:
			case Alignment.CENTER:
				return "ALIGN_CENTER";
			default:
				throw new IllegalArgumentException("Unknown alignment: " + alignment);
		}
	}
}

final AlignmentConverter alignmentConverter = new AlignmentConverter();
%>
		<%=layouterVarName%>.setStretchMinorAxis(<%=gmfLayout.isMatchMinorSize()%>);
		<%=layouterVarName%>.setMinorAlignment(<%=alignmentConverter.convert(gmfLayout.getMinorAlignment())%>);
<%
if (gmfLayout.isForceSingleLine()){
%>		
		<%=layouterVarName%>.setSpacing(<%=gmfLayout.getMajorSpacing()%>);
		<%=layouterVarName%>.setVertical(<%=gmfLayout.isVertical()%>);
<%
} else {
%>
		<%=layouterVarName%>.setMajorAlignment(<%=alignmentConverter.convert(gmfLayout.getMajorAlignment())%>);
		<%=layouterVarName%>.setMajorSpacing(<%=gmfLayout.getMajorSpacing()%>);
		<%=layouterVarName%>.setMinorSpacing(<%=gmfLayout.getMinorSpacing()%>);
		<%=layouterVarName%>.setHorizontal(<%=!gmfLayout.isVertical()%>);
<%
} 
%>


Back to the top