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:org.vaadin.alump.offlinebuilder.demo.DemoUI.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {

    OfflineUIExtension offlineExtension = OfflineUIExtension.get(this);

    // As Panel is half legacy component, using OfflineCssLayout to make content scrollable
    OfflineCssLayout panel = new OfflineCssLayout();
    panel.addStyleName("scrollable-wrapper");
    panel.setSizeFull();// w  ww . ja va  2  s  .c  o m
    setContent(panel);
    offlineExtension.setOfflineRoot(panel);

    VerticalLayout layout = new OfflineVerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.addStyleName("main-layout");
    panel.addComponent(layout);

    Label header = new OfflineLabel("OfflineBuilder");
    header.addStyleName("header-label");
    layout.addComponent(header);

    Label info = new OfflineLabel("OfflineBuilder allows to define offline UI without need of writing GWT"
            + " code. Add-on offers offline extended versions of basic Vaadin UI components and layouts. This way"
            + " your server defined UI can be used on offline mode too.");
    info.addStyleName("info-label");
    layout.addComponent(info);

    info = new OfflineLabel(
            "To test offline functionality. Turn on flight mode on your device or just disconnect"
                    + " from your network connection. Offline UI should look identical with online UI.");
    info.addStyleName("info-label");
    layout.addComponent(info);

    Image image = new OfflineImage();
    image.setWidth("300px");
    image.addStyleName("extra-stylename-image");
    image.setSource(new ThemeResource("img/offline.png"));
    image.setDescription("Example image");
    layout.addComponent(image);

    HorizontalLayout buttonLayout = new OfflineHorizontalLayout();
    buttonLayout.setSpacing(true);
    layout.addComponent(buttonLayout);

    OfflineButton pingButton = new OfflineButton("Ping server");
    pingButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            Notification.show("Server says pong!");
        }
    });
    pingButton.setDescription("Button that will be automatically disabled on offline mode");
    buttonLayout.addComponent(pingButton);

    OfflineButton writeButton = new OfflineButton("Store value (TODO)");
    writeButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            Notification.show("No need to store, in online mode.");
        }
    });
    buttonLayout.addComponent(writeButton);

    /*
    OfflineFormLayout formTest = new OfflineFormLayout();
    OfflineCheckBox checkbox = new OfflineCheckBox("Flag me");
    checkbox.setOfflineValueKey("flag");
    formTest.addComponent(checkbox);
    layout.addComponent(formTest);
    */

    Link link = new OfflineLink("Open project's GitHub page",
            new ExternalResource("https://github.com/alump/OfflineBuilder"));
    link.addStyleName("github-link");
    layout.addComponent(link);
}

From source file:org.vaadin.presentation.views.NewsView.java

private Table createTable(IndexedContainer container) {
    Table table = new Table("Image Table", container);
    table.setSizeFull();// ww  w . ja  v a2s  .  c om
    table.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);

    table.addGeneratedColumn("image1", new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            Item item = source.getItem(itemId);
            Resource url = (Resource) item.getItemProperty("url1").getValue();
            String tags = (String) item.getItemProperty("tags1").getValue();
            int height = (Integer) item.getItemProperty("height").getValue();
            int width = (Integer) item.getItemProperty("width").getValue();
            Image enb = new Image("", url);
            enb.setWidth("320px");
            //                enb.setWidth(width, Unit.PIXELS);
            //                enb.setHeight(height, Unit.PIXELS);
            enb.addClickListener(new MouseEvents.ClickListener() {

                @Override
                public void click(MouseEvents.ClickEvent event) {
                    showNotify(url, tags);
                }
            });
            return enb;

        }

    });
    table.addGeneratedColumn("image2", new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            Item item = source.getItem(itemId);
            Resource url = (Resource) item.getItemProperty("url2").getValue();
            String tags = (String) item.getItemProperty("tags2").getValue();
            int height = (Integer) item.getItemProperty("height").getValue();
            int width = (Integer) item.getItemProperty("width").getValue();
            Image enb = new Image("", url);
            enb.setWidth("320px");
            //                enb.setHeight(height, Unit.PIXELS);
            enb.addClickListener(new MouseEvents.ClickListener() {

                @Override
                public void click(MouseEvents.ClickEvent event) {
                    showNotify(url, tags);
                }
            });
            return enb;

        }

    });
    table.addGeneratedColumn("image3", new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            Item item = source.getItem(itemId);
            Resource url = (Resource) item.getItemProperty("url3").getValue();
            String tags = (String) item.getItemProperty("tags3").getValue();
            int height = (Integer) item.getItemProperty("height").getValue();
            int width = (Integer) item.getItemProperty("width").getValue();
            Image enb = new Image("", url);
            enb.setWidth("320px");
            //                enb.setWidth(width, Unit.PIXELS);
            //                enb.setHeight(height, Unit.PIXELS);
            enb.addClickListener(new MouseEvents.ClickListener() {

                @Override
                public void click(MouseEvents.ClickEvent event) {
                    showNotify(url, tags);
                }
            });
            return enb;

        }

    });
    table.setColumnAlignment("image1", Table.Align.CENTER);
    table.setColumnAlignment("image2", Table.Align.CENTER);
    table.setColumnAlignment("image3", Table.Align.CENTER);

    table.setVisibleColumns(new Object[] { "image1", "image2", "image3" });
    //        table.setColumnExpandRatio("title", 1f);
    return table;
}

