List of usage examples for com.google.gwt.dom.client Element setPropertyDouble
@Override
public void setPropertyDouble(String name, double value)
From source file:com.sencha.gxt.chart.client.draw.engine.VML.java
License:sencha.com license
/** * Applies the fill attribute of a sprite to its VML DOM element. * /*from w w w . ja v a 2 s.c o m*/ * @param sprite the sprite to have its fill set */ private void setFill(Sprite sprite, Element element) { Element fill = element.getPropertyJSO("fill").cast(); if (fill == null) { fill = createNode("fill"); element.setPropertyJSO("fill", fill); element.appendChild(fill); } if (sprite.getFill() == null || sprite.getFill() == Color.NONE) { fill.setPropertyBoolean("on", false); } else { if (sprite.isFillDirty() || ignoreOptimizations) { fill.setPropertyBoolean("on", true); if (sprite.getFill() instanceof Gradient) { Gradient gradient = (Gradient) sprite.getFill(); // VML angle is offset and inverted from standard, and must be // adjusted // to match rotation transform final double degrees; if (sprite.getRotation() != null) { degrees = sprite.getRotation().getDegrees(); } else { degrees = 0; } double angle; angle = -(gradient.getAngle() + 270 + degrees) % 360.0; // IE will flip the angle at 0 degrees... if (angle == 0) { angle = 180; } fill.setPropertyDouble("angle", angle); fill.setPropertyString("type", "gradient"); fill.setPropertyString("method", "sigma"); StringBuilder stops = new StringBuilder(); for (Stop stop : gradient.getStops()) { if (stops.length() > 0) { stops.append(", "); } stops.append(stop.getOffset()).append("% ").append(stop.getColor()); } Element colors = fill.getPropertyJSO("colors").cast(); colors.setPropertyString("value", stops.toString()); } else { fill.setPropertyString("color", sprite.getFill().getColor()); fill.setPropertyString("src", ""); fill.setPropertyString("type", "solid"); } } if (!Double.isNaN(sprite.getOpacity()) && (sprite.isOpacityDirty() || ignoreOptimizations)) { fill.setPropertyString("opacity", String.valueOf(sprite.getOpacity())); } if (!Double.isNaN(sprite.getFillOpacity()) && (sprite.isFillOpacityDirty() || ignoreOptimizations)) { fill.setPropertyString("opacity", String.valueOf(sprite.getFillOpacity())); } } }
From source file:com.sencha.gxt.chart.client.draw.engine.VML.java
License:sencha.com license
/** * Applies the stroke attribute of a sprite to its VML dom element. * //w w w . ja v a2 s .c o m * @param sprite the sprite to have its stroke set */ private void setStroke(Sprite sprite, XElement element) { Element stroke = element.getPropertyJSO("stroke").cast(); if (stroke == null) { stroke = createNode("stroke"); element.setPropertyJSO("stroke", stroke); element.appendChild(stroke); } Color strokeColor = sprite.getStroke(); if (strokeColor == null || strokeColor == Color.NONE || sprite.getStrokeWidth() == 0.0) { stroke.setPropertyBoolean("on", false); } else { stroke.setPropertyBoolean("on", true); if (!(strokeColor instanceof Gradient)) { // VML does NOT support a gradient stroke :( stroke.setPropertyString("color", strokeColor.getColor()); } if (sprite instanceof PathSprite) { PathSprite path = (PathSprite) sprite; LineCap strokeLineCap = path.getStrokeLineCap(); if (strokeLineCap != null) { // legal values for endcap are flat, square, round // http://msdn.microsoft.com/en-us/library/bb229428%28v=vs.85%29.aspx stroke.setPropertyString("endcap", strokeLineCap == LineCap.BUTT ? "flat" : strokeLineCap.getValue()); } if (path.getStrokeLineJoin() != null) { stroke.setPropertyString("joinstyle", path.getStrokeLineJoin().getValue()); } if (!Double.isNaN(path.getMiterLimit())) { stroke.setPropertyDouble("miterlimit", path.getMiterLimit()); } } double width = sprite.getStrokeWidth(); double opacity = sprite.getStrokeOpacity(); if (Double.isNaN(width)) { width = 0.75; } else { width *= 0.75; } if (Double.isNaN(opacity)) { opacity = 1; } // VML Does not support stroke widths under 1, so we're going to fiddle // with stroke-opacity instead. if (width < 1) { opacity *= width; width = 1; } stroke.setPropertyDouble("weight", width); stroke.setPropertyDouble("opacity", opacity); } }
From source file:org.vaadin.addon.gwtgraphics.client.impl.VMLImpl.java
License:Apache License
@Override public void setFillOpacity(Element element, double opacity) { VMLUtil.getOrCreateChildElementWithTagName(element, "fill").setPropertyString("opacity", "" + opacity); element.setPropertyDouble("_fill-opacity", opacity); }
From source file:org.vaadin.addon.gwtgraphics.client.impl.VMLImpl.java
License:Apache License
@Override public void setStrokeOpacity(Element element, double opacity) { VMLUtil.getOrCreateChildElementWithTagName(element, "stroke").setPropertyString("opacity", "" + opacity); element.setPropertyDouble("_stroke-opacity", opacity); }