Java 类com.vaadin.ui.Image 实例源码

项目:svgexamples    文件:SimplyAsAnImageOrIcon.java   
public SimplyAsAnImageOrIcon() {
    setCaption("Image and icon");
    addComponent(new MLabel("Following Image component (rendered as IMG element) contains SVG image. Note, that by using SVG in this way, it is treated as a static image. For eample the js changing the color on click is not executed. See the file example to see how to render an interactive SVG.").withFullWidth());
    Image image = new Image(null, new ClassResource("/pull.svg"));
    image.setWidth("300px");
    addComponent(image);

    addComponent(new MLabel("Following Button has SVG logo as an icon.").withFullWidth());

    Button button = new Button();
    button.setIcon(new ClassResource("/vaadin-logo.svg"));
    button.addStyleNames(ValoTheme.BUTTON_ICON_ONLY, ValoTheme.BUTTON_HUGE);
    addComponent(button);
}
项目:esup-ecandidat    文件:CtrCandFormationView.java   
/**
 * @param txtCode
 * @return une ligne de légende
 */
private HorizontalLayout getLegendLineLayout(String txtCode) {
    HorizontalLayout hlLineLegend = new HorizontalLayout();
    hlLineLegend.setWidth(100, Unit.PERCENTAGE);
    hlLineLegend.setSpacing(true);

    Image flagImg = new Image(null, new ThemeResource("images/icon/Flag-" + txtCode + "-icon.png"));
    Label label = new Label(applicationContext.getMessage("formation.table.flagEtat.tooltip." + txtCode, null,
            UI.getCurrent().getLocale()));
    hlLineLegend.addComponent(flagImg);
    hlLineLegend.setComponentAlignment(flagImg, Alignment.MIDDLE_LEFT);
    hlLineLegend.addComponent(label);
    hlLineLegend.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
    hlLineLegend.setExpandRatio(label, 1);
    return hlLineLegend;
}
项目:vaadin-vertx-samples    文件:MovieDetailsWindow.java   
private Component buildMovieDetails(final Movie movie,
        final Date startTime, final Date endTime) {
    HorizontalLayout details = new HorizontalLayout();
    details.setWidth(100.0f, Unit.PERCENTAGE);
    details.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
    details.setMargin(true);
    details.setSpacing(true);

    final Image coverImage = new Image(null, new ExternalResource(
            movie.getThumbUrl()));
    coverImage.addStyleName("cover");
    details.addComponent(coverImage);

    Component detailsForm = buildDetailsForm(movie, startTime, endTime);
    details.addComponent(detailsForm);
    details.setExpandRatio(detailsForm, 1);

    return details;
}
项目:dungeonstory-java    文件:ImageSelector.java   
public ImageSelector() {
    images = new LinkedList<DSImage>();
    visibleImages = new HashMap<Integer, Image>();
    loadedImages = new LinkedList<Image>();

    mainPanel = new Panel();
    imageLayout = new HorizontalLayout();
    layout = new HorizontalLayout();

    imageMaxWidth = 110;
    imageMaxHeight = 110;

    leftButton = new Button("<", e -> scrollLeft());
    rightButton = new Button(">", e -> scrollRight());
    leftButton.setEnabled(false);
    rightButton.setEnabled(false);
}
项目:dungeonstory-java    文件:ImageSelector.java   
public void scrollTo(int index) {
    if (index >= 0 && maxAllowed > 0) {
        visibleImages.clear();
        imageLayout.removeAllComponents();

        if (index > (loadedImages.size() - maxAllowed)) {
            index = loadedImages.size() - maxAllowed;
        }

        for (int i = index; i < (index + maxAllowed); i++) {
            Image image = loadedImages.get(i);
            addVisibleImage(i, image);
            imageLayout.addComponent(image);
        }

        this.index = index;
    }
}
项目:componentrenderer    文件:CustomerDetailsGenerator.java   
@Override
public Component getDetails(Grid.RowReference rowReference) {
    rowReference.getGrid().scrollTo(rowReference.getItemId());
    Customer customer = (Customer)rowReference.getItemId();

    HorizontalLayout layout = new HorizontalLayout();
    layout.setHeight(300, Sizeable.Unit.PIXELS);
    layout.setMargin(true);
    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;
}
项目:componentrenderer    文件:StaticCustomerDetailsGenerator.java   
@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);
    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;
}
项目:sensorhub    文件:AdminUI.java   
protected Component buildHeader()
{
    HorizontalLayout header = new HorizontalLayout();
    header.setMargin(false);
    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;
}
项目:root    文件:WoundSelector.java   
public void addWoundAtPosition(WoundPosition woundPosition) {
    if (!markedWounds.containsKey(woundPosition)) {

        Image image = getImage(WOUND_INDICATOR);

        if (woundManager.getWoundAtWoundPosition(woundPosition).getEndDate() != null) {
            image = getImage(WOUND_HEALED_INDICATOR);
        }

        image.addClickListener(woundClickListener);
        image.setDescription(woundPosition.getDescription());
        image.setAlternateText(woundPosition.getDescription());

        // Removing half the size of the indicator to put the click position in the middle of the indicator
        float correctedXPos = (float) scaleFactor*(woundPosition.getXPosition() - (image.getWidth() / 2));
        float correctedYPos = (float) scaleFactor*(woundPosition.getYPosition() - (image.getHeight() / 2));

        ComponentPosition imagePosition = new ComponentPosition();
        imagePosition.setLeft((float)correctedXPos, Unit.PIXELS);
        imagePosition.setTop((float)correctedYPos, Unit.PIXELS);
        image.setData(woundPosition);

        markedWounds.put(woundPosition, image);
        addComponent(image);
        setPosition(image, imagePosition);
    }
}
项目:mycollab    文件:AboutWindow.java   
public AboutWindow() {

        MHorizontalLayout content = new MHorizontalLayout().withMargin(true).withFullWidth();
        this.setContent(content);

        Image about = new Image("", new ExternalResource(StorageUtils.generateAssetRelativeLink(WebResourceIds._about)));
        MVerticalLayout rightPanel = new MVerticalLayout();
        ELabel versionLbl = ELabel.h2(String.format("MyCollab Community Edition %s", Version.getVersion()));
        Label javaNameLbl = new Label(String.format("%s, %s", System.getProperty("java.vm.name"),
                System.getProperty("java.runtime.version")));
        Label homeFolderLbl = new Label("Home folder: " + FileUtils.getHomeFolder().getAbsolutePath());
        WebBrowser browser = Page.getCurrent().getWebBrowser();
        Label osLbl = new Label(String.format("%s, %s", System.getProperty("os.name"),
                browser.getBrowserApplication()));
        osLbl.addStyleName(UIConstants.LABEL_WORD_WRAP);
        Div licenseDiv = new Div().appendChild(new Text("Powered by: "))
                .appendChild(new A("https://www.mycollab.com")
                        .appendText("MyCollab")).appendChild(new Text(". Open source under GPL license"));
        Label licenseLbl = ELabel.html(licenseDiv.write());
        Label copyRightLbl = ELabel.html(String.format("&copy; %s - %s MyCollab Ltd. All rights reserved", "2011",
                new GregorianCalendar().get(Calendar.YEAR) + ""));
        rightPanel.with(versionLbl, javaNameLbl, osLbl, homeFolderLbl, licenseLbl, copyRightLbl)
                .withAlign(copyRightLbl, Alignment.BOTTOM_LEFT);
        content.with(about, rightPanel).expand(rightPanel);
    }
