com.vaadin.ui.AbstractOrderedLayout Java Examples

The following examples show how to use com.vaadin.ui.AbstractOrderedLayout. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PartyChartDataManagerImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@Override
public void createPartyLineChart(final AbstractOrderedLayout content,final String partyId) {

	final List<ViewRiksdagenVoteDataBallotPartySummaryDaily> list = getViewRiksdagenVoteDataBallotPartySummaryDaily(
			partyId);

	if (list != null) {
		final Series series = new Series().addSeries(new XYseries().setLabel(PARTY_WON))
				.addSeries(new XYseries().setLabel(PARTY_ABSENT));

		final DataSeries dataSeries = new DataSeries();

		final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);

		addPartyData(dataSeries, simpleDateFormat, list, ViewRiksdagenVoteDataBallotPartySummaryDaily::getPartyWonPercentage);
		addPartyData(dataSeries, simpleDateFormat, list, ViewRiksdagenVoteDataBallotPartySummaryDaily::getPartyPercentageAbsent);

		addChart(content,"Party result by", new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsPartyLineChart(series)).show(), true);
	}
}
 
Example #2
Source File: PartyDocumentChartDataManagerImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@Override
public void createDocumentHistoryPartyChart(final AbstractOrderedLayout content, final String org) {
	final DataSeries dataSeries = new DataSeries();
	final Series series = new Series();

	final Map<String, List<ViewRiksdagenPartyDocumentDailySummary>> allMap = getViewRiksdagenPartyDocumentDailySummaryMap();

	final List<ViewRiksdagenPartyDocumentDailySummary> itemList = allMap
			.get(org.toUpperCase(Locale.ENGLISH).replace(UNDER_SCORE, EMPTY_STRING).trim());

	if (itemList != null) {

		final Map<String, List<ViewRiksdagenPartyDocumentDailySummary>> map = itemList.parallelStream()
				.filter(Objects::nonNull).collect(Collectors
						.groupingBy(t -> StringUtils.defaultIfBlank(t.getEmbeddedId().getDocumentType(), NO_INFO)));

		addDocumentHistoryByPartyData(dataSeries, series, map);
	}

	addChart(content, DOCUMENT_HISTORY_PARTY,
			new DCharts().setDataSeries(dataSeries)
					.setOptions(getChartOptions().createOptionsXYDateFloatLegendInsideOneColumn(series)).show(),
			true);
}
 
Example #3
Source File: DocumentChartDataManagerImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@Override
public void createDocumentTypeChart(final AbstractOrderedLayout content) {
	final Map<String, List<ViewRiksdagenDocumentTypeDailySummary>> map = getDocumentTypeMap();
	final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
	final SimpleDateFormat parseInputDateFormat = new SimpleDateFormat("yyyy-MM-dd",Locale.ENGLISH);

	final DataSeries dataSeries = new DataSeries();
	final Series series = new Series();

	for (final Entry<String, List<ViewRiksdagenDocumentTypeDailySummary>> entry : map.entrySet()) {
		if (entry.getKey() != null && !EMPTY_STRING.equals(entry.getKey())) {
			addDataSeries(simpleDateFormat, parseInputDateFormat, dataSeries, series, entry);
		}
	}

	addChart(content, "Document type",
			new DCharts().setDataSeries(dataSeries)
					.setOptions(getChartOptions().createOptionsXYDateFloatLegendInsideOneColumn(series)).show(),
			true);
}
 
