com.google.gwt.dom.client.ImageElement Java Examples

The following examples show how to use com.google.gwt.dom.client.ImageElement. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ZonalOCRTemplatesPanel.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Redisplays the sample image where the zones can be visually defined
 */
private void updateSample() {
	if (selectedOcrTemplate != null && selectedOcrTemplate.getSample() != null) {
		String url = Util.contextPath() + "ocrtemplateimage/" + selectedOcrTemplate.getId() + "?random="
				+ new Date().getTime();
		sample = new ImageWithCanvases(url, getWidth().intValue() - 50, null, new CallBack() {

			@Override
			public void onImagesLoaded(ImageElement[] imageElements) {
				showZones();
			}
		});

		editorPanel.addMember(sample);
	}
}
 
Example #2
Source File: DataStore.java    From djvu-html5 with GNU General Public License v2.0 6 votes vote down vote up
private CanvasElement prepareMissingTileImage() {
	int tileSize = DjvuContext.getTileSize();
	CanvasElement canvas = createImage(tileSize, tileSize);
	Context2d context2d = canvas.getContext2d();
	context2d.setFillStyle("white");
	context2d.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());
	Image image = new Image();
	final ImageElement imageElement = image.getElement().cast();
	imageElement.getStyle().setProperty("visibility", "hidden");
	Event.setEventListener(imageElement, event -> {
		if (Event.ONLOAD == event.getTypeInt()) {
			missingTileImage.getContext2d().drawImage(imageElement, 0, 0);
			RootPanel.get().getElement().removeChild(imageElement);
		}
	});
	RootPanel.get().getElement().appendChild(imageElement);
	image.setUrl(getBlankImageUrl());
	return canvas;
}
 
Example #3
Source File: AnnotationsWindow.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void showPage(int page) {
	if (pageImage != null) {
		captureNotesPosition();
		bottom.removeMembers(bottom.getMembers());
	}

	pageImage = new ImageWithCanvases(getPageUrl(page), null, new CallBack() {

		@Override
		public void onImagesLoaded(ImageElement[] imageElements) {
			// Reload the document to update the pages count
			if (document.getPages() <= 1)
				DocumentService.Instance.get().getById(document.getId(), new AsyncCallback<GUIDocument>() {

					@Override
					public void onFailure(Throwable caught) {
						Log.serverError(caught);
					}

					@Override
					public void onSuccess(GUIDocument dc) {
						document.setPages(dc.getPages());
						pageCursor.setMax(document.getPages());
						pageCursor.setHint("/" + (document.getPages() > 0 ? document.getPages() : 1));
					}
				});
			showAnnotations(page);
		}
	});
	bottom.addMember(pageImage);
}
 
Example #4
Source File: ImageHelper.java    From gdx-fireapp with Apache License 2.0 5 votes vote down vote up
/**
 * Creates texture region from byte[].
 * <p>
 * GWT platform requires additional step (as far as i know) to deal with Pixmap. It is need to load Image element
 * and wait until it is loaded.
 *
 * @param bytes    Image byte[] representation, not null
 * @param consumer Consumer where you should deal with region, not null
 */
public static void createTextureFromBytes(byte[] bytes, final Consumer<TextureRegion> consumer) {
    String base64 = "data:image/png;base64," + new String(Base64Coder.encode(bytes));
    final Image image = new Image();
    image.setVisible(false);
    image.addLoadHandler(new LoadHandler() {
        @Override
        public void onLoad(LoadEvent event) {
            ImageElement imageElement = image.getElement().cast();
            Pixmap pixmap = new Pixmap(imageElement);
            GdxFIRLogger.log("Image loaded");
            final int orgWidth = pixmap.getWidth();
            final int orgHeight = pixmap.getHeight();
            int width = MathUtils.nextPowerOfTwo(orgWidth);
            int height = MathUtils.nextPowerOfTwo(orgHeight);
            final Pixmap potPixmap = new Pixmap(width, height, pixmap.getFormat());
            potPixmap.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight());
            pixmap.dispose();
            TextureRegion region = new TextureRegion(new Texture(potPixmap), 0, 0, orgWidth, orgHeight);
            potPixmap.dispose();
            RootPanel.get().remove(image);
            consumer.accept(region);
        }
    });
    image.setUrl(base64);
    RootPanel.get().add(image);
}
 