项目:mycollab    文件:AttachmentPreviewView.java   
public AttachmentPreviewView() {
    CssLayout imgWrap = new CssLayout();
    imgWrap.setStyleName("image-wrap");
    imgWrap.setSizeFull();

    this.setStyleName("attachment-preview-view");
    this.setSizeFull();
    this.addComponent(imgWrap, "top: 0px left: 0px; z-index: 0;");

    backBtn = new NavigationButton(UserUIContext.getMessage(GenericI18Enum.M_BUTTON_BACK));
    backBtn.setStyleName("back-btn");

    this.addComponent(backBtn, "top: 15px; left: 15px; z-index: 1;");

    previewImage = new Image();
    imgWrap.addComponent(previewImage);
}
项目:scoutmaster    文件:SchoolView.java   
private Image createEmailIcon(EmailContact emailContact)
{
    final String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
    final FileResource resource = new FileResource(new File(basepath + "/images/email.png"));

    Image image = new Image(null, resource);
    image.setDescription("Click to send an email");
    image.setVisible(false);

    image.addClickListener(new MouseEventLogged.ClickListener()
    {
        private static final long serialVersionUID = 1L;

        @Override
        public void clicked(final com.vaadin.event.MouseEvents.ClickEvent event)
        {
            showMailForm(emailContact);

        }
    });

    return image;
}
项目:own-music-cloud    文件:AboutView.java   
public AboutView() {
    setCaption(Messages.getString("aboutTitle")); //$NON-NLS-1$
    setModal(true);
    setResizable(false);
    center();
    VerticalLayout main = new VerticalLayout();
    Resource logoResource = new ThemeResource("img/omc-logo.png"); //$NON-NLS-1$
    Image appLogoImage = new Image("",logoResource); //$NON-NLS-1$
    Label appLabel = new Label(appName + " v." + version); //$NON-NLS-1$
    Label developerLabel = new Label(developer);
    Link githubLink = new Link(github, new ExternalResource(github));

    main.addComponents(appLogoImage, appLabel, developerLabel, githubLink);
    main.setComponentAlignment(appLabel, Alignment.MIDDLE_CENTER);
    main.setComponentAlignment(developerLabel, Alignment.MIDDLE_CENTER);
    main.setComponentAlignment(githubLink, Alignment.MIDDLE_CENTER);

    setContent(main);
}
项目:material-theme-fw8    文件:NavigationItem.java   
public void setIcon(Resource source) {
    if (source == null) {
        this.icon.setVisible(false);
    } else {
        this.icon.setVisible(true);
        this.icon.removeAllComponents();
        if (source instanceof FontIcon) {
            this.icon.addComponent(new Label(((FontIcon) source).getHtml(), ContentMode.HTML));
        } else {
            this.icon.addComponent(new Image(null, source));
        }
    }
}
项目:garantia    文件:DefaultView.java   
@PostConstruct
void init() {
    VerticalLayout encabezado = new VerticalLayout();
    encabezado.setSizeUndefined();

    Image logo = new Image(null,
            new ThemeResource("img/Header2.jpg"));

    encabezado.addComponent(logo);
    encabezado.setComponentAlignment(logo, Alignment.TOP_LEFT);

    addComponent(encabezado);
    setComponentAlignment(encabezado, Alignment.TOP_LEFT);

    contenedor.setSpacing(true);
    contenedor.setSizeUndefined();
    contenedor.setMargin(true);

    contenedor.addComponent(txtUsuario, 1, 1);
    contenedor.addComponent(txtPassword, 1, 2);

    errorIngreso.setVisible(false);

    contenedor.addComponent(errorIngreso, 1, 3);

    btnIngresar.setImmediate(true);
    btnIngresar.setClickShortcut(KeyCode.ENTER);
    btnIngresar.setIcon(FontAwesome.SIGN_IN);

    contenedor.addComponent(btnIngresar, 1, 4);
    contenedor.setComponentAlignment(btnIngresar, Alignment.BOTTOM_CENTER);

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


    setListener();
}
项目:vaadin-vertx-samples    文件:ScheduleView.java   
private Component buildCatalogView() {
    CssLayout catalog = new CssLayout();
    catalog.setCaption("Catalog");
    catalog.addStyleName("catalog");

    for (final Movie movie : DashboardUI.getDataProvider().getMovies()) {
        VerticalLayout frame = new VerticalLayout();
        frame.addStyleName("frame");
        frame.setWidthUndefined();

        Image poster = new Image(null, new ExternalResource(
                movie.getThumbUrl()));
        poster.setWidth(100.0f, Unit.PIXELS);
        poster.setHeight(145.0f, Unit.PIXELS);
        frame.addComponent(poster);

        Label titleLabel = new Label(movie.getTitle());
        titleLabel.setWidth(120.0f, Unit.PIXELS);
        frame.addComponent(titleLabel);

        frame.addLayoutClickListener(new LayoutClickListener() {
            @Override
            public void layoutClick(final LayoutClickEvent event) {
                if (event.getButton() == MouseButton.LEFT) {
                    MovieDetailsWindow.open(movie, null, null);
                }
            }
        });
        catalog.addComponent(frame);
    }
    return catalog;
}
项目:dungeonstory-java    文件:SummaryStep.java   
private void showCharacterInfo() {

        Messages messages = Messages.getInstance();
        Character character = wizard.getCharacter();

        if (character.getId() == null) {
            FormLayout infoLayout = new FFormLayout().withMargin(true);
            Panel infoPanel = new Panel(messages.getMessage("summaryStep.info.label"), infoLayout);
            layout.addComponent(infoPanel);

            File imageFile = new File(DSConstant.getImageDir() + character.getImage());
            FileResource resource = new FileResource(imageFile);
            Image image = new Image("Image", resource);
            DSLabel nameLabel = new DSLabel(messages.getMessage("summaryStep.name.label"), character.getName());
            DSLabel genderLabel = new DSLabel(messages.getMessage("summaryStep.sex.label"), character.getGender().toString());
            DSLabel ageLabel = new DSLabel(messages.getMessage("summaryStep.age.label"), String.valueOf(character.getAge()));
            DSLabel weightLabel = new DSLabel(messages.getMessage("summaryStep.weight.label"), character.getWeight() + " lbs");
            DSLabel heightLabel = new DSLabel(messages.getMessage("summaryStep.height.label"), character.getHeight());
            DSLabel alignmentLabel = new DSLabel(messages.getMessage("summaryStep.alignment.label"),
                    character.getAlignment().toString());
            DSLabel regionLabel = new DSLabel(messages.getMessage("summaryStep.region.label"), character.getRegion().toString());
            DSLabel backgroundLabel = new DSLabel(messages.getMessage("summaryStep.background.label"),
                    character.getBackground().getBackground().toString());
            DSLabel goldLabel = new DSLabel(messages.getMessage("summaryStep.startingGold.label"), character.getGold());
            infoLayout.addComponents(image, nameLabel, genderLabel, ageLabel, weightLabel, heightLabel, alignmentLabel,
                    regionLabel, backgroundLabel, goldLabel);
        }
    }
