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(float width, 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// w w  w . ja  v a2s .c  om
        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);// w w  w.  ja  va  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);//  w w w  .j  av  a 2  s .c o m
    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);
    logo.setHeight(170f, Unit.PIXELS);//from w w w . j a va 2  s  .  com
    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);/*from  w  ww  .  ja va2  s.  c o  m*/
    logo.setWidth(300f, PIXELS);
    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:org.inakirj.imagerulette.screens.DicePlayView.java

License:Open Source License

/**
 * Loop thread.//from ww  w .ja  v  a2 s .  co  m
 */
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();

            {//from  ww w  . j a  v  a2  s .  co  m
                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;
}

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();

            {/*  w w  w.j  a  va2s. 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.opennms.features.vaadin.dashboard.dashlets.SummaryDashlet.java

License:Open Source License

private Component getLegend(String entity) {
    HorizontalLayout horizontalLayout = new HorizontalLayout();

    horizontalLayout.setSpacing(true);//from www . j  a va 2 s .  c om
    horizontalLayout.addStyleName("summary");
    horizontalLayout.addStyleName("global");

    Label labelx = new Label(entity);
    labelx.addStyleName("summary-font-legend");

    Image ackdImage = new Image(null, new ThemeResource("img/acknowledged.png"));
    ackdImage.setWidth(16, Sizeable.Unit.PIXELS);

    Image unackdImage = new Image(null, new ThemeResource("img/unacknowledged.png"));
    unackdImage.setWidth(16, Sizeable.Unit.PIXELS);

    Label dummyLabel = new Label();
    dummyLabel.setWidth(32, Sizeable.Unit.PIXELS);

    horizontalLayout.addComponent(labelx);
    horizontalLayout.addComponent(ackdImage);
    horizontalLayout.addComponent(unackdImage);
    horizontalLayout.addComponent(dummyLabel);

    horizontalLayout.setComponentAlignment(ackdImage, Alignment.TOP_RIGHT);
    horizontalLayout.setComponentAlignment(unackdImage, Alignment.TOP_RIGHT);

    horizontalLayout.setExpandRatio(labelx, 4.0f);
    horizontalLayout.setExpandRatio(ackdImage, 1.0f);
    horizontalLayout.setExpandRatio(unackdImage, 1.0f);
    horizontalLayout.setExpandRatio(dummyLabel, 1.0f);

    horizontalLayout.setWidth(375, Sizeable.Unit.PIXELS);

    return horizontalLayout;
}