View Javadoc

1   /*
2    * Copyright 2010 James Pether Sörling
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   *	$Id: TestPage.java 5436 2011-04-26 18:25:22Z pether $
17   *  $HeadURL: https://cia.svn.sourceforge.net/svnroot/cia/trunk/citizen-intelligence-agency/src/main/java/com/hack23/cia/web/impl/ui/page/dev/TestPage.java $
18  */
19  package com.hack23.cia.web.impl.ui.page.dev;
20  
21  import java.util.List;
22  import java.util.Map;
23  
24  import org.vaadin.navigator7.Page;
25  import org.vaadin.vaadinvisualizations.OrganizationalChart;
26  import org.vaadin.vaadinvisualizations.PieChart;
27  
28  import com.hack23.cia.model.external.riksdagen.person.impl.RoleStatus;
29  import com.hack23.cia.model.external.riksdagen.person.impl.SexType;
30  import com.hack23.cia.service.api.DataContainer;
31  import com.hack23.cia.service.api.DataSummary;
32  import com.hack23.cia.service.api.DataSummary.DataSummaryId;
33  import com.hack23.cia.web.impl.ui.page.user.AbstractUserPage;
34  import com.vaadin.ui.GridLayout;
35  
36  /**
37   * The Class TestPage.
38   */
39  @Page(uriName = "test", crawlable = true)
40  @SuppressWarnings("serial")
41  public final class TestPage extends AbstractUserPage {
42  
43  	/** The content. */
44  	private final GridLayout content = new GridLayout(2, 2);
45  
46  	/**
47  	 * Instantiates a new test page.
48  	 */
49  	public TestPage() {
50  		super();
51  		final DataContainer<DataSummary, DataSummaryId> dataContainer = getApplicationManager()
52  				.getDataContainer(DataSummary.class);
53  
54  		final List<DataSummary> all = dataContainer.getAll();
55  
56  		final DataSummary dataSummary = all.iterator().next();
57  
58  		final OrganizationalChart oc = new OrganizationalChart();
59  
60  		oc.setSizeFull();
61  		oc.setOption("size", "medium");
62  		oc.setOption("allowCollapse", false);
63  		oc.add("Riksdagen", "", "Riksdagen Content");
64  		oc.add("ParliamentMember", "Riksdagen", "ParliamentMembers :"
65  				+ dataSummary.personSize);
66  		oc.add("Active",
67  				"ParliamentMember",
68  				"Active members :"
69  						+ dataSummary.roleStatusMap
70  								.get(RoleStatus.TJÄNSTGÖRANDE_RIKSDAGSLEDAMOT));
71  		oc.add("Substitute",
72  				"ParliamentMember",
73  				"Substitute members :"
74  						+ dataSummary.roleStatusMap
75  								.get(RoleStatus.TJÄNSTGÖRANDE_ERSÄTTARE));
76  		content.addComponent(oc);
77  
78  		final PieChart roleStatusPieChart = new PieChart();
79  		roleStatusPieChart.setOption("is3D", true);
80  		roleStatusPieChart.setOption("width", 200);
81  		roleStatusPieChart.setOption("height", 200);
82  
83  		final Map<RoleStatus, Integer> roleStatusMap = dataSummary.roleStatusMap;
84  		for (final RoleStatus roleStatus : roleStatusMap.keySet()) {
85  			roleStatusPieChart.add(roleStatus.toString(),
86  					roleStatusMap.get(roleStatus));
87  		}
88  		content.addComponent(roleStatusPieChart);
89  
90  		final PieChart sexTypePieChart = new PieChart();
91  		sexTypePieChart.setOption("is3D", true);
92  		sexTypePieChart.setOption("width", 200);
93  		sexTypePieChart.setOption("height", 200);
94  
95  		final Map<SexType, Integer> sexTypeMap = dataSummary.sexMap;
96  		for (final SexType sexType : sexTypeMap.keySet()) {
97  			sexTypePieChart.add(sexType.toString(), sexTypeMap.get(sexType));
98  		}
99  		content.addComponent(sexTypePieChart);
100 
101 		content.setSizeFull();
102 		content.setMargin(true);
103 		content.setSpacing(true);
104 		setCompositionRoot(content);
105 		setHeight(getScreenHeight());
106 
107 	}
108 
109 	/* (non-Javadoc)
110 	 * @see com.hack23.cia.web.impl.ui.page.common.AbstractPage#getPageTitle()
111 	 */
112 	@Override
113 	public String getPageTitle() {
114 		return "";
115 	}
116 
117 
118 }