Example usage for com.vaadin.ui Image setHeight

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

Introduction

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

Prototype

@Override
    public void setHeight(float height, Unit unit) 

Source Link

Usage

From source file:com.adonis.ui.menu.Menu.java

private void createViewButtonWithEditableImage(final String name, String caption, String nameImage) {
    Button button = new Button(caption, new ClickListener() {
        @Override//from w w w.  ja  va2s .  com
        public void buttonClick(ClickEvent event) {
            navigator.navigateTo(name);
        }

    });

    button.setPrimaryStyleName(ValoTheme.BUTTON_FRIENDLY);
    //        button.setWidth(50, Unit.PERCENTAGE);
    image.setWidth(90, Unit.PIXELS);
    image.setHeight(90, Unit.PIXELS);

    FileReader.createDirectoriesFromCurrent(getInitialPath());
    final Image image = new Image("", new ThemeResource("img/" + nameImage));
    try {
        FileReader.copyFile(VaadinUtils.getResourcePath(nameImage),
                VaadinUtils.getInitialPath() + File.separator + nameImage);
        image.setSource(new FileResource(new File(VaadinUtils.getInitialPath() + File.separator + nameImage)));
    } catch (IOException e) {
        e.printStackTrace();
        image.setSource(new ThemeResource("img/" + nameImage));
    }

    //        image.setWidth(50, Unit.PERCENTAGE);
    image.setWidth(90, Unit.PIXELS);
    image.setHeight(90, Unit.PIXELS);
    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setPrimaryStyleName(ValoTheme.MENU_ITEM);
    horizontalLayout.addComponents(image, button);
    image.addClickListener(new MouseEvents.ClickListener() {
        @Override
        public void click(MouseEvents.ClickEvent event) {
            uploadFieldImage = new UploadField();
            uploadFieldImage.setAcceptFilter("image/*");
            uploadFieldImage.getUpload().addListener(new com.vaadin.v7.ui.Upload.FailedListener() {
                @Override
                public void uploadFailed(com.vaadin.v7.ui.Upload.FailedEvent event) {
                    uploadFieldImage.clearDefaulLayout();
                    horizontalLayout.removeComponent(uploadFieldImage);
                }

                private static final long serialVersionUID = 1L;

            });
            horizontalLayout.addComponent(uploadFieldImage, 2);
            uploadFieldImage.getUpload().addListener(new com.vaadin.v7.ui.Upload.SucceededListener() {

                @Override
                public void uploadSucceeded(com.vaadin.v7.ui.Upload.SucceededEvent event) {
                    File file = (File) uploadFieldImage.getValue();
                    try {
                        showUploadedImage(uploadFieldImage, image, file.getName(), nameImage);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    uploadFieldImage.clearDefaulLayout();
                    horizontalLayout.removeComponent(uploadFieldImage);

                }
            });
            uploadFieldImage.setFieldType(UploadField.FieldType.FILE);
            horizontalLayout.markAsDirty();
            //                image.setWidth(50, Unit.PERCENTAGE);
            image.setWidth(90, Unit.PIXELS);
            image.setHeight(90, Unit.PIXELS);
            image.setVisible(false);
            image.markAsDirty();
            horizontalLayout.addComponent(image, 0);
        }
    });
    button.setVisible(true);
    image.setVisible(true);
    menuItemsLayout.addComponents(horizontalLayout);
    viewButtons.put(name, button);
}

From source file:de.datenhahn.vaadin.componentrenderer.demo.StaticCustomerDetailsGenerator.java

License:Apache License

@Override
public Component getDetails(Grid.RowReference rowReference) {
    rowReference.getGrid().scrollTo(rowReference.getItemId());
    StaticCustomer customer = (StaticCustomer) rowReference.getItemId();

    HorizontalLayout layout = new HorizontalLayout();
    layout.setHeight(300, Sizeable.Unit.PIXELS);
    layout.setMargin(true);//  ww  w .ja  v  a  2  s  .  c o m
    layout.setSpacing(true);
    Image image = new Image("", customer.getPhoto());
    image.setHeight(200, Sizeable.Unit.PIXELS);
    image.setWidth(200, Sizeable.Unit.PIXELS);
    layout.addComponent(image);
    Label nameLabel = new Label("<h1>" + customer.getFirstName() + " " + customer.getLastName() + "</h1>",
            ContentMode.HTML);
    layout.addComponent(nameLabel);
    layout.setExpandRatio(nameLabel, 1.0f);
    return layout;
}

From source file:de.fatalix.lighty.web.component.LightyHeader.java

public LightyHeader() {
    addStyleName(LightyTheme.HEADER_BACKGROUND);
    setWidth(100, Unit.PERCENTAGE);//from   w  w  w.j a  va2 s. c  om
    Image image = new Image(null, new ThemeResource("img/lighty-icon.png"));
    image.setWidth(64, Unit.PIXELS);
    image.setHeight(64, Unit.PIXELS);
    Label headerTitle = new Label("Lighty App");
    headerTitle.addStyleName(LightyLabels.TITLE_CAPTION);
    addComponents(image, headerTitle);
    setExpandRatio(headerTitle, 1.0f);
    setComponentAlignment(headerTitle, Alignment.MIDDLE_LEFT);
}

From source file:de.kaiserpfalzEdv.office.ui.web.widgets.about.AboutPanel.java

License:Apache License

@PostConstruct
public void init() {
    Image logo = new Image(null, new ThemeResource("../images/lichti-wappen.png"));
    logo.setId("about-logo");
    logo.setAlternateText("Logo: Kaiserpfalz EDV-Service");
    logo.setWidth(150f, Unit.PIXELS);/* w  w  w  .j  a va2s.c  o  m*/
    logo.setHeight(170f, Unit.PIXELS);
    logo.setCaption("Kaiserpfalz EDV-Service");

    addComponent(logo);
    setComponentAlignment(logo, Alignment.MIDDLE_CENTER);

    Label name = new Label(
            "<div style='text-align: center;'><b>" + application.get(ApplicationMetaData.APPLICATION_NAME)
                    + "</b>" + "<br/>" + "<i><small>Version "
                    + application.get(ApplicationMetaData.APPLICATION_VERSION) + "</small></i></div>",
            ContentMode.HTML);
    name.setWidth(200f, Unit.PIXELS);
    addComponent(name);
    setComponentAlignment(name, Alignment.MIDDLE_CENTER);

    addComponent(new Label(""));
    addComponent(new Label("License: " + license.getId()));
    addComponent(new Label("Licensee: " + license.getLicensee()));
    addComponent(new Label(""));
    addComponent(new Label("Issued: " + license.getIssueDate()));
    addComponent(new Label("Issuer: " + license.getIssuer()));
    addComponent(new Label(""));
    addComponent(new Label("Valid (Time): " + license.getStart() + " - " + license.getExpiry()));
    addComponent(new Label("Valid (Version): " + license.getVersionRange().getStart() + " - "
            + license.getVersionRange().getEnd()));

    LOG.trace("Initialized: {}", this);
    LOG.trace("  application: {}", application);
    LOG.trace("  license: {}", license);
}

From source file:de.kaiserpfalzEdv.vaadin.about.AboutViewImpl.java

License:Apache License

private void initalizeOverview() {
    overviewLayout = createGridLayout(2, 3);
    overviewLayout.setHeight(300f, PIXELS);
    overviewLayout.setWidth(100f, PERCENTAGE);
    overviewLayout.setColumnExpandRatio(0, 70f);
    overviewLayout.setColumnExpandRatio(1, 30f);
    overviewLayout.setRowExpandRatio(0, 33f);
    overviewLayout.setRowExpandRatio(1, 33f);
    overviewLayout.setRowExpandRatio(2, 33f);

    Image logo = new Image("", new ThemeResource("img/logo.png"));
    logo.setHeight(300f, PIXELS);
    logo.setWidth(300f, PIXELS);/*  w w w  . j a  va  2  s  . com*/
    overviewLayout.addComponent(logo, 0, 0, 0, 2);

    overviewLayout.addComponent(createOverviewLabel("about.application"), 1, 0);
    overviewLayout.addComponent(createOverviewLabel("about.version"), 1, 1);
    overviewLayout.addComponent(createManufactorLabel("about.manufactor"), 1, 2);

    mainLayout.addComponent(overviewLayout);
}

From source file:de.symeda.sormas.ui.dashboard.map.DashboardMapComponent.java

License:Open Source License

public static HorizontalLayout buildMapIconLegendEntry(String iconName, String labelCaption) {
    Image icon = new Image(null, new ExternalResource("VAADIN/map/marker/" + iconName + ".png"));
    icon.setWidth(12.375f, Unit.PIXELS);
    icon.setHeight(16.875f, Unit.PIXELS);
    return buildLegendEntry(icon, labelCaption);
}

From source file:de.symeda.sormas.ui.login.LoginScreen.java

License:Open Source License

private CssLayout buildLoginInformation() {
    CssLayout loginInformation = new CssLayout();
    loginInformation.setStyleName("login-information");

    VerticalLayout innerLayout = new VerticalLayout();
    innerLayout.setSizeFull();//from  www.j ava2s  .  c  om

    Image img = new Image(null, new ThemeResource("img/sormas-logo-big.png"));
    img.setHeight(240, Unit.PIXELS);
    innerLayout.addComponent(img);
    innerLayout.setComponentAlignment(img, Alignment.TOP_CENTER);
    innerLayout.setExpandRatio(img, 0);

    Label loginInfoText = new Label("<h1>SORMAS</h1>"
            + "<h2 style='color:white'>Surveillance, Outbreak Response Management and Analysis System</h2>"
            + "<h3 style='color:white; text-transform:uppercase'>&#9679; Disease Prevention<br>&#9679; Disease Detection<br>&#9679; Outbreak Response</h3>",
            ContentMode.HTML);
    loginInfoText.setWidth(100, Unit.PERCENTAGE);
    innerLayout.addComponent(loginInfoText);
    innerLayout.setExpandRatio(loginInfoText, 1);

    Label loginInfoCopyright = new Label(" 2019 SORMAS. All Rights Reserved.");
    loginInfoCopyright.setWidth(100, Unit.PERCENTAGE);
    innerLayout.addComponent(loginInfoCopyright);
    innerLayout.setExpandRatio(loginInfoCopyright, 0);
    innerLayout.setComponentAlignment(loginInfoCopyright, Alignment.BOTTOM_LEFT);

    loginInformation.addComponent(innerLayout);
    return loginInformation;
}

From source file:management.limbr.ui.VaadinUI.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {

    final VerticalLayout root = new VerticalLayout();
    root.setSizeFull();/*from w ww  . j av a2s  . com*/
    root.setMargin(true);
    root.setSpacing(true);
    setContent(root);

    Image logo = new Image(null, new ExternalResource("images/logo1.png"));
    logo.setHeight(1.2f, Unit.EM);
    logo.setWidthUndefined();

    CssLayout navBar = new CssLayout();
    navBar.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    navBar.addComponent(logo);
    navBar.addComponent(createNavButton("Users", UsersViewImpl.VIEW_NAME));
    root.addComponent(navBar);

    final Panel viewContainer = new Panel();
    viewContainer.setSizeFull();
    root.addComponent(viewContainer);
    root.setExpandRatio(viewContainer, 1.0f);

    Navigator navigator = new Navigator(this, viewContainer);
    navigator.addProvider(viewProvider);

}

From source file:org.inakirj.imagerulette.screens.DicePlayView.java

License:Open Source License

/**
 * Loop thread./*  ww w.  ja  v  a  2s  .  com*/
 */
private void onPickABallClick() {
    int value = randomizer.nextInt(lotteryList.size());
    Image img = (Image) lotteryList.get(value);
    img.setWidth(78, Unit.PIXELS);
    img.setHeight(81, Unit.PIXELS);
    img.addStyleName("random-image");
    imageLayout.replaceComponent(randomImgToBeReplaced, img);
    randomImgToBeReplaced = img;
    String imgUrlToIncrease = (String) img.getData();
    Integer currentValue = statsImageIdOcurrencesMap.get(imgUrlToIncrease);
    currentValue++;
    statsImageIdOcurrencesMap.put(imgUrlToIncrease, new Integer(currentValue));
    calculateStats();
}

From source file:org.opennms.features.vaadin.dashboard.dashlets.ChartsDashlet.java

License:Open Source License

@Override
public DashletComponent getWallboardComponent() {
    if (m_dashletComponent == null) {
        m_dashletComponent = new AbstractDashletComponent() {
            private VerticalLayout m_verticalLayout = new VerticalLayout();

            {// w w  w. ja v a  2 s  . c  om
                m_verticalLayout.setCaption(getName());
                m_verticalLayout.setSizeFull();
            }

            @Override
            public void refresh() {
                String newImage = "/opennms/charts?chart-name=" + getDashletSpec().getParameters().get("chart");

                String maximizeHeightString = getDashletSpec().getParameters().get("maximizeHeight");
                String maximizeWidthString = getDashletSpec().getParameters().get("maximizeWidth");

                boolean maximizeHeight = ("true".equals(maximizeHeightString)
                        || "yes".equals(maximizeHeightString) || "1".equals(maximizeHeightString));
                boolean maximizeWidth = ("true".equals(maximizeWidthString) || "yes".equals(maximizeWidthString)
                        || "1".equals(maximizeWidthString));

                if (!newImage.equals(m_imageUrl)) {
                    m_imageUrl = newImage;
                    m_verticalLayout.removeAllComponents();
                    Image image = new Image(null, new ExternalResource(m_imageUrl));
                    if (maximizeHeight && maximizeWidth) {
                        image.setSizeFull();
                    } else {
                        if (maximizeHeight) {
                            image.setHeight(100, Sizeable.Unit.PERCENTAGE);
                        }
                        if (maximizeWidth) {
                            image.setWidth(100, Sizeable.Unit.PERCENTAGE);
                        }
                    }
                    m_verticalLayout.addComponent(image);
                    m_verticalLayout.setComponentAlignment(image, Alignment.MIDDLE_CENTER);
                }
            }

            @Override
            public Component getComponent() {
                return m_verticalLayout;
            }
        };
    }

    return m_dashletComponent;
}