Example usage for com.vaadin.ui HorizontalLayout setMargin

List of usage examples for com.vaadin.ui HorizontalLayout setMargin

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout setMargin.

Prototype

@Override
    public void setMargin(boolean enabled) 

Source Link

Usage

From source file:de.symeda.sormas.ui.dashboard.DashboardFilterLayout.java

License:Open Source License

private void createDateFilters() {
    HorizontalLayout dateFilterLayout = new HorizontalLayout();
    dateFilterLayout.addStyleName(CssStyles.LAYOUT_MINIMAL);
    dateFilterLayout.setSpacing(true);//from   ww w  .j a va2s.c  o m
    addComponent(dateFilterLayout);
    Date now = new Date();

    // Date filters
    Button todayButton = new Button(I18nProperties.getCaption(Captions.dashboardToday));
    initializeDateFilterButton(todayButton);
    todayButton.addClickListener(e -> {
        setDateFilter(DateHelper.getStartOfDay(now), DateHelper.getEndOfDay(now));
        dashboardView.refreshDashboard();
    });

    Button yesterdayButton = new Button(I18nProperties.getCaption(Captions.dashboardYesterday));
    initializeDateFilterButton(yesterdayButton);
    yesterdayButton.addClickListener(e -> {
        setDateFilter(DateHelper.getStartOfDay(DateHelper.subtractDays(now, 1)),
                DateHelper.getEndOfDay(DateHelper.subtractDays(now, 1)));
        dashboardView.refreshDashboard();
    });

    Button thisWeekButton = new Button(I18nProperties.getCaption(Captions.dashboardThisWeek));
    initializeDateFilterButton(thisWeekButton);
    thisWeekButton.addClickListener(e -> {
        setDateFilter(DateHelper.getStartOfWeek(now), DateHelper.getEndOfWeek(now));
        dashboardView.refreshDashboard();
    });
    CssStyles.style(thisWeekButton, CssStyles.BUTTON_FILTER_DARK);
    CssStyles.removeStyles(thisWeekButton, CssStyles.BUTTON_FILTER_LIGHT);

    Button lastWeekButton = new Button(I18nProperties.getCaption(Captions.dashboardLastWeek));
    initializeDateFilterButton(lastWeekButton);
    lastWeekButton.addClickListener(e -> {
        setDateFilter(DateHelper.getStartOfWeek(DateHelper.subtractWeeks(now, 1)),
                DateHelper.getEndOfWeek(DateHelper.subtractWeeks(now, 1)));
        dashboardView.refreshDashboard();
    });

    Button thisYearButton = new Button(I18nProperties.getCaption(Captions.dashboardThisYear));
    initializeDateFilterButton(thisYearButton);
    thisYearButton.addClickListener(e -> {
        setDateFilter(DateHelper.getStartOfYear(now), DateHelper.getEndOfYear(now));
        dashboardView.refreshDashboard();
    });

    Button lastYearButton = new Button(I18nProperties.getCaption(Captions.dashboardLastYear));
    initializeDateFilterButton(lastYearButton);
    lastYearButton.addClickListener(e -> {
        setDateFilter(DateHelper.getStartOfYear(DateHelper.subtractYears(now, 1)),
                DateHelper.getEndOfYear(DateHelper.subtractYears(now, 1)));
        dashboardView.refreshDashboard();
    });

    customButton = new PopupButton(I18nProperties.getCaption(Captions.dashboardCustom));
    initializeDateFilterButton(customButton);

    // Custom filter
    HorizontalLayout customDateFilterLayout = new HorizontalLayout();
    customDateFilterLayout.setSpacing(true);
    customDateFilterLayout.setMargin(true);

    // 'Apply custom filter' button
    Button applyButton = new Button(I18nProperties.getCaption(Captions.dashboardApplyCustomFilter));
    CssStyles.style(applyButton, CssStyles.FORCE_CAPTION, ValoTheme.BUTTON_PRIMARY);

    // Date & Epi Week filter
    EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = new EpiWeekAndDateFilterComponent<>(
            applyButton, true, true, I18nProperties.getString(Strings.infoCaseDate));
    customDateFilterLayout.addComponent(weekAndDateFilter);
    dashboardDataProvider
            .setDateFilterOption((DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter().getValue());
    dashboardDataProvider.setFromDate(
            DateHelper.getEpiWeekStart((EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue()));
    dashboardDataProvider
            .setToDate(DateHelper.getEpiWeekEnd((EpiWeek) weekAndDateFilter.getWeekToFilter().getValue()));

    customDateFilterLayout.addComponent(applyButton);

    // Apply button listener
    applyButton.addClickListener(e -> {
        DateFilterOption dateFilterOption = (DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter()
                .getValue();
        Date fromDate = null;
        Date toDate = null;
        EpiWeek fromWeek = null;
        EpiWeek toWeek = null;
        dashboardDataProvider.setDateFilterOption(dateFilterOption);
        if (dateFilterOption == DateFilterOption.DATE) {
            fromDate = weekAndDateFilter.getDateFromFilter().getValue();
            dashboardDataProvider.setFromDate(fromDate);
            toDate = weekAndDateFilter.getDateToFilter().getValue();
            dashboardDataProvider.setToDate(toDate);
        } else {
            fromWeek = (EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue();
            dashboardDataProvider.setFromDate(DateHelper.getEpiWeekStart(fromWeek));
            toWeek = (EpiWeek) weekAndDateFilter.getWeekToFilter().getValue();
            dashboardDataProvider.setToDate(DateHelper.getEpiWeekEnd(toWeek));
        }

        if ((fromDate != null && toDate != null) || (fromWeek != null && toWeek != null)) {
            changeDateFilterButtonsStyles(customButton);
            dashboardView.refreshDashboard();
            if (dateFilterOption == DateFilterOption.DATE) {
                customButton.setCaption(DateHelper.formatLocalShortDate(fromDate) + " - "
                        + DateHelper.formatLocalShortDate(toDate));
            } else {
                customButton.setCaption(fromWeek.toShortString() + " - " + toWeek.toShortString());
            }
        } else {
            if (dateFilterOption == DateFilterOption.DATE) {
                new Notification(I18nProperties.getString(Strings.headingMissingDateFilter),
                        I18nProperties.getString(Strings.messageMissingDateFilter), Type.ERROR_MESSAGE, false)
                                .show(Page.getCurrent());
            } else {
                new Notification(I18nProperties.getString(Strings.headingMissingEpiWeekFilter),
                        I18nProperties.getString(Strings.messageMissingEpiWeekFilter), Type.ERROR_MESSAGE,
                        false).show(Page.getCurrent());
            }
        }
    });

    customButton.setContent(customDateFilterLayout);

    dateFilterLayout.addComponents(todayButton, yesterdayButton, thisWeekButton, lastWeekButton, thisYearButton,
            lastYearButton, customButton);

    infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
    infoLabel.setSizeUndefined();
    CssStyles.style(infoLabel, CssStyles.LABEL_XLARGE, CssStyles.LABEL_SECONDARY);
    addComponent(infoLabel);
    setComponentAlignment(infoLabel, Alignment.TOP_RIGHT);
}

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);/*from   ww  w.  j a  v  a2  s .  c o  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.map.DashboardMapComponent.java

License:Open Source License

private VerticalLayout createLegend() {
    VerticalLayout legendLayout = new VerticalLayout();
    legendLayout.setSpacing(false);/* w w w  . j  a va 2 s  .c  o m*/
    legendLayout.setMargin(true);
    legendLayout.setSizeUndefined();

    // Disable map key dropdown if no layers have been selected
    if (showCases || showContacts || showEvents || showRegions) {
        legendDropdown.setEnabled(true);
    } else {
        legendDropdown.setEnabled(false);
        return legendLayout;
    }

    // Health facilities

    // Cases
    if (showCases) {
        if (mapCaseDisplayMode == MapCaseDisplayMode.HEALTH_FACILITY
                || mapCaseDisplayMode == MapCaseDisplayMode.HEALTH_FACILITY_OR_CASE_ADDRESS) {
            Label facilitiesKeyLabel = new Label(I18nProperties.getCaption(Captions.dashboardHealthFacilities));
            CssStyles.style(facilitiesKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
            legendLayout.addComponent(facilitiesKeyLabel);

            HorizontalLayout facilitiesKeyLayout = new HorizontalLayout();
            {
                facilitiesKeyLayout.setSpacing(false);
                facilitiesKeyLayout.setMargin(false);
                HorizontalLayout legendEntry = buildMarkerLegendEntry(MarkerIcon.FACILITY_UNCLASSIFIED,
                        I18nProperties.getCaption(Captions.dashboardNotYetClassifiedOnly));
                CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
                facilitiesKeyLayout.addComponent(legendEntry);
                legendEntry = buildMarkerLegendEntry(MarkerIcon.FACILITY_SUSPECT,
                        I18nProperties.getCaption(Captions.dashboardGt1SuspectCases));
                CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
                facilitiesKeyLayout.addComponent(legendEntry);
                legendEntry = buildMarkerLegendEntry(MarkerIcon.FACILITY_PROBABLE,
                        I18nProperties.getCaption(Captions.dashboardGt1ProbableCases));
                CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
                facilitiesKeyLayout.addComponent(legendEntry);
                legendEntry = buildMarkerLegendEntry(MarkerIcon.FACILITY_CONFIRMED,
                        I18nProperties.getCaption(Captions.dashboardGt1ConfirmedCases));
                facilitiesKeyLayout.addComponent(legendEntry);
            }
            legendLayout.addComponent(facilitiesKeyLayout);
        }

        Label casesKeyLabel = new Label(I18nProperties.getString(Strings.entityCases));
        if (mapCaseDisplayMode == MapCaseDisplayMode.HEALTH_FACILITY
                || mapCaseDisplayMode == MapCaseDisplayMode.HEALTH_FACILITY_OR_CASE_ADDRESS) {
            CssStyles.style(casesKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);
        } else {
            CssStyles.style(casesKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
        }
        legendLayout.addComponent(casesKeyLabel);

        HorizontalLayout casesKeyLayout = new HorizontalLayout();
        {
            casesKeyLayout.setSpacing(false);
            casesKeyLayout.setMargin(false);
            HorizontalLayout legendEntry = buildMarkerLegendEntry(MarkerIcon.CASE_UNCLASSIFIED,
                    I18nProperties.getCaption(Captions.dashboardNotYetClassified));
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            casesKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.CASE_SUSPECT,
                    I18nProperties.getCaption(Captions.dashboardSuspect));
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            casesKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.CASE_PROBABLE,
                    I18nProperties.getCaption(Captions.dashboardProbable));
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            casesKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.CASE_CONFIRMED,
                    I18nProperties.getCaption(Captions.dashboardConfirmed));
            casesKeyLayout.addComponent(legendEntry);
        }
        legendLayout.addComponent(casesKeyLayout);
    }

    // Contacts
    if (showContacts) {
        Label contactsKeyLabel = new Label(I18nProperties.getString(Strings.entityContacts));
        if (showCases) {
            CssStyles.style(contactsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);
        } else {
            CssStyles.style(contactsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
        }
        legendLayout.addComponent(contactsKeyLabel);

        HorizontalLayout contactsKeyLayout = new HorizontalLayout();
        {
            contactsKeyLayout.setSpacing(false);
            contactsKeyLayout.setMargin(false);
            HorizontalLayout legendEntry = buildMarkerLegendEntry(MarkerIcon.CONTACT_OK,
                    I18nProperties.getCaption(Captions.dashboardLastVisitLt24));
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            contactsKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.CONTACT_OVERDUE,
                    I18nProperties.getCaption(Captions.dashboardLastVisitLt48));
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            contactsKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.CONTACT_LONG_OVERDUE,
                    I18nProperties.getCaption(Captions.dashboardLastVisitGt48));
            contactsKeyLayout.addComponent(legendEntry);
        }
        legendLayout.addComponent(contactsKeyLayout);
    }

    // Events
    if (showEvents) {
        Label eventsKeyLabel = new Label(I18nProperties.getString(Strings.entityEvents));
        if (showCases || showContacts) {
            CssStyles.style(eventsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);
        } else {
            CssStyles.style(eventsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
        }
        legendLayout.addComponent(eventsKeyLabel);

        HorizontalLayout eventsKeyLayout = new HorizontalLayout();
        {
            eventsKeyLayout.setSpacing(false);
            eventsKeyLayout.setMargin(false);
            HorizontalLayout legendEntry = buildMarkerLegendEntry(MarkerIcon.EVENT_RUMOR,
                    EventStatus.POSSIBLE.toString());
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            eventsKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.EVENT_OUTBREAK, EventStatus.CONFIRMED.toString());
            eventsKeyLayout.addComponent(legendEntry);
        }
        legendLayout.addComponent(eventsKeyLayout);
    }

    // Districts
    if (showRegions && districtValuesLowerQuartile != null && districtValuesMedian != null
            && districtValuesUpperQuartile != null) {
        Label districtsKeyLabel = new Label(I18nProperties.getString(Strings.entityDistricts));
        if (showCases || showContacts || showEvents) {
            CssStyles.style(districtsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);
        } else {
            CssStyles.style(districtsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
        }
        legendLayout.addComponent(districtsKeyLabel);
        legendLayout.addComponent(buildRegionLegend(false, caseMeasure, emptyPopulationDistrictPresent,
                districtValuesLowerQuartile, districtValuesMedian, districtValuesUpperQuartile));

        Label descLabel = new Label(I18nProperties.getString(Strings.infoDashboardIncidence));
        CssStyles.style(descLabel, CssStyles.LABEL_SMALL);
        legendLayout.addComponent(descLabel);
    }

    return legendLayout;
}

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();//w w w.  j  a v a 2 s . c  o m
    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.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);//  ww w  . ja v a 2s  .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 DashboardStatisticsSubComponent createCaseComponent() {
    DashboardStatisticsSubComponent caseComponent = new DashboardStatisticsSubComponent();

    // Header/*from w ww  .j a va  2 s . c o m*/
    HorizontalLayout headerLayout = new HorizontalLayout();
    headerLayout.setMargin(false);
    headerLayout.setSpacing(false);
    // count
    caseCountLabel = new Label();
    CssStyles.style(caseCountLabel, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_XXXLARGE, CssStyles.LABEL_BOLD,
            CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
    headerLayout.addComponent(caseCountLabel);
    // title
    Label caseComponentTitle = new Label(I18nProperties.getCaption(Captions.dashboardNewCases));
    CssStyles.style(caseComponentTitle, CssStyles.H2, CssStyles.HSPACE_LEFT_4);
    headerLayout.addComponent(caseComponentTitle);

    caseComponent.addComponent(headerLayout);

    // Count layout
    CssLayout countLayout = caseComponent.createCountLayout(true);
    caseClassificationConfirmed = new DashboardStatisticsCountElement(
            I18nProperties.getCaption(Captions.dashboardConfirmed), CountElementStyle.CRITICAL);
    caseComponent.addComponentToCountLayout(countLayout, caseClassificationConfirmed);
    caseClassificationProbable = new DashboardStatisticsCountElement(
            I18nProperties.getCaption(Captions.dashboardProbable), CountElementStyle.IMPORTANT);
    caseComponent.addComponentToCountLayout(countLayout, caseClassificationProbable);
    caseClassificationSuspect = new DashboardStatisticsCountElement(
            I18nProperties.getCaption(Captions.dashboardSuspect), CountElementStyle.RELEVANT);
    caseComponent.addComponentToCountLayout(countLayout, caseClassificationSuspect);
    caseClassificationNotACase = new DashboardStatisticsCountElement(
            I18nProperties.getCaption(Captions.dashboardNotACase), CountElementStyle.POSITIVE);
    caseComponent.addComponentToCountLayout(countLayout, caseClassificationNotACase);
    caseClassificationNotYetClassified = new DashboardStatisticsCountElement(
            I18nProperties.getCaption(Captions.dashboardNotYetClassified), CountElementStyle.MINOR);
    caseComponent.addComponentToCountLayout(countLayout, caseClassificationNotYetClassified);
    caseComponent.addComponent(countLayout);

    return caseComponent;
}

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);
    component.setSpacing(false);//from   w w w.java2  s . c o m
    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.DiseaseStatisticsComponent.java

