Java Code Examples for com.google.gwt.user.client.ui.Image

The following examples show how to use com.google.gwt.user.client.ui.Image. These examples are extracted from open source projects. 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 Project: djvu-html5   Source File: DataStore.java    License: 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 2
Source Project: geowe-core   Source File: ActionBar.java    License: GNU General Public License v3.0 6 votes vote down vote up
public ActionBar() {
	super();
	setWidth(300);
	setHeaderVisible(false);
	addStyleName(ThemeStyles.get().style().borderBottom());
	setPosition(0, 0);
	getElement().getStyle().setPosition(Position.ABSOLUTE);
	HorizontalPanel horizontalGroup = new HorizontalPanel();
	horizontalGroup.add(getMenuButton());
	horizontalGroup.add(new SeparatorToolItem());
	Image image = new Image(ImageProvider.INSTANCE.menulogoGeowe());
	horizontalGroup.add(image);
	horizontalGroup.add(new SeparatorToolItem());
	horizontalGroup.add(new SeparatorToolItem());						
	horizontalGroup.add(getGeocodingButton());
	setWidget(horizontalGroup);		
}
 
Example 3
Source Project: appinventor-extensions   Source File: Icon.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new icon with the specified caption.
 *
 * @param image  image shown on icon (preferably 16 x 16px)
 * @param caption  caption shown below image
 */
public Icon(Image image, String caption) {

  panel = new VerticalPanel() {
    @Override
    public void onBrowserEvent(Event event) {
      Icon.this.onBrowserEvent(event);
    }
  };
  panel.add(image);
  panel.setCellHorizontalAlignment(image, VerticalPanel.ALIGN_CENTER);
  captionLabel = new Label(caption);
  panel.add(captionLabel);

  initWidget(panel);

  setStylePrimaryName("ode-Icon");
}
 
Example 4
Source Project: unitime   Source File: SolverPage.java    License: Apache License 2.0 6 votes vote down vote up
public SolverStatus() {
	super("unitime-SolverStatus");
	iStatus = new P("status-label");
	iIcon = new Image(RESOURCES.helpIcon()); iIcon.addStyleName("status-icon");
	iIcon.setVisible(false);
	add(iStatus); add(iIcon);
	RPC.execute(new PageNameRpcRequest("Solver Status"), new AsyncCallback<PageNameInterface>() {
		@Override
		public void onFailure(Throwable caught) {}
		@Override
		public void onSuccess(final PageNameInterface result) {
			iIcon.setTitle(MESSAGES.pageHelp(result.getName()));
			iIcon.setVisible(true);
			iIcon.addClickHandler(new ClickHandler() {
				@Override
				public void onClick(ClickEvent event) {
					if (result.getHelpUrl() == null || result.getHelpUrl().isEmpty()) return;
					UniTimeFrameDialog.openDialog(MESSAGES.pageHelp(result.getName()), result.getHelpUrl());
				}
			});
		}
	});
}
 
Example 5
Source Project: unitime   Source File: WebTable.java    License: Apache License 2.0 6 votes vote down vote up
public IconsCell add(ImageResource resource, final String title, final boolean html) {
	if (resource == null) return this;
	Image icon = new Image(resource);
	String text = title;
	if (html) { HTML h = new HTML(title); text = h.getText(); }
	icon.setTitle(text);
	icon.setAltText(text);
	if (iPanel.getWidgetCount() > 0)
		icon.getElement().getStyle().setMarginLeft(3, Unit.PX);
	iPanel.add(icon);
	iPanel.setCellVerticalAlignment(icon, HasVerticalAlignment.ALIGN_MIDDLE);
	if (title != null && !title.isEmpty()) {
		icon.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				event.stopPropagation();
				UniTimeConfirmationDialog.info(title, html);
			}
		});
	}
	return this;
}
 
Example 6
Source Project: unitime   Source File: TimePreferenceCell.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void refresh() {
	clear();
	RoomCookie cookie = RoomCookie.getInstance();
	if (iPattern != null && !iPattern.isEmpty() && !cookie.isGridAsText()) {
		final Image availability = new Image(GWT.getHostPageBaseURL() + "pattern?pref=" + iPattern + "&v=" + (cookie.areRoomsHorizontal() ? "0" : "1") + (cookie.hasMode() ? "&s=" + cookie.getMode() : ""));
		availability.setStyleName("grid");
		add(availability);
	} else {
		for (PreferenceInfo p: iPreferences) {
			P prf = new P("prf");
			prf.setText(p.getOwnerName());
			PreferenceInterface preference = iProperties.getPreference(p.getPreference());
			if (preference != null) {
				prf.getElement().getStyle().setColor(preference.getColor());
				prf.setTitle(preference.getName() + " " + p.getOwnerName());
			}
			add(prf);
		}
	}
}
 
