com.google.gwt.event.dom.client.LoadHandler Java Examples

The following examples show how to use com.google.gwt.event.dom.client.LoadHandler. 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: PreviewWidget.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
private Frame createFrame() {
	final Frame frame = new Frame(DEFAULT_TEMPLATE_PATH);
	frame.getElement().setId(DEFAULT_FRAME_NAME);
	frame.setTitle(UIMessages.INSTANCE.previewTitle());
	frame.setWidth("500px");
	frame.setHeight("500px");
	frame.getElement().getStyle().setBackgroundColor("gray");

	frame.setVisible(true);
	RootPanel.get().add(frame);

	frame.addLoadHandler(new LoadHandler() {

		@Override
		public void onLoad(LoadEvent event) {
			frame.getElement().getStyle().setBackgroundColor("white");
			zoomPageComboBox.setValue(75);
		}

	});

	return frame;
}
 
Example #2
Source File: Gallery.java    From gwtbootstrap3-extras with Apache License 2.0 6 votes vote down vote up
@Override
public void add(final Widget child) {
    if(child instanceof GalleryImage) {
        ((GalleryImage) child).addLoadHandler(new LoadHandler() {
            @Override
            public void onLoad(LoadEvent event) {
                if(thumbnailWidth != null) {
                    child.setWidth(thumbnailWidth);
                }
                if(thumbnailHeight != null) {
                    child.setHeight(thumbnailHeight);
                }
            }
        });

        super.add(child);
    } else {
        throw new IllegalArgumentException("Gallery can only contain GalleryImage's.");
    }
}
 
Example #3
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 #4
Source File: TutorialPanel.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * 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
  final Image image = new Image(img);
  image.addLoadHandler(new LoadHandler() {
      public void onLoad(LoadEvent evt) {
        final int imageWidth = image.getWidth();
        final int imageHeight = image.getHeight();
        final int windowWidth = (int) ((float) Window.getClientWidth() * 0.8);
        final int windowHeight = (int) ((float) Window.getClientHeight() * 0.9);
        int effectiveWidth = imageWidth;
        int effectiveHeight = imageHeight;

        if (imageWidth > windowWidth) {
          effectiveWidth = windowWidth;
          effectiveHeight = (int)(imageHeight * ((float)effectiveWidth / imageWidth));
        }

        if (effectiveHeight > windowHeight) {
          effectiveHeight = windowHeight;
          effectiveWidth = (int)(imageWidth * ((float)effectiveHeight / imageHeight));
        }

        image.setPixelSize(effectiveWidth, effectiveHeight);
        dialogBox.center();
      }
    });

  image.setStyleName("DialogBox-image");
  holder.add(ok);
  DialogBoxContents.add(image);
  DialogBoxContents.add(holder);
  dialogBox.setWidget(DialogBoxContents);
  dialogBox.center();
  dialogBox.show();
}
 
Example #5
Source File: FullCalendar.java    From gwtbootstrap3-extras with Apache License 2.0 4 votes vote down vote up
@Override
public HandlerRegistration addLoadHandler(final LoadHandler handler) {
    return super.addDomHandler(handler, LoadEvent.getType());
}
 
Example #6
Source File: GalleryImage.java    From gwtbootstrap3-extras with Apache License 2.0 4 votes vote down vote up
@Override
public HandlerRegistration addLoadHandler(LoadHandler handler) {
    return image.addHandler(handler, LoadEvent.getType());
}