Example usage for com.google.gwt.dom.client ImageElement getSrc

List of usage examples for com.google.gwt.dom.client ImageElement getSrc

Introduction

In this page you can find the example usage for com.google.gwt.dom.client ImageElement getSrc.

Prototype

public String getSrc() 

Source Link

Document

URI designating the source of this image.

Usage

From source file:com.ait.lienzo.client.core.shape.Sprite.java

License:Open Source License

public Sprite(ImageElement sprite, double rate, SpriteBehaviorMap bmap, String behavior) {
    super(ShapeType.SPRITE);

    setURL(sprite.getSrc()).setTickRate(rate).setSpriteBehaviorMap(bmap).setSpriteBehavior(behavior);

    m_sprite = sprite;/*  www .  j a v a 2s .  c o  m*/

    if (null != m_loaded) {
        m_loaded.onSpriteLoaded(this);
    }
}

From source file:com.dom_distiller.client.IEReadingViewParser.java

License:Open Source License

private void findImages() {
    mImages = new ArrayList<MarkupParser.Image>();

    NodeList<Element> allImages = mRoot.getElementsByTagName("IMG");
    for (int i = 0; i < allImages.getLength(); i++) {
        ImageElement imgElem = ImageElement.as(allImages.getItem(i));

        // As long as the image has a caption, it's relevant regardless of size;
        // otherwise, it's relevant if its size is good.
        String caption = getCaption(imgElem);
        if ((caption != null && !caption.isEmpty()) || isImageRelevantBySize(imgElem)) {
            // Add relevant image to list.
            MarkupParser.Image image = new MarkupParser.Image();
            image.url = imgElem.getSrc();
            image.caption = caption;/*w w w .  j  a v a  2  s  .  c o  m*/
            image.width = imgElem.getWidth();
            image.height = imgElem.getHeight();
            mImages.add(image);
        }
    }
}

From source file:com.spaceapplications.vaadin.addon.eventtimeline.gwt.canvas.client.impl.ie.CanvasImplIE.java

License:Apache License

@Override
public void drawImage(ImageElement image, double sx, double sy, double sWidth, double sHeight, double dx,
        double dy, double dWidth, double dHeight) {

    int iWidth = image.getWidth();
    int iHeight = image.getHeight();
    int dX = (int) (getCoordX(dx, dy) / 10.0);
    int dY = (int) (getCoordY(dx, dy) / 10.0);
    scratchStack.clear();/*w  ww.  j a  va  2  s  .co  m*/
    scratchStack.push("<v:group style=\"position:absolute;width:10;height:10;");

    // If the transformation matrix has a rotation/scale we apply a filter
    // Create a padding bounding box to prevent clipping
    if (context.matrix[0] != 1 || context.matrix[3] != 0) {
        scratchStack.push("padding-right:");
        // TODO verify px suffix
        scratchStack.push(DOM.getStyleAttribute(element, "width"));
        scratchStack.push(";padding-bottom:");
        // TODO verify px suffix
        scratchStack.push(DOM.getStyleAttribute(element, "height"));
        scratchStack.push(";filter:progid:DXImageTransform.Microsoft.Matrix(M11='");
        scratchStack.push(matrix[0] + "',M12='");
        scratchStack.push(matrix[3] + "',M21='");
        scratchStack.push(matrix[1] + "',M22='");
        scratchStack.push(matrix[4] + "',Dx='");
        scratchStack.push(floor(dX) + "',Dy='");
        scratchStack.push(floor(dY) + "', SizingMethod='clip');");
    } else {
        scratchStack.push("left:");
        scratchStack.push(dX + "px;");
        scratchStack.push("top:");
        scratchStack.push(dY + "px");
    }
    scratchStack.push("\" coordsize=\"100,100\" coordorigin=\"0,0\"><v:image src=\"");
    scratchStack.push(image.getSrc());
    scratchStack.push("\" style=\"width:" + (int) (dWidth * 10));
    scratchStack.push(";height:" + (int) (dHeight * 10));
    scratchStack.push(";\" cropleft=\"" + (sx / iWidth));
    scratchStack.push("\" croptop=\"" + (sy / iHeight));
    scratchStack.push("\" cropright=\"" + ((iWidth - sx - sWidth) / iWidth));
    scratchStack.push("\" cropbottom=\"" + ((iHeight - sy - sHeight) / iHeight));
    scratchStack.push("\"/></v:group>");
    insert("BeforeEnd", scratchStack.join());
}

