Example usage for com.vaadin.ui Image Image

List of usage examples for com.vaadin.ui Image Image

Introduction

In this page you can find the example usage for com.vaadin.ui Image Image.

Prototype

public Image() 

Source Link

Document

Creates a new empty Image.

Usage

From source file:com.foc.vaadin.gui.components.FVBlobDisplay.java

License:Apache License

public void displayPDFFile() {
    BlobResource blobResource = getBlobResource();
    if (blobResource != null) {
        String fileName = blobResource.getFilename();
        if (fileName != null) {
            String mimeType = blobResource.getMIMEType();

            StreamSource streamSource = new StreamSource() {
                private DownloadStream downloadStream = getBlobResource() != null
                        ? getBlobResource().getStream()
                        : null;//from   w ww.jav a  2  s . c  o  m

                @Override
                public InputStream getStream() {

                    return downloadStream != null ? downloadStream.getStream() : null;
                }
            };
            String viewButtonCaption = "View "
                    + fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()) + " File";
            Button viewDocButton = new Button(viewButtonCaption);
            viewDocButton.setStyleName(Reindeer.BUTTON_LINK);
            if (streamSource != null) {
                StreamResource streamResource = new StreamResource(streamSource, fileName);
                streamResource.setMIMEType(mimeType);

                BrowserWindowOpener opener = new BrowserWindowOpener(streamResource);
                opener.extend(viewDocButton);
                settingsLayout.addComponent(viewDocButton);
                Resource resource = FVIconFactory.getInstance().getFVIcon(FVIconFactory.ICON_NOTE);
                Image image = new Image();
                image.setSource(resource);
                addComponent(image);
            }
        }
    }
}

From source file:com.foc.vaadin.gui.components.FVBlobDisplay.java

License:Apache License

private Image displayImage(BlobResource blobResource) {
    Image image = new Image();
    image.setSource(blobResource);// w ww.java2  s .  c om
    FVImageField imageField = new FVImageField(null, getAttributes());
    image = imageField.resizeImage(image, MAX_WIDTH, MAX_HEIGHT);

    setWidth(image.getWidth() + "px");
    setHeight(image.getHeight() + "px");

    return image;
}

From source file:com.foc.vaadin.gui.components.FVImageField.java

License:Apache License

public void setProperty(FProperty property) {
    if (property != null && property.getFocField() != null) {
        if (property instanceof FCloudStorageProperty) {
            setCloudStorageProperty((FCloudStorageProperty) property);
        } else if (property instanceof FImageProperty) {
            this.setImageProperty((FImageProperty) property);
        } else if (property instanceof FBlobMediumProperty) {
            this.setBlobMediumProperty((FBlobMediumProperty) property);
        }/*from  www  .  j a  v  a 2  s. c  o m*/
    }

    adjustDownloadButtonVisibility(property);

    if (resource != null) {
        resource.setProperty(property);
    }

    boolean showImage = true;
    String showImgStr = getAttributes() != null ? getAttributes().getValue(FXML.ATT_SHOW_IMAGE) : "true";
    if (showImgStr != null && (showImgStr.trim().toLowerCase().equals("false")
            || showImgStr.trim().toLowerCase().equals("0"))) {
        showImage = false;
    }
    if (showImage) {
        embedded = new Image();
        embedded.setImmediate(false);
        setEmbedded(embedded);

        boolean error = refreshImageFromProperty();
        setIsImage(!error);

        addComponentAsFirst(embedded);
        setExpandRatio(embedded, 1);
        reactToEditable();
    }
}

From source file:com.mycollab.mobile.ui.AttachmentPreviewView.java

License:Open Source License

public AttachmentPreviewView() {
    CssLayout imgWrap = new CssLayout();
    imgWrap.setStyleName("image-wrap");
    imgWrap.setSizeFull();/*from w ww  .  jav  a2  s  . co  m*/

    this.setStyleName("attachment-preview-view");
    this.setSizeFull();
    this.addComponent(imgWrap, "top: 0px left: 0px; z-index: 0;");

    backBtn = new NavigationButton(UserUIContext.getMessage(GenericI18Enum.M_BUTTON_BACK));
    backBtn.setStyleName("back-btn");

    this.addComponent(backBtn, "top: 15px; left: 15px; z-index: 1;");

    previewImage = new Image();
    imgWrap.addComponent(previewImage);
}

From source file:com.mycollab.vaadin.web.ui.AddViewLayout2.java

License:Open Source License

