Example usage for com.vaadin.ui Image setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:com.klwork.explorer.ui.business.social.QQWeiboDisplayPage.java

License:Apache License

@Override
public Image initOriginalPic(final SocialUserWeibo userWeibo) {
    // /*from   ww  w.j  ava2s . com*/
    String origPic = userWeibo.getOriginalPic();
    Image image = currentImage(origPic, null, "/460");
    // System.out.println("" + image.getHeight());
    if (image != null) {
        image.setHeight("120px");
        image.setWidth("120px");

    }
    return image;
}

From source file:com.klwork.explorer.ui.business.social.SinaWeiboDisplayPage.java

License:Apache License

@Override
public Image initOriginalPic(final SocialUserWeibo userWeibo) {
    // //w w  w . j a  va2s  .  co m
    String origPic = userWeibo.getOriginalPic();
    Image image = currentImage(origPic, null, "");
    // System.out.println("" + image.getHeight());
    if (image != null) {
        image.setHeight("200px");
        image.setWidth("200px");

    }
    return image;
}

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * This method creates image for cover.//from www. j  a  v  a2s .  c  o  m
 * 
 * @param cover
 *            The external cover for current track.
 * @return The image with set resource.
 */
private Image createImageCover(ExternalResource cover) {
    Image image = new Image(null, cover);
    image.setHeight("120px");
    image.setWidth("120px");

    return image;
}

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * @param audioFile//  www  . j  a v a  2 s.c o m
 * @param cover
 * @return
 */
private Component createPlayImage(final AudioFile audioFile, ExternalResource cover) {

    AbsoluteLayout absoluteLayout = new AbsoluteLayout();
    absoluteLayout.setWidth("120px");
    absoluteLayout.setHeight("120px");
    absoluteLayout.addComponent(createImageCover(cover));

    final Image play = createImageCover(
            new ExternalResource("http://www.gelab.com.tr/interfaces/gelab/images/PlayButton.png"));
    play.setWidth("50px");
    play.setHeight("50px");
    play.addClickListener(new ClickListener() {

        private static final long serialVersionUID = -5184601350921707969L;

        @Override
        public void click(ClickEvent event) {
            MusicPlayerPanel musicPanel = MusicPlayerPanel.getInstance(getPlayerLayout());

            watched.addObserver(musicPanel);

            MusicPlayerPanel.setAudio(audioFile);
            MusicPlayerPanel.runDefaultSetup();

            if (isPlay.equals(false)) {
                watched.setValue(isPlay = true);
                play.setSource(new ExternalResource(
                        "http://icons.iconarchive.com/icons/icons-land/play-stop-pause/256/Pause-Disabled-icon.png"));
            } else {
                watched.setValue(isPlay = false);
                play.setSource(
                        new ExternalResource("http://www.gelab.com.tr/interfaces/gelab/images/PlayButton.png"));
            }

        }
    });

    absoluteLayout.addComponent(play, "top: 30px; left: 30px;");

    return absoluteLayout;
}

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);//  w  w w .  jav  a2s .  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: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);/* w  w  w.j a  va  2s.  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);/*w  ww.j  av a2s  . 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;
}

From source file:dhbw.clippinggorilla.userinterface.windows.ManageSourcesWindow.java

public void refreshSources() {
    sourcesLayout.removeAllComponents();
    SourceUtils.getSources().stream().sorted((s1, s2) -> s1.getName().compareToIgnoreCase(s2.getName()))
            .forEach(source -> {/* w  w w .  j  a v a2 s  .c  o  m*/
                try {
                    GridLayout sourceLayout = new GridLayout(4, 1);
                    sourceLayout.setSizeFull();

                    Image sourceLogo = new Image();
                    URL url = source.getLogo();
                    if (url != null) {
                        sourceLogo.setSource(new ExternalResource(url));
                    }
                    sourceLogo.setWidth("150px");

                    VerticalLayout sourceText = new VerticalLayout();
                    sourceText.setSizeFull();

                    Label labelHeadLine = new Label(
                            source.getCategory().getIcon().getHtml() + "  " + source.getName(),
                            ContentMode.HTML);
                    labelHeadLine.addStyleName(ValoTheme.LABEL_H2);

                    Label labelDescription = new Label(source.getDescription(), ContentMode.HTML);
                    labelDescription.addStyleName(ValoTheme.LABEL_SMALL);
                    labelDescription.setWidth("100%");

                    sourceText.setMargin(false);
                    sourceText.addComponents(labelHeadLine, labelDescription);

                    Button buttonEdit = new Button(VaadinIcons.EDIT);
                    buttonEdit.addStyleName(ValoTheme.BUTTON_PRIMARY);
                    buttonEdit.addClickListener(
                            ce -> UI.getCurrent().addWindow(NewSourceWindow.createEditMode(source)));

                    Button buttonDelete = new Button(VaadinIcons.TRASH);
                    buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER);
                    buttonDelete.addClickListener(ce -> {
                        sourcesLayout.removeComponent(sourceLayout);
                        sourceLayouts.remove(source.getName().toLowerCase().replaceAll(" ", "")
                                .replaceAll("-", "").replaceAll("_", ""));
                        SourceUtils.removeSource(source);
                    });

                    sourceLayout.addComponents(sourceLogo, sourceText, buttonEdit, buttonDelete);
                    sourceLayout.setComponentAlignment(sourceLogo, Alignment.MIDDLE_CENTER);
                    sourceLayout.setComponentAlignment(buttonEdit, Alignment.MIDDLE_CENTER);
                    sourceLayout.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER);
                    sourceLayout.setColumnExpandRatio(1, 5);
                    sourceLayout.setSpacing(true);

                    sourceLayouts.put(source.getName().toLowerCase().replaceAll(" ", "").replaceAll("-", "")
                            .replaceAll("_", ""), sourceLayout);
                    sourcesLayout.addComponent(sourceLayout);
                } catch (Exception e) {
                    Log.error("Skipping Source! ", e);
                }
            });
}

From source file:edu.kit.dama.ui.admin.login.B2AccessLoginComponent.java

License:Apache License

@Override
public AbstractLayout getLoginForm() {
    if (loginForm == null) {
        Image im = new Image(null,
                new ExternalResource("https://b2access.eudat.eu:8443/home/VAADIN/themes/common/img/logo.png"));
        im.setWidth("300px");
        loginForm = new VerticalLayout(im);
        loginForm.setWidth("300px");
    }//from ww  w  .  ja  va  2 s  .  c  om
    return loginForm;
}

From source file:edu.kit.dama.ui.admin.login.OrcidLoginComponent.java

License:Apache License

@Override
public AbstractLayout getLoginForm() {
    if (loginForm == null) {
        Image im = new Image(null,
                new ExternalResource("http://ebling.library.wisc.edu/images/logos/orcid-hero-logo.png"));
        im.setWidth("300px");
        loginForm = new VerticalLayout(im);
        loginForm.setWidth("300px");
    }//  w w w .j av  a 2s .co m
    return loginForm;
}