List of usage examples for com.google.gwt.dom.client Element setPropertyBoolean
@Override
public void setPropertyBoolean(String name, boolean value)
From source file:com.cgxlib.xq.client.impl.AttributeImpl.java
License:Apache License
public void removeAttribute(XQ xq, String key) { for (Element e : xq.elements()) { if (e.getNodeType() != 1) { continue; }/*from w w w . java 2 s . c o m*/ if (JsUtils.hasProperty(e, key)) { if (BOOLEAN_ATTR_REGEX.test(key)) { e.setPropertyBoolean(key, false); } else { e.setPropertyObject(key, null); } } e.removeAttribute(key); } }
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 www . ja v a 2s . co 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 . j a va 2 s. co 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:com.smartgwt.mobile.client.widgets.Canvas.java
License:Open Source License
@SGWTInternal public void _setHandleDisabled(boolean disabled) { final Element elem = getElement(); if (disabled) { elem.addClassName(_CSS.disabledClass()); } else {/* ww w . ja v a 2 s . c o m*/ elem.removeClassName(_CSS.disabledClass()); } elem.setPropertyBoolean("disabled", disabled); }
From source file:com.tractionsoftware.gwt.user.client.util.DomUtils.java
License:Apache License
/** * It's enough to just set the disabled attribute on the * element, but we want to also add a "disabled" class so that we can * style it.//from w w w.java 2s . c o m * * At some point we'll just be able to use .button:disabled, * but that doesn't work in IE8- */ public static void setEnabled(Element element, boolean enabled) { element.setPropertyBoolean("disabled", !enabled); setStyleName(element, "disabled", !enabled); }
From source file:org.rstudio.studio.client.workbench.views.console.shell.impl.PlainTextEditorImpl.java
License:Open Source License
/** * Webkit doesn't like empty editable SPANs--it is not possible to * drive the focus into one. However, empty editable DIVs are fine. * /*w w w . j av a2 s.c o m*/ * Firefox likes empty editable DIVs only slightly more--they put * themselves about 0.5em too high and sometimes collapse their height * to just a few pixels. However, a DIV that contains two SPANs--one to * set the height with a zero-width space and the other being editable-- * works great. * * This method takes one or the other approach, and returns the actual * contentEditable element. */ public Element setupTextContainer(Element element) { element.setPropertyBoolean("contentEditable", true); return element; }
From source file:org.rstudio.studio.client.workbench.views.console.shell.impl.PlainTextEditorImplFirefox.java
License:Open Source License
/** * @see org.rstudio.studio.client.workbench.views.console.shell.impl.PlainTextEditorImpl#setupTextContainer(Element) *//*w w w . java2 s . c o m*/ @Override public Element setupTextContainer(Element element) { Element zwspSpan = Document.get().createSpanElement(); zwspSpan.setInnerText("\u200B"); Element textContainer = Document.get().createDivElement(); textContainer.getStyle().setDisplay(Display.INLINE); element.appendChild(zwspSpan); element.appendChild(textContainer); textContainer.setPropertyBoolean("contentEditable", true); textContainer_ = textContainer; return textContainer_; }
From source file:org.vaadin.addon.gwtgraphics.client.impl.VMLImpl.java
License:Apache License
@Override public Element createElement(Class<? extends VectorObject> type) { Element element = null;/*w w w . j ava 2s . co m*/ if (type == Rectangle.class) { element = VMLUtil.createVMLElement("roundrect"); element.setAttribute("arcsize", ""); } else if (type == Circle.class || type == Ellipse.class) { element = VMLUtil.createVMLElement("oval"); } else if (type == Path.class) { element = VMLUtil.createVMLElement("shape"); setDefaultSize(element); } else if (type == Text.class) { element = VMLUtil.createVMLElement("shape"); setDefaultSize(element); Element path = VMLUtil.createVMLElement("path"); path.setPropertyBoolean("textpathok", true); path.setPropertyString("v", "m 0,0 l 1,0"); element.appendChild(path); Element textpath = VMLUtil.createVMLElement("textpath"); textpath.setPropertyBoolean("on", true); // textpath.getStyle().setProperty("v-text-align", "left"); element.appendChild(textpath); } else if (type == Image.class) { element = VMLUtil.createVMLElement("image"); } else if (type == Line.class) { element = VMLUtil.createVMLElement("line"); } else if (type == Group.class) { element = VMLUtil.createVMLElement("group"); setDefaultSize(element); } return element; }
From source file:org.vaadin.addon.gwtgraphics.client.impl.VMLImpl.java
License:Apache License
@Override public void setFillColor(Element element, String color) { Element fill = VMLUtil.getOrCreateChildElementWithTagName(element, "fill"); if (color == null) { fill.setPropertyString("color", "black"); fill.setPropertyBoolean("on", false); } else {//from w ww . ja va2 s. c o m fill.setPropertyString("color", color); fill.setPropertyBoolean("on", true); } element.setPropertyString("_fill-color", color); }
From source file:org.vaadin.addon.gwtgraphics.client.impl.VMLImpl.java
License:Apache License
@Override public void setStrokeColor(Element element, String color) { Element stroke = VMLUtil.getOrCreateChildElementWithTagName(element, "stroke"); stroke.setPropertyString("color", color); stroke.setPropertyBoolean("on", color != null ? true : false); element.setPropertyString("_stroke-color", color); }