Search in sources :

Example 1 with ImageElement

use of com.google.gwt.dom.client.ImageElement in project playn by threerings.

the class HtmlImage method toSubPattern.

@Override
protected Pattern toSubPattern(AbstractImageGL<?> image, boolean repeatX, boolean repeatY, float x, float y, float width, float height) {
    CanvasElement canvas = Document.get().createElement("canvas").<CanvasElement>cast();
    canvas.setWidth(MathUtil.iceil(width));
    canvas.setHeight(MathUtil.iceil(height));
    canvas.getContext2d().drawImage(img, x, y, width, height, 0, 0, width, height);
    ImageElement subelem = canvas.cast();
    return new HtmlPattern(image, subelem, repeatX, repeatY);
}
Also used : ImageElement(com.google.gwt.dom.client.ImageElement) CanvasElement(com.google.gwt.dom.client.CanvasElement)

Example 2 with ImageElement

use of com.google.gwt.dom.client.ImageElement in project playn by threerings.

the class HtmlAssets method adaptImage.

private HtmlImage adaptImage(String url, Scale scale) {
    ImageElement img = Document.get().createImageElement();
    /*
     * When the server provides an appropriate {@literal Access-Control-Allow-Origin} response
     * header, allow images to be served cross origin on supported, CORS enabled, browsers.
     */
    setCrossOrigin(img, "anonymous");
    img.setSrc(url);
    return new HtmlImage(platform.graphics().ctx(), scale, img);
}
Also used : ImageElement(com.google.gwt.dom.client.ImageElement)

Example 3 with ImageElement

use of com.google.gwt.dom.client.ImageElement in project ovirt-engine by oVirt.

the class IconEditorWidget method validateIcon.

private void validateIcon() {
    final IconWithOsDefault oldValue = getValue();
    createValidationImageElement(icon, new ImageElementCallback() {

        @Override
        public void onElementReady(ImageElement imageElement) {
            validationResult = new IconValidation(imageElement).validate(icon);
            updateErrorIconLabel(validationResult);
            final IconWithOsDefault newValue = getValue();
            ValueChangeEvent.fireIfNotEqual(IconEditorWidget.this, oldValue, newValue);
        }
    });
}
Also used : ImageElement(com.google.gwt.dom.client.ImageElement) IconWithOsDefault(org.ovirt.engine.ui.uicommonweb.models.vms.IconWithOsDefault) IconValidation(org.ovirt.engine.ui.uicommonweb.validation.IconValidation)

Example 4 with ImageElement

use of com.google.gwt.dom.client.ImageElement in project gwt-cs by iSergio.

the class LoadImages method buildPanel.