Example #4
Source File: OrgDocumentChartDataManagerImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@Override
public void createDocumentHistoryChartByOrg(final AbstractOrderedLayout content, final String org) {
	final String searchOrg = org.toUpperCase(Locale.ENGLISH).replace(UNDER_SCORE, EMPTY_STRING)
			.replace(MINUS_SIGN, EMPTY_STRING).trim();

	final DataSeries dataSeries = new DataSeries();
	final Series series = new Series();

	final Map<String, List<ViewRiksdagenOrgDocumentDailySummary>> allMap = getViewRiksdagenOrgDocumentDailySummaryMap();

	final List<ViewRiksdagenOrgDocumentDailySummary> itemList = allMap.get(searchOrg);

	if (itemList != null) {
		addDocumentHistoryByOrgData(dataSeries, series, itemList);
	}

	addChart(content, DOCUMENT_HISTORY_BY_ORG,
			new DCharts().setDataSeries(dataSeries)
					.setOptions(getChartOptions().createOptionsXYDateFloatLegendInsideOneColumn(series)).show(),
			true);
}
 
Example #5
Source File: PartySupportsChartDataManagerImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@Override
public void createPartyChart(final AbstractOrderedLayout content, final String partyId) {

	final DataContainer<ViewRiksdagenPartyBallotSupportAnnualSummary, ViewRiksdagenPartyBallotSupportAnnualSummaryEmbeddedId> dataContainer = getApplicationManager()
			.getDataContainer(ViewRiksdagenPartyBallotSupportAnnualSummary.class);

	final List<ViewRiksdagenPartyBallotSupportAnnualSummary> list = dataContainer.findListByEmbeddedProperty(ViewRiksdagenPartyBallotSupportAnnualSummary.class,				
			ViewRiksdagenPartyBallotSupportAnnualSummary_.embeddedId,
			ViewRiksdagenPartyBallotSupportAnnualSummaryEmbeddedId.class,
			ViewRiksdagenPartyBallotSupportAnnualSummaryEmbeddedId_.party, partyId);

	final Map<String, List<ViewRiksdagenPartyBallotSupportAnnualSummary>> map = list.parallelStream().filter(Objects::nonNull)
	.collect(Collectors.groupingBy(t -> t.getEmbeddedId().getOtherParty()));
				
	final Series series = new Series();
	final DataSeries dataSeries = new DataSeries();
		
	addData(map, series, dataSeries);
		
	addChart(content,"Party support ballot", new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsPartyLineChart(series)).show(), true);
}
 
Example #6
Source File: AdminChartDataManagerImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@Override
public void createApplicationActionEventPageElementDailySummaryChart(final AbstractOrderedLayout content,
		final String page, final String elementId) {
	final List<ViewApplicationActionEventPageElementDailySummary> list = getApplicationActionEventPageElementDailySummaryList(
			page, elementId);

	final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
	final Series series = new Series();
	final DataSeries dataSeries = new DataSeries();

	addViewApplicationActionEventPageElementDailySummaryValues(PAGE_HITS, series, list, dataSeries,
			simpleDateFormat, ViewApplicationActionEventPageElementDailySummary::getHits);
	addViewApplicationActionEventPageElementDailySummaryValues(PAGE_RANK, series, list, dataSeries,
			simpleDateFormat, ViewApplicationActionEventPageElementDailySummary::getRank);

	addChart(content, "Page element Action Events daily Summary",
			new DCharts().setDataSeries(dataSeries)
					.setOptions(getChartOptions().createOptionsXYDateFloatLogYAxisLegendOutside(series)).show(),
			true);
}
 
Example #7
Source File: PartyCoalationChartDataManagerImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@Override
public void createPartyChart(final AbstractOrderedLayout content, final String partyId) {

	final DataContainer<ViewRiksdagenPartyCoalationAgainstAnnualSummary, ViewRiksdagenPartyCoalationAgainstAnnualSummaryEmbeddedId> dataContainer = getApplicationManager()
			.getDataContainer(ViewRiksdagenPartyCoalationAgainstAnnualSummary.class);

	final Map<String, List<ViewRiksdagenPartyCoalationAgainstAnnualSummary>> map = dataContainer.getAll().parallelStream()
			.filter(t -> t.getEmbeddedId().getGroupAgainst().contains(partyId) && t.getTotal() > FILTER_LOW_VALUES)
			.collect(Collectors.groupingBy(t -> t.getEmbeddedId().getGroupAgainst()));

	final Series series = new Series();
	final DataSeries dataSeries = new DataSeries();

	addData(map, series, dataSeries);

	addChart(content, "Part of coalations against committee proposal in ballot more than twice", new DCharts()
			.setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsCountryLineChart(series)).show(),
			true);
}
 
