blob: cf8e083cfa3b1d368d86ff938d5373cf7d43cdb3 (
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
|
/*****************************************************************************
* 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.FillStyle;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
import org.eclipse.papyrus.infra.gmfdiag.css.helper.GradientHelper;
import org.eclipse.papyrus.infra.gmfdiag.css.style.CSSFillStyle;
import org.w3c.dom.css.CSSValue;
public class CSSFillStyleDelegate implements CSSFillStyle {
private FillStyle fillStyle;
private ExtendedCSSEngine engine;
public CSSFillStyleDelegate(FillStyle fillStyle, ExtendedCSSEngine engine) {
this.fillStyle = fillStyle;
this.engine = engine;
}
////////////////////////////////////////////////
// Implements a getter for each CSS property //
////////////////////////////////////////////////
public int getCSSFillColor() {
CSSValue cssValue = engine.retrievePropertyValue(fillStyle, "fillColor");
if(cssValue == null) {
Object defaultValue = NotationPackage.eINSTANCE.getFillStyle_FillColor().getDefaultValue();
return (Integer)defaultValue;
}
return (Integer)engine.convert(cssValue, "GMFColor", null);
}
public int getCSSTransparency() {
CSSValue cssValue = engine.retrievePropertyValue(fillStyle, "transparency");
if(cssValue == null) {
Object defaultValue = NotationPackage.eINSTANCE.getFillStyle_Transparency().getDefaultValue();
return (Integer)defaultValue;
}
return (Integer)engine.convert(cssValue, Integer.class, null);
}
public org.eclipse.gmf.runtime.notation.datatype.GradientData getCSSGradient() {
return GradientHelper.computeGradient(engine, fillStyle);
}
}
|