@Override
public void buildPanel() {
    csVPanel = new ViewerPanel();
    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    org.cesiumjs.cs.core.PinBuilder pinBuilder = new org.cesiumjs.cs.core.PinBuilder();
    pinBuilder.fromUrlPromise(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color_Overlay.png", Color.WHITE().withAlpha(0.0f), 256).then(new Fulfill<CanvasElement>() {

        @Override
        public void onFulfilled(CanvasElement value) {
            BillboardGraphicsOptions billboardOptions = new BillboardGraphicsOptions();
            billboardOptions.image = new ConstantProperty<>(value.toDataUrl());
            EntityOptions entityOptions = new EntityOptions();
            entityOptions.name = "Pin billboard through fromUrl";
            entityOptions.billboard = new BillboardGraphics(billboardOptions);
            entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(35, 35));
            csVPanel.getViewer().entities().add(new Entity(entityOptions));
        }
    });
    Resource.fetchImage((ResourceImageOptions) ResourceImageOptions.create(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color_Overlay.png")).then(new Fulfill<JsImage>() {

        @Override
        public void onFulfilled(JsImage value) {
            Canvas canvas = Canvas.createIfSupported();
            canvas.setWidth(value.width + "px");
            canvas.setHeight(value.height + "px");
            Context2d context = canvas.getContext2d();
            context.scale(0.1, 0.1);
            context.drawImage((ImageElement) (Object) value, 0, 0);
            BillboardGraphicsOptions billboardOptions = new BillboardGraphicsOptions();
            billboardOptions.image = new ConstantProperty<>(canvas.toDataUrl());
            EntityOptions entityOptions = new EntityOptions();
            entityOptions.name = "Pin billboard through canvas";
            entityOptions.billboard = new BillboardGraphics(billboardOptions);
            entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(45, 45));
            csVPanel.getViewer().entities().add(new Entity(entityOptions));
        }
    });
    // CORS not loaded
    Resource.fetchImage((ResourceImageOptions) ResourceImageOptions.create("https://www.linux.org.ru/tango/img/games-logo.png")).then(new Fulfill<JsImage>() {

        @Override
        public void onFulfilled(JsImage value) {
            Canvas canvas = Canvas.createIfSupported();
            canvas.setWidth(value.width + "px");
            canvas.setHeight(value.height + "px");
            Context2d context = canvas.getContext2d();
            context.scale(0.1, 0.1);
            context.drawImage((ImageElement) (Object) value, 0, 0);
            BillboardGraphicsOptions billboardOptions = new BillboardGraphicsOptions();
            billboardOptions.image = new ConstantProperty<>(canvas.toDataUrl());
            EntityOptions entityOptions = new EntityOptions();
            entityOptions.name = "Pin billboard CORS";
            entityOptions.billboard = new BillboardGraphics(billboardOptions);
            entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(55, 55));
            csVPanel.getViewer().entities().add(new Entity(entityOptions));
        }
    });
    // Cors not loaded!
    final JsImage imageAmz = new JsImage();
    imageAmz.crossOrigin = "*";
    imageAmz.onload = new JsImage.Listener() {

        @Override
        public void function() {
            Cesium.log(imageAmz);
            /*Canvas canvas = Canvas.createIfSupported();
                canvas.setWidth(imageAmz.width + "px");
                canvas.setHeight(imageAmz.height + "px");
                Context2d context = canvas.getContext2d();
                context.scale(0.1, 0.1);
                context.drawImage((ImageElement) (Object) imageAmz, 0, 0);*/
            BillboardGraphicsOptions billboardOptions = new BillboardGraphicsOptions();
            billboardOptions.image = new ConstantProperty<>(imageAmz);
            // billboardOptions.image = new ConstantProperty<>(canvas.toDataUrl("image/png"));
            EntityOptions entityOptions = new EntityOptions();
            entityOptions.name = "Pin billboard CORS";
            entityOptions.billboard = new BillboardGraphics(billboardOptions);
            entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(65, 65));
            csVPanel.getViewer().entities().add(new Entity(entityOptions));
        }
    };
    imageAmz.src = "https://d1.awsstatic.com/products/cloudfront/cloudfront-100_PoP_600x400.4a1edd6022833c54c41370ad9f615ae818350a23.png";
    // Worked, have Access-Control-Allow-Origin: *
    final JsImage imageWiki = new JsImage();
    imageWiki.crossOrigin = "*";
    imageWiki.onload = new JsImage.Listener() {

        @Override
        public void function() {
            Cesium.log(imageWiki);
            Canvas canvas = Canvas.createIfSupported();
            canvas.setWidth(imageWiki.width + "px");
            canvas.setHeight(imageWiki.height + "px");
            Context2d context = canvas.getContext2d();
            context.drawImage((ImageElement) (Object) imageWiki, 0, 0);
            BillboardGraphicsOptions billboardOptions = new BillboardGraphicsOptions();
            billboardOptions.image = new ConstantProperty<>(canvas.toDataUrl("image/png"));
            EntityOptions entityOptions = new EntityOptions();
            entityOptions.name = "Pin billboard CORS";
            entityOptions.billboard = new BillboardGraphics(billboardOptions);
            entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(75, 75));
            csVPanel.getViewer().entities().add(new Entity(entityOptions));
        }
    };
    imageWiki.src = "https://ru.wikipedia.org/static/images/project-logos/ruwiki-2x.png";
    contentPanel.add(new HTML("<p>Cluster labels, billboards and points.</p>"));
    contentPanel.add(aPanel);
    initWidget(contentPanel);
}
Also used : Entity(org.cesiumjs.cs.datasources.Entity) AbsolutePanel(com.google.gwt.user.client.ui.AbsolutePanel) HTML(com.google.gwt.user.client.ui.HTML) CanvasElement(com.google.gwt.dom.client.CanvasElement) EntityOptions(org.cesiumjs.cs.datasources.options.EntityOptions) ImageElement(com.google.gwt.dom.client.ImageElement) ResourceImageOptions(org.cesiumjs.cs.core.options.ResourceImageOptions) ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) ConstantProperty(org.cesiumjs.cs.datasources.properties.ConstantProperty) Canvas(com.google.gwt.canvas.client.Canvas) BillboardGraphics(org.cesiumjs.cs.datasources.graphics.BillboardGraphics) ConstantPositionProperty(org.cesiumjs.cs.datasources.properties.ConstantPositionProperty) BillboardGraphics(org.cesiumjs.cs.datasources.graphics.BillboardGraphics) JsImage(org.cesiumjs.cs.js.JsImage) Context2d(com.google.gwt.canvas.dom.client.Context2d) BillboardGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.BillboardGraphicsOptions)

