diff options
Diffstat (limited to 'sandbox/org.eclipse.papyrus.prototype.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/prototype/infra/gmfdiag/css/style/impl/CSSShapeStyleImpl.java')
-rw-r--r-- | sandbox/org.eclipse.papyrus.prototype.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/prototype/infra/gmfdiag/css/style/impl/CSSShapeStyleImpl.java | 163 |
1 files changed, 145 insertions, 18 deletions
diff --git a/sandbox/org.eclipse.papyrus.prototype.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/prototype/infra/gmfdiag/css/style/impl/CSSShapeStyleImpl.java b/sandbox/org.eclipse.papyrus.prototype.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/prototype/infra/gmfdiag/css/style/impl/CSSShapeStyleImpl.java index ef9d0feacbb..77b003aea98 100644 --- a/sandbox/org.eclipse.papyrus.prototype.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/prototype/infra/gmfdiag/css/style/impl/CSSShapeStyleImpl.java +++ b/sandbox/org.eclipse.papyrus.prototype.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/prototype/infra/gmfdiag/css/style/impl/CSSShapeStyleImpl.java @@ -5,10 +5,13 @@ import java.io.IOException; import org.eclipse.e4.ui.css.core.css2.CSS2ColorHelper; import org.eclipse.e4.ui.css.core.dom.CSSStylableElement; import org.eclipse.e4.ui.css.core.engine.CSSEngine; +import org.eclipse.gmf.runtime.notation.GradientStyle; import org.eclipse.gmf.runtime.notation.NotationPackage; import org.eclipse.gmf.runtime.notation.ShapeStyle; +import org.eclipse.gmf.runtime.notation.datatype.GradientData; import org.eclipse.papyrus.infra.emf.Activator; import org.eclipse.papyrus.prototype.infra.gmfdiag.css.helper.ConversionHelper; +import org.eclipse.papyrus.prototype.infra.gmfdiag.css.helper.ParserHelper; import org.eclipse.papyrus.prototype.infra.gmfdiag.css.style.CSSShapeStyle; import org.w3c.dom.css.CSSValue; import org.w3c.dom.css.RGBColor; @@ -122,26 +125,16 @@ public class CSSShapeStyleImpl implements CSSShapeStyle { public int getCSSFillColor() { String cssValue = engine.retrieveCSSProperty(element, "fillColor", ""); - if(cssValue == null) { - Object defaultValue = NotationPackage.eINSTANCE.getFillStyle_FillColor().getDefaultValue(); - return (Integer)defaultValue; - } else { + if(cssValue != null) { try { CSSValue value = engine.parsePropertyValue(cssValue); - RGBColor color; - if(value instanceof RGBColor) { - color = (RGBColor)value; - } else { - color = CSS2ColorHelper.getRGBColor(cssValue); - } - - return ConversionHelper.getIntColor(color); + return ConversionHelper.getIntColor(cssValue, value); } catch (IOException ex) { Activator.log.error(ex); } } - return Integer.parseInt(cssValue); + return (Integer)NotationPackage.eINSTANCE.getFillStyle_FillColor().getDefaultValue(); } public int getCSSTransparency() { @@ -153,13 +146,115 @@ public class CSSShapeStyleImpl implements CSSShapeStyle { return Integer.parseInt(cssValue); } + //Type 1 : + //gradientColor:#ABCDEF; + //gradientStyle:vertical; + + //Type 2 : + //(gradient:#FEDCBA #ABCDEF horizontal;) //Currently not supported, as diagrams usually seek for #fillColor() + //gradient:#ABCDEF horizontal; + //gradient:#ABCDEF + //gradient:horizontal public org.eclipse.gmf.runtime.notation.datatype.GradientData getCSSGradient() { - String cssValue = engine.retrieveCSSProperty(element, "gradient", ""); - if(cssValue == null) { - Object defaultValue = NotationPackage.eINSTANCE.getFillStyle_Gradient().getDefaultValue(); - return (org.eclipse.gmf.runtime.notation.datatype.GradientData)defaultValue; + //Type 1 + String gradientColor = engine.retrieveCSSProperty(element, "gradientColor", ""); + String gradientStyle = engine.retrieveCSSProperty(element, "gradientStyle", ""); + + if(gradientColor != null || gradientStyle != null) { + int color1 = getGradientColor(gradientColor); + int color2 = 0; //Unused by Papyrus diagrams + int style = getGradientStyle(gradientStyle); + GradientData data = new GradientData(color1, color2, style); + return data; + } + + //Type 2 + String gradient = engine.retrieveCSSProperty(element, "gradient", ""); + + if(gradient != null) { + int[] gradientValues = parseGradient(gradient); + return new GradientData(gradientValues[0], gradientValues[1], gradientValues[2]); } - return null; + + //Default + return getDefaultGradient(); + } + + /** [color1, color2, style] */ + private int[] parseGradient(String gradient) { + String color1, color2, style; + color1 = color2 = style = null; + + String[] values = ParserHelper.parseValues(engine, gradient); + + if(values.length == 3) { + color1 = values[0]; + color2 = values[1]; + style = values[2]; + } else if(values.length == 2) { + color1 = values[0]; + String value = values[1]; + if(isGradientStyle(value)) { + style = value; + } else { + color2 = value; + } + } else if(values.length == 1) { + String value = values[0]; + if(isGradientStyle(value)) { + style = value; + } else { + color1 = value; + } + } + + return parseGradient(color1, color2, style); + } + + private int[] parseGradient(String sColor1, String sColor2, String sStyle) { + int color1, color2, style; + color1 = color2 = style = -1; + + color1 = getGradientColor(sColor1); + color2 = 0; //Unused + style = getGradientStyle(sStyle); + + return new int[]{ color1, color2, style }; + } + + private boolean isGradientStyle(String value) { + return GRADIENT_VERTICAL.equals(value) || GRADIENT_HORIZONTAL.equals(value); + } + + private int getGradientColor(String gradientColor) { + if(gradientColor != null) { + CSSValue cssValue; + try { + cssValue = engine.parsePropertyValue(gradientColor); + return ConversionHelper.getIntColor(gradientColor, cssValue); + } catch (IOException ex) { + Activator.log.error(ex); + } + } + + //Default value + return new GradientData().getGradientColor1(); + } + + private int getGradientStyle(String gradientStyle) { + if(GRADIENT_VERTICAL.equals(gradientStyle)) { + return GradientStyle.VERTICAL; + } else if(GRADIENT_HORIZONTAL.equals(gradientStyle)) { + return GradientStyle.HORIZONTAL; + } + + //Default value + return new GradientData().getGradientStyle(); + } + + private GradientData getDefaultGradient() { + Object defaultValue = NotationPackage.eINSTANCE.getFillStyle_Gradient().getDefaultValue(); + return (GradientData)defaultValue; } public int getCSSLineColor() { @@ -203,4 +298,36 @@ public class CSSShapeStyleImpl implements CSSShapeStyle { } return Integer.parseInt(cssValue); } + + public boolean getCSSElementIcon() { + String cssValue = engine.retrieveCSSProperty(element, "elementIcon", ""); + if(cssValue == null) { + return false; + } + return Boolean.parseBoolean(cssValue); + } + + public boolean getStereotypeDisplay() { + String cssValue = engine.retrieveCSSProperty(element, "stereotypeDisplay", ""); + if(cssValue == null) { + return false; + } + return Boolean.parseBoolean(cssValue); + } + + public boolean getShadow() { + String cssValue = engine.retrieveCSSProperty(element, "shadow", ""); + if(cssValue == null) { + return false; + } + return Boolean.parseBoolean(cssValue); + } + + public int getQualifiedNameDepth() { + String cssValue = engine.retrieveCSSProperty(element, "qualifiedNameDepth", ""); + if(cssValue == null) { + return 1000; + } + return Integer.parseInt(cssValue); + } } |