本文整理汇总了Java中com.google.gwt.user.client.ui.Image.addLoadHandler方法的典型用法代码示例。如果您正苦于以下问题:Java Image.addLoadHandler方法的具体用法?Java Image.addLoadHandler怎么用?Java Image.addLoadHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.user.client.ui.Image
的用法示例。
在下文中一共展示了Image.addLoadHandler方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadImage
import com.google.gwt.user.client.ui.Image; //导入方法依赖的package包/类
/**
* Shows a resource as the {@code <img>} element.
*/
public void loadImage(String url) {
ClientUtils.setMembers(display, imgContainer);
image = new Image();
image.addLoadHandler(this);
image.addErrorHandler(this);
image.setUrl(url);
drawHandler = imgContainer.addDrawHandler(this);
resizedHandler = imgContainer.addResizedHandler(this);
ClientUtils.fine(LOG, "loadImage url: %s, width: %s", url, image.getWidth());
if (image.getWidth() == 0) {
WidgetCanvas widgetCanvas = new WidgetCanvas(image);
widgetCanvas.setVisible(false);
widgetCanvas.setWidth(1);
widgetCanvas.setHeight(1);
widgetCanvas.draw();
Img loadingImg = new Img("[SKIN]/loadingSmall.gif", 16, 16);
// Img loadingImg = new Img("[SKIN]/shared/progressCursorTracker.gif", 16, 16);
loadingImg.setAltText(i18n.ImportBatchDataSource_State_LOADING());
loadingImg.setPrompt(i18n.ImportBatchDataSource_State_LOADING());
loadingImg.setLayoutAlign(Alignment.CENTER);
imgContainer.setMembers(loadingImg, widgetCanvas);
}
scheduleForRender();
}
示例2: handleDoubleClick
import com.google.gwt.user.client.ui.Image; //导入方法依赖的package包/类
protected void handleDoubleClick(TableData.Row row) {
VerticalPanel vp = new VerticalPanel();
final Image previewImage = new Image(getFullSizeUrl(row));
final HTML caption = new HTML(getPopUpCaption(row));
String title = getThumbnailDesc(row).replace("<em>", "").replace("</em>", "");
caption.setWidth("320px");
previewImage.addLoadHandler(new LoadHandler() {
public void onLoad(LoadEvent ev) {
caption.setWidth(previewImage.getWidth() + "px");
}
});
GwtUtil.setStyle(vp, "margin", "8px");
vp.setCellHorizontalAlignment(previewImage, HasHorizontalAlignment.ALIGN_CENTER);
vp.setCellVerticalAlignment(previewImage, HasVerticalAlignment.ALIGN_MIDDLE);
vp.add(previewImage);
vp.add(caption);
PopupPane popupPane = new PopupPane(title, vp, PopupType.STANDARD, false, false);
popupPane.show();
}
示例3: createTextureFromBytes
import com.google.gwt.user.client.ui.Image; //导入方法依赖的package包/类
/**
* 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);
Gdx.app.log("ImageHelper", "pixmap: " + pixmap.getWidth() + "/" + pixmap.getHeight());
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);
}
示例4: createImageDialog
import com.google.gwt.user.client.ui.Image; //导入方法依赖的package包/类
/**
* Enlarges image on page
*/
private static void createImageDialog(String img) {
// Create the UI elements of the DialogBox
final DialogBox dialogBox = new DialogBox(true, true); // DialogBox(autohide, modal)
dialogBox.setStylePrimaryName("ode-DialogBox");
dialogBox.setGlassEnabled(true);
dialogBox.setAnimationEnabled(true);
VerticalPanel DialogBoxContents = new VerticalPanel();
FlowPanel holder = new FlowPanel();
Button ok = new Button("Close");
ok.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
dialogBox.hide();
}
});
ok.setStyleName("DialogBox-button");
// Adds Image
Image image = new Image(img);
image.addLoadHandler(new LoadHandler() {
public void onLoad(LoadEvent evt) {
dialogBox.center();
}
});
image.setStyleName("DialogBox-image");
holder.add(ok);
DialogBoxContents.add(image);
DialogBoxContents.add(holder);
dialogBox.setWidget(DialogBoxContents);
dialogBox.center();
dialogBox.show();
}
示例5: ImageContainer
import com.google.gwt.user.client.ui.Image; //导入方法依赖的package包/类
public ImageContainer(String imageUrl, boolean isSecure) {
image = new Image(imageUrl);
//this.loadedCallbacks.add(loadedCallback);
image.addLoadHandler(this);
image.addErrorHandler(this);
image.setVisible(false);
if (!image.getUrl().equalsIgnoreCase("")) {
Image.prefetch(image.getUrl());
// Add image to Root Panel so that loaded callback gets fired if image does exist
RootPanel.get().add(image);
}
}
示例6: getMap
import com.google.gwt.user.client.ui.Image; //导入方法依赖的package包/类
private void getMap() {
// canvas size in px
final int width = 1121;
final int height = 2585;
// get the 2D rendering context
context = mapCanvas.getContext2d();
// initialize the canvas
mapCanvas.setWidth(width + "px");
mapCanvas.setHeight(height + "px");
mapCanvas.setPixelSize(width, height);
mapCanvas.setCoordinateSpaceWidth(width);
mapCanvas.setCoordinateSpaceHeight(height);
container.setWidth(width + "px");
final Image seattleImage = new Image(Resources.INSTANCE.seattleArea());
seattleImage.addLoadHandler(new LoadHandler() {
@Override
public void onLoad(LoadEvent event) {
ImageElement imageElement = seattleImage.getElement().cast();
context.drawImage(imageElement, 0, 0);
}
});
seattleImage.setVisible(false);
container.add(seattleImage);
}
示例7: getMap
import com.google.gwt.user.client.ui.Image; //导入方法依赖的package包/类
private void getMap() {
// Tacoma map canvas size in px
final int width = 1360;
final int height = 1204;
// get the 2D rendering context
context = mapCanvas.getContext2d();
// initialize the canvas
mapCanvas.setWidth(width + "px");
mapCanvas.setHeight(height + "px");
mapCanvas.setPixelSize(width, height);
mapCanvas.setCoordinateSpaceWidth(width);
mapCanvas.setCoordinateSpaceHeight(height);
container.setWidth(width + "px");
final Image tacomaImage = new Image(Resources.INSTANCE.tacomaArea());
tacomaImage.addLoadHandler(new LoadHandler() {
@Override
public void onLoad(LoadEvent event) {
ImageElement imageElement = tacomaImage.getElement().cast();
context.drawImage(imageElement, 0, 0);
}
});
tacomaImage.setVisible(false);
container.add(tacomaImage);
}
示例8: load
import com.google.gwt.user.client.ui.Image; //导入方法依赖的package包/类
public void load() {
if (!loading && GWT.isClient()) {
String mapParameter = Window.Location.getParameter("map");
if (mapParameter != null && !mapParameter.isEmpty()) {
loading=true;
mapName = mapParameter;
mapFile = null;
final Image img = new Image("img.php?mode=native&url=" + mapParameter);
img.setVisible(false);
RootPanel.get().add(img);
img.addLoadHandler(new LoadHandler() {
@Override
public void onLoad(LoadEvent event) {
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
ImageElement imgElement = ImageElement.as(img.getElement());
RootPanel.get().remove(img);
Pixmap pixmap = new ScreenshotHelper().asPixmap(imgElement);
if (pixmap != null) {
Layer layer = layerManager.getLayer("RAW", RenderMask.Mask.BASIC);
layer.drawPixmapToFit(pixmap);
layer.invalidateTexture();
pixmap.dispose();
processed = true;
world.getSystem(RefreshHandlerSystem.class).restart();
}
}
});
}
});
}
}
if (!loading && mapFile != null) {
loading = true;
processed = true;
layerManager.getLayer("RAW", RenderMask.Mask.BASIC).drawPixmapToFit(new Pixmap(Gdx.files.internal(mapFile)));
}
}