Example #5
Source File: DjVuPage.java    From djvu-html5 with GNU General Public License v2.0 5 votes vote down vote up
private GPixmap decodeJPEG(CachedInputStream iff) throws IOException {
	final GPixmap result = new GPixmap();

	final Image image = new Image();
	final ImageElement imageElement = image.getElement().cast();
	imageElement.getStyle().setProperty("visibility", "hidden");
	Event.setEventListener(imageElement, new EventListener() {
		@Override
		public void onBrowserEvent(Event event) {
			if (Event.ONLOAD == event.getTypeInt()) {
				final int w = imageElement.getWidth(), h = imageElement.getHeight();
				final Canvas canvas = Canvas.createIfSupported();
				canvas.setWidth(w + "px");
				canvas.setCoordinateSpaceWidth(w);
				canvas.setHeight(h + "px");
				canvas.setCoordinateSpaceHeight(h);
				canvas.getContext2d().drawImage(imageElement, 0, 0);

				result.init(h, w, null);
				//TODO result.setImageData(canvas.getContext2d().getImageData(0, 0, w, h));
			}
		}
	});
	
	StringBuilder data = new StringBuilder();
	int b;
	while ((b = iff.read()) != -1) {
		data.append((char) b);
	}
	String dataURL = "data:image/jpeg;base64," + btoa(data.toString());
	image.setUrl(dataURL);

	return result;
}
 
Example #6
Source File: Image.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected Image(Image source) {
	super(source);
	this.imgElement = ImageElement.as(this.getElement());

	this.setSrc(source.src);
	this.setAlt(source.alt);
	this.widthPx = source.widthPx;
	this.heightPx = source.heightPx;
	this.keepPropertions = source.keepPropertions;

	this.resetSize();
}
 
Example #7
Source File: MaterialImage.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public int getWidth() {
    return ((ImageElement)getElement().cast()).getWidth();
}
 
Example #8
Source File: MaterialImage.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public int getHeight() {
    return ((ImageElement)getElement().cast()).getHeight();
}
 
Example #9
Source File: BlipMetaDomImpl.java    From swellrt with Apache License 2.0 4 votes vote down vote up
private ImageElement getAvatar() {
  if (avatar == null) {
    avatar = load(id, Components.AVATAR).cast();
  }
  return avatar;
}
 
Example #10
Source File: Image.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Image() {
	super(ImageElement.TAG);
	this.imgElement = ImageElement.as(this.getElement());
}
 
Example #11
Source File: GraphicsContext.java    From openchemlib-js with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void drawImage(Image image, int x, int y) {
    ctx.drawImage(ImageElement.as(image.getElement()), x, y);
}
 
Example #12
Source File: BlipMetaDomImpl.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
private ImageElement getAvatar() {
  if (avatar == null) {
    avatar = load(id, Components.AVATAR).cast();
  }
  return avatar;
}
 
Example #13
Source File: GraphicsContext.java    From openchemlib-js with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Draws a scaled subset of an image.
 *
 * @param image an {@link com.google.gwt.dom.client.CanvasElement} object
 * @param sx    the x coordinate of the upper-left corner of the source
 *              rectangle
 * @param sy    the y coordinate of the upper-left corner of the source
 *              rectangle
 * @param sw    the width of the source rectangle
 * @param sh    the width of the source rectangle
 * @param dx    the x coordinate of the upper-left corner of the destination
 *              rectangle
 * @param dy    the y coordinate of the upper-left corner of the destination
 *              rectangle
 * @param dw    the width of the destination rectangle
 * @param dh    the height of the destination rectangle
 */
public final void drawImage(Image image, double sx, double sy, double sw, double sh, double dx, double dy,
        double dw, double dh) {
    ctx.drawImage(ImageElement.as(image.getElement()), sx, sy, sw, sh, dx, dy, dw, dh);
}
 
Example #14
Source File: ImageTile.java    From gwt-ol with Apache License 2.0 votes vote down vote up
public native ImageElement getImage();