Example 5 with ImageElement

use of com.google.gwt.dom.client.ImageElement in project che by eclipse.

the class AbstractPresentationRenderer method getIconContainer.

/** {@inheritDoc} */
@Override
public Element getIconContainer(SVGResource icon) {
    if (icon != null) {
        OMSVGSVGElement svg = icon.getSvg();
        svg.addClassNameBaseVal(treeStyles.styles().iconContainer());
        svg.setWidth(Style.Unit.PX, 16);
        svg.setHeight(Style.Unit.PX, 16);
        return svg.getElement();
    }
    ImageElement emptyIcon = Document.get().createImageElement();
    emptyIcon.setSrc(TreeView.blankImageUrl);
    emptyIcon.setClassName(treeStyles.styles().iconContainer());
    return emptyIcon;
}
Also used : OMSVGSVGElement(org.vectomatic.dom.svg.OMSVGSVGElement) ImageElement(com.google.gwt.dom.client.ImageElement)

Aggregations

ImageElement (com.google.gwt.dom.client.ImageElement)12 CanvasElement (com.google.gwt.dom.client.CanvasElement)2 NativeEvent (com.google.gwt.dom.client.NativeEvent)2 ImageLoader (com.ait.lienzo.client.core.image.ImageLoader)1 Canvas (com.google.gwt.canvas.client.Canvas)1 Context2d (com.google.gwt.canvas.dom.client.Context2d)1 Element (com.google.gwt.dom.client.Element)1 IFrameElement (com.google.gwt.dom.client.IFrameElement)1 Style (com.google.gwt.dom.client.Style)1 JSONString (com.google.gwt.json.client.JSONString)1 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)1 HTML (com.google.gwt.user.client.ui.HTML)1 WebGLTexture (com.google.gwt.webgl.client.WebGLTexture)1 Inject (com.google.inject.Inject)1 Matcher (java.util.regex.Matcher)1 ResourceImageOptions (org.cesiumjs.cs.core.options.ResourceImageOptions)1 Entity (org.cesiumjs.cs.datasources.Entity)1 BillboardGraphics (org.cesiumjs.cs.datasources.graphics.BillboardGraphics)1 BillboardGraphicsOptions (org.cesiumjs.cs.datasources.graphics.options.BillboardGraphicsOptions)1 EntityOptions (org.cesiumjs.cs.datasources.options.EntityOptions)1