List of usage examples for com.vaadin.ui Image Image
public Image(String caption, Resource source)
From source file:de.symeda.sormas.ui.symptoms.SymptomsForm.java
License:Open Source License
private void setUpMonkeypoxVisibilities() { // Monkeypox picture resemblance fields FieldHelper.setVisibleWhen(getFieldGroup(), monkeypoxImageFieldIds, SymptomsDto.LESIONS, Arrays.asList(SymptomState.YES), true); // Set up images Image lesionsImg1 = new Image(null, new ThemeResource("img/monkeypox-lesions-1.png")); CssStyles.style(lesionsImg1, CssStyles.VSPACE_3); Image lesionsImg2 = new Image(null, new ThemeResource("img/monkeypox-lesions-2.png")); CssStyles.style(lesionsImg2, CssStyles.VSPACE_3); Image lesionsImg3 = new Image(null, new ThemeResource("img/monkeypox-lesions-3.png")); CssStyles.style(lesionsImg3, CssStyles.VSPACE_3); Image lesionsImg4 = new Image(null, new ThemeResource("img/monkeypox-lesions-4.png")); CssStyles.style(lesionsImg4, CssStyles.VSPACE_3); getContent().addComponent(lesionsImg1, MONKEYPOX_LESIONS_IMG1); getContent().addComponent(lesionsImg2, MONKEYPOX_LESIONS_IMG2); getContent().addComponent(lesionsImg3, MONKEYPOX_LESIONS_IMG3); getContent().addComponent(lesionsImg4, MONKEYPOX_LESIONS_IMG4); List<String> monkeypoxImages = Arrays.asList(MONKEYPOX_LESIONS_IMG1, MONKEYPOX_LESIONS_IMG2, MONKEYPOX_LESIONS_IMG3, MONKEYPOX_LESIONS_IMG4); // Set up initial visibility boolean lesionsSetToYes = getFieldGroup().getField(SymptomsDto.LESIONS).getValue() == SymptomState.YES; for (String monkeypoxImage : monkeypoxImages) { getContent().getComponent(monkeypoxImage).setVisible(lesionsSetToYes); }/*from www. j a va 2 s . c om*/ // Set up image visibility listener getFieldGroup().getField(SymptomsDto.LESIONS).addValueChangeListener(e -> { for (String monkeypoxImage : monkeypoxImages) { getContent().getComponent(monkeypoxImage) .setVisible(e.getProperty().getValue() == SymptomState.YES); } }); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientView.java
License:Open Source License
void updateContentGraph() { Resource resource = getGraphResourceAndParseNewGraph(); if (resource != null) { graphSectionContent.removeAllComponents(); Image graphImage = new Image("", resource); graphSectionContent.addComponent(graphImage); graphSectionContent.setComponentAlignment(graphImage, Alignment.MIDDLE_CENTER); } else {//from w ww . j av a2 s . c o m Label error = new Label("Project Graph can not be computed at that time for this project"); error.setStyleName(ValoTheme.LABEL_FAILURE); graphSectionContent.removeAllComponents(); graphSectionContent.addComponent(error); graphSectionContent.setComponentAlignment(error, Alignment.MIDDLE_CENTER); LOGGER.error(String.format("%s: %s", error.getValue(), currentBean.getId())); } }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.ProjectView.java
License:Open Source License
/** * /* w w w . j a v a 2s . c o m*/ */ void updateContentGraph() { Resource resource = getGraphResourceAndParseNewGraph(); if (resource != null) { graphSectionContent.removeAllComponents(); Image graphImage = new Image("", resource); graphSectionContent.addComponent(graphImage); graphSectionContent.setComponentAlignment(graphImage, Alignment.MIDDLE_CENTER); } else { Label error = new Label("Project Graph can not be computed at that time for this project"); error.setStyleName(ValoTheme.LABEL_FAILURE); graphSectionContent.removeAllComponents(); graphSectionContent.addComponent(error); graphSectionContent.setComponentAlignment(error, Alignment.MIDDLE_CENTER); LOGGER.error(String.format("%s: %s", error.getValue(), currentBean.getId())); } }
From source file:edu.kit.dama.ui.admin.login.B2AccessLoginComponent.java
License:Apache License
@Override public AbstractLayout getLoginForm() { if (loginForm == null) { Image im = new Image(null, new ExternalResource("https://b2access.eudat.eu:8443/home/VAADIN/themes/common/img/logo.png")); im.setWidth("300px"); loginForm = new VerticalLayout(im); loginForm.setWidth("300px"); }/*from w w w . j a va 2 s. co m*/ return loginForm; }
From source file:edu.kit.dama.ui.admin.login.OrcidLoginComponent.java
License:Apache License
@Override public AbstractLayout getLoginForm() { if (loginForm == null) { Image im = new Image(null, new ExternalResource("http://ebling.library.wisc.edu/images/logos/orcid-hero-logo.png")); im.setWidth("300px"); loginForm = new VerticalLayout(im); loginForm.setWidth("300px"); }/*ww w . ja va2 s .c o m*/ return loginForm; }
From source file:edu.kit.dama.ui.admin.LoginInformationBar.java
License:Apache License
/** * Build a menu item and return it.//from w w w . jav a 2 s . com * * @param pId The item id. * @param pImage The item image. * * @return The item. */ private Image buildMenuItem(String pId, ThemeResource pImage) { Image item = new Image(null, pImage); item.setId(pId); item.addStyleName("shadow"); item.addStyleName("menu"); item.addStyleName("myclickablecomponent"); item.setWidth("70px"); new HelpExtension().extend(item); return item; }
From source file:edu.kit.dama.ui.admin.MainControlPanel.java
License:Apache License
/** * Create a new cell for the UI. Each cell contains an image located in the * provided resource and a help label for the cell adverse to it. * Furthermore, a style is provided which can be 'help-left' or 'help-right' * depending on which side the help text should be aligned (help in left col * -> align right)./*from ww w.j av a 2s .com*/ * * @param pResourceString The image resource string. * @param The alignment of the image (TOP_LEFT or TOP_RIGHT, depending on * the column) * @param cellNumber The cell number (0-3) counting from top left to bottom * right * @param pHelp The help string which may contain HTML tags. * @param pStyle The help label style ('help-left' or 'help-right'). * * @return The cell layout. */ private VerticalLayout createCell(String pResourceString, Alignment pAlignment, int cellNumber, String pHelp, String pStyle) { final String cellHeight = "132px"; //create the cell image Image cellImage = new Image(null, new ThemeResource(pResourceString)); cellImage.addStyleName("border"); //create the cell image wrapper, which provides the shadow and this show/hide functionality VerticalLayout imageWrapper = new VerticalLayout(cellImage); imageWrapper.addComponent(cellImage); imageWrapper.setComponentAlignment(cellImage, Alignment.MIDDLE_CENTER); imageWrapper.setWidth(cellHeight); imageWrapper.setHeight(cellHeight); imageWrapper.addStyleName("shadow"); imageWrapper.addStyleName("visible"); //help label for the cell adverse to the current cell Label oppositeCellHelp = new Label(pHelp, ContentMode.HTML); oppositeCellHelp.addStyleName(pStyle); oppositeCellHelp.setSizeFull(); oppositeCellHelp.addStyleName("invisible"); oppositeCellHelp.setHeight(cellHeight); //the cell layout containing image and help label VerticalLayout cell = new VerticalLayout(); cell.addComponent(imageWrapper); cell.setComponentAlignment(imageWrapper, pAlignment); cell.setMargin(true); cell.addComponent(oppositeCellHelp); cell.setComponentAlignment(oppositeCellHelp, Alignment.MIDDLE_CENTER); //define component ids depending on the provided cell number //--------- //| 0 | 1 | //| 2 | 3 | //--------- //Each cell gets the id 'image<cellNumber>' //The currently created wrapper and help label are getting the cellId of the adverse cell (0 -> 1, 1 -> 0, 2 -> 3, 3 -> 2). //These ids are used then by edu.kit.dama.ui.admin.client.HelpConnector to show/hide elements on mouse over. switch (cellNumber) { case 0: cellImage.setId("image0"); //this cell contains the help for cell 1 imageWrapper.setId("image1_wrapper"); oppositeCellHelp.setId("image1_help"); break; case 1: cellImage.setId("image1"); //this cell contains the help for cell 0 imageWrapper.setId("image0_wrapper"); oppositeCellHelp.setId("image0_help"); break; case 2: cellImage.setId("image2"); //this cell contains the help for cell 3 imageWrapper.setId("image3_wrapper"); oppositeCellHelp.setId("image3_help"); break; case 3: cellImage.setId("image3"); //this cell contains the help for cell 2 imageWrapper.setId("image2_wrapper"); oppositeCellHelp.setId("image2_help"); break; } //link the HelpExtension to the image new HelpExtension().extend(cellImage); return cell; }
From source file:edu.kit.dama.ui.commons.util.UIUtils7.java
License:Apache License
public static void openResourceSubWindow(File sourceFile) { boolean fileAccessible = sourceFile != null && sourceFile.exists() && sourceFile.canRead(); // Set subwindow for displaying file resource final Window window = new Window(fileAccessible ? sourceFile.getName() : "Information"); window.center();//w w w . j a v a2s. c o m // Set window layout VerticalLayout windowLayout = new VerticalLayout(); windowLayout.setSizeFull(); if (fileAccessible) { // Set resource that has to be embedded final Embedded resource = new Embedded(null, new FileResource(sourceFile)); if ("application/octet-stream".equals(resource.getMimeType())) { window.setWidth("570px"); window.setHeight("150px"); windowLayout.setMargin(true); Label attentionNote = new Label( "A file preview is not possible as the file type is not supported by your browser."); attentionNote.setContentMode(ContentMode.HTML); Link fileURL = new Link("Click here for downloading the file.", new FileResource(sourceFile)); windowLayout.addComponent(attentionNote); windowLayout.addComponent(fileURL); windowLayout.setComponentAlignment(attentionNote, Alignment.MIDDLE_CENTER); windowLayout.setComponentAlignment(fileURL, Alignment.MIDDLE_CENTER); } else { window.setResizable(true); window.setWidth("800px"); window.setHeight("500px"); final Image image = new Image(null, new FileResource(sourceFile)); image.setSizeFull(); windowLayout.addComponent(image); } } else { //file is not accessible window.setWidth("570px"); window.setHeight("150px"); windowLayout.setMargin(true); Label attentionNote = new Label("Provided file cannot be accessed."); attentionNote.setContentMode(ContentMode.HTML); windowLayout.addComponent(attentionNote); windowLayout.setComponentAlignment(attentionNote, Alignment.MIDDLE_CENTER); } window.setContent(windowLayout); UI.getCurrent().addWindow(window); }
From source file:edu.kit.dama.ui.components.ConfirmationWindow7.java
License:Apache License
/** * Builds a customized subwindow <b>ConfirmationWindow</b> that allows the * user to confirm his previously requested action. * * @param pTitle The title of the window. * @param pMessage The message shown in the window. * @param pOptionType The type of the window (OK or YES_NO) which defines the * visible buttons.//from w w w . j a va 2s . c om * @param pMessageType The message type (INFORMATION, WARNING, ERROR) which * determines the icon. If pMessageType is null, no icon will be shown. * @param pListener The listener which receives the result if a button was * pressed or the window was closed. * */ ConfirmationWindow7(String pTitle, String pMessage, OPTION_TYPE pOptionType, MESSAGE_TYPE pMessageType, IConfirmationWindowListener7 pListener) { this.listener = pListener; //basic setup //set caption depending on type String caption = pTitle; if (caption == null) { if (pMessageType != null) { switch (pMessageType) { case QUESTION: caption = DEFAULT_TITLE; break; case INFORMATION: caption = "Information"; break; case WARNING: caption = "Warning"; break; case ERROR: caption = "Error"; break; } } else { //no type provided...use default title caption = DEFAULT_TITLE; } } setCaption(caption); setModal(true); center(); // Build line of buttons depending on pOptionType HorizontalLayout buttonLine = new HorizontalLayout(); buttonLine.setSpacing(true); buttonLine.setWidth("100%"); //add spacer Label spacer = new Label(); buttonLine.addComponent(spacer); //add buttons if (OPTION_TYPE.YES_NO_OPTION.equals(pOptionType)) { buttonLine.addComponent(buildYesButton("Yes")); buttonLine.addComponent(buildNoButton()); buttonLine.setComponentAlignment(yesButton, Alignment.MIDDLE_RIGHT); buttonLine.setComponentAlignment(noButton, Alignment.MIDDLE_RIGHT); //Assign ENTER to the YES button yesButton.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); //Assign ESC to the NO button noButton.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); } else { buttonLine.addComponent(buildYesButton("OK")); buttonLine.setComponentAlignment(yesButton, Alignment.MIDDLE_RIGHT); //Assign ENTER to the OK button yesButton.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); //Assign ESC to close the dialog setCloseShortcut(ShortcutAction.KeyCode.ESCAPE, null); } buttonLine.setExpandRatio(spacer, 1.0f); //determine the icon depending on pMessageType ThemeResource icon = null; if (pMessageType != null) { switch (pMessageType) { case QUESTION: icon = new ThemeResource("img/24x24/question.png"); break; case INFORMATION: icon = new ThemeResource("img/24x24/information.png"); break; case WARNING: icon = new ThemeResource("img/24x24/warning.png"); break; case ERROR: icon = new ThemeResource("img/24x24/forbidden.png"); break; } } Component iconComponent = new Label(); if (icon != null) { //icon was set, overwrite icon component iconComponent = new Image(null, icon); } //build the message label Label message = new Label(pMessage, ContentMode.HTML); message.setSizeUndefined(); //build the main layout GridLayout mainLayout = new UIUtils7.GridLayoutBuilder(2, 2) .addComponent(iconComponent, Alignment.TOP_LEFT, 0, 0, 1, 1).addComponent(message, 1, 0, 1, 1) .addComponent(buttonLine, 0, 1, 2, 1).getLayout(); mainLayout.setMargin(true); mainLayout.setSpacing(true); mainLayout.setColumnExpandRatio(0, .05f); mainLayout.setColumnExpandRatio(1, 1f); mainLayout.setRowExpandRatio(0, 1f); mainLayout.setRowExpandRatio(1, .05f); setContent(mainLayout); //add the close listener addCloseListener(new CloseListener() { @Override public void windowClose(CloseEvent e) { fireCloseEvents(RESULT.CANCEL); } }); }
From source file:edu.kit.dama.ui.repo.components.EntryRenderPanel.java
License:Apache License
/** * Set the image component. Currently, an automatically generated * placeholder image is used. This could be changed by e.g. storing * thumbnails in the data organization of an object or by storing additional * image information as new entity in the database. * * @param pObject The object to set the image for. *//* w w w . jav a 2 s. co m*/ private void setImage(DigitalObject pObject) { //just use test for image...later check data organization final String text = pObject.getLabel(); typeImage = new Image(null, new StreamResource(new StreamResource.StreamSource() { @Override public InputStream getStream() { try { return new ByteArrayInputStream(TextImage.from(text).withSize(40).getBytes()); } catch (IOException ex) { //error...should not occur..but return empty array to avoid failing return new ByteArrayInputStream(new byte[] {}); } } }, "dummy.png")); }