From source file:uicomponents.BarcodePreviewComponent.java

License:Open Source License

public BarcodePreviewComponent(SampleToBarcodeFieldTranslator translator) {
    this.translator = translator;
    setSpacing(true);// w w  w  . j  a  va 2  s.c om
    setMargin(true);

    Resource res = new ThemeResource("img/qrtest.png");
    Image qr = new Image(null, res);
    qr.setHeight("140px");
    qr.setWidth("140px");
    Image qr2 = new Image(null, res);
    qr2.setHeight("140px");
    qr2.setWidth("140px");

    code = new TextField();
    info1 = new TextField();
    info2 = new TextField();

    codedName = new OptionGroup("Put ID on sticker:");
    codedName.addItems(Arrays.asList("QBiC ID", "Lab ID", "Secondary Name"));
    codedName.setImmediate(true);
    codedName.addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
    codedName.select("QBiC ID");

    code.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    code.setWidth("200px");
    code.addStyleName("barcode-large");

    styleInfoField(info1);
    styleInfoField(info2);
    styleInfoField(qbicInfo);

    VerticalLayout box = new VerticalLayout();
    box.setHeight("110px");
    box.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    box.addComponent(code);
    box.addComponent(info1);
    box.addComponent(info2);
    box.addComponent(qbicInfo);
    box.setWidth("190px");

    HorizontalLayout test = new HorizontalLayout();
    test.setSizeFull();
    test.addComponent(qr);
    test.addComponent(box);
    test.addComponent(qr2);

    setFieldsReadOnly(true);
    List<String> options = new ArrayList<String>(Arrays.asList("Tissue/Extr. Material", "Secondary Name",
            "QBiC ID", "Lab ID", "MHC Type", "Used Antibody"));
    select1 = new ComboBox("First Info", options);
    select1.setStyleName(Styles.boxTheme);
    select1.setImmediate(true);
    select1.select("Tissue/Extr. Material");
    select2 = new ComboBox("Second Info", options);
    select2.select("Secondary Name");
    select2.setImmediate(true);
    select2.setStyleName(Styles.boxTheme);

    ValueChangeListener vc = new ValueChangeListener() {

        /**
         * 
         */
        private static final long serialVersionUID = -7466519211904860012L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            refresh();
        }
    };
    codedName.addValueChangeListener(vc);
    select1.addValueChangeListener(vc);
    select2.addValueChangeListener(vc);

    HorizontalLayout designBox = new HorizontalLayout();
    designBox.addComponent(select1);
    designBox.addComponent(select2);
    designBox.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
    designBox.setSpacing(true);

    VerticalLayout previewBox = new VerticalLayout();
    previewBox.setStyleName(ValoTheme.LAYOUT_CARD);
    previewBox.setCaption("Barcode Example");
    previewBox.addComponent(test);

    addComponent(previewBox);
    addComponent(codedName);
    addComponent(designBox);

    //    overwrite = new CheckBox("Overwrite existing Tube Barcode Files");
    //    addComponent(ProjectwizardUI.questionize(overwrite,
    //        "Overwrites existing files of barcode stickers. This is useful when "
    //            + "the design was changed after creating them.", "Overwrite Sticker Files"));
}

From source file:uk.co.intec.keyDatesApp.components.HeaderComponent.java

License:Apache License

/**
 * Constructor, passing the Vaadin application page
 *
 * @param ui//ww  w .j  a v a2 s .  co  m
 *            MainUI application page
 */
public HeaderComponent(MainUI ui) {
    setHeight("50px");
    setStyleName("header");

    final HorizontalLayout bannerArea = new HorizontalLayout();
    bannerArea.setStyleName("menuArea");
    bannerArea.setSizeFull();

    final ThemeResource resource = new ThemeResource("img/intec-logo.gif.png");
    final Image bannerImg = new Image();
    bannerImg.setAlternateText("Intec");
    bannerImg.setHeight("50px");
    bannerImg.setDescription("Intec Logo");
    bannerImg.setSource(resource);
    bannerImg.setWidth(null);
    bannerImg.setStyleName("bannerImg");

    setMenubar(new MenuBar());
    getMenubar().setStyleName(ValoTheme.MENU_SUBTITLE);
    getMenubar().addStyleName("valo-menu-subtitle-indent");
    getMenubar().setWidth(100, Unit.PERCENTAGE);

    if (!"Anonymous".equals(getUserName())) {
        final MenuItem logout = menubar.addItem("Logout", null);
        logout.setStyleName("menuRight");
    }

    final MenuItem userItem = menubar.addItem(getUserName(), null);
    userItem.setStyleName("menuRight");

    bannerArea.addComponents(bannerImg, menubar);
    bannerArea.setExpandRatio(menubar, 1);
    addComponent(bannerArea);
    setExpandRatio(bannerArea, 1);
    setSizeFull();
}