List of usage examples for com.google.gwt.resources.client ImageResource getWidth
int getWidth();
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); }/*from w w w.j av a 2 s. co 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); }//w w w . j a va 2s. c o m 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;//from ww w. j av a 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;/* w ww. ja v a 2 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 w ww.j a v a 2 s . c om 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.ImageTextButton.java
License:Apache License
private void updateImageElementFromImageResource(Element imageSpan, ImageResource res, int spacing) { SafeUri url = res.getSafeUri();// w w w .j ava2 s .c o m int width = res.getWidth(); int height = res.getHeight(); int paddingRight = width + spacing; String style = "url(\"" + url.asString() + "\") no-repeat scroll left center"; imageSpan.getStyle().setProperty("background", style); imageSpan.getStyle().setPropertyPx("width", width); imageSpan.getStyle().setPropertyPx("height", height); imageSpan.getStyle().setPropertyPx("paddingRight", paddingRight); }
From source file:org.onebusaway.webapp.gwt.common.resources.map.StopIconFactory.java
License:Apache License
public static Marker getStopSelectionCircle(LatLng p, boolean bigger) { ImageResource resource = bigger ? _r.getSelectionCircle36() : _r.getSelectionCircle30(); Icon icon = Icon.newInstance(); icon.setImageURL(resource.getURL()); int w = resource.getWidth(); int h = resource.getHeight(); int w2 = w / 2; int h2 = h / 2; icon.setIconSize(Size.newInstance(w, h)); icon.setIconAnchor(Point.newInstance(w2, h2)); icon.setInfoWindowAnchor(Point.newInstance(w2, h2)); MarkerOptions options = MarkerOptions.newInstance(icon); return new Marker(p, options); }
From source file:org.onebusaway.webapp.gwt.mobile_application.MobileApplication.java
License:Apache License
private NavigationController createNavigationController(String id, String title, ImageResource img, ViewController firstView) {/*from w w w .j a v a2 s. c om*/ Image image = new Image(img.getURL(), img.getLeft(), img.getTop(), img.getWidth(), img.getHeight()); NavigationController navigationController = new NavigationController(); navigationController.getTabBarItem().setName(title); navigationController.getTabBarItem().setImage(image); navigationController.getNavigationItem().setId(id); navigationController.getNavigationItem().setTitle(title); navigationController.pushViewController(firstView); return navigationController; }
From source file:org.onebusaway.webapp.gwt.viewkit.NavigationBar.java
License:Apache License
private Grid createButton(EBarButtonSystemItem systemItem) { ViewKitResources resources = ViewKitResources.INSTANCE; ImageResource r = null; switch (systemItem) { case CROSS_HAIRS: r = resources.BarButtonSystemCrossHairsImage(); break;/*w w w .j a v a 2 s . c om*/ case REFRESH: default: r = resources.BarButtonSystemRefreshImage(); break; } Image image = new Image(r.getURL(), r.getLeft(), r.getTop(), r.getWidth(), r.getHeight()); Grid button = createButton(); button.setWidget(0, 1, image); return button; }
From source file:org.rstudio.core.client.widget.InlineToolbarButton.java
License:Open Source License
@UiConstructor public InlineToolbarButton(ImageResource icon, String label, String description) { icon_ = new Image(icon); label_ = new SpanLabel(label, false); zeroHeightPanel_ = new ZeroHeightPanel(icon.getWidth(), icon.getHeight(), 4); if (StringUtil.isNullOrEmpty(label)) label_.setVisible(false);/*from w w w. jav a 2 s . c o m*/ initWidget(GWT.<Binder>create(Binder.class).createAndBindUi(this)); setTitle(description); }