Example #8
Source File: GovernmentBodyChartDataManagerImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
@Override
public void createMinistryGovernmentBodyHeadcountSummaryChart(final AbstractOrderedLayout content) {
	final Map<Integer, List<GovernmentBodyAnnualSummary>> map = esvApi.getData();
	final List<String> ministryNames = esvApi.getMinistryNames();

	final DataSeries dataSeries = new DataSeries();
	final Series series = new Series();

	for (final String ministryName : ministryNames) {

		series.addSeries(new XYseries().setLabel(ministryName));
		dataSeries.newSeries();

		for (final Entry<Integer, List<GovernmentBodyAnnualSummary>> entry : map.entrySet()) {
			addDataSerieValue(dataSeries, entry, entry.getValue().stream()
					.filter((final GovernmentBodyAnnualSummary p) -> p.getMinistry().equalsIgnoreCase(ministryName))
					.mapToInt(GovernmentBodyAnnualSummary::getHeadCount).sum());
		}
	}

	addChart(content, ANNUAL_HEADCOUNT_ALL_MINISTRIES,
			new DCharts().setDataSeries(dataSeries)
					.setOptions(getChartOptions().createOptionsXYDateFloatLogYAxisLegendOutside(series)).show(),
			true);

}
 
Example #9
Source File: GovernmentOutcomeChartDataManagerImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public void createGovernmentOutcomeChart(final AbstractOrderedLayout content) {
	final Map<String, List<GovernmentOperationPeriodOutcome>> map = esvApi.getReport();
	final DataSeries dataSeries = new DataSeries();
	final Series series = new Series();

	createPeriodData(map,GovernmentOperationPeriodOutcome.Variables.TOTAL_REVENUE, dataSeries, series);
	createPeriodData(map,GovernmentOperationPeriodOutcome.Variables.TOTAL_EXPENDITURES, dataSeries, series);		

	addChart(content, "GovernmentOperationPeriodOutcome",
			new DCharts().setDataSeries(dataSeries)
					.setOptions(getChartOptions().createOptionsXYDateFloatLogYAxisLegendOutside(series)).show(),
			true);

}
 
Example #10
Source File: DefaultVerticalLayoutDropHandler.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected void handleHTML5Drop(DragAndDropEvent event) {
    VerticalLayoutTargetDetails details = (VerticalLayoutTargetDetails) event
            .getTargetDetails();
    AbstractOrderedLayout layout = (AbstractOrderedLayout) details
            .getTarget();
    int idx = (details).getOverIndex();

    // Increase index if component is dropped after or above a
    // previous
    // component
    VerticalDropLocation loc = (details).getDropLocation();
    if (loc == VerticalDropLocation.MIDDLE
            || loc == VerticalDropLocation.BOTTOM) {
        idx++;
    }

    Component comp = resolveComponentFromHTML5Drop(event);

    // Add component
    if (idx >= 0) {
        layout.addComponent(comp, idx);
    } else {
        layout.addComponent(comp);
    }

    // Add component alignment if given
    if (dropAlignment != null) {
        layout.setComponentAlignment(comp, dropAlignment);
    }

}
 
Example #11
Source File: DefaultVerticalLayoutDropHandler.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected void handleHTML5Drop(DragAndDropEvent event) {
    VerticalLayoutTargetDetails details = (VerticalLayoutTargetDetails) event
            .getTargetDetails();
    AbstractOrderedLayout layout = (AbstractOrderedLayout) details
            .getTarget();
    int idx = (details).getOverIndex();

    // Increase index if component is dropped after or above a
    // previous
    // component
    VerticalDropLocation loc = (details).getDropLocation();
    if (loc == VerticalDropLocation.MIDDLE
            || loc == VerticalDropLocation.BOTTOM) {
        idx++;
    }

    Component comp = resolveComponentFromHTML5Drop(event);

    // Add component
    if (idx >= 0) {
        layout.addComponent(comp, idx);
    } else {
        layout.addComponent(comp);
    }

    // Add component alignment if given
    if (dropAlignment != null) {
        layout.setComponentAlignment(comp, dropAlignment);
    }

}
 
