Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c247df9b7dac789f8065326fb2a372ec150e6397 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*****************************************************************************
 * Copyright (c) 2012 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:
 *  Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
 *****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.style.impl;

import org.eclipse.gmf.runtime.notation.ConnectorStyle;
import org.eclipse.gmf.runtime.notation.JumpLinkStatus;
import org.eclipse.gmf.runtime.notation.JumpLinkType;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.Routing;
import org.eclipse.gmf.runtime.notation.Smoothness;
import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
import org.eclipse.papyrus.infra.gmfdiag.css.style.CSSConnectorStyle;
import org.w3c.dom.css.CSSValue;

public class CSSConnectorStyleDelegate implements CSSConnectorStyle {

	private ConnectorStyle connectorStyle;

	private ExtendedCSSEngine engine;

	public CSSConnectorStyleDelegate(ConnectorStyle connectorStyle, ExtendedCSSEngine engine) {
		this.connectorStyle = connectorStyle;
		this.engine = engine;
	}

	// //////////////////////////////////////////////
	// Implements a getter for each CSS property //
	// //////////////////////////////////////////////

	@Override
	public int getCSSRoundedBendpointsRadius() {
		CSSValue cssValue = engine.retrievePropertyValue(connectorStyle, "roundedBendpointsRadius");
		if (cssValue == null) {
			Object defaultValue = NotationPackage.eINSTANCE.getRoundedCornersStyle_RoundedBendpointsRadius().getDefaultValue();
			return (Integer) defaultValue;
		}
		return (Integer) engine.convert(cssValue, Integer.class, null);
	}

	@Override
	public Routing getCSSRouting() {
		CSSValue cssValue = engine.retrievePropertyValue(connectorStyle, "routing");
		if (cssValue == null) {
			Object defaultValue = NotationPackage.eINSTANCE.getRoutingStyle_Routing().getDefaultValue();
			return (Routing) defaultValue;
		}
		return Routing.get(cssValue.getCssText());
	}

	@Override
	public Smoothness getCSSSmoothness() {
		CSSValue cssValue = engine.retrievePropertyValue(connectorStyle, "smoothness");
		if (cssValue == null) {
			Object defaultValue = NotationPackage.eINSTANCE.getRoutingStyle_Smoothness().getDefaultValue();
			return (Smoothness) defaultValue;
		}
		return Smoothness.get(cssValue.getCssText());
	}

	@Override
	public boolean isCSSAvoidObstructions() {
		CSSValue cssValue = engine.retrievePropertyValue(connectorStyle, "avoidObstructions");
		if (cssValue == null) {
			Object defaultValue = NotationPackage.eINSTANCE.getRoutingStyle_AvoidObstructions().getDefaultValue();
			return (Boolean) defaultValue;
		}
		return (Boolean) engine.convert(cssValue, Boolean.class, null);
	}

	@Override
	public boolean isCSSClosestDistance() {
		CSSValue cssValue = engine.retrievePropertyValue(connectorStyle, "closestDistance");
		if (cssValue == null) {
			Object defaultValue = NotationPackage.eINSTANCE.getRoutingStyle_ClosestDistance().getDefaultValue();
			return (Boolean) defaultValue;
		}
		return (Boolean) engine.convert(cssValue, Boolean.class, null);
	}

	@Override
	public JumpLinkStatus getCSSJumpLinkStatus() {
		CSSValue cssValue = engine.retrievePropertyValue(connectorStyle, "jumpLinkStatus");
		if (cssValue == null) {
			Object defaultValue = NotationPackage.eINSTANCE.getRoutingStyle_JumpLinkStatus().getDefaultValue();
			return (JumpLinkStatus) defaultValue;
		}
		return JumpLinkStatus.get(cssValue.getCssText());
	}

	@Override
	public JumpLinkType getCSSJumpLinkType() {
		CSSValue cssValue = engine.retrievePropertyValue(connectorStyle, "jumpLinkType");
		if (cssValue == null) {
			Object defaultValue = NotationPackage.eINSTANCE.getRoutingStyle_JumpLinkType().getDefaultValue();
			return (JumpLinkType) defaultValue;
		}
		return JumpLinkType.get(cssValue.getCssText());
	}

	@Override
	public boolean isCSSJumpLinksReverse() {
		CSSValue cssValue = engine.retrievePropertyValue(connectorStyle, "jumpLinksReverse");
		if (cssValue == null) {
			Object defaultValue = NotationPackage.eINSTANCE.getRoutingStyle_JumpLinksReverse().getDefaultValue();
			return (Boolean) defaultValue;
		}
		return (Boolean) engine.convert(cssValue, Boolean.class, null);
	}

	@Override
	public int getCSSLineColor() {
		CSSValue cssValue = engine.retrievePropertyValue(connectorStyle, "lineColor");
		if (cssValue == null) {
			Object defaultValue = NotationPackage.eINSTANCE.getLineStyle_LineColor().getDefaultValue();
			return (Integer) defaultValue;
		}
		return (Integer) engine.convert(cssValue, "GMFColor", null);
	}

	@Override
	public int getCSSLineWidth() {
		CSSValue cssValue = engine.retrievePropertyValue(connectorStyle, "lineWidth");
		if (cssValue == null) {
			Object defaultValue = NotationPackage.eINSTANCE.getLineStyle_LineWidth().getDefaultValue();
			return (Integer) defaultValue;
		}
		return (Integer) engine.convert(cssValue, Integer.class, null);
	}
}

Back to the top