List of usage examples for com.google.gwt.resources.client ImageResource getHeight
int getHeight();
From source file:org.activityinfo.ui.client.page.entry.location.LocationMap.java
License:Open Source License
private DivIcon createIcon(String label) { ImageResource markerImage = SiteFormResources.INSTANCE.blankMarker(); DivIconOptions iconOptions = new DivIconOptions(); iconOptions.setClassName(SiteFormResources.INSTANCE.style().locationMarker()); iconOptions.setIconSize(new Point(markerImage.getWidth(), markerImage.getHeight())); iconOptions.setIconAnchor(new Point(markerImage.getWidth() / 2, markerImage.getHeight())); iconOptions.setHtml(label);/*from w w w . ja va 2s . c o m*/ DivIcon icon = new DivIcon(iconOptions); return icon; }
From source file:org.cruxframework.crux.widgets.client.promobanner.BannerImpl.java
License:Apache License
protected void addBanner(ImageResource image, String title, String text, String styleName, String buttonLabel, final SelectHandler selectHandler) { SimplePanel panel = new SimplePanel(); Style style = panel.getElement().getStyle(); style.setProperty("background", "url(" + Screen.rewriteUrl(image.getSafeUri().asString()) + ") no-repeat " + (-image.getLeft() + "px ") + (-image.getTop() + "px")); style.setPropertyPx("width", image.getWidth()); style.setPropertyPx("height", image.getHeight()); doAddBanner(title, text, styleName, buttonLabel, selectHandler, panel); }
From source file:org.eclipse.emf.edit.ui.EditorEntryPoint.java
License:Open Source License
protected ImageData getImageData(Object image) { ImageData imageData = new ImageData(); if (image instanceof ImageResource) { ImageResource imageResource = (ImageResource) image; imageData.height = imageResource.getHeight(); imageData.width = imageResource.getWidth(); } else if (image instanceof ComposedImage) { ComposedImage composedImage = (ComposedImage) image; List<ComposedImage.Size> sizes = new ArrayList<ComposedImage.Size>(); List<Object> images = new ArrayList<Object>(composedImage.getImages()); List<ImageData> nestedImagesData = new ArrayList<ImageData>(); for (Object nestedImage : images) { ImageData nestedImageData = getImageData(nestedImage); ComposedImage.Size size = new ComposedImage.Size(); size.height = nestedImageData.height; size.width = nestedImageData.width; sizes.add(size);/*from ww w. jav a 2 s .c o m*/ nestedImagesData.add(nestedImageData); } } return imageData; }
From source file:org.kaaproject.avro.ui.gwt.client.widget.ActionsButton.java
License:Apache License
@UiConstructor public ActionsButton(ImageResource imageResource, String text) { super();//from www. j av a2s . c o m if (template == null) { template = GWT.create(Template.class); } getElement().getStyle().setPaddingRight(20, Unit.PX); int index = 0; if (imageResource != null) { getElement().getStyle().setPaddingLeft(20, Unit.PX); SafeUri uri = imageResource.getSafeUri(); int width = imageResource.getWidth(); int height = imageResource.getHeight(); int paddingLeft = width; String background = "url(\"" + uri.asString() + "\") no-repeat scroll right center"; Element imageSpan = DOM.createElement("span"); imageSpan.setInnerText(" "); imageSpan.getStyle().setProperty("background", background); imageSpan.getStyle().setWidth(width, Unit.PX); imageSpan.getStyle().setHeight(height, Unit.PX); imageSpan.getStyle().setPaddingLeft(paddingLeft, Unit.PX); imageSpan.getStyle().setMarginRight(10, Unit.PX); DOM.insertChild(getElement(), imageSpan, index++); } Element caretSpan = DOM.createElement("span"); caretSpan.setClassName(Utils.avroUiStyle.buttonCaret()); DOM.insertChild(getElement(), caretSpan, index); Element textElement = DOM.createElement("span"); textElement.setInnerText(text); DOM.insertChild(caretSpan, textElement, 0); actionsPopup = new PopupPanel(true, false); actionsPopup.addStyleName(Utils.avroUiStyle.actionPopup()); actionsPopup.setWidget(menu); actionsPopup.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { ActionsButton.this.setDown(false); } }); actionsPopup.addAutoHidePartner(getElement()); addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (!actionsPopup.isShowing()) { // Instantiate the popup and show it. final Element parent = ActionsButton.this.getElement(); actionsPopup.setPopupPositionAndShow(new PopupPanel.PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { int left = parent.getAbsoluteLeft(); int top = parent.getAbsoluteTop() + parent.getOffsetHeight() + 2; if (left + actionsPopup.getOffsetWidth() > Window.getClientWidth()) { left = parent.getAbsoluteRight() - actionsPopup.getOffsetWidth(); } actionsPopup.setPopupPosition(left, top); } }); } else { actionsPopup.hide(); } } }); }
From source file:org.kaaproject.avro.ui.gwt.client.widget.ActionsButton.java
License:Apache License
public HandlerRegistration addMenuItem(ImageResource image, String text, final ActionMenuItemListener listener) { SafeHtml html = null;//from w w w . j a v a 2s . com if (image != null) { SafeUri uri = image.getSafeUri(); int left = image.getLeft(); int top = image.getTop(); int width = image.getWidth(); int height = image.getHeight(); int paddingRight = width + 8; String background = "url(\"" + uri.asString() + "\") no-repeat " + (-left + "px ") + (-top + "px"); SafeStylesBuilder builder = new SafeStylesBuilder(); builder.trustedNameAndValue("background", background).width(width, Unit.PX).height(height, Unit.PX) .paddingRight(paddingRight, Unit.PX); SafeStyles style = SafeStylesUtils.fromTrustedString(builder.toSafeStyles().asString()); html = template.menuImageItemContent(style, text); } else { html = template.menuItemContent(text); } final MenuItem item = new MenuItem(html, new Command() { @Override public void execute() { if (actionsPopup != null && actionsPopup.isVisible()) actionsPopup.hide(); listener.onMenuItemSelected(); } }); menu.addItem(item); HandlerRegistration registration = new HandlerRegistration() { @Override public void removeHandler() { menu.removeItem(item); } }; return registration; }
From source file:org.kaaproject.avro.ui.gwt.client.widget.grid.cell.ActionButtonCell.java
License:Apache License
public ActionButtonCell(ImageResource imageResource, String text, boolean small, ActionListener<T> listener, ActionValidator<T> validator) { super(CLICK, KEYDOWN); this.listener = listener; this.validator = validator; if (template == null) { template = GWT.create(Template.class); }// ww w .j ava2s. c o m SafeUri uri = imageResource.getSafeUri(); int width = imageResource.getWidth(); int height = imageResource.getHeight(); int paddingLeft = width; String background = "url(\"" + uri.asString() + "\") no-repeat scroll right center"; SafeStylesBuilder builder = new SafeStylesBuilder(); builder.trustedNameAndValue("background", background).width(width, Unit.PX).height(height, Unit.PX) .paddingLeft(paddingLeft, Unit.PX); SafeStyles style = SafeStylesUtils.fromTrustedString(builder.toSafeStyles().asString()); if (small) { this.actionButtonHtml = template.actionButtonSmall(Utils.avroUiStyle.cellButton(), Utils.avroUiStyle.cellButtonSmall(), text, style); } else { this.actionButtonHtml = template.actionButton(Utils.avroUiStyle.cellButton(), text, style); } }
From source file:org.kaaproject.avro.ui.gwt.client.widget.grid.cell.ActionsButtonCell.java
License:Apache License
public ActionsButtonCell(ImageResource imageResource, String text) { super(CLICK, KEYDOWN); if (template == null) { template = GWT.create(Template.class); }//from w ww . ja va2 s .com SafeStylesBuilder buttonStyleBuilder = new SafeStylesBuilder(); SafeStylesBuilder imageStyleBuilder = new SafeStylesBuilder(); buttonStyleBuilder.verticalAlign(VerticalAlign.MIDDLE).paddingRight(20, Unit.PX); if (imageResource != null) { buttonStyleBuilder.paddingLeft(20, Unit.PX); SafeUri uri = imageResource.getSafeUri(); int width = imageResource.getWidth(); int height = imageResource.getHeight(); int paddingLeft = width; String background = "url(\"" + uri.asString() + "\") no-repeat scroll right center"; imageStyleBuilder.trustedNameAndValue("background", background).width(width, Unit.PX) .height(height, Unit.PX).paddingLeft(paddingLeft, Unit.PX).marginRight(10, Unit.PX); } else { imageStyleBuilder.display(Display.NONE); } SafeStyles buttonStyle = SafeStylesUtils.fromTrustedString(buttonStyleBuilder.toSafeStyles().asString()); SafeStyles imageStyle = SafeStylesUtils.fromTrustedString(imageStyleBuilder.toSafeStyles().asString()); this.actionsButtonHtml = template.actionsButtonUp(buttonStyle, imageStyle, Utils.avroUiStyle.buttonCaret(), text); this.actionsButtonHtmlDown = template.actionsButtonDown(buttonStyle, imageStyle, Utils.avroUiStyle.buttonCaret(), text); actionsPopup = new PopupPanel(true, false); actionsPopup.addStyleName(Utils.avroUiStyle.actionPopup()); actionsPopup.setWidget(menu); }
From source file:org.kaaproject.avro.ui.gwt.client.widget.grid.cell.ActionsButtonCell.java
License:Apache License
public void addMenuItem(ImageResource image, String text, final ActionMenuItemListener<T> listener) { SafeHtml html = null;//ww w. j a va 2s. c o m if (image != null) { SafeUri uri = image.getSafeUri(); int left = image.getLeft(); int top = image.getTop(); int width = image.getWidth(); int height = image.getHeight(); int paddingRight = width + 8; String background = "url(\"" + uri.asString() + "\") no-repeat " + (-left + "px ") + (-top + "px"); SafeStylesBuilder builder = new SafeStylesBuilder(); builder.trustedNameAndValue("background", background).width(width, Unit.PX).height(height, Unit.PX) .paddingRight(paddingRight, Unit.PX); SafeStyles style = SafeStylesUtils.fromTrustedString(builder.toSafeStyles().asString()); html = template.menuImageItemContent(style, text); } else { html = template.menuItemContent(text); } final MenuItem item = new MenuItem(html, new Command() { @Override public void execute() { if (actionsPopup != null && actionsPopup.isVisible()) actionsPopup.hide(); listener.onMenuItemSelected(currentValue); } }); menu.addItem(item); }
From source file:org.kaaproject.kaa.sandbox.web.client.mvp.view.widget.ActionsLabel.java
License:Apache License
public void addMenuItem(ImageResource image, String text, final ActionMenuItemListener listener) { SafeHtml html = null;/*from ww w . j a va2 s . c o m*/ if (image != null) { SafeUri uri = image.getSafeUri(); int left = image.getLeft(); int top = image.getTop(); int width = image.getWidth(); int height = image.getHeight(); int paddingRight = width + 8; String background = "url(\"" + uri.asString() + "\") no-repeat " + (-left + "px ") + (-top + "px"); SafeStylesBuilder builder = new SafeStylesBuilder(); builder.trustedNameAndValue("background", background).width(width, Unit.PX).height(height, Unit.PX) .paddingRight(paddingRight, Unit.PX); SafeStyles style = SafeStylesUtils.fromTrustedString(builder.toSafeStyles().asString()); html = template.menuImageItemContent(style, text); } else { html = template.menuItemContent(text); } MenuItem item = new MenuItem(html, new Command() { @Override public void execute() { if (actionsPopup != null && actionsPopup.isVisible()) actionsPopup.hide(); listener.onMenuItemSelected(); } }); menu.addItem(item); }
From source file:org.kaaproject.kaa.server.admin.client.mvp.view.widget.ActionsLabel.java
License:Apache License
public void addMenuItem(ImageResource image, String text, final ActionMenuItemListener listener) { SafeHtml html = null;/*from www . j a v a2 s . c o m*/ if (image != null) { SafeUri uri = image.getSafeUri(); int left = image.getLeft(); int top = image.getTop(); int width = image.getWidth(); int height = image.getHeight(); int paddingRight = width + 8; String background = "url(\"" + uri.asString() + "\") no-repeat " + (-left + "px ") + (-top + "px"); SafeStylesBuilder builder = new SafeStylesBuilder(); builder.trustedNameAndValue("background", background).width(width, Unit.PX).height(height, Unit.PX) .paddingRight(paddingRight, Unit.PX); SafeStyles style = SafeStylesUtils.fromTrustedString(builder.toSafeStyles().asString()); html = template.menuImageItemContent(style, text); } else { html = template.menuItemContent(text); } MenuItem item = new MenuItem(html, new Command() { @Override public void execute() { if (actionsPopup != null && actionsPopup.isVisible()) { actionsPopup.hide(); } listener.onMenuItemSelected(); } }); menu.addItem(item); }