本文整理汇总了Java中com.google.gwt.user.client.ui.SimplePanel.setWidth方法的典型用法代码示例。如果您正苦于以下问题:Java SimplePanel.setWidth方法的具体用法?Java SimplePanel.setWidth怎么用?Java SimplePanel.setWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.user.client.ui.SimplePanel
的用法示例。
在下文中一共展示了SimplePanel.setWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSizeWidget
import com.google.gwt.user.client.ui.SimplePanel; //导入方法依赖的package包/类
private static Widget getSizeWidget(ChangeInfo c) {
int largeChangeSize = Gerrit.info().change().largeChange();
int changedLines = c.insertions() + c.deletions();
int p = 100;
if (changedLines < largeChangeSize) {
p = changedLines * 100 / largeChangeSize;
}
int width = Math.max(2, 70 * p / 100);
int red = p >= 50 ? 255 : (int) Math.round((p) * 5.12);
int green = p <= 50 ? 255 : (int) Math.round(256 - (p - 50) * 5.12);
String bg = "#" + toHex(red) + toHex(green) + "00";
SimplePanel panel = new SimplePanel();
panel.setStyleName(Gerrit.RESOURCES.css().changeSize());
panel.setWidth(width + "px");
panel.getElement().getStyle().setBackgroundColor(bg);
return panel;
}
示例2: rightAlign
import com.google.gwt.user.client.ui.SimplePanel; //导入方法依赖的package包/类
public static Widget rightAlign(Widget w) {
SimplePanel wrapper = new SimplePanel();
wrapper.setWidth("100%");
wrapper.setWidget(w);
DOM.setElementAttribute(wrapper.getElement(), "align", "right");
return wrapper;
// HorizontalPanel hp = new HorizontalPanel();
// hp.setWidth("100%");
// hp.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
// hp.add(w);
// return hp;
}
示例3: TabBarItemComponent
import com.google.gwt.user.client.ui.SimplePanel; //导入方法依赖的package包/类
public TabBarItemComponent(TabBarItem item, EnumSystemTabItemType systemTabType) {
this.item = item;
this.systemTabType = systemTabType;
setStylePrimaryName(TAB_ITEM_CLASS_NAME);
TabImage tabImage = item.getImage();
setHeight("100%");
setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
boolean hasText = false;
this.addStyleName(INTERACTIVE_CLASS_NAME);
// Check if we have text
if (item.getName() != null && !item.getName().equals("")) {
hasText = true;
}
// Add Image
if (tabImage != null) {
boolean isSystemImage = false;
if (tabImage.getSystemImage() != null && tabImage.getSystemImage()) isSystemImage = true;
int tabImageSize = hasText ? (TAB_BAR_HEIGHT - IMAGE_PADDING_TOP - TAB_TEXT_HEIGHT) : (TAB_BAR_HEIGHT - IMAGE_PADDING_TOP);
imageComponent = new SimplePanel();
imageComponent.setStylePrimaryName(TAB_IMAGE_CLASS_NAME);
imageComponent.setWidth("100%");
imageComponent.setHeight(tabImageSize + "px");
String marginStr = hasText ? IMAGE_PADDING_TOP + "px 0 0 0" : IMAGE_PADDING_TOP + "px 0";
DOM.setStyleAttribute(imageComponent.getElement(), "margin", marginStr);
Element elem = imageComponent.getElement();
String imagePath = "";
if (isSystemImage) {
imagePath = BrowserUtils.getSystemImageDir() + tabImage.getSrc();
} else {
imagePath = WebConsole.getConsoleUnit().getControllerService().getController().getResourcesUrl() + tabImage.getSrc();
}
DOM.setStyleAttribute(elem, "backgroundImage", "url(" + imagePath + ")");
DOM.setStyleAttribute(elem, "backgroundRepeat", "no-repeat");
DOM.setStyleAttribute(elem, "backgroundPosition", "center center");
DOM.setStyleAttribute(elem, "backgroundColor", "transparent");
DOM.setStyleAttribute(elem, "backgroundSize", "contain");
DOM.setStyleAttribute(elem, "border", "none");
this.add(imageComponent);
hasImage = true;
}
// Add Text
if (item.getName() != null && !item.getName().equals("")) {
int lineHeight = hasImage ? TAB_TEXT_HEIGHT : TAB_BAR_HEIGHT;
nameComponent = new Label();
nameComponent.setText(item.getName());
nameComponent.setWidth("100%");
nameComponent.setStylePrimaryName(TAB_TEXT_CLASS_NAME);
DOM.setStyleAttribute(nameComponent.getElement(), "lineHeight", lineHeight + "px");
this.add(nameComponent);
hasText = true;
}
}