License:Open Source License

private Layout createLastReportedCommunityComponent() {
    HorizontalLayout component = new HorizontalLayout();
    component.setMargin(false);
    component.setSpacing(false);//from w w  w  .j a  v  a  2s .c o  m

    // value
    lastReportedCommunityLabel = new Label("NONE");
    CssStyles.style(lastReportedCommunityLabel, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_BOLD,
            CssStyles.LABEL_LARGE, CssStyles.HSPACE_RIGHT_3, CssStyles.VSPACE_TOP_5);
    component.addComponent(lastReportedCommunityLabel);

    // title
    Label titleLabel = new Label(
            I18nProperties.getCaption("Last Reported " + I18nProperties.getCaption(Captions.community)));
    CssStyles.style(titleLabel, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_UPPERCASE, CssStyles.VSPACE_TOP_4);
    component.addComponent(titleLabel);

    return component;
}

From source file:de.symeda.sormas.ui.dashboard.surveillance.DiseaseStatisticsComponent.java

License:Open Source License

private Layout createOutbreakDistrictComponent() {
    HorizontalLayout component = new HorizontalLayout();
    component.setMargin(false);
    component.setSpacing(false);/*w ww . ja  v a  2s. co m*/

    // count
    outbreakDistrictCountLabel = new Label();
    CssStyles.style(outbreakDistrictCountLabel, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_BOLD,
            CssStyles.LABEL_LARGE, CssStyles.HSPACE_RIGHT_3, CssStyles.VSPACE_TOP_5);
    component.addComponent(outbreakDistrictCountLabel);

    // title
    Label titleLabel = new Label(I18nProperties.getCaption(Captions.dashboardOutbreakDistricts));
    CssStyles.style(titleLabel, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_UPPERCASE, CssStyles.VSPACE_TOP_4);
    component.addComponent(titleLabel);

    return component;
}

