List of usage examples for com.vaadin.ui HorizontalLayout setWidth
@Override public void setWidth(float width, Unit unit)
From source file:de.symeda.sormas.ui.dashboard.diagram.AbstractEpiCurveComponent.java
License:Open Source License
private HorizontalLayout createHeader() { HorizontalLayout epiCurveHeaderLayout = new HorizontalLayout(); epiCurveHeaderLayout.setWidth(100, Unit.PERCENTAGE); epiCurveHeaderLayout.setSpacing(true); CssStyles.style(epiCurveHeaderLayout, CssStyles.VSPACE_4); epiCurveLabel = new Label(I18nProperties.getString(Strings.headingEpiCurve)); epiCurveLabel.setSizeUndefined();//from w w w .j a va 2s.c o m CssStyles.style(epiCurveLabel, CssStyles.H2, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE); epiCurveHeaderLayout.addComponent(epiCurveLabel); epiCurveHeaderLayout.setComponentAlignment(epiCurveLabel, Alignment.BOTTOM_LEFT); epiCurveHeaderLayout.setExpandRatio(epiCurveLabel, 1); // "Expand" and "Collapse" buttons Button expandEpiCurveButton = new Button("", VaadinIcons.EXPAND); CssStyles.style(expandEpiCurveButton, CssStyles.BUTTON_SUBTLE); expandEpiCurveButton.addStyleName(CssStyles.VSPACE_NONE); Button collapseEpiCurveButton = new Button("", VaadinIcons.COMPRESS); CssStyles.style(collapseEpiCurveButton, CssStyles.BUTTON_SUBTLE); collapseEpiCurveButton.addStyleName(CssStyles.VSPACE_NONE); expandEpiCurveButton.addClickListener(e -> { externalExpandListener.accept(true); epiCurveHeaderLayout.removeComponent(expandEpiCurveButton); epiCurveHeaderLayout.addComponent(collapseEpiCurveButton); epiCurveHeaderLayout.setComponentAlignment(collapseEpiCurveButton, Alignment.MIDDLE_RIGHT); }); collapseEpiCurveButton.addClickListener(e -> { externalExpandListener.accept(false); epiCurveHeaderLayout.removeComponent(collapseEpiCurveButton); epiCurveHeaderLayout.addComponent(expandEpiCurveButton); epiCurveHeaderLayout.setComponentAlignment(expandEpiCurveButton, Alignment.MIDDLE_RIGHT); }); epiCurveHeaderLayout.addComponent(expandEpiCurveButton); epiCurveHeaderLayout.setComponentAlignment(expandEpiCurveButton, Alignment.MIDDLE_RIGHT); return epiCurveHeaderLayout; }
From source file:de.symeda.sormas.ui.dashboard.diagram.AbstractEpiCurveComponent.java
License:Open Source License
private HorizontalLayout createFooter() { HorizontalLayout epiCurveFooterLayout = new HorizontalLayout(); epiCurveFooterLayout.setWidth(100, Unit.PERCENTAGE); epiCurveFooterLayout.setSpacing(true); CssStyles.style(epiCurveFooterLayout, CssStyles.VSPACE_4); // Grouping// w w w . ja v a 2s . com PopupButton groupingDropdown = new PopupButton(I18nProperties.getCaption(Captions.dashboardGrouping)); CssStyles.style(groupingDropdown, CssStyles.BUTTON_SUBTLE); { VerticalLayout groupingLayout = new VerticalLayout(); groupingLayout.setMargin(true); groupingLayout.setSizeUndefined(); groupingDropdown.setContent(groupingLayout); // Grouping option group OptionGroup groupingSelect = new OptionGroup(); groupingSelect.setWidth(100, Unit.PERCENTAGE); groupingSelect.addItems((Object[]) EpiCurveGrouping.values()); groupingSelect.setValue(epiCurveGrouping); groupingSelect.addValueChangeListener(e -> { epiCurveGrouping = (EpiCurveGrouping) e.getProperty().getValue(); clearAndFillEpiCurveChart(); }); groupingLayout.addComponent(groupingSelect); // "Always show at least 7 entries" checkbox CheckBox minimumEntriesCheckbox = new CheckBox( I18nProperties.getCaption(Captions.dashboardShowMinimumEntries)); CssStyles.style(minimumEntriesCheckbox, CssStyles.VSPACE_NONE); minimumEntriesCheckbox.setValue(showMinimumEntries); minimumEntriesCheckbox.addValueChangeListener(e -> { showMinimumEntries = (boolean) e.getProperty().getValue(); clearAndFillEpiCurveChart(); }); groupingLayout.addComponent(minimumEntriesCheckbox); groupingDropdown.setContent(groupingLayout); } epiCurveFooterLayout.addComponent(groupingDropdown); epiCurveFooterLayout.setComponentAlignment(groupingDropdown, Alignment.MIDDLE_RIGHT); epiCurveFooterLayout.setExpandRatio(groupingDropdown, 1); // Epi curve mode AbstractComponent epiCurveModeSelector = createEpiCurveModeSelector(); epiCurveFooterLayout.addComponent(epiCurveModeSelector); epiCurveFooterLayout.setComponentAlignment(epiCurveModeSelector, Alignment.MIDDLE_RIGHT); epiCurveFooterLayout.setExpandRatio(epiCurveModeSelector, 0); return epiCurveFooterLayout; }
From source file:de.symeda.sormas.ui.dashboard.map.DashboardMapComponent.java
License:Open Source License
private HorizontalLayout createHeader() { HorizontalLayout mapHeaderLayout = new HorizontalLayout(); mapHeaderLayout.setWidth(100, Unit.PERCENTAGE); mapHeaderLayout.setSpacing(true);// w w w .jav a2 s .c o m CssStyles.style(mapHeaderLayout, CssStyles.VSPACE_4); Label mapLabel = new Label(); if (dashboardDataProvider.getDashboardType() == DashboardType.SURVEILLANCE) { mapLabel.setValue(I18nProperties.getString(Strings.headingCaseStatusMap)); } else { mapLabel.setValue(I18nProperties.getString(Strings.headingContactMap)); } mapLabel.setSizeUndefined(); CssStyles.style(mapLabel, CssStyles.H2, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE); mapHeaderLayout.addComponent(mapLabel); mapHeaderLayout.setComponentAlignment(mapLabel, Alignment.BOTTOM_LEFT); mapHeaderLayout.setExpandRatio(mapLabel, 1); // "Expand" and "Collapse" buttons Button expandMapButton = new Button("", VaadinIcons.EXPAND); CssStyles.style(expandMapButton, CssStyles.BUTTON_SUBTLE); expandMapButton.addStyleName(CssStyles.VSPACE_NONE); Button collapseMapButton = new Button("", VaadinIcons.COMPRESS); CssStyles.style(collapseMapButton, CssStyles.BUTTON_SUBTLE); collapseMapButton.addStyleName(CssStyles.VSPACE_NONE); expandMapButton.addClickListener(e -> { externalExpandListener.accept(true); mapHeaderLayout.removeComponent(expandMapButton); mapHeaderLayout.addComponent(collapseMapButton); mapHeaderLayout.setComponentAlignment(collapseMapButton, Alignment.MIDDLE_RIGHT); }); collapseMapButton.addClickListener(e -> { externalExpandListener.accept(false); mapHeaderLayout.removeComponent(collapseMapButton); mapHeaderLayout.addComponent(expandMapButton); mapHeaderLayout.setComponentAlignment(expandMapButton, Alignment.MIDDLE_RIGHT); }); mapHeaderLayout.addComponent(expandMapButton); mapHeaderLayout.setComponentAlignment(expandMapButton, Alignment.MIDDLE_RIGHT); return mapHeaderLayout; }
From source file:de.symeda.sormas.ui.dashboard.map.DashboardMapComponent.java
License:Open Source License
private HorizontalLayout createFooter() { HorizontalLayout mapFooterLayout = new HorizontalLayout(); mapFooterLayout.setWidth(100, Unit.PERCENTAGE); mapFooterLayout.setSpacing(true);//www . j av a2s . co m CssStyles.style(mapFooterLayout, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3); // Map key dropdown button legendDropdown = new PopupButton(I18nProperties.getCaption(Captions.dashboardMapKey)); CssStyles.style(legendDropdown, CssStyles.BUTTON_SUBTLE); legendDropdown.setContent(createLegend()); mapFooterLayout.addComponent(legendDropdown); mapFooterLayout.setComponentAlignment(legendDropdown, Alignment.MIDDLE_RIGHT); mapFooterLayout.setExpandRatio(legendDropdown, 1); // Layers dropdown button PopupButton layersDropdown = new PopupButton(I18nProperties.getCaption(Captions.dashboardMapLayers)); { CssStyles.style(layersDropdown, CssStyles.BUTTON_SUBTLE); VerticalLayout layersLayout = new VerticalLayout(); layersLayout.setMargin(true); layersLayout.setSpacing(false); layersLayout.setSizeUndefined(); layersDropdown.setContent(layersLayout); // Add check boxes and apply button { OptionGroup mapCaseDisplayModeSelect = new OptionGroup(); mapCaseDisplayModeSelect.setWidth(100, Unit.PERCENTAGE); mapCaseDisplayModeSelect.addItems((Object[]) MapCaseDisplayMode.values()); mapCaseDisplayModeSelect.setValue(mapCaseDisplayMode); mapCaseDisplayModeSelect.addValueChangeListener(event -> { mapCaseDisplayMode = (MapCaseDisplayMode) event.getProperty().getValue(); refreshMap(); }); HorizontalLayout showCasesLayout = new HorizontalLayout(); { showCasesLayout.setMargin(false); showCasesLayout.setSpacing(false); CheckBox showCasesCheckBox = new CheckBox(); showCasesCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowCases)); showCasesCheckBox.setValue(showCases); showCasesCheckBox.addValueChangeListener(e -> { showCases = (boolean) e.getProperty().getValue(); mapCaseDisplayModeSelect.setEnabled(showCases); mapCaseDisplayModeSelect.setValue(mapCaseDisplayMode); refreshMap(); }); showCasesLayout.addComponent(showCasesCheckBox); Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML); infoLabel.setDescription(I18nProperties.getString(Strings.infoCaseMap)); CssStyles.style(infoLabel, CssStyles.LABEL_MEDIUM, CssStyles.LABEL_SECONDARY, CssStyles.HSPACE_LEFT_3); infoLabel.setHeightUndefined(); showCasesLayout.addComponent(infoLabel); showCasesLayout.setComponentAlignment(infoLabel, Alignment.TOP_CENTER); } layersLayout.addComponent(showCasesLayout); layersLayout.addComponent(mapCaseDisplayModeSelect); mapCaseDisplayModeSelect.setEnabled(showCases); CheckBox showConfirmedContactsCheckBox = new CheckBox(); CheckBox showUnconfirmedContactsCheckBox = new CheckBox(); CheckBox showContactsCheckBox = new CheckBox(); showContactsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowContacts)); showContactsCheckBox.setValue(showContacts); showContactsCheckBox.addValueChangeListener(e -> { showContacts = (boolean) e.getProperty().getValue(); showConfirmedContactsCheckBox.setEnabled(showContacts); showConfirmedContactsCheckBox.setValue(true); showUnconfirmedContactsCheckBox.setEnabled(showContacts); showUnconfirmedContactsCheckBox.setValue(true); refreshMap(); }); layersLayout.addComponent(showContactsCheckBox); showConfirmedContactsCheckBox .setCaption(I18nProperties.getCaption(Captions.dashboardShowConfirmedContacts)); showConfirmedContactsCheckBox.setValue(showConfirmedContacts); showConfirmedContactsCheckBox.addValueChangeListener(e -> { showConfirmedContacts = (boolean) e.getProperty().getValue(); refreshMap(); }); layersLayout.addComponent(showConfirmedContactsCheckBox); CssStyles.style(showUnconfirmedContactsCheckBox, CssStyles.VSPACE_3); showUnconfirmedContactsCheckBox .setCaption(I18nProperties.getCaption(Captions.dashboardShowUnconfirmedContacts)); showUnconfirmedContactsCheckBox.setValue(showUnconfirmedContacts); showUnconfirmedContactsCheckBox.addValueChangeListener(e -> { showUnconfirmedContacts = (boolean) e.getProperty().getValue(); refreshMap(); }); layersLayout.addComponent(showUnconfirmedContactsCheckBox); showConfirmedContactsCheckBox.setEnabled(showContacts); showUnconfirmedContactsCheckBox.setEnabled(showContacts); CheckBox showEventsCheckBox = new CheckBox(); CssStyles.style(showEventsCheckBox, CssStyles.VSPACE_3); showEventsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowEvents)); showEventsCheckBox.setValue(showEvents); showEventsCheckBox.addValueChangeListener(e -> { showEvents = (boolean) e.getProperty().getValue(); refreshMap(); }); layersLayout.addComponent(showEventsCheckBox); if (UserProvider.getCurrent().hasUserRole(UserRole.NATIONAL_USER) || UserProvider.getCurrent().hasUserRole(UserRole.NATIONAL_CLINICIAN) || UserProvider.getCurrent().hasUserRole(UserRole.NATIONAL_OBSERVER)) { OptionGroup regionMapVisualizationSelect = new OptionGroup(); regionMapVisualizationSelect.setWidth(100, Unit.PERCENTAGE); regionMapVisualizationSelect.addItems((Object[]) CaseMeasure.values()); regionMapVisualizationSelect.setValue(caseMeasure); regionMapVisualizationSelect.addValueChangeListener(event -> { caseMeasure = (CaseMeasure) event.getProperty().getValue(); refreshMap(); }); HorizontalLayout showRegionsLayout = new HorizontalLayout(); { showRegionsLayout.setMargin(false); showRegionsLayout.setSpacing(false); CheckBox showRegionsCheckBox = new CheckBox(); showRegionsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowRegions)); showRegionsCheckBox.setValue(showRegions); showRegionsCheckBox.addValueChangeListener(e -> { showRegions = (boolean) e.getProperty().getValue(); regionMapVisualizationSelect.setEnabled(showRegions); regionMapVisualizationSelect.setValue(caseMeasure); refreshMap(); }); showRegionsLayout.addComponent(showRegionsCheckBox); Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML); infoLabel.setDescription(I18nProperties.getString(Strings.infoCaseIncidence)); CssStyles.style(infoLabel, CssStyles.LABEL_MEDIUM, CssStyles.LABEL_SECONDARY, CssStyles.HSPACE_LEFT_3); infoLabel.setHeightUndefined(); showRegionsLayout.addComponent(infoLabel); showRegionsLayout.setComponentAlignment(infoLabel, Alignment.TOP_CENTER); } layersLayout.addComponent(showRegionsLayout); layersLayout.addComponent(regionMapVisualizationSelect); regionMapVisualizationSelect.setEnabled(showRegions); } } } mapFooterLayout.addComponent(layersDropdown); mapFooterLayout.setComponentAlignment(layersDropdown, Alignment.MIDDLE_RIGHT); return mapFooterLayout; }
From source file:de.symeda.sormas.ui.dashboard.statistics.DashboardStatisticsGraphicalGrowthElement.java
License:Open Source License
public DashboardStatisticsGraphicalGrowthElement(String caption, String svgFillClass) { this.setMargin(false); this.setSpacing(false); HorizontalLayout captionAndValueLayout = new HorizontalLayout(); captionAndValueLayout.setMargin(false); captionAndValueLayout.setSpacing(false); captionAndValueLayout.setWidth(100, Unit.PERCENTAGE); Label captionLabel = new Label(caption); CssStyles.style(captionLabel, CssStyles.LABEL_SECONDARY, CssStyles.LABEL_BOLD); captionAndValueLayout.addComponent(captionLabel); countLabel = new Label(); CssStyles.style(countLabel, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_BOLD, CssStyles.HSPACE_RIGHT_4); countLabel.setWidthUndefined();/*from w w w . j a v a 2s . com*/ captionAndValueLayout.addComponent(countLabel); growthLabel = new Label(); growthLabel.setHeightUndefined(); growthLabel.setWidthUndefined(); growthLabel.setContentMode(ContentMode.HTML); CssStyles.style(growthLabel, CssStyles.LABEL_SMALL, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_BOLD, CssStyles.HSPACE_RIGHT_4); captionAndValueLayout.addComponent(growthLabel); percentageLabel = new Label(); CssStyles.style(percentageLabel, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_BOLD); percentageLabel.setWidthUndefined(); captionAndValueLayout.addComponent(percentageLabel); captionAndValueLayout.setComponentAlignment(captionLabel, Alignment.MIDDLE_LEFT); captionAndValueLayout.setComponentAlignment(countLabel, Alignment.MIDDLE_RIGHT); captionAndValueLayout.setComponentAlignment(growthLabel, Alignment.MIDDLE_RIGHT); captionAndValueLayout.setComponentAlignment(percentageLabel, Alignment.MIDDLE_RIGHT); captionAndValueLayout.setExpandRatio(captionLabel, 1); addComponent(captionAndValueLayout); svgBarElement = new SvgBarElement(svgFillClass); svgBarElement.setWidth(100, Unit.PERCENTAGE); addComponent(svgBarElement); }
From source file:de.symeda.sormas.ui.dashboard.statistics.DashboardStatisticsPercentageElement.java
License:Open Source License
public DashboardStatisticsPercentageElement(String caption, String svgFillClass) { this.setMargin(false); this.setSpacing(false); HorizontalLayout captionAndValueLayout = new HorizontalLayout(); captionAndValueLayout.setWidth(100, Unit.PERCENTAGE); Label captionLabel = new Label(caption); captionLabel.setWidthUndefined();// w w w . j a va 2s . c o m CssStyles.style(captionLabel, CssStyles.LABEL_SECONDARY, CssStyles.LABEL_BOLD); captionAndValueLayout.addComponent(captionLabel); percentageLabel = new Label(); CssStyles.style(percentageLabel, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_BOLD); percentageLabel.setWidthUndefined(); captionAndValueLayout.addComponent(percentageLabel); captionAndValueLayout.setComponentAlignment(captionLabel, Alignment.MIDDLE_LEFT); captionAndValueLayout.setComponentAlignment(percentageLabel, Alignment.MIDDLE_RIGHT); addComponent(captionAndValueLayout); svgBarElement = new SvgBarElement(svgFillClass); svgBarElement.setWidth(100, Unit.PERCENTAGE); addComponent(svgBarElement); }
From source file:de.symeda.sormas.ui.dashboard.statistics.DashboardStatisticsSubComponent.java
License:Open Source License
public void addHeader(String headline, Image icon, boolean showTotalCount) { HorizontalLayout headerLayout = new HorizontalLayout(); headerLayout.setWidth(100, Unit.PERCENTAGE); headerLayout.setSpacing(true);/*from w w w. jav a 2 s . c om*/ headerLayout.setMargin(false); CssStyles.style(headerLayout, CssStyles.VSPACE_4); VerticalLayout labelAndTotalLayout = new VerticalLayout(); { labelAndTotalLayout.setMargin(false); labelAndTotalLayout.setSpacing(false); Label headlineLabel = new Label(headline); CssStyles.style(headlineLabel, CssStyles.H2, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE); labelAndTotalLayout.addComponent(headlineLabel); if (showTotalCount) { totalCountLabel = new Label(); CssStyles.style(totalCountLabel, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_XXXLARGE, CssStyles.LABEL_BOLD, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE); labelAndTotalLayout.addComponent(totalCountLabel); } else { CssStyles.style(labelAndTotalLayout, CssStyles.VSPACE_4); } } headerLayout.addComponent(labelAndTotalLayout); headerLayout.setComponentAlignment(labelAndTotalLayout, Alignment.BOTTOM_LEFT); headerLayout.setHeightUndefined(); headerLayout.setExpandRatio(labelAndTotalLayout, 1); if (icon != null) { headerLayout.addComponent(icon); headerLayout.setComponentAlignment(icon, Alignment.TOP_RIGHT); } addComponent(headerLayout); setExpandRatio(headerLayout, 0); }
From source file:de.symeda.sormas.ui.dashboard.surveillance.DiseaseStatisticsComponent.java
License:Open Source License
private Layout createCaseFatalityComponent() { HorizontalLayout component = new HorizontalLayout(); component.setMargin(false);/* ww w. jav a 2 s .c o m*/ component.setSpacing(false); component.setWidth(100, Unit.PERCENTAGE); // rate { HorizontalLayout rateLayout = new HorizontalLayout(); rateLayout.setMargin(false); rateLayout.setSpacing(false); // value caseFatalityRateValue = new Label("00.0%"); CssStyles.style(caseFatalityRateValue, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_BOLD, CssStyles.LABEL_LARGE, CssStyles.HSPACE_RIGHT_3, CssStyles.VSPACE_TOP_5); rateLayout.addComponent(caseFatalityRateValue); // title Label titleLabel = new Label(I18nProperties.getCaption(Captions.dashboardCaseFatalityRate)); CssStyles.style(titleLabel, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_UPPERCASE, CssStyles.VSPACE_TOP_4); rateLayout.addComponent(titleLabel); component.addComponent(rateLayout); component.setExpandRatio(rateLayout, 1); } // count { HorizontalLayout countLayout = new HorizontalLayout(); countLayout.setMargin(false); countLayout.setSpacing(false); // title Label titleLabel = new Label(I18nProperties.getCaption(Captions.dashboardFatalities)); CssStyles.style(titleLabel, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_UPPERCASE, CssStyles.VSPACE_TOP_4, CssStyles.HSPACE_RIGHT_3); countLayout.addComponent(titleLabel); // value caseFatalityCountValue = new Label("0"); CssStyles.style(caseFatalityCountValue, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_BOLD, CssStyles.LABEL_LARGE, CssStyles.HSPACE_RIGHT_5, CssStyles.VSPACE_TOP_5); countLayout.addComponent(caseFatalityCountValue); // growth caseFatalityCountGrowth = new Label("", ContentMode.HTML); CssStyles.style(caseFatalityCountGrowth, CssStyles.VSPACE_TOP_5); countLayout.addComponent(caseFatalityCountGrowth); component.addComponent(countLayout); component.setExpandRatio(countLayout, 0); component.setComponentAlignment(countLayout, Alignment.MIDDLE_RIGHT); } return component; }
From source file:de.symeda.sormas.ui.dashboard.surveillance.DiseaseTileComponent.java
License:Open Source License
void addTopLayout(Disease disease, Long casesCount, boolean isOutbreak) { HorizontalLayout layout = new HorizontalLayout(); layout.setMargin(false);/*from w w w. j a v a 2s . co m*/ layout.setSpacing(false); CssStyles.style(layout, CssStyles.getDiseaseColor(disease)); layout.setHeight(75, Unit.PIXELS); layout.setWidth(100, Unit.PERCENTAGE); VerticalLayout nameAndOutbreakLayout = new VerticalLayout(); nameAndOutbreakLayout.setMargin(false); nameAndOutbreakLayout.setSpacing(false); nameAndOutbreakLayout.setHeight(100, Unit.PERCENTAGE); nameAndOutbreakLayout.setWidth(100, Unit.PERCENTAGE); HorizontalLayout nameLayout = new HorizontalLayout(); nameLayout.setMargin(false); nameLayout.setSpacing(false); nameLayout.setWidth(100, Unit.PERCENTAGE); nameLayout.setHeight(100, Unit.PERCENTAGE); Label nameLabel = new Label(disease.toShortString()); CssStyles.style(nameLabel, CssStyles.LABEL_WHITE, nameLabel.getValue().length() > 12 ? CssStyles.LABEL_LARGE : CssStyles.LABEL_XLARGE, CssStyles.LABEL_BOLD, CssStyles.ALIGN_CENTER, CssStyles.LABEL_UPPERCASE); nameLayout.addComponent(nameLabel); nameLayout.setComponentAlignment(nameLabel, Alignment.MIDDLE_CENTER); nameAndOutbreakLayout.addComponent(nameLayout); nameAndOutbreakLayout.setExpandRatio(nameLayout, 1); if (isOutbreak) { HorizontalLayout outbreakLayout = new HorizontalLayout(); outbreakLayout.setMargin(false); outbreakLayout.setSpacing(false); CssStyles.style(outbreakLayout, CssStyles.BACKGROUND_CRITICAL); outbreakLayout.setWidth(100, Unit.PERCENTAGE); outbreakLayout.setHeight(30, Unit.PIXELS); Label outbreakLabel = new Label(I18nProperties.getCaption(Captions.dashboardOutbreak)); CssStyles.style(outbreakLabel, CssStyles.LABEL_WHITE, CssStyles.ALIGN_CENTER, CssStyles.LABEL_UPPERCASE); outbreakLayout.addComponent(outbreakLabel); outbreakLayout.setComponentAlignment(outbreakLabel, Alignment.MIDDLE_CENTER); nameAndOutbreakLayout.addComponent(outbreakLayout); } layout.addComponent(nameAndOutbreakLayout); layout.setExpandRatio(nameAndOutbreakLayout, 1); HorizontalLayout countLayout = new HorizontalLayout(); countLayout.setMargin(false); countLayout.setSpacing(false); CssStyles.style(countLayout, CssStyles.getDiseaseColor(disease), CssStyles.BACKGROUND_DARKER); countLayout.setHeight(100, Unit.PERCENTAGE); countLayout.setWidth(100, Unit.PERCENTAGE); Label countLabel = new Label(casesCount.toString()); CssStyles.style(countLabel, CssStyles.LABEL_WHITE, CssStyles.LABEL_BOLD, CssStyles.LABEL_XXXLARGE, CssStyles.ALIGN_CENTER); countLayout.addComponent(countLabel); countLayout.setComponentAlignment(countLabel, Alignment.MIDDLE_CENTER); layout.addComponent(countLayout); layout.setExpandRatio(countLayout, 0.65f); addComponent(layout); }
From source file:de.symeda.sormas.ui.dashboard.surveillance.DiseaseTileComponent.java
License:Open Source License
HorizontalLayout createStatsItem(String label, String value, boolean isCritical) { HorizontalLayout layout = new HorizontalLayout(); layout.setWidth(100, Unit.PERCENTAGE); layout.setMargin(false);/* ww w.j a v a2 s . co m*/ layout.setSpacing(false); Label nameLabel = new Label(label); CssStyles.style(nameLabel, CssStyles.LABEL_PRIMARY, isCritical ? CssStyles.LABEL_CRITICAL : "", CssStyles.HSPACE_LEFT_3); layout.addComponent(nameLabel); layout.setExpandRatio(nameLabel, 1); Label valueLabel = new Label(value); CssStyles.style(valueLabel, CssStyles.LABEL_PRIMARY, isCritical ? CssStyles.LABEL_CRITICAL : "", CssStyles.ALIGN_CENTER); layout.addComponent(valueLabel); layout.setExpandRatio(valueLabel, 0.65f); return layout; }