Example #12
Source File: Box.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Try to imitate a VerticalGlue of Swing BoxLayout
 */
public static void addVerticalGlue(AbstractOrderedLayout layout) {
	Label label = new Label(" ");
	label.setHeight("100%");
	layout.addComponent(label);
	layout.setExpandRatio(label, 1.0f);
}
 
Example #13
Source File: AdminChartDataManagerImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public void createApplicationActionEventPageDailySummaryChart(final AbstractOrderedLayout content) {

	final Map<String, List<ViewApplicationActionEventPageDailySummary>> map = getApplicationActionEventPageDailySummaryMap();

	final DataSeries dataSeries = new DataSeries();

	final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);

	final Series series = new Series();

	for (final Entry<String, List<ViewApplicationActionEventPageDailySummary>> entry : map.entrySet()) {

		if (entry.getKey() != null) {
			series.addSeries(new XYseries().setLabel(entry.getKey()));

			dataSeries.newSeries();
			final List<ViewApplicationActionEventPageDailySummary> list = entry.getValue();
			for (final ViewApplicationActionEventPageDailySummary viewRiksdagenVoteDataBallotPartySummaryDaily : list) {
				dataSeries.add(
						simpleDateFormat.format(
								viewRiksdagenVoteDataBallotPartySummaryDaily.getEmbeddedId().getCreatedDate()),
						viewRiksdagenVoteDataBallotPartySummaryDaily.getHits());
			}
		}

	}

	addChart(content, "Application Action Events daily Summary",
			new DCharts().setDataSeries(dataSeries)
					.setOptions(getChartOptions().createOptionsXYDateFloatLogYAxisLegendOutside(series)).show(),
			true);
}
 
Example #14
Source File: WebWindow.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void add(Component childComponent, int index) {
    if (childComponent.getParent() != null && childComponent.getParent() != this) {
        throw new IllegalStateException("Component already has parent");
    }

    if (ownComponents.contains(childComponent)) {
        com.vaadin.ui.Component composition = childComponent.unwrapComposition(com.vaadin.ui.Component.class);
        int existingIndex = ((AbstractOrderedLayout)getContainer()).getComponentIndex(composition);
        if (index > existingIndex) {
            index--;
        }

        remove(childComponent);
    }

    com.vaadin.ui.ComponentContainer container = getContainer();
    com.vaadin.ui.Component vComponent = childComponent.unwrapComposition(com.vaadin.ui.Component.class);
    ((AbstractOrderedLayout)container).addComponent(vComponent, index);

    com.vaadin.ui.Alignment alignment = WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment());
    ((AbstractOrderedLayout) container).setComponentAlignment(vComponent, alignment);

    if (childComponent instanceof BelongToFrame
            && ((BelongToFrame) childComponent).getFrame() == null) {
        ((BelongToFrame) childComponent).setFrame(this);
    } else {
        registerComponent(childComponent);
    }

    if (index == ownComponents.size()) {
        ownComponents.add(childComponent);
    } else {
        ownComponents.add(index, childComponent);
    }

    childComponent.setParent(this);
}
 