From source file:forplay.html.HtmlImageLayerDom.java

License:Apache License

@Override
public void setImage(final Image img) {
    Asserts.checkArgument(img instanceof HtmlImage);

    // Make sure redundant setImage() calls don't cost much.
    if (htmlImage == img) {
        return;/*from   w  w  w.  j av a 2s  .  co m*/
    }

    htmlImage = (HtmlImage) img;
    ImageElement imgElem = htmlImage.img.cast();
    element().getStyle().setBackgroundImage("url(" + imgElem.getSrc() + ")");
    element().getStyle().setOverflow(Overflow.HIDDEN);

    img.addCallback(new ResourceCallback<Image>() {
        @Override
        public void done(Image resource) {
            applySize();
            applyBackgroundSize();
        }

        @Override
        public void error(Throwable err) {
            // Nothing to be done about errors.
        }
    });
}

From source file:gwt.canvas.client.impl.ie.CanvasImplIE.java

License:Apache License

public void drawImage(ImageElement image, double sx, double sy, double sWidth, double sHeight, double dx,
        double dy, double dWidth, double dHeight) {

    int iWidth = image.getWidth();
    int iHeight = image.getHeight();
    int dX = (int) (getCoordX(dx, dy) / 10.0);
    int dY = (int) (getCoordY(dx, dy) / 10.0);
    scratchStack.clear();//w  ww .j  a  v  a 2s.  c o m
    scratchStack.push("<v:group style=\"position:absolute;width:10;height:10;");

    // If the transformation matrix has a rotation/scale we apply a filter
    // Create a padding bounding box to prevent clipping
    if (context.matrix[0] != 1 || context.matrix[3] != 0) {
        scratchStack.push("padding-right:");
        // TODO verify px suffix
        scratchStack.push(DOM.getStyleAttribute(element, "width"));
        scratchStack.push(";padding-bottom:");
        // TODO verify px suffix
        scratchStack.push(DOM.getStyleAttribute(element, "height"));
        scratchStack.push(";filter:progid:DXImageTransform.Microsoft.Matrix(M11='");
        scratchStack.push(matrix[0] + "',M12='");
        scratchStack.push(matrix[3] + "',M21='");
        scratchStack.push(matrix[1] + "',M22='");
        scratchStack.push(matrix[4] + "',Dx='");
        scratchStack.push(floor(dX) + "',Dy='");
        scratchStack.push(floor(dY) + "', SizingMethod='clip');");
    } else {
        scratchStack.push("left:");
        scratchStack.push(dX + "px;");
        scratchStack.push("top:");
        scratchStack.push(dY + "px");
    }
    scratchStack.push("\" coordsize=\"100,100\" coordorigin=\"0,0\"><v:image src=\"");
    scratchStack.push(image.getSrc());
    scratchStack.push("\" style=\"width:" + (int) (dWidth * 10));
    scratchStack.push(";height:" + (int) (dHeight * 10));
    scratchStack.push(";\" cropleft=\"" + (sx / iWidth));
    scratchStack.push("\" croptop=\"" + (sy / iHeight));
    scratchStack.push("\" cropright=\"" + ((iWidth - sx - sWidth) / iWidth));
    scratchStack.push("\" cropbottom=\"" + ((iHeight - sy - sHeight) / iHeight));
    scratchStack.push("\"/></v:group>");
    insert("BeforeEnd", scratchStack.join());
}

From source file:org.chromium.distiller.DomUtil.java

License:Open Source License

public static void makeSrcSetAbsolute(ImageElement ie) {
    String srcset = ie.getAttribute("srcset");
    if (srcset == "") {
        ie.removeAttribute("srcset");
        return;//from w  w  w.j  a  va2  s .  c om
    }

    String oldsrc = ie.getSrc();
    String[] sizes = StringUtil.jsSplit(srcset, ",");
    for (int i = 0; i < sizes.length; i++) {
        String size = StringUtil.jsTrim(sizes[i]);
        if (size.isEmpty())
            continue;
        String[] comp = size.split(" ");
        ie.setSrc(comp[0]);
        comp[0] = ie.getSrc();
        sizes[i] = StringUtil.join(comp, " ");
    }
    ie.setAttribute("srcset", StringUtil.join(sizes, ", "));
    ie.setSrc(oldsrc);
}

From source file:org.chromium.distiller.webdocument.WebImage.java

License:Open Source License

