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:org.opennms.features.vaadin.dashboard.dashlets.ImageDashlet.java

License:Open Source License

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

            {/*from w  ww  . j a  v  a 2s  . c o  m*/
                m_verticalLayout.setCaption(getName());
                m_verticalLayout.setSizeFull();
            }

            @Override
            public void refresh() {
                String newImage = getDashletSpec().getParameters().get("imageUrl");

                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;
}

From source file:org.sensorhub.ui.AdminUI.java

License:Mozilla Public License

protected Component buildHeader() {
    HorizontalLayout header = new HorizontalLayout();
    header.setMargin(false);//from   w w w  .  j av a 2s . c  o  m
    header.setHeight(100.0f, Unit.PIXELS);
    header.setWidth(100.0f, Unit.PERCENTAGE);
    Image img = new Image(null, LOGO_ICON);
    img.setHeight(90, Unit.PIXELS);
    img.setStyleName(STYLE_LOGO);
    header.addComponent(img);
    Label title = new Label("SensorHub");
    title.addStyleName(UIConstants.STYLE_H1);
    title.addStyleName(STYLE_LOGO);
    title.setWidth(null);
    header.addComponent(title);
    header.setExpandRatio(img, 0);
    header.setExpandRatio(title, 1);
    header.setComponentAlignment(img, Alignment.MIDDLE_LEFT);
    header.setComponentAlignment(title, Alignment.MIDDLE_RIGHT);
    return header;
}