本文整理汇总了Java中com.vaadin.ui.Image.setSource方法的典型用法代码示例。如果您正苦于以下问题:Java Image.setSource方法的具体用法?Java Image.setSource怎么用?Java Image.setSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vaadin.ui.Image
的用法示例。
在下文中一共展示了Image.setSource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addImage
import com.vaadin.ui.Image; //导入方法依赖的package包/类
public void addImage(DSImage image) {
image.setIndex(images.size());
images.add(image);
Image loadedImage = new Image();
loadedImage.setSource(image.getResource());
if (loadedImage.getWidth() > imageMaxWidth) {
loadedImage.setWidth(imageMaxWidth, Unit.PIXELS);
}
if (loadedImage.getHeight() > imageMaxHeight) {
loadedImage.setHeight(imageMaxHeight, Unit.PIXELS);
}
loadedImage.setData(image.getIndex());
loadedImage.addClickListener(event -> {
if (isSelectable()) {
DSImage clicked = images.get((int) loadedImage.getData());
// Notification.show(selectedImage.toString(), Type.HUMANIZED_MESSAGE);
setValue(clicked);
}
});
loadedImages.add(loadedImage);
if (visibleImages.size() < maxAllowed || maxAllowed < 0) {
addVisibleImage(image.getIndex(), loadedImage);
}
}
示例2: generateCell
import com.vaadin.ui.Image; //导入方法依赖的package包/类
@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
User user = (User) itemId;
Image image = new Image();
image.addStyleName("users-menu-image");
if (user.getImage() != null) {
StreamResource.StreamSource imagesource = new UserImageSource(user.getImage().toStream());
StreamResource resource = new StreamResource(imagesource, UUID.randomUUID().toString());
image.setSource(resource);
} else {
image.setSource(new ThemeResource("img/profile-pic-300px.jpg"));
}
ValoUserItemButton btnUsername = new ValoUserItemButton(user, ValoUserItemButton.TYPE.USER_NAME);
ValoUserItemButton btnFullName = new ValoUserItemButton(user, ValoUserItemButton.TYPE.FULL_NAME);
VerticalLayout nameLayout = new VerticalLayout(btnFullName, btnUsername);
nameLayout.setSizeFull();
nameLayout.setComponentAlignment(btnFullName, Alignment.BOTTOM_LEFT);
nameLayout.setComponentAlignment(btnUsername, Alignment.TOP_LEFT);
HorizontalLayout usersHorizontalLayout = new HorizontalLayout(image, nameLayout);
usersHorizontalLayout.setComponentAlignment(image, Alignment.MIDDLE_CENTER);
usersHorizontalLayout.setComponentAlignment(nameLayout, Alignment.MIDDLE_LEFT);
usersHorizontalLayout.setExpandRatio(nameLayout, 1f);
usersHorizontalLayout.addStyleName("users-horizontal-layout");
usersHorizontalLayout.setWidth(100, Unit.PERCENTAGE);
usersHorizontalLayout.setHeight(45, Unit.PIXELS);
usersHorizontalLayout.setSpacing(true);
return usersHorizontalLayout;
}
示例3: getMinifiedView
import com.vaadin.ui.Image; //导入方法依赖的package包/类
@Override
public Component getMinifiedView() {
Image img = new Image();
img.setSource(getFilterIcon());
img.setDescription(getFilterStateDesc());
return img;
}