List of usage examples for com.vaadin.ui Image Image
public Image(String caption, Resource source)
From source file:org.opennms.features.vaadin.dashboard.dashlets.SummaryDashlet.java
License:Open Source License
/** * Returns the component showing the alarms and the trends by severity * * @return the {@link Component}/* w ww. j a v a 2s .c o m*/ */ private Component getComponentUei(int width) { VerticalLayout verticalLayout = new VerticalLayout(); int overallSum = 0; int severitySum = 0; verticalLayout.addComponent(getLegend("UEI")); String[] ueis = { "uei.opennms.org/nodes/nodeLostService", "uei.opennms.org/nodes/interfaceDown", "uei.opennms.org/nodes/nodeDown" }; for (int i = 0; i < ueis.length; i++) { String uei = ueis[i]; HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSpacing(true); horizontalLayout.addStyleName("summary"); if (i == 0) { horizontalLayout.addStyleName(OnmsSeverity.MINOR.name().toLowerCase()); } else { if (i == 1) { horizontalLayout.addStyleName(OnmsSeverity.MINOR.name().toLowerCase()); } else { horizontalLayout.addStyleName(OnmsSeverity.MAJOR.name().toLowerCase()); } } int acknowledged = countByUei(true, m_timeslot, uei); int notAcknowledged = countByUei(false, m_timeslot, uei); Label labelSeverity = new Label(uei.replace("uei.opennms.org/nodes/", "")); labelSeverity.addStyleName("summary-font"); Label labelAcknowledge = new Label(String.valueOf(acknowledged)); labelAcknowledge.addStyleName("summary-font"); Label labelNotAcknowledged = new Label(String.valueOf(notAcknowledged)); labelNotAcknowledged.addStyleName("summary-font"); horizontalLayout.addComponent(labelSeverity); horizontalLayout.addComponent(labelAcknowledge); horizontalLayout.addComponent(labelNotAcknowledged); int status = computeTrend(acknowledged, notAcknowledged); severitySum += i; overallSum += i * status; Image image = new Image(null, new ThemeResource("img/a" + status + ".png")); image.setWidth(width, Sizeable.Unit.PIXELS); horizontalLayout.addComponent(image); horizontalLayout.setExpandRatio(labelSeverity, 4.0f); horizontalLayout.setExpandRatio(labelAcknowledge, 1.0f); horizontalLayout.setExpandRatio(labelNotAcknowledged, 1.0f); horizontalLayout.setExpandRatio(image, 1.0f); horizontalLayout.setComponentAlignment(image, Alignment.TOP_CENTER); horizontalLayout.setWidth(375, Sizeable.Unit.PIXELS); verticalLayout.addComponent(horizontalLayout); } int globalTrend = (int) Math.max(0, Math.min(4, Math.round(((double) overallSum) / ((double) severitySum)))); Image image = new Image(null, new ThemeResource("img/a" + globalTrend + ".png")); image.setWidth(width * 8, Sizeable.Unit.PIXELS); VerticalLayout globalTrendLayout = new VerticalLayout(); globalTrendLayout.setSpacing(true); globalTrendLayout.addStyleName("summary"); globalTrendLayout.addStyleName("global"); globalTrendLayout.setSizeFull(); Label labelTitle = new Label("Alarms trend by UEI"); labelTitle.addStyleName("summary-font"); labelTitle.setSizeUndefined(); Label labelTimeslot = new Label("(" + getHumanReadableFormat(m_timeslot) + ")"); labelTimeslot.addStyleName("summary-font"); labelTimeslot.setSizeUndefined(); globalTrendLayout.addComponent(labelTitle); globalTrendLayout.addComponent(labelTimeslot); globalTrendLayout.addComponent(image); globalTrendLayout.setWidth(375, Sizeable.Unit.PIXELS); globalTrendLayout.setComponentAlignment(labelTitle, Alignment.MIDDLE_CENTER); globalTrendLayout.setComponentAlignment(labelTimeslot, Alignment.MIDDLE_CENTER); globalTrendLayout.setComponentAlignment(image, Alignment.MIDDLE_CENTER); globalTrendLayout.setExpandRatio(labelTitle, 1.0f); verticalLayout.addComponent(globalTrendLayout, 0); m_boosted = (globalTrend > 2); return verticalLayout; }
From source file:org.ow2.sirocco.cloudmanager.MyUI.java
License:Open Source License
@Override protected void init(final VaadinRequest request) { this.userName = request.getUserPrincipal().getName(); this.identityContext.setUserName(this.userName); this.getPage().setTitle("Sirocco Dashboard"); final VerticalLayout layout = new VerticalLayout(); layout.setSizeFull();/*from w w w .j a v a 2s .c o m*/ this.setContent(layout); // Top header ********************* HorizontalLayout header = new HorizontalLayout(); header.setMargin(true); header.setWidth("100%"); header.setHeight("70px"); header.setStyleName("topHeader"); // logo Image image = new Image(null, new ThemeResource("img/sirocco_small_logo.png")); header.addComponent(image); // spacer Label spacer = new Label(); spacer.setWidth("100%"); header.addComponent(spacer); header.setExpandRatio(spacer, 1.0f); HorizontalLayout rightButtons = new HorizontalLayout(); rightButtons.setStyleName("topHeader"); rightButtons.setSpacing(true); this.userName = request.getUserPrincipal().getName(); User user = null; try { user = this.userManager.getUserByUsername(this.userName); } catch (CloudProviderException e) { e.printStackTrace(); } Label label = new Label("Tenant:"); label.setStyleName("topHeaderLabel"); rightButtons.addComponent(label); final ComboBox tenantSelect = new ComboBox(); tenantSelect.setTextInputAllowed(false); tenantSelect.setNullSelectionAllowed(false); for (Tenant tenant : user.getTenants()) { tenantSelect.addItem(tenant.getName()); } tenantSelect.setValue(user.getTenants().iterator().next().getName()); tenantSelect.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { Notification.show("Switching to tenant " + tenantSelect.getValue()); } }); tenantSelect.setImmediate(true); rightButtons.addComponent(tenantSelect); this.tenantId = user.getTenants().iterator().next().getUuid(); this.identityContext.setTenantId(this.tenantId); // logged user name label = new Label("Logged in as: " + this.userName); label.setStyleName("topHeaderLabel"); rightButtons.addComponent(label); // sign out button Button button = new Button("Sign Out"); // button.setStyleName(BaseTheme.BUTTON_LINK); button.addClickListener(new Button.ClickListener() { public void buttonClick(final ClickEvent event) { MyUI.this.logout(); } }); rightButtons.addComponent(button); header.addComponent(rightButtons); layout.addComponent(header); // Split view HorizontalSplitPanel splitPanel = new HorizontalSplitPanel(); splitPanel.setSizeFull(); splitPanel.setFirstComponent(this.createLeftMenu()); this.inventoryContainer = new VerticalLayout(); this.inventoryContainer.setSizeFull(); this.inventoryContainer.addComponent(this.machineView); splitPanel.setSecondComponent(this.inventoryContainer); splitPanel.setSplitPosition(15); layout.addComponent(splitPanel); layout.setExpandRatio(splitPanel, 1.0f); this.listenToNotifications(); }
From source file:org.plukh.fluffymeow.ui.Header.java
License:Open Source License
@Inject public Header(HeaderUserComponent loginComponent, LocaleChooserComponent localeChooser) { log.trace("Creating Header..."); this.loginComponent = loginComponent; this.localeChooser = localeChooser; setWidth("100%"); setMargin(true);/*from w ww . j av a2s .c o m*/ setSpacing(true); Resource resource = new ThemeResource("logo.png"); logoImage = new Image(null, resource); logoImage.addStyleName("pointer"); logoImage.addClickListener(this::onLogoImageClick); addComponent(logoImage); addComponent(loginComponent); addComponent(localeChooser); setExpandRatio(loginComponent, 1.0f); setComponentAlignment(loginComponent, Alignment.BOTTOM_LEFT); setComponentAlignment(localeChooser, Alignment.BOTTOM_RIGHT); log.debug("Header created"); }
From source file:org.plukh.fluffymeow.ui.i18n.LocaleChooserComponent.java
License:Open Source License
@Inject public LocaleChooserComponent() { log.trace("Creating LocaleChooserComponent..."); setSizeUndefined();//from ww w.ja v a2s . co m HorizontalLayout layout = new HorizontalLayout(); flags = new ArrayList<>(); languages.forEach(language -> { Resource flagResource = new ThemeResource(language.getFlagFile()); Image flag = new Image(null, flagResource); flag.addStyleName("pointer"); flag.addClickListener(event -> onLanguageChange(language.getLocale())); flag.setData(language.getMessage()); log.debug("Created flag for locale " + language.getLocale()); flags.add(flag); layout.addComponent(flag); }); setCompositionRoot(layout); log.debug("LocaleChooserComponent created"); }
From source file:org.rapidpm.jumpstart.vaadin.ui.basics.RapidTopPanel.java
License:Apache License
@PostConstruct private void createIconsLayout() { iconsLayout.setWidth("100%"); iconsLayout.setMargin(new MarginInfo(false, false, false, false)); if (propertyService.hasKey("app.logo")) { final String resourceName = propertyService.resolve("app.logo"); final Image iconLeft = new Image(null, new ClassResource(resourceName)); final Image iconRight = new Image(null, new ClassResource(resourceName)); iconsLayout.addComponent(iconLeft); iconsLayout.setComponentAlignment(iconLeft, Alignment.TOP_LEFT); if (propertyService.hasKey("app.version")) { final Label versionLabel = new Label(propertyService.resolve("app.version")); versionLabel.setSizeUndefined(); iconsLayout.addComponent(versionLabel); iconsLayout.setComponentAlignment(versionLabel, Alignment.MIDDLE_CENTER); iconsLayout.setExpandRatio(versionLabel, 1.0f); }/*ww w . j a v a 2 s . c o m*/ iconsLayout.addComponent(iconRight); iconsLayout.setComponentAlignment(iconRight, Alignment.TOP_RIGHT); } }
From source file:org.sensorhub.ui.AdminUI.java
License:Mozilla Public License
protected Component buildHeader() { HorizontalLayout header = new HorizontalLayout(); header.setMargin(false);//ww w .j a v a 2s . c o m 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; }
From source file:org.vaadin.addons.lazyquerycontainer.QueryItemStatusColumnGenerator.java
License:Apache License
/** * Generates cell component.//from w w w . j ava2 s .c o m * * @param source The table this cell is generated for. * @param itemId ID of the item this cell is presenting property of. * @param columnId ID of the column this cell is located at. * @return Component used to render this cell. */ public Component generateCell(final Table source, final Object itemId, final Object columnId) { Property statusProperty = source.getItem(itemId).getItemProperty(columnId); noneIconResource = new ClassResource(QueryItemStatusColumnGenerator.class, "images/textfield.png"); addedIconResource = new ClassResource(QueryItemStatusColumnGenerator.class, "images/textfield_add.png"); modifiedIconResource = new ClassResource(QueryItemStatusColumnGenerator.class, "images/textfield_rename.png"); removedIconResource = new ClassResource(QueryItemStatusColumnGenerator.class, "images/textfield_delete.png"); statusIcon = new Image(null, noneIconResource); statusIcon.setHeight("16px"); if (statusProperty instanceof ValueChangeNotifier) { ValueChangeNotifier notifier = (ValueChangeNotifier) statusProperty; notifier.addValueChangeListener(this); } refreshImage(statusProperty); return statusIcon; }
From source file:org.vaadin.presentation.views.NewsView.java
private Table createTable(IndexedContainer container) { Table table = new Table("Image Table", container); table.setSizeFull();// w w w .j ava2s . co m 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:org.vaadin.tori.component.PanicComponent.java
License:Apache License
public PanicComponent() { setCompositionRoot(layout);//w w w . j a v a 2 s. c o m setSizeFull(); layout.setSizeFull(); final Image panicImage = new Image(null, new ThemeResource("images/panic.png")); layout.addComponent(panicImage); layout.setComponentAlignment(panicImage, Alignment.MIDDLE_CENTER); }
From source file:probe.com.view.core.chart4j.VennDiagramContainer.java
public VennDiagramContainer() { ArrayList<String> grI = new ArrayList<String>(); grI.add("A"); grI.add("B"); grI.add("C"); grI.add("D"); ArrayList<String> grII = new ArrayList<String>(); grII.add("E"); grII.add("F"); grII.add("G"); grII.add("A"); grII.add("B"); ArrayList<String> grIII = new ArrayList<String>(); grI.add("I"); grI.add("H"); grI.add("C"); grI.add("D"); ArrayList<String> grIIII = new ArrayList<String>(); grII.add("J"); grII.add("K"); grII.add("L"); grII.add("A"); grII.add("B"); VennCode vennDiagramPanel = new VennCode(); VennDiagramPanel vdp = new VennDiagramPanel(grI, grII, grIII, grIIII, "A", "B", "C", "D", Color.yellow, Color.yellow, Color.yellow, Color.yellow); JPanel xyPlotPanel = new JPanel(); xyPlotPanel.add(vennDiagramPanel);// w w w .j ava 2s . c o m xyPlotPanel.setSize(500, 500); vennDiagramPanel.setSize(500, 500); Image img = new Image("", new ExternalResource(chartImgGenerator.generateHeatMap(vennDiagramPanel))); this.addComponent(img); MainApp main = new MainApp(7, DESIGN_ATTR_PLAIN_TEXT, DESIGN_ATTR_PLAIN_TEXT); main.createDiagrams(1, 0); }