public AddViewLayout2(String title, Resource icon) {
    this.setMargin(new MarginInfo(false, false, true, false));
    setStyleName("addview-layout");

    this.viewIcon = icon;

    header = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false)).withFullWidth();
    header.setDefaultComponentAlignment(Alignment.TOP_LEFT);

    if (!(icon instanceof FontAwesome)) {
        Image iconEmbed = new Image();
        iconEmbed.setSource(icon);/*from  w  w  w. j a  va  2s .  com*/
        header.with(iconEmbed);
    }

    titleLbl = ELabel.h2("");
    header.with(titleLbl).expand(titleLbl);

    if (title == null) {
        if (icon != null) {
            this.setTitle(UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED));
        }
    } else {
        this.setTitle(title);
    }

    this.addComponent(header);

    body = new MVerticalLayout().withSpacing(false).withMargin(false).withStyleName("addview-layout-body");
    this.addComponent(body);
}

From source file:com.mycompany.exodious.login.java

public login() {
    this.setId("loginPanel");
    this.setSpacing(true);
    Image logo = new Image();
    logo.setId("logo");
    logo.setSource(slikaLogo);//from ww w.  j a  va  2 s.co  m
    logo.setHeight("18em");
    logo.setWidth("30em");
    Label welcome = new Label("Welcome, please login");
    welcome.setId("welcome");
    TextField username = new TextField("Your ID");
    PasswordField password = new PasswordField("Password");
    Button submit = new Button("Login");
    submit.setIcon(FontAwesome.SIGN_IN);
    submit.addStyleName(ValoTheme.BUTTON_PRIMARY);

    submit.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {

        }
    });

    addComponents(logo, welcome, username, password, submit);
    setComponentAlignment(logo, Alignment.MIDDLE_CENTER);
    setComponentAlignment(welcome, Alignment.MIDDLE_CENTER);
    setComponentAlignment(username, Alignment.MIDDLE_CENTER);
    setComponentAlignment(password, Alignment.MIDDLE_CENTER);
    setComponentAlignment(submit, Alignment.MIDDLE_CENTER);
}

From source file:com.uib.onlinepeptideshaker.presenter.view.SmallSideBtn.java

public SmallSideBtn(String iconUrl) {
    Image icon = new Image();
    icon.setSource(new ThemeResource(iconUrl));
    icon.setSizeFull();/*from   w  w  w . j  av a 2  s. com*/
    SmallSideBtn.this.addComponent(icon);
    SmallSideBtn.this.setSizeFull();
    SmallSideBtn.this.setStyleName("smallmenubtn");
}

From source file:de.fatalix.bookery.view.common.BookDetailLayout.java

License:Open Source License

private HorizontalLayout createImageLayout() {
    image = new Image();
    image.setImmediate(true);//from ww  w. j  a v  a 2 s.  co  m
    image.setHeight("200px");
    image.setWidth("130px");

    downloadButton = new Button("download", FontAwesome.DOWNLOAD);
    downloadButton.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    downloadButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                loadData(presenter.updateShared(bookEntry,
                        SecurityUtils.getSubject().getPrincipal().toString()));
            } catch (SolrServerException | IOException ex) {
                Notification.show("Unexpected Error!\n" + ex.getMessage(), Notification.Type.ERROR_MESSAGE);
                logger.error(ex, ex);
            }
        }
    });

    fileDownloader = new FileDownloader(new StreamResource(new BookStreamSource(null), "blbla.epub"));
    fileDownloader.extend(downloadButton);

    sendToKindleButton = new Button("Kindle", FontAwesome.BOOK);
    sendToKindleButton.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    sendToKindleButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                presenter.shareBookWithKindle(bookEntry, SecurityUtils.getSubject().getPrincipal().toString());
                Notification.show("Book is sent to kindle", Notification.Type.HUMANIZED_MESSAGE);
                loadData(presenter.updateShared(bookEntry,
                        SecurityUtils.getSubject().getPrincipal().toString()));
            } catch (SolrServerException | IOException | MessagingException ex) {
                Notification.show("Unexpected Error!\n" + ex.getMessage(), Notification.Type.ERROR_MESSAGE);
                logger.error(ex, ex);
            }
        }
    });

    likeButton = new Button("0 likes", FontAwesome.THUMBS_O_UP);
    likeButton.addStyleName(ValoTheme.BUTTON_LINK);
    likeButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                BookEntry updatedEntry = presenter.updateLike(bookEntry,
                        SecurityUtils.getSubject().getPrincipal().toString());
                loadData(updatedEntry);
            } catch (SolrServerException | IOException ex) {
                Notification.show("Unexpected Error!\n" + ex.getMessage(), Notification.Type.ERROR_MESSAGE);
                logger.error(ex, ex);
            }
        }
    });

    watchListButton = new Button("merken", FontAwesome.STAR_O);
    watchListButton.addStyleName(ValoTheme.BUTTON_LINK);
    watchListButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            presenter.addRemoveFromWatchList(bookEntry, SecurityUtils.getSubject().getPrincipal().toString());
            loadData(bookEntry);
        }
    });
    downloadCount = new Label("0 downloads");

    VerticalLayout rightLayout = new VerticalLayout(sendToKindleButton, downloadButton, watchListButton,
            likeButton, downloadCount);
    rightLayout.setComponentAlignment(downloadCount, Alignment.MIDDLE_CENTER);
    rightLayout.setSpacing(true);

    HorizontalLayout layout = new HorizontalLayout(image, rightLayout);
    layout.setSpacing(true);
    return layout;
}