Example #15
Source File: DecisionChartDataManagerImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public void createDecisionTypeChart(final AbstractOrderedLayout content) {

	final Map<String, List<ViewRiksdagenCommitteeDecisionTypeDailySummary>> map = getCommitteeDecisionTypeMap();

	final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);

	final DataSeries dataSeries = new DataSeries();

	final Series series = new Series();

	for (final Entry<String, List<ViewRiksdagenCommitteeDecisionTypeDailySummary>> entry : map.entrySet()) {

		if (entry.getKey() != null) {
			series.addSeries(new XYseries().setLabel(entry.getKey()));

			dataSeries.newSeries();
			final List<ViewRiksdagenCommitteeDecisionTypeDailySummary> list = entry.getValue();
			for (final ViewRiksdagenCommitteeDecisionTypeDailySummary item : list) {
				dataSeries.add(simpleDateFormat.format(item.getEmbeddedId().getDecisionDate()), item.getTotal());
			}
		}

	}

	addChart(content, "Decision type daily summary",
			new DCharts().setDataSeries(dataSeries)
					.setOptions(getChartOptions().createOptionsXYDateFloatLegendInsideOneColumn(series)).show(),
			true);
}
 
Example #16
Source File: DecisionChartDataManagerImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public void createDecisionTypeChart(final AbstractOrderedLayout content, final String org) {

	final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);

	final DataSeries dataSeries = new DataSeries();
	final Series series = new Series();

	final Map<String, List<ViewRiksdagenCommitteeDecisionTypeOrgDailySummary>> allMap = getCommitteeDecisionTypeOrgMap();

	final List<ViewRiksdagenCommitteeDecisionTypeOrgDailySummary> itemList = allMap
			.get(org.toUpperCase(Locale.ENGLISH).replace(UNDER_SCORE, EMPTY_STRING).trim());

	if (itemList != null) {

		final Map<String, List<ViewRiksdagenCommitteeDecisionTypeOrgDailySummary>> map = itemList.parallelStream()
				.filter(t -> t != null && t.getEmbeddedId().getDecisionDate() != null)
				.collect(Collectors.groupingBy(t -> t.getEmbeddedId().getDecisionType()));

		addDecisionTypeByOrgData(simpleDateFormat, dataSeries, series, map);
	}

	addChart(content, "Org Decision type daily summary",
			new DCharts().setDataSeries(dataSeries)
					.setOptions(getChartOptions().createOptionsXYDateFloatLegendInsideOneColumn(series)).show(),
			true);
}
 
Example #17
Source File: DefaultFormLayoutDropHandler.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected void handleHTML5Drop(DragAndDropEvent event) {
    FormLayoutTargetDetails details = (FormLayoutTargetDetails) event
            .getTargetDetails();
    int idx = details.getOverIndex();
    AbstractOrderedLayout layout = (AbstractOrderedLayout) details
            .getTarget();

    // Increase index if component is dropped after or above a
    // previous component
    VerticalDropLocation loc = details.getDropLocation();
    if (loc == VerticalDropLocation.MIDDLE
            || loc == VerticalDropLocation.BOTTOM) {
        idx++;
    }

    // Add component
    if (idx >= 0) {
        layout.addComponent(resolveComponentFromHTML5Drop(event), idx);
    } else {
        layout.addComponent(resolveComponentFromHTML5Drop(event));
    }

    // Add component alignment if given
    if (dropAlignment != null) {
        layout.setComponentAlignment(resolveComponentFromHTML5Drop(event),
                dropAlignment);
    }
}
 
Example #18
Source File: WebWindow.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected AbstractOrderedLayout createLayout() {
    CubaWindowVerticalLayout layout = new CubaWindowVerticalLayout();
    layout.setStyleName(C_WINDOW_LAYOUT);
    layout.setSizeFull();

    layout.addActionHandler(actionsHolder);

    return layout;
}
 
Example #19
Source File: WebWindow.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void resetExpanded() {
    if (getContainer() instanceof AbstractOrderedLayout) {
        AbstractOrderedLayout container = (AbstractOrderedLayout) getContainer();

        for (com.vaadin.ui.Component child : container) {
            container.setExpandRatio(child, 0.0f);
        }
    } else {
        throw new UnsupportedOperationException();
    }
}
 
Example #20
Source File: Box.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Try to imitate HorizontalStruct on Swing BoxLayout
 * @param layout Layout to add the struct
 * @param width struct withd
 */
