List of usage examples for com.google.gwt.dom.client Element setPropertyString
@Override
public void setPropertyString(String name, String value)
From source file:client.net.sf.saxon.ce.dom.HTMLWriter.java
License:Mozilla Public License
public void attribute(int nameCode, CharSequence value) throws XPathException { String localName = namePool.getLocalName(nameCode); String uri = namePool.getURI(nameCode); String val = value.toString(); Element element = (Element) currentNode; // must be HTML write mode if (mode != WriteMode.XML && NamespaceConstant.HTML_PROP.equals(uri)) { element.setPropertyString(localName, val); } else if (mode != WriteMode.XML && NamespaceConstant.HTML_STYLE_PROP.equals(uri)) { // if localName starts with '_-' then remove the underscore e.g _-webkit-transition if (localName.length() > 1 && localName.charAt(0) == '_' && localName.charAt(1) == '-') { localName = localName.substring(1); }//from w w w. jav a 2s . c o m localName = HTMLWriter.getCamelCaseName(localName); element.getStyle().setProperty(localName, val); } else if (uri != null && !uri.isEmpty()) { String fullname = namePool.getDisplayName(nameCode); setAttribute(document, element, fullname, uri, val, mode); } else { localName = tableAttributeFix(localName, mode); element.setAttribute(localName, val); setAttributeProps(element, localName, val); } }
From source file:com.ait.ext4j.client.core.DomUtil.java
License:Apache License
public static void setID(Element element, String id) { element.setPropertyString("id", id); }
From source file:com.ritchey.client.view.CellPanel.java
License:Apache License
/** * Sets the height of the cell associated with the given widget, related to * the panel as a whole.//from w w w . j a v a 2s . c o m * * @param w the widget whose cell height is to be set * @param height the cell's height, in CSS units */ public void setCellHeight(Widget w, String height) { Element td = getWidgetTd(w); if (td != null) { td.setPropertyString("height", height); } }
From source file:com.ritchey.client.view.CellPanel.java
License:Apache License
/** * Sets the width of the cell associated with the given widget, related to the * panel as a whole.// ww w.java 2 s . co m * * @param w the widget whose cell width is to be set * @param width the cell's width, in CSS units */ public void setCellWidth(Widget w, String width) { Element td = getWidgetTd(w); if (td != null) { td.setPropertyString("width", width); } }
From source file:com.ritchey.client.view.CellPanel.java
License:Apache License
/** * @deprecated Call and override {@link #setCellHorizontalAlignment(Element, * HorizontalAlignmentConstant)} instead. *///from ww w . ja v a2s . c o m @Deprecated protected void setCellHorizontalAlignment(com.google.gwt.user.client.Element td, HorizontalAlignmentConstant align) { td.setPropertyString("align", align.getTextAlignString()); }
From source file:com.scurab.web.drifmaps.client.controls.RatingCSSImpl.java
License:Apache License
public void setSelectable(Element e, boolean selectable) { e.getStyle().setProperty("userSelect", selectable ? "" : "none"); e.setPropertyString("unselectable", selectable ? "" : "on"); }
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. * /* ww w .j av 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. * //from w w w . j a v a2 s . com * @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.sencha.gxt.chart.client.draw.engine.VML.java
License:sencha.com license
/** * Applies the attributes of the passed {@link TextSprite} to its VML element. * /*from ww w . j a v a2 s.c o m*/ * @param sprite the sprite whose attributes to use */ private void setTextAttributes(TextSprite sprite, XElement element) { Element textPath = element.childElement("textPath").cast(); Style textStyle = textPath.getStyle(); textBBoxCache.remove(sprite); if (sprite.isFontSizeDirty() || ignoreOptimizations) { if (sprite.getFontSize() > 0) { textStyle.setFontSize(sprite.getFontSize(), Unit.PX); } else { textStyle.clearFontSize(); } } if (sprite.isFontStyleDirty() || ignoreOptimizations) { if (sprite.getFontStyle() != null) { textStyle.setFontStyle(sprite.getFontStyle()); } else { textStyle.clearFontStyle(); } } if (sprite.isFontWeightDirty() || ignoreOptimizations) { if (sprite.getFontWeight() != null) { textStyle.setFontWeight(sprite.getFontWeight()); } else { textStyle.clearFontWeight(); } } if (sprite.isFontDirty() || ignoreOptimizations) { if (sprite.getFont() != null) { textStyle.setProperty("fontFamily", sprite.getFont()); } else { textStyle.clearProperty("fontFamily"); } } // text-anchor emulation if (sprite.isTextAnchorDirty() || ignoreOptimizations) { if (sprite.getTextAnchor() == TextAnchor.MIDDLE) { setTextAlign(textStyle, "center"); } else if (sprite.getTextAnchor() == TextAnchor.END) { setTextAlign(textStyle, "right"); } else { setTextAlign(textStyle, "left"); } } if (sprite.isTextDirty() || ignoreOptimizations) { if (sprite.getText() != null) { textPath.setPropertyString("string", sprite.getText()); } else { textPath.setPropertyString("string", ""); } } if (sprite.isTextBaselineDirty() || sprite.isXDirty() || sprite.isYDirty() || ignoreOptimizations) { double height = sprite.getFontSize(); if (sprite.getTextBaseline() == TextBaseline.MIDDLE) { height = 0; } else if (sprite.getTextBaseline() == TextBaseline.BOTTOM) { height *= -1; } Element path = element.childElement("path").cast(); path.setPropertyString("v", new StringBuilder().append("m").append(Math.round(sprite.getX() * zoom)).append(",") .append(Math.round((sprite.getY() + (height / 2.0)) * zoom)).append(" l") .append(Math.round(sprite.getX() * zoom) + 1).append(",") .append(Math.round((sprite.getY() + (height / 2.0)) * zoom)).toString()); textRenderedPoints.put(sprite, new PrecisePoint(sprite.getX(), sprite.getY())); textRenderedBaseline.put(sprite, sprite.getTextBaseline()); } }
From source file:com.sencha.gxt.chart.client.draw.engine.VML.java
License:sencha.com license
/** * Applies transformation to passed sprite * //from w w w . j av a 2s .c om * @param sprite the sprite to be transformed */ private void transform(Sprite sprite) { double deltaDegrees = 0; double deltaScaleX = 1; double deltaScaleY = 1; Matrix matrix = new Matrix(); Rotation rotation = sprite.getRotation(); Scaling scaling = sprite.getScaling(); Translation translation = sprite.getTranslation(); sprite.transformMatrix(); XElement element = getElement(sprite); Style style = element.getStyle(); Element skew = element.getPropertyJSO("skew").cast(); if (rotation != null) { matrix.rotate(rotation.getDegrees(), rotation.getX(), rotation.getY()); deltaDegrees += rotation.getDegrees(); } if (scaling != null) { matrix.scale(scaling.getX(), scaling.getY(), scaling.getCenterX(), scaling.getCenterY()); deltaScaleX *= scaling.getX(); deltaScaleY *= scaling.getY(); } if (translation != null) { matrix.translate(translation.getX(), translation.getY()); } if (viewBoxShift != null) { matrix.prepend(viewBoxShift.getX(), 0, 0, viewBoxShift.getX(), viewBoxShift.getCenterX() * viewBoxShift.getX(), viewBoxShift.getCenterY() * viewBoxShift.getX()); } if (!(sprite instanceof ImageSprite) && skew != null) { // matrix transform via VML skew skew.setPropertyString("origin", "0,0"); skew.setPropertyString("matrix", new StringBuilder().append(toFixed(matrix.get(0, 0), 4)).append(", ") .append(toFixed(matrix.get(0, 1), 4)).append(", ").append(toFixed(matrix.get(1, 0), 4)) .append(", ").append(toFixed(matrix.get(1, 1), 4)).append(", 0, 0").toString()); // ensure offset is less than or equal to 32767 and greater than or equal // to -32768, otherwise VMl crashes double offsetX = Math.max(Math.min(matrix.get(0, 2), 32767), -32768); double offsetY = Math.max(Math.min(matrix.get(1, 2), 32767), -32768); String offset = toFixed(offsetX, 4) + ", " + toFixed(offsetY, 4); skew.setPropertyString("offset", offset); } else { double deltaX = matrix.get(0, 2); double deltaY = matrix.get(1, 2); // Scale via coordsize property double zoomScaleX = zoom / deltaScaleX; double zoomScaleY = zoom / deltaScaleY; element.setPropertyString("coordsize", Math.abs(zoomScaleX) + " " + Math.abs(zoomScaleY)); // Rotate via rotation property double newAngle = deltaDegrees * (deltaScaleX * ((deltaScaleY < 0) ? -1 : 1)); if ((style.getProperty("rotation") == null && newAngle != 0)) { style.setProperty("rotation", String.valueOf(newAngle)); } else if (style.getProperty("rotation") != null && newAngle != Double.valueOf(style.getProperty("rotation"))) { style.setProperty("rotation", String.valueOf(newAngle)); } if (deltaDegrees != 0) { // Compensate x/y position due to rotation Matrix compMatrix = new Matrix(); compMatrix.rotate(-deltaDegrees, deltaX, deltaY); deltaX = deltaX * compMatrix.get(0, 0) + deltaY * compMatrix.get(0, 1) + compMatrix.get(0, 2); deltaY = deltaX * compMatrix.get(1, 0) + deltaY * compMatrix.get(1, 1) + compMatrix.get(1, 2); } String flip = ""; // Handle negative scaling via flipping if (deltaScaleX < 0) { flip += "x"; } if (deltaScaleY < 0) { flip += " y"; } if (!flip.equals("")) { style.setProperty("flip", flip); } // Translate via coordorigin property element.setPropertyString("coordorigin", (-zoomScaleX * (deltaX / ((ImageSprite) sprite).getWidth())) + " " + (-zoomScaleY * (deltaY / ((ImageSprite) sprite).getHeight()))); } }