@Override
public String generateOutput(boolean textOnly) {
    if (textOnly)
        return "";

    ImageElement ie = ImageElement.as(Element.as(imgElement.cloneNode(false)));
    ie.setSrc(ie.getSrc());
    DomUtil.makeSrcSetAbsolute(ie);/*from  ww w  .  ja v a 2s .  c  om*/
    DomUtil.stripImageElement(ie);

    Element container = Document.get().createDivElement();
    container.appendChild(ie);
    return container.getInnerHTML();
}

From source file:org.palaso.languageforge.client.lex.controls.gwtcanvas.impl.GWTCanvasImplIE6.java

License:Apache License

public void drawImage(ImageElement img, double sourceX, double sourceY, double sourceWidth, double sourceHeight,
        double destX, double destY, double destWidth, double destHeight) {

    double fullWidth = img.getWidth();
    double fullHeight = img.getHeight();

    JSOStack<String> vmlStr = JSOStack.getScratchArray();

    vmlStr.push("<g_vml_:group style=\"position:absolute;width:10px;height:10px;");
    double dX = getCoordX(matrix, destX, destY);
    double dY = getCoordY(matrix, destX, destY);

    // If we have a transformation matrix with rotation/scale, we
    // apply a filter
    if (context.matrix[0] != 1 || context.matrix[1] != 0) {

        // We create a padding bounding box to prevent clipping.
        vmlStr.push("padding-right:");
        vmlStr.push(parentWidth + "px;");
        vmlStr.push("padding-bottom:");
        vmlStr.push(parentHeight + "px;");
        vmlStr.push("filter:progid:DXImageTransform.Microsoft.Matrix(M11='");
        vmlStr.push("" + matrix[0]);
        vmlStr.push("',");
        vmlStr.push("M12='");
        vmlStr.push("" + matrix[1]);
        vmlStr.push("',");
        vmlStr.push("M21='");
        vmlStr.push("" + matrix[3]);
        vmlStr.push("',");
        vmlStr.push("M22='");
        vmlStr.push("" + matrix[4]);
        vmlStr.push("',");
        vmlStr.push("Dx='");
        vmlStr.push("" + Math.floor(((dX / 10))));
        vmlStr.push("',");
        vmlStr.push("Dy='");
        vmlStr.push("" + Math.floor(((dY / 10))));
        vmlStr.push("', SizingMethod='clip');");

    } else {//from  w w w  .  j  a  va 2  s  .  c  o  m
        vmlStr.push("left:");
        vmlStr.push((int) dX / 10 + "px;");
        vmlStr.push("top:");
        vmlStr.push((int) dY / 10 + "px");
    }

    vmlStr.push("\" coordsize=\"100 100\" coordorigin=\"0 0\"><g_vml_:image src=\"");
    vmlStr.push(img.getSrc());
    vmlStr.push("\" style=\"");

    vmlStr.push("width:");
    vmlStr.push(String.valueOf((int) (destWidth * 10)));
    vmlStr.push("px;height:");
    vmlStr.push(String.valueOf((int) (destHeight * 10)));
    vmlStr.push("px;\" cropleft=\"");
    vmlStr.push(String.valueOf(sourceX / fullWidth));
    vmlStr.push("\" croptop=\"");
    vmlStr.push(String.valueOf(sourceY / fullHeight));
    vmlStr.push("\" cropright=\"");
    vmlStr.push(String.valueOf((fullWidth - sourceX - sourceWidth) / fullWidth));
    vmlStr.push("\" cropbottom=\"");
    vmlStr.push(String.valueOf((fullHeight - sourceY - sourceHeight) / fullHeight));
    vmlStr.push("\"/></g_vml_:group>");

    insert("BeforeEnd", vmlStr.join());
}

From source file:org.vaadin.alump.fancylayouts.gwt.client.GwtFancyImage.java

License:Apache License

public void setImage(String url, int index) {
    if (index >= images.size()) {
        addImage(url);//from  w ww .  ja v  a  2 s  .  c om
    } else {
        ImageElement replaced = images.get(index);
        if (!replaced.getSrc().equals(url)) {
            replaced.setSrc(url);
        }
    }
}

From source file:org.vaadin.alump.fancylayouts.gwt.client.GwtFancyImage.java

License:Apache License

public void removeImage(String url) {
    for (ImageElement image : images) {
        if (image.getSrc().equals(url)) {
            getElement().removeChild(image);
            images.remove(image);/*from  w  w w  . j  ava2  s .  c o  m*/
            break;
        }
    }
}