From source file:de.fatalix.bookery.view.common.BookSearchLayout.java

License:Open Source License

private VerticalLayout createBookCoverLayout(final BookEntry bookEntry) {
    Image image = new Image();
    image.setDescription(bookEntry.getTitle() + " von " + bookEntry.getAuthor());
    image.setHeight("200px");
    image.setWidth("130px");
    image.setImmediate(true);//from   w ww .ja  v  a2  s .c  om
    if (bookEntry.getThumbnail() != null) {
        StreamResource.StreamSource source = new ByteStreamResource(bookEntry.getThumbnail());
        image.setSource(new StreamResource(source, bookEntry.getId() + "_thumb.png"));
    } else if (bookEntry.getCover() != null) {
        StreamResource.StreamSource source = new ByteStreamResource(bookEntry.getCover());
        image.setSource(new StreamResource(source, bookEntry.getId() + ".png"));
    }

    final MButton watchListButton = new MButton()
            .withIcon(presenter.isOnWatchList(bookEntry, SecurityUtils.getSubject().getPrincipal().toString())
                    ? FontAwesome.STAR
                    : FontAwesome.STAR_O)
            .withStyleName(ValoTheme.BUTTON_LINK);
    watchListButton.addStyleName("quick-action");

    watchListButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            watchListButton.setIcon(presenter.addRemoveFromWatchList(bookEntry,
                    SecurityUtils.getSubject().getPrincipal().toString()) ? FontAwesome.STAR
                            : FontAwesome.STAR_O);
        }
    });

    final MButton likeButton = new MButton().withCaption("" + bookEntry.getLikes())
            .withIcon(FontAwesome.THUMBS_O_UP).withStyleName(ValoTheme.BUTTON_LINK);
    likeButton.addStyleName("quick-action");

    likeButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                BookEntry updatedBook = presenter.updateLike(bookEntry,
                        SecurityUtils.getSubject().getPrincipal().toString());
                bookEntry.setLikes(updatedBook.getLikes());
                bookEntry.setLikedby(updatedBook.getLikedby());
                likeButton.setCaption("" + bookEntry.getLikes());
            } catch (SolrServerException | IOException ex) {
                java.util.logging.Logger.getLogger(BookSearchLayout.class.getName()).log(Level.SEVERE, null,
                        ex);
            }

        }
    });
    final MButton downloadsButton = new MButton().withCaption("" + bookEntry.getDownloads())
            .withIcon(FontAwesome.DOWNLOAD).withStyleName(ValoTheme.BUTTON_LINK);
    downloadsButton.addStyleName("quick-action");
    HorizontalLayout quickActionLayout = new HorizontalLayout(watchListButton, likeButton, downloadsButton);
    quickActionLayout.addStyleName("quick-action-layout");

    VerticalLayout result = new VerticalLayout(image, quickActionLayout);
    //result.setHeight("210px");
    //result.setWidth("140px");
    result.addStyleName("pointer-cursor");
    result.addStyleName("book-card");
    result.setComponentAlignment(image, Alignment.MIDDLE_CENTER);

    result.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            bookDetailLayout.loadData(bookEntry);
            bookDetailLayout.setLayoutVisible(true);
            //BookDetailDialog dialogInstance = bookDetail.get();
            //dialogInstance.loadData(bookEntry);
            //UI.getCurrent().addWindow(dialogInstance);
        }
    });
    return result;
}

From source file:de.fatalix.bookery.view.common.SuggestLaneLayout.java

License:Open Source License

private VerticalLayout createBookCoverLayout(final BookEntry bookEntry) {
    Image image = new Image();
    image.setDescription(bookEntry.getTitle() + " von " + bookEntry.getAuthor());
    image.setHeight("200px");
    image.setWidth("130px");
    image.setImmediate(true);/*from w  ww .j a  v  a2  s .  c o m*/
    if (bookEntry.getThumbnail() != null) {
        StreamResource.StreamSource source = new ByteStreamResource(bookEntry.getThumbnail());
        image.setSource(new StreamResource(source, bookEntry.getId() + "_thumb.png"));
    } else if (bookEntry.getCover() != null) {
        StreamResource.StreamSource source = new ByteStreamResource(bookEntry.getCover());
        image.setSource(new StreamResource(source, bookEntry.getId() + ".png"));
    }

    VerticalLayout result = new VerticalLayout(image);
    result.setHeight("210px");
    result.addStyleName("pointer-cursor");
    result.addStyleName("book-cover");
    result.setComponentAlignment(image, Alignment.MIDDLE_CENTER);

    result.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            bookDetailLayout.loadData(bookEntry);
            bookDetailLayout.setLayoutVisible(true);
        }
    });
    return result;
}