public static void addHorizontalStruct(AbstractOrderedLayout layout, int width) {
	Label label = new Label();
	label.setWidth(width + "px");
	layout.addComponent(label);
	layout.setExpandRatio(label, 0f);
}
 
Example #21
Source File: AdminChartDataManagerImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public void createApplicationActionEventPageModeDailySummaryChart(final AbstractOrderedLayout content,
		final String page) {

	final Map<String, List<ViewApplicationActionEventPageModeDailySummary>> map = getApplicationActionEventPageModeDailySummaryMap(
			page);

	final DataSeries dataSeries = new DataSeries();

	final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);

	final Series series = new Series();

	for (final Entry<String, List<ViewApplicationActionEventPageModeDailySummary>> entry : map.entrySet()) {

		if (entry.getKey() != null) {
			series.addSeries(new XYseries().setLabel(entry.getKey()));

			dataSeries.newSeries();
			final List<ViewApplicationActionEventPageModeDailySummary> list = entry.getValue();
			for (final ViewApplicationActionEventPageModeDailySummary item : list) {
				dataSeries.add(simpleDateFormat.format(item.getEmbeddedId().getCreatedDate()), item.getHits());
			}
		}

	}

	addChart(content, "Page Action Events daily Summary",
			new DCharts().setDataSeries(dataSeries)
					.setOptions(getChartOptions().createOptionsXYDateFloatLogYAxisLegendOutside(series)).show(),
			true);
}
 
Example #22
Source File: BallotChartDataManagerImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public void createChart(final Tab tab,final AbstractOrderedLayout content,final ViewRiksdagenVoteDataBallotSummary viewRiksdagenVoteDataBallotSummary) {
	final DataSeries dataSeries = new DataSeries();

	dataSeries.newSeries().add("Yes", viewRiksdagenVoteDataBallotSummary.getYesVotes());
	dataSeries.newSeries().add("No", viewRiksdagenVoteDataBallotSummary.getNoVotes());
	dataSeries.newSeries().add("Abstain", viewRiksdagenVoteDataBallotSummary.getAbstainVotes());
	dataSeries.newSeries().add("Absent", viewRiksdagenVoteDataBallotSummary.getAbsentVotes());

	final String caption = "Summary : " +viewRiksdagenVoteDataBallotSummary.getEmbeddedId().getIssue() + " " + viewRiksdagenVoteDataBallotSummary.getEmbeddedId().getConcern();
	tab.setCaption(caption);

	addChart(content,caption, new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsDonoutChart()).show(), true);
}
 
Example #23
Source File: Box.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Try to imitate VerticalStruct of Swing BoxLayout
 * @param layout  layout to add struct
 * @param height struct height
 */
public static void addVerticalStruct(AbstractOrderedLayout layout, int height) {
	Label label = new Label();
	label.setHeight(height + "px");
	layout.addComponent(label);
	layout.setExpandRatio(label, 0f);
}
 
Example #24
Source File: BallotChartDataManagerImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public void createChart(final Tab tab,final AbstractOrderedLayout content,final List<ViewRiksdagenVoteDataBallotPartySummary> partyList) {
	final DataSeries dataSeries = new DataSeries();

	final Series series = new Series();

	series.addSeries(new XYseries().setLabel("Yes"));
	series.addSeries(new XYseries().setLabel("No"));
	series.addSeries(new XYseries().setLabel("Abstain"));
	series.addSeries(new XYseries().setLabel("Absent"));

	String caption=null;
	for (final ViewRiksdagenVoteDataBallotPartySummary viewRiksdagenVoteDataBallotPartySummary : partyList) {
		if (caption == null) {
			caption = "Party Summary : " + viewRiksdagenVoteDataBallotPartySummary.getEmbeddedId().getIssue() + " " + viewRiksdagenVoteDataBallotPartySummary.getEmbeddedId().getConcern();
			content.setCaption(caption);
			tab.setCaption(caption);
		}

		dataSeries.newSeries()
		.add(getPartyName(viewRiksdagenVoteDataBallotPartySummary.getEmbeddedId().getParty()), viewRiksdagenVoteDataBallotPartySummary.getPartyYesVotes())
		.add(getPartyName(viewRiksdagenVoteDataBallotPartySummary.getEmbeddedId().getParty()),viewRiksdagenVoteDataBallotPartySummary.getPartyNoVotes())
		.add(getPartyName(viewRiksdagenVoteDataBallotPartySummary.getEmbeddedId().getParty()),viewRiksdagenVoteDataBallotPartySummary.getPartyAbstainVotes())
		.add(getPartyName(viewRiksdagenVoteDataBallotPartySummary.getEmbeddedId().getParty()),viewRiksdagenVoteDataBallotPartySummary.getPartyAbsentVotes());
	}


	addChart(content,caption + " ( 4 circles Yes/No/Abstain/Absent votes by party )", new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsDonoutChartWithSeries(series)).show(), true);
}
 
