List of usage examples for com.vaadin.ui Image setData
public void setData(Object data)
From source file:org.inakirj.imagerulette.screens.DiceURLSetupView.java
License:Open Source License
/** * Sets the layout.//from w w w . j av a2 s .co m */ private void setLayout() { imagesLayout = new VerticalComponentGroup(); imagesLayout.setWidth(100, Unit.PERCENTAGE); ImageUtils.getAllImageURL().stream().forEach(i -> { HorizontalLayout sliderLAyout = new HorizontalLayout(); if (imagesLayout.getComponentCount() % 2 == 0) { sliderLAyout.addStyleName("dice-banner-1"); } else { sliderLAyout.addStyleName("dice-banner-2"); } sliderLAyout.setWidth(100, Unit.PERCENTAGE); Image img = new Image("", i.getSource()); img.addStyleName("dice-image"); img.setData(i.getData()); Slider slider = new Slider(); slider.addStyleName("dice-slider"); Label total = new Label(); total.addStyleName("size-24");// TODO is not working // Adding image sliderLAyout.addComponent(img); // Adding slider slider.setMin(0); slider.setMax(5); slider.setWidth(80, Unit.PERCENTAGE); slider.addValueChangeListener(s -> { total.setValue("x " + slider.getValue().intValue()); enableDiceTabOrNot(); }); sliderLAyout.addComponent(slider); // Adding label total.setValue("x 0"); sliderLAyout.addComponent(total); sliderLAyout.setExpandRatio(img, 2); sliderLAyout.setExpandRatio(slider, 7); sliderLAyout.setExpandRatio(total, 1); sliderLAyout.setComponentAlignment(img, Alignment.BOTTOM_LEFT); sliderLAyout.setComponentAlignment(slider, Alignment.BOTTOM_LEFT); sliderLAyout.setComponentAlignment(total, Alignment.BOTTOM_LEFT); // Adding layout imagesLayout.addComponent(sliderLAyout); }); addComponent(imagesLayout); }
From source file:org.inakirj.imagerulette.screens.DiceURLSetupView.java
License:Open Source License
/** * Generate lottery list./*w w w . jav a2 s .c o m*/ * * @return the list */ private List<Object> generateLotteryList() { List<Object> randomList = new ArrayList<>(); Iterator<Component> iterator = imagesLayout.iterator(); while (iterator.hasNext()) { HorizontalLayout hl = (HorizontalLayout) iterator.next(); Image imageSelected = (Image) hl.getComponent(0); Image img = new Image("", imageSelected.getSource()); img.setData(imageSelected.getData()); Slider slider = (Slider) hl.getComponent(1); int rep = slider.getValue().intValue(); while (rep > 0) { randomList.add(img); rep--; } } return randomList; }
From source file:org.inakirj.imagerulette.utils.ImageUtils.java
License:Open Source License
/** * Gets the image URL./*from w w w . j av a 2 s .co m*/ * * @return the image URL */ public static List<Image> getAllImageURL() { List<Image> result = new ArrayList<>(); CookieManager sm = new CookieManager(); Image img; for (String url : sm.getAllURLs()) { ExternalResource resource = new ExternalResource(url); img = new Image("", resource); img.setData(url); result.add(img); } return result; }
From source file:org.plukh.fluffymeow.ui.i18n.LocaleChooserComponent.java
License:Open Source License
@Inject public LocaleChooserComponent() { log.trace("Creating LocaleChooserComponent..."); setSizeUndefined();/* w ww . j a v a 2s .c om*/ HorizontalLayout layout = new HorizontalLayout(); flags = new ArrayList<>(); languages.forEach(language -> { Resource flagResource = new ThemeResource(language.getFlagFile()); Image flag = new Image(null, flagResource); flag.addStyleName("pointer"); flag.addClickListener(event -> onLanguageChange(language.getLocale())); flag.setData(language.getMessage()); log.debug("Created flag for locale " + language.getLocale()); flags.add(flag); layout.addComponent(flag); }); setCompositionRoot(layout); log.debug("LocaleChooserComponent created"); }