Example usage for com.vaadin.ui CssLayout setHeight

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

Introduction

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

Prototype

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

Source Link

Usage

From source file:net.pkhsolutions.pecsapp.ui.components.PagePanel.java

License:Open Source License

private void updateLayout(Property.ValueChangeEvent event) {
    final PageLayout layout = Objects.requireNonNull(model.getLayout().getValue());
    if (layout.getOrientation().equals(PageOrientation.PORTRAIT)) {
        page.setWidth(layout.getPageSize().getWidthMm(), Unit.MM);
        page.setHeight(layout.getPageSize().getHeightMm(), Unit.MM);
    } else {/*w  w  w . j a v  a 2 s  .c o m*/
        page.setWidth(layout.getPageSize().getHeightMm(), Unit.MM);
        page.setHeight(layout.getPageSize().getWidthMm(), Unit.MM);
    }
    page.removeAllComponents();
    final float rowHeight = page.getHeight() / layout.getRows();
    final float cellWidth = page.getWidth() / layout.getColumns();
    rows = new CssLayout[layout.getRows()];
    cells = new PictureLayout[layout.getRows()][layout.getColumns()];
    for (int i = 0; i < layout.getRows(); ++i) {
        CssLayout row = new CssLayout();
        row.addStyleName("page-row");
        row.setWidth("100%");
        row.setHeight(rowHeight, page.getHeightUnits());
        page.addComponent(row);
        rows[i] = row;
        for (int j = 0; j < layout.getColumns(); ++j) {
            PictureLayout cell = new PictureLayout(model.getPictureModel(j, i));
            cell.addStyleName("page-row-cell");
            cell.setWidth(cellWidth, page.getWidthUnits());
            cell.setHeight("100%");
            row.addComponent(cell);
            cells[i][j] = cell;
        }
    }
}

From source file:org.activiti.explorer.ui.custom.TaskListHeader.java

License:Apache License

protected void initInputField() {
    // Csslayout is used to style inputtext as rounded
    CssLayout csslayout = new CssLayout();
    csslayout.setHeight(24, UNITS_PIXELS);
    csslayout.setWidth(100, UNITS_PERCENTAGE);
    layout.addComponent(csslayout);/* w w w . java  2  s  .co m*/

    inputField = new TextField();
    inputField.setWidth(100, UNITS_PERCENTAGE);
    inputField.addStyleName(ExplorerLayout.STYLE_SEARCHBOX);
    inputField.setInputPrompt(i18nManager.getMessage(Messages.TASK_CREATE_NEW));
    inputField.focus();
    csslayout.addComponent(inputField);

    layout.setComponentAlignment(csslayout, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(csslayout, 1.0f);
}

From source file:org.vaadin.alump.scaleimage.demo.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    VerticalLayout layout = new VerticalLayout();
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setMargin(true);//from w ww .jav a2s  .c o m
    layout.setSpacing(true);
    setContent(layout);

    // Big image that will scale to match with your page width, will
    // show the center of given picture. See SCSS file.
    ScaleImage bigCenterImage = new ScaleImage();
    bigCenterImage.setWidth("100%");
    bigCenterImage.setHeight("200px");
    bigCenterImage.setStyleName("big-center-image");
    bigCenterImage.setSource(new ThemeResource("images/big-center-image.jpg"));
    bigCenterImage.addClickListener(new MouseEvents.ClickListener() {
        @Override
        public void click(MouseEvents.ClickEvent clickEvent) {
            Notification.show("Big center image clicked!");
        }
    });
    layout.addComponent(bigCenterImage);

    // Tile with image, where images will be scaled to match with tile size.
    // tileimage will cover space of tile and indicator image will be at
    // top left corner.
    // Uses absolute left/right/top/down positioning. See SCSS file.
    final CssLayout tile = new CssLayout();
    tile.setStyleName("tile");
    tile.setWidth(100, Unit.PIXELS);
    tile.setHeight(100, Unit.PIXELS);
    layout.addComponent(tile);
    tile.addLayoutClickListener(new LayoutClickListener() {

        @Override
        public void layoutClick(LayoutClickEvent event) {
            int size = (int) Math.round(100.0 + Math.random() * 100.0);
            tile.setWidth(size, Unit.PIXELS);
            tile.setHeight(size, Unit.PIXELS);
        }

    });

    ScaleImage tileImage = new ScaleImage();
    tileImage.setSource(new ThemeResource("images/tile-image.jpg"));
    tileImage.setStyleName("tile-image");
    tile.addComponent(tileImage);
    ScaleImage indicatorImage = new ScaleImage();
    indicatorImage.setSource(new ThemeResource("images/tile-indicator.png"));
    indicatorImage.setStyleName("tile-indicator");
    tile.addComponent(indicatorImage);
    Label tileLabel = new Label("Click tile to scale it.");
    tile.addComponent(tileLabel);

    extendedImage = new ExtendedScaleImage();
    extendedImage.setSource(new ThemeResource("images/tile-indicator.png"));
    extendedImage.setWidth("200px");
    extendedImage.setHeight("400px");
    extendedImage.setStyleName("extended-image");
    layout.addComponent(extendedImage);

    Button moveButton = new Button("Move background", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Boolean val = extendedImage.getPosition();
            if (val == null) {
                val = true;
            }

            extendedImage.setPosition(!val.booleanValue());

        }
    });
    layout.addComponent(moveButton);

    // Test how well scale image behaves inside alignment layout

    HorizontalLayout alignLayout = new HorizontalLayout();
    alignLayout.setSpacing(true);
    alignLayout.setWidth("200px");
    layout.addComponent(alignLayout);

    Label label = new Label("Alignment test:");
    label.addStyleName("align-label");
    alignLayout.addComponent(label);
    alignLayout.setExpandRatio(label, 1.0f);
    alignLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);

    ScaleImage alignImage = new ScaleImage();
    alignImage.setSource(new ThemeResource("images/tile-image.jpg"));
    alignImage.setWidth("20px");
    alignImage.setHeight("20px");
    alignLayout.addComponent(alignImage);
    alignLayout.setComponentAlignment(alignImage, Alignment.BOTTOM_CENTER);
}