Example #25
Source File: CommonDialogWindow.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private final void init() {

        if (content instanceof AbstractOrderedLayout) {
            ((AbstractOrderedLayout) content).setSpacing(true);
            ((AbstractOrderedLayout) content).setMargin(true);
        }
        if (content instanceof GridLayout) {
            addStyleName("marginTop");
        }

        if (content != null) {
            mainLayout.addComponent(content);
            mainLayout.setExpandRatio(content, 1.0F);
        }

        createMandatoryLabel();

        final HorizontalLayout buttonLayout = createActionButtonsLayout();
        mainLayout.addComponent(buttonLayout);
        mainLayout.setComponentAlignment(buttonLayout, Alignment.TOP_CENTER);

        setCaption(caption);
        setCaptionAsHtml(true);
        setContent(mainLayout);
        setResizable(false);
        center();
        setModal(true);
        addStyleName("fontsize");
        setOrginaleValues();
        addComponentListeners();
    }
 
Example #26
Source File: FormFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends Serializable> void addFormPanelTextFields(final AbstractOrderedLayout panelContent, final T item,
		final Class<T> beanType, final List<String> displayProperties) {


	final Panel formPanel = new Panel();
	formPanel.setSizeFull();


	panelContent.addComponent(formPanel);
	if (displayProperties.size() > SIZE_FOR_GRID) {
		panelContent.setExpandRatio(formPanel, ContentRatio.GRID);
	}
	else {
		panelContent.setExpandRatio(formPanel, ContentRatio.SMALL_GRID);
	}


	final FormLayout formContent = new FormLayout();
	formPanel.setContent(formContent);
	formContent.setWidth(ContentSize.FULL_SIZE);

	final Binder<T> binder = new Binder<>(beanType);
	binder.setBean(item);
	binder.setReadOnly(true);

	PropertyDescriptor[] propertyDescriptors=null;
	try {
		final BeanInfo info = Introspector.getBeanInfo(item.getClass());
		propertyDescriptors = info.getPropertyDescriptors();
	} catch (final IntrospectionException exception) {
		LOGGER.error("No able to getfieldtypes for type:+ item.getClass()", exception);
	}

	createDisplayPropertyConverters(displayProperties, formContent, binder, propertyDescriptors);
}
 
Example #27
Source File: GridFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends Serializable> void createBasicBeanItemGrid(final AbstractOrderedLayout panelContent,
		final Class<T> dataType, final List<T> datasource, final String caption, final String[] columnOrder,
		final String[] hideColumns, final PageItemRendererClickListener<?> listener, final String actionId,
		final ListPropertyConverter[] collectionPropertyConverters) {
	createBasicBeanItemNestedPropertiesGrid(panelContent, dataType, datasource, caption, null, columnOrder,
			hideColumns, listener, actionId, collectionPropertyConverters);

}
 
