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: AggregatedCountryDataPanel.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/user/AggregatedCountryDataPanel.java $
18  */
19  package com.hack23.cia.web.impl.ui.page.user;
20  
21  import java.awt.geom.Point2D;
22  
23  import org.vaadin.hezamu.googlemapwidget.GoogleMap;
24  import org.vaadin.hezamu.googlemapwidget.GoogleMap.MapControl;
25  import org.vaadin.navigator7.ParamPageLink;
26  
27  import com.hack23.cia.model.internal.application.data.impl.AggregatedCountryData;
28  import com.hack23.cia.web.impl.ui.common.ApplicationUserStateHolder;
29  import com.hack23.cia.web.impl.ui.page.common.panel.AbstractPanel;
30  import com.vaadin.Application;
31  import com.vaadin.ui.GridLayout;
32  import com.vaadin.ui.Label;
33  
34  /**
35   * The Class AggregatedCountryDataPanel.
36   */
37  public final class AggregatedCountryDataPanel extends AbstractPanel {
38  
39  	/** The grid. */
40  	private GridLayout grid = null;
41  
42  	/** The Constant serialVersionUID. */
43  	private static final long serialVersionUID = 1L;
44  
45  	/**
46  	 * Instantiates a new aggregated country data panel.
47  	 */
48  	public AggregatedCountryDataPanel() {
49  		super();
50  	}
51  
52  	/**
53  	 * Update.
54  	 *
55  	 * @param countryData
56  	 *            the country data
57  	 */
58  	public void update(final AggregatedCountryData countryData) {
59  		grid =new GridLayout(2,20);
60  		setContent(grid);
61  		grid.setSizeFull();
62  		grid.setSpacing(true);
63  		grid.setMargin(true);
64  
65  		grid.addComponent( new ParamPageLink(countryData.getCountry().getName(), CountryPage.class,countryData.getCountry().getName(),countryData.getCountry().getIso2Code()),0,0,1,0);
66  		grid.addComponent(new Label(translateFromEnglish("Capital city") +":" + countryData.getCountry().getCapitalCity()),0,1,1,1);
67  		grid.addComponent(new Label(translateFromEnglish("Region") + ":" + countryData.getCountry().getRegion().getValue().toString()),0,2,1,2);
68  		grid.addComponent(new Label(translateFromEnglish("Income Level") +":" +countryData.getCountry().getIncomeLevel().getValue().toString()),0,3,1,3);
69  		grid.addComponent(new Label(translateFromEnglish("Lending type") + ":" +countryData.getCountry().getLendingType().getValue().toString()),0,4,1,4);
70  
71  		final GoogleMap googleMap = new GoogleMap((Application) ApplicationUserStateHolder.getUserState(), new Point2D.Double(Double.parseDouble(countryData.getCountry().getLongitude()),Double.parseDouble(countryData.getCountry().getLatitude())), 8,"ABQIAAAAagA4tNdqcS8SXcZ_cgTm_RQivw8bcKxPPx7tIHHiFwHV7JsBShRkP80wfGiF4WJMBTHoFKIMAx_ohg");
72  		grid.addComponent(googleMap,0,5,1,19);
73  		googleMap.addControl(MapControl.MenuMapTypeControl);
74  
75  		googleMap.setSizeFull();
76  		setCaption(countryData.getCountry().getName());
77  	}
78  
79  }