Example 7
@Override
public AbstractImagePrototype scrollTableDescending() {
	return new AbstractImagePrototype() {
		public void applyTo(Image image) {
			image.setUrl("img/sort_desc.gif");
		}

		public Image createImage() {
			return new Image("img/sort_desc.gif");
		}

		public String getHTML() {
			return "<img border=\"0\" src=\"img/sort_desc.gif\"/>";
		}
	};
}
 
Example 8
@Override
public AbstractImagePrototype scrollTableFillWidth() {
	return new AbstractImagePrototype() {
		public void applyTo(Image image) {
			image.setUrl("img/fill_width.gif");
		}

		public Image createImage() {
			return new Image("img/fill_width.gif");
		}

		public String getHTML() {
			return "<img border=\"0\" src=\"img/fill_width.gif\"/>";
		}
	};
}
 
Example 9
/**
 * WorkflowManager
 */
public WorkflowManager() {
	workflowGraph = new Image();
	scrollGraphPanel = new ScrollPanel(workflowGraph);
	toolbar = new TabToolbarWorkflow(this);
	workflowTable = new WorkflowTable(this);
	workflowDetailTable = new WorkflowDetailTable();
	vPanel = new VerticalPanel();
	vPanel.add(toolbar); // Always visible

	toolbar.setHeight("" + TOOLBAR_HEADER + "px");
	toolbar.setWidth("100%");
	vPanel.setCellHeight(toolbar, "" + TOOLBAR_HEADER + "px");

	initWidget(vPanel);
}
 
Example 10
Source Project: gwtbootstrap3-extras   Source File: GalleryImage.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void setHeight(String height) {
    super.setHeight(height);
    image.setHeight(height);

    Scheduler.get().scheduleDeferred(new Command() {
        @Override
        public void execute() {
            for (Widget child : GalleryImage.this) {
                if (child instanceof HasClickHandlers && !(child instanceof Image)) {
                    Style style = child.getElement().getStyle();
                    style.setBottom((double) image.getHeight(), Unit.PX);
                }
            }
        }
    });
}
 
Example 11
/**
 * The status
 */
public Status() {
	super(false, true);
	hPanel = new HorizontalPanel();
	image = new Image(OKMBundleResources.INSTANCE.indicator());
	msg = new HTML("");
	space = new HTML("");

	hPanel.add(image);
	hPanel.add(msg);
	hPanel.add(space);

	hPanel.setCellVerticalAlignment(image, HasAlignment.ALIGN_MIDDLE);
	hPanel.setCellVerticalAlignment(msg, HasAlignment.ALIGN_MIDDLE);
	hPanel.setCellHorizontalAlignment(image, HasAlignment.ALIGN_CENTER);
	hPanel.setCellWidth(image, "30px");
	hPanel.setCellWidth(space, "7px");

	hPanel.setHeight("25px");

	msg.setStyleName("okm-NoWrap");

	super.hide();
	setWidget(hPanel);
}
 
Example 12
Source Project: unitime   Source File: PageLabelImpl.java    License: Apache License 2.0 6 votes vote down vote up
public PageLabelImpl() {
       iName = new P("text");
       
	iHelp = new Image(RESOURCES.help());
	iHelp.addStyleName("icon");
	iHelp.setVisible(false);
	
	add(iName);
	add(iHelp);
	
	iHelp.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			if (iUrl == null || iUrl.isEmpty()) return;
			UniTimeFrameDialog.openDialog(MESSAGES.pageHelp(getText()), iUrl);
		}
	});
}
 
Example 13
/**
 * FuturamaWalking
 */
public FuturamaWalking() {
	// Establishes auto-close when click outside
	super(false, false);
	left = -180;
	top = Window.getClientHeight() - 80 - 21;

	vPanel = new VerticalPanel();
	vPanel.setWidth("186px");
	vPanel.setHeight("80px");

	logo = new Image("img/eastereggs/futurama_walking.gif");
	vPanel.add(logo);

	setPopupPosition(left, top);

	hide();
	setWidget(vPanel);
}
 
Example 14
/**
 * Draw the current ESR image
 *
 * @param ctx
 */
private void drawESRButtons(GraphicsContext ctx) {
  int row = Model.rowFromESRType(model.getESRType());
  int y = (int) (IMAGE_HEIGHT * scale / ROWS * 3);
  int x = (int) (IMAGE_WIDTH * scale / COLS * 1);
  double dx = IMAGE_WIDTH * scale / COLS;
  double dy = IMAGE_HEIGHT * scale / ROWS;

  Image node = null;
  switch (row) {
  case 0:
    break;
  case 1:
    node = BUTTON_ESROR;
    break;
  case 2:
    node = BUTTON_ESRAND;
    break;
  }
  if (node != null) {
    ctx.clearRect(x, y, node.getWidth() * scale, node.getHeight() * scale);
    ctx.drawImage(node, 0, 0, node.getWidth(), node.getHeight(), x, y, node.getWidth() * scale,
        node.getHeight() * scale);
  }

}
 
