List of usage examples for com.google.gwt.resources.client ImageResource getHeight
int getHeight();
From source file:com.novartis.pcs.ontology.webapp.client.view.ActionIconCellDecorator.java
License:Apache License
private SafeHtml getImageHtml(ImageResource res, VerticalAlignmentConstant valign) { AbstractImagePrototype proto = AbstractImagePrototype.create(res); SafeHtml image = SafeHtmlUtils.fromTrustedString(proto.getHTML()); // Create the wrapper based on the vertical alignment. SafeStylesBuilder cssStyles = new SafeStylesBuilder().appendTrustedString(direction + ":0px;"); if (HasVerticalAlignment.ALIGN_TOP == valign) { return templates.imageWrapperTop(cssStyles.toSafeStyles(), image); } else if (HasVerticalAlignment.ALIGN_BOTTOM == valign) { return templates.imageWrapperBottom(cssStyles.toSafeStyles(), image); } else {/*from w w w .j a v a2 s . c o m*/ int halfHeight = (int) Math.round(res.getHeight() / 2.0); cssStyles.appendTrustedString("margin-top:-" + halfHeight + "px;"); return templates.imageWrapperMiddle(cssStyles.toSafeStyles(), image); } }
From source file:com.sencha.gxt.chart.client.draw.sprite.ImageSprite.java
License:sencha.com license
/** * Sets the {@link ImageResource} used by the image sprite. * //ww w . j a va2s.c o m * @param resource the image resource */ public void setResource(ImageResource resource) { if (resource != this.resource) { this.resource = resource; if (resource != null) { this.setWidth(resource.getWidth()); this.setHeight(resource.getHeight()); } else { this.setWidth(Double.NaN); this.setHeight(Double.NaN); } resourceDirty = true; } }
From source file:cz.metacentrum.perun.webgui.widgets.ImageResourceAltRenderer.java
License:Apache License
public SafeHtml render(ImageResource image, String alt) { if (image instanceof ImageResourcePrototype.Bundle) { return AbstractImagePrototype.create(image).getSafeHtml(); } else {/*from w w w . j av a 2 s. c o m*/ return TEMPLATE.image(image.getSafeUri(), image.getWidth(), image.getHeight(), alt); } }
From source file:de.swm.commons.mobile.client.widgets.DecoratedListItem.java
License:Apache License
/** * Default constructor./*from ww w . j a v a2 s .c om*/ * * @param image image od the text box * @param title title * @param subtitle subtitle */ @UiConstructor public DecoratedListItem(ImageResource image, String title, String subtitle) { this(); this.img.setUrlAndVisibleRect(image.getSafeUri(), image.getLeft(), image.getTop(), image.getWidth(), image.getHeight()); this.titleLabel.setText(title); this.subtitleLabel.setText(subtitle); }
From source file:de.swm.commons.mobile.client.widgets.ImageButton.java
License:Apache License
public void setIcon(ImageResource image) { img.setResource(image);// w w w .j a v a2s . co m getElement().getStyle().setHeight(image.getHeight(), Unit.PX); getElement().getStyle().setWidth(image.getWidth(), Unit.PX); }
From source file:de.swm.commons.mobile.client.widgets.publictransport.TripListItem.java
License:Apache License
/** * Default constructor./*from w w w .jav a 2s . c o m*/ * * @param progress . * @param category . * @param title . * @param subtitle . * @param subSubTitle . * @param dalay . * @param departurePlatform . * @param arrivalPlatform . */ public TripListItem(ImageResource progress, ImageResource category, String title, String subtitle, String subSubTitle, String dalay, String departurePlatform, String arrivalPlatform) { addStyleName(SWMMobile.getTheme().getMGWTCssBundle().getTripListItemCss().tripListMainPanel()); HorizontalPanel panel = new HorizontalPanel(); panel.addStyleName(SWMMobile.getTheme().getMGWTCssBundle().getTripListItemCss().tripHPanel()); progressImage = new Image(progress); panel.add(progressImage); panel.getElement().getStyle().setHeight(progress.getHeight(), Unit.PX); categoryImage = new Image(category); categoryImage .addStyleName(SWMMobile.getTheme().getMGWTCssBundle().getTripListItemCss().tripTransportImage()); panel.add(categoryImage); VerticalPanel vPanel = new VerticalPanel(); vPanel.addStyleName(SWMMobile.getTheme().getMGWTCssBundle().getTripListItemCss().tripVPanel()); //title HorizontalPanel titlePanel = new HorizontalPanel(); titlePanel.addStyleName(SWMMobile.getTheme().getMGWTCssBundle().getTripListItemCss().tripListTitlePanel()); titleLabel = new Label(title); titleLabel.addStyleName(SWMMobile.getTheme().getMGWTCssBundle().getTripListItemCss().tripListItemTitle()); titlePanel.add(titleLabel); HorizontalPanel timeAndPlatformPanel = new HorizontalPanel(); timeAndPlatformPanel .addStyleName(SWMMobile.getTheme().getMGWTCssBundle().getTripListItemCss().tripListTimePanel()); final Label departurePlatformLabel = new Label(departurePlatform); departurePlatformLabel .addStyleName(SWMMobile.getTheme().getMGWTCssBundle().getTripListItemCss().tripListTimeLabel()); departurePlatformLabel .addStyleName(SWMMobile.getTheme().getMGWTCssBundle().getTripListItemCss().tripPunctual()); timeAndPlatformPanel.add(departurePlatformLabel); timeLabel = new Label(dalay); timeLabel.addStyleName(SWMMobile.getTheme().getMGWTCssBundle().getTripListItemCss().tripListTimeLabel()); timeAndPlatformPanel.add(timeLabel); titlePanel.add(timeAndPlatformPanel); vPanel.add(titlePanel); //subtitle subtitleLabel = new Label(subtitle); subtitleLabel .addStyleName(SWMMobile.getTheme().getMGWTCssBundle().getTripListItemCss().tripListItemSubtitle()); vPanel.add(subtitleLabel); //subsub title HorizontalPanel subsubTitlePanel = new HorizontalPanel(); subSubtitleLabel = new Label(subSubTitle); subSubtitleLabel.addStyleName( SWMMobile.getTheme().getMGWTCssBundle().getTripListItemCss().tripListItemSubSubtitle()); subsubTitlePanel.add(subSubtitleLabel); HorizontalPanel arrivalPlatformPanel = new HorizontalPanel(); arrivalPlatformPanel .addStyleName(SWMMobile.getTheme().getMGWTCssBundle().getTripListItemCss().tripListTimePanel()); final Label arrivalPlatformLabel = new Label(arrivalPlatform); arrivalPlatformLabel .addStyleName(SWMMobile.getTheme().getMGWTCssBundle().getTripListItemCss().tripListTimeLabel()); arrivalPlatformLabel .addStyleName(SWMMobile.getTheme().getMGWTCssBundle().getTripListItemCss().tripPunctual()); arrivalPlatformPanel.add(arrivalPlatformLabel); subsubTitlePanel.add(arrivalPlatformPanel); vPanel.add(subsubTitlePanel); panel.add(vPanel); add(panel); }
From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.button.Css3ButtonCellAppearance.java
License:sencha.com license
@Override public void render(ButtonCell<M> cell, Context context, M value, SafeHtmlBuilder sb) { String constantHtml = cell.getHTML(); boolean hasConstantHtml = constantHtml != null && constantHtml.length() != 0; boolean isBoolean = value != null && value instanceof Boolean; // is a boolean always a toggle button? String text = hasConstantHtml ? cell.getText() : (value != null && !isBoolean) ? SafeHtmlUtils.htmlEscape(value.toString()) : ""; ImageResource icon = cell.getIcon(); IconAlign iconAlign = cell.getIconAlign(); String arrowClass = ""; String scaleClass = ""; String iconClass = ""; int width = cell.getWidth(); int height = cell.getHeight(); boolean hasIcon = cell.getIcon() != null; boolean isSplitButton = cell instanceof SplitButtonCell; boolean hasMenu = cell.getMenu() != null; boolean hasWidth = width != -1; if (cell.getMenu() != null) { if (cell instanceof SplitButtonCell) { switch (cell.getArrowAlign()) { case RIGHT: arrowClass = style.split(); break; case BOTTOM: arrowClass = style.splitBottom(); break; }/*from ww w . j av a 2 s .co m*/ } else { switch (cell.getArrowAlign()) { case RIGHT: arrowClass = style.arrow(); break; case BOTTOM: arrowClass = style.arrowBottom(); break; } } } ButtonScale scale = cell.getScale(); switch (scale) { case SMALL: scaleClass = style.small(); break; case MEDIUM: scaleClass = style.medium(); break; case LARGE: scaleClass = style.large(); break; } if (icon != null) { switch (iconAlign) { case TOP: iconClass = style.iconTop(); break; case BOTTOM: iconClass = style.iconBottom(); break; case LEFT: iconClass = style.iconLeft(); break; case RIGHT: iconClass = style.iconRight(); break; } } String buttonClass = style.button(); boolean hasText = text != null && !text.equals(""); if (!hasText) { buttonClass += " " + style.noText(); } // toggle button if (value == Boolean.TRUE) { buttonClass += " " + style.pressed(); } String innerClass = style.buttonInner() + " " + iconClass; innerClass += " " + arrowClass; innerClass += " " + scaleClass; SafeHtmlBuilder builder = new SafeHtmlBuilder(); SafeStylesBuilder ss = new SafeStylesBuilder(); if (height != -1) { ButtonDetails bd = resources.theme().button(); EdgeDetails padding = bd.padding(); EdgeDetails paddingInner = bd.radiusMinusBorderWidth(); int ah = height; ah -= padding.top(); ah -= padding.bottom(); ah -= paddingInner.top(); ah -= paddingInner.bottom(); ss.appendTrustedString("line-height: " + ah + "px;"); } builder.appendHtmlConstant("<div class='" + buttonClass + "'>"); // get iconbuilder ready SafeHtmlBuilder iconBuilder = new SafeHtmlBuilder(); if (icon != null) { int iconWidth = icon != null ? icon.getWidth() : 0; int iconHeight = icon != null ? icon.getHeight() : 0; String styles = "width: " + iconWidth + "px; height: " + iconHeight + "px;"; iconBuilder.appendHtmlConstant("<div class='" + iconClass + "' style='" + styles + "'>"); iconBuilder.append(AbstractImagePrototype.create(icon).getSafeHtml()); iconBuilder.appendHtmlConstant("</div>"); } // for left / right aligned icons with a fixed button width we render the icon outside of the inner div if (hasWidth && hasIcon && iconAlign == IconAlign.LEFT) { builder.append(iconBuilder.toSafeHtml()); } if (hasWidth && hasIcon && (iconAlign == IconAlign.LEFT)) { int tw = width - (resources.theme().button().borderRadius() * 2); if (isSplitButton && cell.getArrowAlign() == ButtonArrowAlign.RIGHT) { tw -= resources.split().getWidth() + 10; } if (!isSplitButton && iconAlign == IconAlign.LEFT && hasMenu && cell.getArrowAlign() == ButtonArrowAlign.RIGHT) { tw -= resources.arrow().getWidth() + 10; } if (hasIcon && iconAlign == IconAlign.LEFT) { tw -= icon.getWidth(); } ss.appendTrustedString("width: " + tw + "px;"); } builder.appendHtmlConstant("<div class='" + innerClass + "' style='" + ss.toSafeStyles().asString() + "'>"); if (icon != null) { if ((!hasWidth && iconAlign == IconAlign.LEFT) || iconAlign == IconAlign.TOP) { builder.append(iconBuilder.toSafeHtml()); } builder.appendHtmlConstant(text); if (iconAlign == IconAlign.RIGHT || iconAlign == IconAlign.BOTTOM) { builder.append(iconBuilder.toSafeHtml()); } } else { builder.appendHtmlConstant(text); } builder.appendHtmlConstant("</div></div>"); sb.append(builder.toSafeHtml()); }
From source file:mx.org.pescadormvp.core.client.internallinks.InternalButtonLink.java
License:Open Source License
/** * Set the image to be used in the button. *//*from w w w . j a v a2s . c om*/ public void setImageResource(ImageResource imageResource) { ensureImage(); imageWidth = imageResource.getWidth(); imageHeight = imageResource.getHeight(); image.setResource(imageResource); setupImage(); }
From source file:mx.org.pescadormvp.core.client.internallinks.InternalCheckableItemLink.java
License:Open Source License
/** * Set whether or not there should be a checkmark next to the item. *//*from ww w. j a v a2 s . c o m*/ public void setChecked(boolean checked) { ImageResource checkmarkImage = itemResources.checkmarkImage(); if (checked) { image.setResource(checkmarkImage); } else { image.setResource(itemResources.clearImage()); image.setWidth(checkmarkImage.getWidth() + "px"); image.setHeight(checkmarkImage.getHeight() + "px"); } setImageStyle(); setMinSizes(); }
From source file:mx.org.pescadormvp.core.client.internallinks.InternalCheckableItemLink.java
License:Open Source License
/** * Does not actually change sizes, but sets data that is used by the widget * this is attached to.// w ww. j a v a2s. c o m */ private void setMinSizes() { if (!isAttached()) return; ImageResource checkmarkImage = itemResources.checkmarkImage(); minHeight = Math.max(DOMUtils.getElementHeight(textArea), checkmarkImage.getHeight() + (IMAGE_PADDING * 2)) + (ITEM_CONTAINER_PADDING * 2); minWidth = checkmarkImage.getWidth() + (IMAGE_PADDING * 2) + DOMUtils.getElementWidth(textArea) + (ITEM_CONTAINER_PADDING * 2); }