项目:dungeonstory-java    文件:ImageSelector.java   
public void addImage(DSImage image) {
        image.setIndex(images.size());
        images.add(image);
        Image loadedImage = new Image();
        loadedImage.setSource(image.getResource());

        if (loadedImage.getWidth() > imageMaxWidth) {
            loadedImage.setWidth(imageMaxWidth, Unit.PIXELS);
        }
        if (loadedImage.getHeight() > imageMaxHeight) {
            loadedImage.setHeight(imageMaxHeight, Unit.PIXELS);
        }

        loadedImage.setData(image.getIndex());
        loadedImage.addClickListener(event -> {
            if (isSelectable()) {
                DSImage clicked = images.get((int) loadedImage.getData());
//                Notification.show(selectedImage.toString(), Type.HUMANIZED_MESSAGE);
                setValue(clicked);
            }
        });
        loadedImages.add(loadedImage);

        if (visibleImages.size() < maxAllowed || maxAllowed < 0) {
            addVisibleImage(image.getIndex(), loadedImage);
        }
    }
项目:dungeonstory-java    文件:ImageSelector.java   
public void scrollRight() {
    if (index < (loadedImages.size() - maxAllowed)) {
        //remove first image
        Image removedImage = getVisibleImage(index);
        imageLayout.removeComponent(removedImage);
        visibleImages.remove(removedImage.getData());

        //            CssAnimation translate = new CssAnimation(removedImage, new Css().translateX("-150px")).duration(500);
        //            CssAnimation opacity = new CssAnimation(removedImage, new Css().opacity(0)).duration(500);
        //            Animator.animate(translate.sendEndEvent());
        //            Animator.animate(opacity);

        //                        animator.addListener(endEvent -> {
        //                            CssAnimation animation = endEvent.getAnimation();
        //                            if (animation.equals(translate)) {
        //                                imageLayout.removeComponent(removedImage);
        //                                visibleImages.remove(removedImage.getData());
        //                            }
        //                        });

        //            for (Image image : visibleImages.values()) {
        //                Animator.animate(image, new Css().translateX("-150px")).duration(500);
        //            }

        //add the next image
        Image addedImage = loadedImages.get(index + maxAllowed);
        addVisibleImage((Integer) addedImage.getData(), addedImage);
        index++;
    }
}
项目:dungeonstory-java    文件:ImageSelector.java   
public void scrollLeft() {
    if (index > 0) {
        //remove last image
        Image removedImage = getVisibleImage(index + maxAllowed - 1);
        imageLayout.removeComponent(removedImage);
        visibleImages.remove(removedImage.getData());

        //add previous image
        Image addedImage = loadedImages.get(index - 1);
        addVisibleImage((Integer) addedImage.getData(), addedImage, true);
        index--;
    }
}
项目:dungeonstory-java    文件:ImageSelector.java   
private void addVisibleImage(Integer key, Image image, boolean first) {
    visibleImages.put(key, image);
    if (first) {
        imageLayout.addComponentAsFirst(image);
    } else {
        imageLayout.addComponent(image);
    }
}
项目:dungeonstory-java    文件:ImageSelector.java   
@Override
protected void doSetValue(DSImage value) {
    if (isSelectable()) {
        visibleImages.values().stream().forEach(image -> image.removeStyleName("image-bordered-selected"));
        if (value != null) {
            Image selected = loadedImages.get(value.getIndex());
            selected.addStyleName("image-bordered-selected");
        }
        selectedImage = value;
    }

}
项目:freemarker-layout    文件:ProductsTable.java   
private void showDetails(Product product) {
    FreemarkerLayout productLayout = new FreemarkerLayout();
    productLayout.setTemplateFileName("templates/product-details.html");
    productLayout.setDataModel(product);
    productLayout.addComponent(new Image(null, new ClassResource(product.getImage())), "image");

    Window window = new Window("Details", productLayout);
    window.setModal(true);
    window.setResizable(false);
    UI.getCurrent().addWindow(window);
}
项目:hybridbpm    文件:UsersMenu.java   
@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
    User user = (User) itemId;
    Image image = new Image();
    image.addStyleName("users-menu-image");
    if (user.getImage() != null) {
        StreamResource.StreamSource imagesource = new UserImageSource(user.getImage().toStream());
        StreamResource resource = new StreamResource(imagesource, UUID.randomUUID().toString());
        image.setSource(resource);
    } else {
        image.setSource(new ThemeResource("img/profile-pic-300px.jpg"));
    }

    ValoUserItemButton btnUsername = new ValoUserItemButton(user, ValoUserItemButton.TYPE.USER_NAME);
    ValoUserItemButton btnFullName = new ValoUserItemButton(user, ValoUserItemButton.TYPE.FULL_NAME);

    VerticalLayout nameLayout = new VerticalLayout(btnFullName, btnUsername);
    nameLayout.setSizeFull();
    nameLayout.setComponentAlignment(btnFullName, Alignment.BOTTOM_LEFT);
    nameLayout.setComponentAlignment(btnUsername, Alignment.TOP_LEFT);

    HorizontalLayout usersHorizontalLayout = new HorizontalLayout(image, nameLayout);
    usersHorizontalLayout.setComponentAlignment(image, Alignment.MIDDLE_CENTER);
    usersHorizontalLayout.setComponentAlignment(nameLayout, Alignment.MIDDLE_LEFT);
    usersHorizontalLayout.setExpandRatio(nameLayout, 1f);
    usersHorizontalLayout.addStyleName("users-horizontal-layout");
    usersHorizontalLayout.setWidth(100, Unit.PERCENTAGE);
    usersHorizontalLayout.setHeight(45, Unit.PIXELS);
    usersHorizontalLayout.setSpacing(true);

    return usersHorizontalLayout;
}
项目:componentrenderer    文件:ViewComponents.java   
public static Image createDetailsIcons(Grid grid, Customer customer) {
    final Image imageDown = new Image("", new ThemeResource("../demotheme/img/caret-down.png"));
    final Image imageUp = new Image("", new ThemeResource("../demotheme/img/caret-up.png"));
    imageDown.setCaption(null);
    imageDown.setHeight(32, Sizeable.Unit.PIXELS);
    imageDown.setWidth(32, Sizeable.Unit.PIXELS);
    imageUp.setCaption(null);
    imageUp.setHeight(32, Sizeable.Unit.PIXELS);
    imageDown.setWidth(32, Sizeable.Unit.PIXELS);

    imageDown.addShortcutListener(new ShortcutListener("enter", ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            if (sender == imageDown || sender == imageUp) {
                Notification.show("Shortcut captured");
                grid.setDetailsVisible(customer, !grid.isDetailsVisible(customer));
            }
        }
    });
    imageDown.addClickListener(event -> grid.setDetailsVisible(customer, true));
    imageUp.addClickListener(event -> grid.setDetailsVisible(customer, false));

    if (grid.isDetailsVisible(customer)) {
        return imageUp;
    } else {
        return imageDown;
    }
}
项目:root    文件:WoundSelector.java   
public WoundSelector(WoundManager woundManager, Sex sex, float scaleFactor) {
    this.woundManager = woundManager;
    this.scaleFactor = scaleFactor;

    Image backgroundImage;

    this.sex = (sex != null) ? sex : Sex.NEUTER;
    if (sex == Sex.FEMALE)
        backgroundImage = getImage(BODY_IMAGE_FEMALE);
    else if (sex == Sex.MALE)
        backgroundImage = getImage(BODY_IMAGE_MALE);
    else 
        backgroundImage = getImage(BODY_IMAGE);

    backgroundImage.addClickListener(this);

    selectionIndicator = getImage(SELECTION_INDICATOR);
    selectionIndicator.setVisible(false);

    selectedWoundIndicator = getImage(WOUND_SELECTION_INDICATOR);
    selectedWoundIndicator.setVisible(false);

    selctedWoundHealedIndicator = getImage(WOUND_HEALED_INDICATOR);
    selctedWoundHealedIndicator.setVisible(false); 

    addComponents(backgroundImage, 
            selectionIndicator, selectedWoundIndicator, selctedWoundHealedIndicator);

    setWidth(backgroundImage.getWidth(), Unit.PIXELS);
    setHeight(backgroundImage.getHeight(), Unit.PIXELS);
}
项目:root    文件:WoundSelector.java   
private Image getImage(String imageFilename) {
    String basePath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
    String filePath = basePath + "/" + imageFilename;
    File imageFile = new File(filePath);
    BufferedImage bufferedImage;
    Image image = new Image(null, new FileResource(imageFile));

    if (imageFilename == BODY_IMAGE || imageFilename == BODY_IMAGE_FEMALE || imageFilename == BODY_IMAGE_MALE) {
        image.setHeight(Math.round(scaleFactor*BODY_IMAGE_HEIGHT), Unit.PIXELS);
        image.setWidth(Math.round(scaleFactor*BODY_IMAGE_WIDTH), Unit.PIXELS);
    }
    else if (imageFilename == SELECTION_INDICATOR 
                || imageFilename == WOUND_INDICATOR
                || imageFilename == WOUND_HEALED_INDICATOR
                || imageFilename == WOUND_SELECTION_INDICATOR) {
        image.setHeight(Math.round(scaleFactor*INDICATOR_HEIGHT), Unit.PIXELS);
        image.setWidth(Math.round(scaleFactor*INDICATOR_WIDTH), Unit.PIXELS);
    }
    else {
        // We need to load the image and get the size since Vaadin Touchkit cannot read the size itself
        try {
            bufferedImage = ImageIO.read(imageFile);
            image.setHeight(Math.round(scaleFactor*bufferedImage.getHeight()), Unit.PIXELS);
            image.setWidth(Math.round(scaleFactor*bufferedImage.getWidth()), Unit.PIXELS);
        } catch (IOException e) {
            // we fail silently and let Vaadin use autosizing
        }
    }

    return image;
}
项目:root    文件:WoundSelector.java   
@Override
public void click(ClickEvent event) {
    Object sourceData = ((Image)event.getSource()).getData();
    if (sourceData != null) {
        WoundPosition woundPosition = (WoundPosition)sourceData;
        selectedWoundPosition = woundPosition;
        existingWoundSelected = true;

        woundManager.setSelectedWoundPosition(selectedWoundPosition);

        refreshSelectedWound();
    }
}
项目:root    文件:WoundSelector.java   
public void removeWoundAtPosition(WoundPosition woundPosition) {
    if (markedWounds.containsKey(woundPosition)) {
        Image image = markedWounds.get(woundPosition);
        markedWounds.remove(woundPosition);
        removeComponent(image);
    }
}
项目:vexer    文件:TemplateSubmissionStatisticsGiver.java   
@Override
public Component getMinifiedView() {
    Image img = new Image();
    img.setSource(getFilterIcon());
    img.setDescription(getFilterStateDesc());

    return img;
}
项目:vexer    文件:TemplateExecutor.java   
private void doLayout(TemplateExerciseData exerciseData, String oldAnswer) {
    if (exerciseData.getImgFile() != null) {
        exerLayout.addComponent(new Image(null, exerciseData.getImgFile()
                .getAsResource()));
    }
    exerLayout.addComponent(new Label(exerciseData.getQuestion()));
    answerField.setValue(oldAnswer);
    exerLayout.addComponent(answerField);
}
项目:vexer    文件:StatSubmInfoFilterEditor.java   
@Override
public Component getMinifiedView() {
    Image img = new Image();
    img.setSource(getFilterIcon());
    img.setDescription(getFilterStateDesc());

    return img;
}
项目:vexer    文件:StatSubmInfoFilterEditor.java   
@Override
public Component getMinifiedView() {
    Image img = new Image();
    img.setSource(getFilterIcon());
    img.setDescription(getFilterStateDesc());

    return img;

}
项目:vexer    文件:StatSubmInfoFilterEditor.java   
@Override
public Component getMinifiedView() {
    Image img = new Image();
    img.setSource(getFilterIcon());
    img.setDescription(getFilterStateDesc());

    return img;

}
项目:mycollab    文件:ProjectMemberListDisplay.java   
@Override
public Component generateRow(IBeanList<SimpleProjectMember> host, final SimpleProjectMember member, int
        rowIndex) {
    MHorizontalLayout mainLayout = new MHorizontalLayout().withMargin(true).withFullWidth();
    Image memberAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getMemberAvatarId(), 48);
    memberAvatar.addStyleName(UIConstants.CIRCLE_BOX);

    MVerticalLayout memberInfoLayout = new MVerticalLayout().withMargin(false);
    mainLayout.with(memberAvatar, memberInfoLayout).expand(memberInfoLayout);

    A memberLink = new A(ProjectLinkGenerator.generateProjectMemberLink(CurrentProjectVariables
            .getProjectId(), member.getUsername())).appendText(member.getDisplayName());
    Label memberLbl = ELabel.html(memberLink.write()).withStyleName(UIConstants.TEXT_ELLIPSIS);
    memberInfoLayout.addComponent(memberLbl);

    if (Boolean.TRUE.equals(AppUI.getBillingAccount().getDisplayemailpublicly())) {
        Label memberEmailLabel = ELabel.html(String.format("<a href='mailto:%s'>%s</a>", member.getUsername(), member.getUsername()))
                .withStyleName(UIConstants.META_INFO);
        memberInfoLayout.addComponent(memberEmailLabel);
    }

    ELabel memberSinceLabel = ELabel.html(UserUIContext.getMessage(UserI18nEnum.OPT_MEMBER_SINCE, UserUIContext.formatPrettyTime(member.getJoindate())))
            .withDescription(UserUIContext.formatDateTime(member.getJoindate())).withStyleName(UIConstants.META_INFO);
    memberInfoLayout.addComponent(memberSinceLabel);

    ELabel lastAccessTimeLbl = ELabel.html(UserUIContext.getMessage(UserI18nEnum.OPT_MEMBER_LOGGED_IN,
            UserUIContext.formatPrettyTime(member.getLastAccessTime())))
            .withDescription(UserUIContext.formatDateTime(member.getLastAccessTime())).withStyleName(UIConstants.META_INFO);
    memberInfoLayout.addComponent(lastAccessTimeLbl);

    String memberWorksInfo = String.format("%s %s  %s %s  %s %s  %s %s", ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK).getHtml(), new Span().appendText("" + member.getNumOpenTasks()).setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_TASKS)), ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG).getHtml(), new Span().appendText("" + member.getNumOpenBugs())
            .setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_BUGS)), FontAwesome.MONEY.getHtml(), new Span().appendText("" + NumberUtils.roundDouble(2,
            member.getTotalBillableLogTime())).setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS)), FontAwesome.GIFT.getHtml(), new Span().appendText("" + NumberUtils.roundDouble(2, member.getTotalNonBillableLogTime()))
            .setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS)));

    Label memberWorkStatus = ELabel.html(memberWorksInfo).withStyleName(UIConstants.META_INFO).withFullWidth();
    memberInfoLayout.addComponent(new MCssLayout(memberWorkStatus).withFullWidth());

    return mainLayout;
}
项目:mycollab    文件:ProjectMembersWidget.java   
@Override
public Component generateRow(IBeanList<SimpleProjectMember> host, SimpleProjectMember member, int rowIndex) {
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withStyleName("list-row");
    Image userAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getMemberAvatarId(), 48);
    userAvatar.addStyleName(UIConstants.CIRCLE_BOX);
    layout.addComponent(userAvatar);

    VerticalLayout content = new VerticalLayout();
    content.addComponent(new ELabel(buildAssigneeValue(member), ContentMode.HTML).withStyleName(UIConstants.TEXT_ELLIPSIS));
    layout.with(content).expand(content);

    CssLayout footer = new CssLayout();

    String roleVal;
    if (member.isProjectOwner()) {
        roleVal = UserUIContext.getMessage(ProjectRoleI18nEnum.OPT_ADMIN_ROLE_DISPLAY);
    } else {
        roleVal = member.getRoleName();
    }
    ELabel memberRole = ELabel.html(roleVal).withDescription(UserUIContext.getMessage(ProjectRoleI18nEnum.SINGLE))
            .withStyleName(UIConstants.META_INFO);
    footer.addComponent(memberRole);

    String memberWorksInfo = ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK).getHtml() + "&nbsp;" +
            new Span().appendText("" + member.getNumOpenTasks()).setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_TASKS)) +
            "&nbsp;&nbsp;" +
            ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG).getHtml() + "&nbsp;" +
            new Span().appendText("" + member.getNumOpenBugs()).setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_BUGS)) + "&nbsp;&nbsp;"
            + FontAwesome.MONEY.getHtml() + "&nbsp;" + new Span().appendText("" + NumberUtils.roundDouble(2,
            member.getTotalBillableLogTime())).setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS)) + "&nbsp;&nbsp;" +
            FontAwesome.GIFT.getHtml() +
            "&nbsp;" + new Span().appendText("" + NumberUtils.roundDouble(2, member.getTotalNonBillableLogTime()))
            .setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS));

    ELabel memberWorkStatus = ELabel.html(memberWorksInfo).withStyleName(UIConstants.META_INFO);
    footer.addComponent(memberWorkStatus);

    content.addComponent(footer);
    return layout;
}
项目:mycollab    文件:ProjectMemberBlock.java   
public ProjectMemberBlock(String username, String userAvatarId, String displayName) {
    withMargin(false).withWidth("80px");
    Image userAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(userAvatarId, 48, displayName);
    userAvatar.addStyleName(UIConstants.CIRCLE_BOX);
    A userLink = new A().setId("tag" + TooltipHelper.TOOLTIP_ID).
            setHref(ProjectLinkGenerator.generateProjectMemberLink(CurrentProjectVariables.getProjectId(),
                    username)).appendText(StringUtils.trim(displayName, 30, true));
    userLink.setAttribute("onmouseover", TooltipHelper.userHoverJsFunction(username));
    userLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction());
    ELabel userLbl = ELabel.html(userLink.write()).withStyleName(ValoTheme.LABEL_SMALL);
    with(userAvatar, userLbl);
}
项目:mycollab    文件:UserBlock.java   
public UserBlock(String username, String userAvatarId, String displayName) {
    withMargin(false).withWidth("80px");
    Image avatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(userAvatarId, 48);
    avatar.addStyleName(UIConstants.CIRCLE_BOX);

    A userLink = new A().setId("tag" + TooltipHelper.TOOLTIP_ID).setHref(AccountLinkGenerator.generateUserLink(username))
            .appendText(StringUtils.trim(displayName, 30, true));
    userLink.setAttribute("onmouseover", TooltipHelper.userHoverJsFunction(username));
    userLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction());

    with(avatar, ELabel.html(userLink.write()));
}
项目:webcam    文件:GifBoothUI.java   
private void addImage(final File imageFile) {
    FileResource imageResource = new FileResource(imageFile);

    // Frame list
    Image image = new Image(null, imageResource);
    image.setWidth("104px");
    final CssLayout wrapper = new CssLayout();
    wrapper.addComponent(image);
    image.addClickListener(new ClickListener() {

        @Override
        public void click(ClickEvent event) {
            framesLayout.removeComponent(wrapper);
            preview.removeImage(imageFiles.indexOf(imageFile));
            imageFiles.remove(imageFile);
            downloadButton.setEnabled(!imageFiles.isEmpty());
        }
    });
    framesLayout.addComponent(wrapper);

    // Add to preview animation
    preview.addImage(imageResource);

    // Add to our internal list
    imageFiles.add(imageFile);
    if (imageFiles.size() > 1) {
        webcamAndGif.replaceComponent(gifImage, preview);
        downloadButton.setEnabled(true);
    }
}
项目:scoutmaster    文件:HomeView.java   
private void addLogo(final VerticalLayout viewLayout)
{
    final VerticalLayout layout = new VerticalLayout();
    HorizontalLayout buttons = getLoginAccountButtons();
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setWidth("100%");
    buttonLayout.addComponent(buttons);
    buttonLayout.setComponentAlignment(buttons, Alignment.TOP_RIGHT);

    layout.addComponent(buttonLayout);

    // So the logo
    final HorizontalLayout logoLayout = new HorizontalLayout();
    logoLayout.setWidth("100%");

    final String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
    final FileResource resource = new FileResource(new File(basepath + "/images/scoutmaster-logo.png"));

    final Image image = new Image(null, resource);
    image.setAlternateText("Scoutmaster Logo");
    logoLayout.addComponent(image);

    layout.addComponent(logoLayout);
    layout.setComponentAlignment(logoLayout, Alignment.TOP_LEFT);

    viewLayout.addComponent(layout);

}