Example #28
Source File: GovernmentBodyChartDataManagerImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public void createMinistryGovernmentBodyHeadcountSummaryChart(final AbstractOrderedLayout content,
		final String name) {
	final Map<Integer, List<GovernmentBodyAnnualSummary>> map = esvApi.getDataPerMinistry(name);
	final List<String> governmentBodyNames = esvApi.getGovernmentBodyNames(name);

	final DataSeries dataSeries = new DataSeries();
	final Series series = new Series();

	for (final String govBodyName : governmentBodyNames) {

		series.addSeries(new XYseries().setLabel(govBodyName));
		dataSeries.newSeries();

		for (final Entry<Integer, List<GovernmentBodyAnnualSummary>> entry : map.entrySet()) {
			addDataSerieValue(dataSeries, entry, entry.getValue().stream()
					.filter((final GovernmentBodyAnnualSummary p) -> p.getName().equalsIgnoreCase(govBodyName))
					.mapToInt(GovernmentBodyAnnualSummary::getHeadCount).sum());
		}
	}

	addChart(content, name + ANNUAL_HEADCOUNT_SUMMARY_ALL_GOVERNMENT_BODIES,
			new DCharts().setDataSeries(dataSeries)
					.setOptions(getChartOptions().createOptionsXYDateFloatLogYAxisLegendOutside(series)).show(),
			true);

}
 
Example #29
Source File: AbstractChartDataManagerImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the chart.
 *
 * @param content
 *            the content
 * @param caption
 *            the caption
 * @param chart
 *            the chart
 * @param fullPage
 *            the full page
 */
protected final void addChart(final AbstractOrderedLayout content,final String caption, final DCharts chart, final boolean fullPage) {
	final HorizontalLayout horizontalLayout = new HorizontalLayout();

	final int browserWindowWidth = getChartWindowWidth();

	final int browserWindowHeight = getChartWindowHeight(fullPage);

	horizontalLayout.setWidth(browserWindowWidth, Unit.PIXELS);
	horizontalLayout.setHeight(browserWindowHeight, Unit.PIXELS);
	horizontalLayout.setMargin(true);
	horizontalLayout.setSpacing(false);
	horizontalLayout.addStyleName("v-layout-content-overview-panel-level1");

	final Panel formPanel = new Panel();
	formPanel.setSizeFull();
	formPanel.setContent(horizontalLayout);
	formPanel.setCaption(caption);

	content.addComponent(formPanel);
	content.setExpandRatio(formPanel, ContentRatio.LARGE);


	chart.setWidth(100, Unit.PERCENTAGE);
	chart.setHeight(100, Unit.PERCENTAGE);
	chart.setMarginRight(CHART_RIGHT_MARGIN);
	chart.setMarginLeft(CHART_LEFT_MARGIN);
	chart.setMarginBottom(CHART_BOTTOM_MARGIN_SIZE);
	chart.setMarginTop(CHART_TOP_MARGIN_SIZE);

	horizontalLayout.addComponent(chart);
	chart.setCaption(caption);
}
 
Example #30
Source File: WorldIndicatorChartDataManagerImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public void createIndicatorChart(final AbstractOrderedLayout content,final List<WorldBankData> list,
		final ViewWorldbankIndicatorDataCountrySummary summary) {

	final Map<Country, List<WorldBankData>> countryIndicatorsMap = list.stream()
			.collect(Collectors.groupingBy(WorldBankData::getCountry, Collectors.toList()));


	final Series series = new Series();
	final DataSeries dataSeries = new DataSeries();


	for (final Entry<Country, List<WorldBankData>> entry : countryIndicatorsMap.entrySet() ) {
		series.addSeries(new XYseries().setLabel(entry.getKey().getValue()));

		dataSeries.newSeries();

		for (final WorldBankData item : entry.getValue()) {
			if (item != null && item.getYearDate() != null && item.getDataValue() != null
					&& !item.getDataValue().isEmpty()) {
				dataSeries.add(item.getYearDate() + "-01-01", Float.valueOf(item.getDataValue()));
			}
		}
	}

	addChart(content,summary.getIndicatorName(), new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsCountryLineChart(series)).show(), false);
}