Example 15
Source Project: unitime   Source File: WebTable.java    License: Apache License 2.0 6 votes vote down vote up
public IconCell(ImageResource resource, final String title, String text) {
	super(null);
	iIcon = new Image(resource);
	iIcon.setTitle(title);
	iIcon.setAltText(title);
	if (text != null && !text.isEmpty()) {
		iLabel = new HTML(text, false);
		iPanel = new HorizontalPanel();
		iPanel.setStyleName("icon");
		iPanel.add(iIcon);
		iPanel.add(iLabel);
		iIcon.getElement().getStyle().setPaddingRight(3, Unit.PX);
		iPanel.setCellVerticalAlignment(iIcon, HasVerticalAlignment.ALIGN_MIDDLE);
	}
	if (title != null && !title.isEmpty()) {
		iIcon.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				event.stopPropagation();
				UniTimeConfirmationDialog.info(title);
			}
		});
	}
}
 
Example 16
Source Project: gdx-fireapp   Source File: ImageHelper.java    License: 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 17
Source Project: appinventor-extensions   Source File: GalleryPage.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to update the app image
 * @param url  The URL of the image to show
 * @param container  The container that image widget resides
 */
private void updateAppImage(String url, final Panel container) {
    image = new Image();
    image.addStyleName("app-image");
    image.setUrl(url);
    // if the user has provided a gallery app image, we'll load it. But if not
    // the error will occur and we'll load default image
    image.addErrorHandler(new ErrorHandler() {
      public void onError(ErrorEvent event) {
        image.setResource(GalleryImages.get().genericApp());
      }
    });
    container.add(image);

    if(gallery.getSystemEnvironment() != null &&
        gallery.getSystemEnvironment().toString().equals("Development")){
      final OdeAsyncCallback<String> callback = new OdeAsyncCallback<String>(
        // failure message
        MESSAGES.galleryError()) {
          @Override
          public void onSuccess(String newUrl) {
            if (newUrl != null) {
              image.setUrl(newUrl + "?" + System.currentTimeMillis());
            }
          }
        };
      Ode.getInstance().getGalleryService().getBlobServingUrl(url, callback);
    }
}
 
Example 18
Source Project: appinventor-extensions   Source File: GalleryGuiFactory.java    License: Apache License 2.0 5 votes vote down vote up
private GalleryAppWidget(final GalleryApp app) {
  nameLabel = new Label(app.getTitle());
  authorLabel = new Label(app.getDeveloperName());
  numDownloadsLabel = new Label(Integer.toString(app.getDownloads()));
  numLikesLabel = new Label(Integer.toString(app.getLikes()));
  numViewsLabel = new Label(Integer.toString(app.getViews()));
  numCommentsLabel = new Label(Integer.toString(app.getComments()));
  image = new Image();
  image.addErrorHandler(new ErrorHandler() {
    public void onError(ErrorEvent event) {
      image.setResource(GalleryImages.get().genericApp());
    }
  });
  String url = gallery.getCloudImageURL(app.getGalleryAppId());
  image.setUrl(url);

  if(gallery.getSystemEnvironment() != null &&
      gallery.getSystemEnvironment().equals("Development")){
    final OdeAsyncCallback<String> callback = new OdeAsyncCallback<String>(
      // failure message
      MESSAGES.galleryError()) {
        @Override
        public void onSuccess(String newUrl) {
          if (newUrl != null) {
            image.setUrl(newUrl + "?" + System.currentTimeMillis());
          }
        }
      };
    Ode.getInstance().getGalleryService().getBlobServingUrl(url, callback);
  }
}
 
Example 19
Source Project: appinventor-extensions   Source File: Box.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Minimizes a box.
 */
private void minimize() {
  scrollPanel.setVisible(false);
  minimizeButton.getUpFace().setImage(new Image(Ode.getImageBundle().boxRestore()));
  minimizeButton.setTitle(MESSAGES.hdrRestore());

  if (highlightCaption && captionAlreadySeen) {
    captionLabel.setStylePrimaryName("ode-Box-header-caption");
  }
  captionAlreadySeen = true;

  restoreHeight = height;
  height = MINIMIZED_HEIGHT;
  onResize(width, height);
}
 
Example 20
Source Project: swellrt   Source File: ImageThumbnailWidget.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create a double buffer loader for a given image widget
 *
 * @param spinner
 * @param imageToLoad
 */