From source file:de.symeda.sormas.ui.dashboard.surveillance.DiseaseStatisticsComponent.java

License:Open Source License

private DashboardStatisticsSubComponent createEventComponent() {
    DashboardStatisticsSubComponent eventComponent = new DashboardStatisticsSubComponent();

    // Header/*w  w  w  .  j a  v a  2  s .co  m*/
    HorizontalLayout headerLayout = new HorizontalLayout();
    headerLayout.setMargin(false);
    headerLayout.setSpacing(false);

    // count
    eventCountLabel = new Label();
    CssStyles.style(eventCountLabel, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_XXXLARGE, CssStyles.LABEL_BOLD,
            CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
    headerLayout.addComponent(eventCountLabel);
    // title
    Label titleLabel = new Label(I18nProperties.getCaption(Captions.dashboardNewEvents));
    CssStyles.style(titleLabel, CssStyles.H2, CssStyles.HSPACE_LEFT_4);
    headerLayout.addComponent(titleLabel);

    eventComponent.addComponent(headerLayout);

    // Count layout
    CssLayout countLayout = eventComponent.createCountLayout(true);
    eventStatusConfirmed = new DashboardStatisticsCountElement(
            I18nProperties.getCaption(Captions.dashboardConfirmed), CountElementStyle.CRITICAL);
    eventComponent.addComponentToCountLayout(countLayout, eventStatusConfirmed);
    eventStatusPossible = new DashboardStatisticsCountElement(
            I18nProperties.getCaption(Captions.dashboardPossible), CountElementStyle.IMPORTANT);
    eventComponent.addComponentToCountLayout(countLayout, eventStatusPossible);
    eventStatusNotAnEvent = new DashboardStatisticsCountElement(
            I18nProperties.getCaption(Captions.dashboardNotAnEvent), CountElementStyle.POSITIVE);
    eventComponent.addComponentToCountLayout(countLayout, eventStatusNotAnEvent);
    eventComponent.addComponent(countLayout);

    return eventComponent;
}