Package com.google.gwt.user.client

Examples of com.google.gwt.user.client.Element


   * @param group group
   * @param type type
   * @return the newly created group element or null if creation failed
   */
  protected Element createGroup(String namespace, Object parent, Object group, String type) {
    Element parentElement;
    if (parent == null) {
      parentElement = getRootElement();
    } else {
      parentElement = getGroup(parent);
    }
    if (parentElement == null) {
      return null;
    } else {
      Element element;
      if (DOM.NS_HTML.equals(namespace)) {
        element = DOM.createElement("div");
      } else {
        element = DOM.createElementNS(namespace, type);
      }
View Full Code Here


   */
  protected Element createElement(Object parent, String name, String type, Style style, boolean generateId) {
    if (null == name) {
      return null;
    }
    Element parentElement;
    if (parent == null) {
      parentElement = getRootElement();
    } else {
      parentElement = getGroup(parent);
    }
    if (parentElement == null) {
      return null;
    } else {
      Element element;
      switch (namespace) {
        case SVG:
          element = DOM.createElementNS(DOM.NS_SVG, type);
          if (style != null) {
            applyStyle(element, style);
          }
          break;
        case VML:
          element = DOM.createElementNS(DOM.NS_VML, type);
          Element stroke = DOM.createElementNS(DOM.NS_VML, "stroke");
          element.appendChild(stroke);
          Element fill = DOM.createElementNS(DOM.NS_VML, "fill");
          element.appendChild(fill);
          if ("shape".equals(name)) {
            // Set the size .....if the parent has a coordsize defined, take it over:
            String coordsize = parentElement.getAttribute("coordsize");
            if (coordsize != null && coordsize.length() > 0) {
View Full Code Here

   *            parent group object
   * @param name
   *            The element's name.
   */
  public void deleteElement(Object parent, String name) {
    Element element = getElement(parent, name);
    if (element != null) {
      Element group = (Element) element.getParentElement();
      if (group != null) {
        DOM.removeChild(group, element);
        elementToName.remove(element.getId());
      }
    }
View Full Code Here

   *
   * @param object
   *            The group's object.
   */
  public void deleteGroup(Object object) {
    Element element = getGroup(object);
    if (element != null) {
      Element parent = (Element) element.getParentElement();
      if (parent != null) {
        try {
          DOM.removeChild(parent, element);
          groupToId.remove(object);
        } catch (Exception e) {
View Full Code Here

   *            The parent element, onto whom to attach the initial DOM structure.
   */
  public SvgGraphicsContext(Widget parent) {
    this.parent = parent;
    // the root SVG node
    Element rootNode = DOM.createElementNS(DOM.NS_SVG, "svg");
    String sWidth = Integer.toString(width);
    String sHeight = Integer.toString(height);
    DOM.setElementAttribute(rootNode, "width", sWidth);
    DOM.setElementAttribute(rootNode, "height", sHeight);
    DOM.setElementAttribute(rootNode, "viewBox", "0 0 " + sWidth + " " + sHeight);
    DOM.setElementAttribute(rootNode, "xml:base", GWT.getHostPageBaseURL());
    helper = new DomHelper(rootNode, Namespace.SVG);

    // Point style definitions:
    defsGroup = new Composite("style_defs");
    defs = helper.drawGroup(null, defsGroup, "defs");

    // Append to parent: we need a top div or the svg is blocked by any peer div !!!
    Element divNode = DOM.createElementNS(DOM.NS_HTML, "div");
    DOM.setStyleAttribute(divNode, "position", "absolute");
    DOM.setStyleAttribute(divNode, "width", "100%");
    DOM.setStyleAttribute(divNode, "height", "100%");
    id = DOM.createUniqueId();
    divNode.setId(id);

    parent.getElement().appendChild(divNode);
    divNode.appendChild(rootNode);
  }
View Full Code Here

   * @param style
   *            The styling object by which the circle should be drawn.
   */
  public void drawCircle(Object parent, String name, Coordinate position, double radius, ShapeStyle style) {
    if (isAttached()) {
      Element circle = helper.createOrUpdateElement(parent, name, "circle", style);
      DOM.setElementAttribute(circle, "cx", Integer.toString((int) position.getX()));
      DOM.setElementAttribute(circle, "cy", Integer.toString((int) position.getY()));
      DOM.setElementAttribute(circle, "r", Integer.toString((int) radius));
    }
  }
View Full Code Here

   * @param transformation
   *            transformation to apply to the group
   */
  public void drawData(Object parent, Object object, String data, Matrix transformation) {
    if (isAttached()) {
      Element group = helper.getGroup(object);
      if (group == null) {
        group = helper.createOrUpdateGroup(parent, object, transformation, null);
        DOM.setInnerSvg(group, data);
      }
    }
View Full Code Here

   * @param style
   *            A styling object to be passed along with the image. Can be null.
   */
  public void drawImage(Object parent, String name, String href, Bbox bounds, PictureStyle style) {
    if (isAttached()) {
      Element image = helper.createOrUpdateElement(parent, name, "image", style);
      DOM.setElementAttribute(image, "x", Integer.toString((int) bounds.getX()));
      DOM.setElementAttribute(image, "y", Integer.toString((int) bounds.getY()));
      DOM.setElementAttribute(image, "width", Integer.toString((int) bounds.getWidth()));
      DOM.setElementAttribute(image, "height", Integer.toString((int) bounds.getHeight()));
      DOM.setElementAttributeNS(DOM.NS_XLINK, image, "xlink:href", href);
View Full Code Here

   *            The styling object for the LineString. Watch out for fill colors! If the fill opacity is not 0, then
   *            the LineString will have a fill surface.
   */
  public void drawLine(Object parent, String name, LineString line, ShapeStyle style) {
    if (isAttached()) {
      Element element = helper.createOrUpdateElement(parent, name, "path", style);
      if (line != null) {
        DOM.setElementAttribute(element, "d", SvgPathDecoder.decode(line));
      }
    }
  }
View Full Code Here

   * @param style
   *            The styling object for the Polygon.
   */
  public void drawPolygon(Object parent, String name, Polygon polygon, ShapeStyle style) {
    if (isAttached()) {
      Element element = helper.createOrUpdateElement(parent, name, "path", style);
      if (polygon != null) {
        DOM.setElementAttribute(element, "d", SvgPathDecoder.decode(polygon));
        DOM.setElementAttribute(element, "fill-rule", "evenodd");
      }
    }
View Full Code Here

TOP

Related Classes of com.google.gwt.user.client.Element

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.