public DoubleBufferImage(Widget spinner, Widget error, Image imageToLoad) {
  if (UserAgent.isIE()) {
    DomHelper.makeUnselectable(doubleLoadedImage.getElement());
  }
  this.spinner = spinner;
  this.error = error;
  this.imageToLoad = imageToLoad;
}
 
Example 21
Source Project: dashbuilder   Source File: Chart.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates snapshot of current state of chart as image
 * @return Image object or null if Chart not rendered (or in progress)
 */
public Image getSnapshot(){
    String code= getBase64Image(nativeCanvas);
    if(code == null)
        return null;
    Image image = new Image(code);
    return image;
}
 
Example 22
Source Project: appinventor-extensions   Source File: MockMap.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void collectTypesAndIcons(Map<String, String> typesAndIcons) {
  super.collectTypesAndIcons(typesAndIcons);
  // These types can be loaded dynamically using LoadFromURL, so we want to show
  // generic options even though the user might not have explicitly created one
  typesAndIcons.put("Marker", new Image(images.marker()).getElement().getString());
  typesAndIcons.put("LineString", new Image(images.linestring()).getElement().getString());
  typesAndIcons.put("Polygon", new Image(images.polygon()).getElement().getString());
}
 
Example 23
Source Project: appinventor-extensions   Source File: MockForm.java    License: Apache License 2.0 5 votes vote down vote up
PhoneBar() {
  phoneBarImage = new Image(images.phonebar());

  bar = new DockPanel();
  bar.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
  bar.add(phoneBarImage, DockPanel.EAST);

  initWidget(bar);

  setStylePrimaryName("ode-SimpleMockFormPhoneBar");
  setSize("100%", HEIGHT + "px");
}
 
Example 24
Source Project: appinventor-extensions   Source File: MockMarker.java    License: Apache License 2.0 5 votes vote down vote up
public MockMarker(SimpleEditor editor) {
  super(editor, TYPE, images.marker());
  Image image = new Image();
  image.setResource(Ode.getImageBundle().marker());
  image.setWidth("30");
  image.setHeight("50");
  panel.setWidget(image);
  this.unsinkEvents(Event.MOUSEEVENTS);
  initIcon();
  initMarker(0, 0);
}
 
Example 25
/**
 * Creates a new instance of a non-visible component whose icon is
 * loaded dynamically (not part of the icon image bundle)
 */
public MockNonVisibleComponent(SimpleEditor editor, String type, Image iconImage) {
  super(editor, type, iconImage);
  iconWidget = new Icon(iconImage);

  initComponent(iconWidget);
}
 
Example 26
public MockFeatureCollection(SimpleEditor editor) {
  super(editor, TYPE, images.featurecollection(), new MockFeatureCollectionLayout());

  SimplePanel panel = new SimplePanel();
  panel.setWidth("16px");
  panel.setHeight("16px");
  panel.setStylePrimaryName("ode-SimpleMockComponent");
  Image icon = new Image(images.featurecollection());
  panel.add(icon);

  initComponent(panel);
  initCollection();
  initialized = true;
}
 
Example 27
Source Project: appinventor-extensions   Source File: Ode.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to create push buttons.
 *
 * @param img  image to shown on face of push button
 * @param tip  text to show in tooltip
 * @return  newly created push button
 */
public static PushButton createPushButton(ImageResource img, String tip,
                                          ClickHandler handler) {
  PushButton pb = new PushButton(new Image(img));
  pb.addClickHandler(handler);
  pb.setTitle(tip);
  return pb;
}
 
Example 28
Source Project: sc2gears   Source File: ClientUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns a widget which indicates that the logged in user is being checked.
 * @return a widget which indicates that the logged in user is being checked
 */
public static Widget createCheckingUserWidget() {
	final HorizontalPanel panel = new HorizontalPanel();
	panel.setHeight( "20px" );
	
	panel.add( new Image( "/images/loading.gif" ) );
	panel.add( createHorizontalEmptyWidget( 3 ) );
	panel.add( styledWidget( new Label( "Checking user..." ), "note" ) );
	
	return panel;
}
 
Example 29
/**
 * ToolBarBoxExample
 */
public ToolBarBoxExample() {
	toolBarBoxExtension = new ToolBarBoxExtension(new Image(OKMExtensionBundleExampleResources.INSTANCE.general()),
			"new toolbar") {
		@Override
		public Widget getWidget() {
			return hPanel;
		}
	};

	hPanel = new HorizontalPanel();
	hPanel.add(new HTML("new toolbarbox example"));
}
 
Example 30
public ToolBarButtonExample() {
	button = new ToolBarButton(new Image(OKMExtensionBundleExampleResources.INSTANCE.box()), title, new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			Window.alert("make some operation");
		}
	});
}