Subversion Repositories eFlore/Applications.del

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 benjamin 1
package org.tela_botanica.del.client.vues.rechercheobservations.vote;
9 benjamin 2
 
3
import java.util.List;
4
 
5
import org.cobogw.gwt.user.client.ui.Rating;
14 benjamin 6
import org.tela_botanica.del.client.modeles.ObservationValidation;
9 benjamin 7
 
8
import com.google.gwt.user.client.ui.Composite;
9
import com.google.gwt.user.client.ui.HTML;
10
import com.google.gwt.user.client.ui.HorizontalPanel;
11
import com.google.gwt.user.client.ui.Panel;
12
import com.google.gwt.user.client.ui.VerticalPanel;
13
 
14 benjamin 14
public class MoyenneVoteVue extends Composite {
9 benjamin 15
 
16
	private Panel mainPanel = new VerticalPanel();
17
 
14 benjamin 18
	protected MoyenneVoteVue(List<ObservationValidation> validationDatas) {
9 benjamin 19
 
20
		int meanVote = 0;
21
		int nbVote = 0;
14 benjamin 22
		for (ObservationValidation imageCelValidationData : validationDatas) {
9 benjamin 23
 
24
			meanVote += imageCelValidationData.getVote();
25
			nbVote++;
26
		}
27
		if (nbVote > 0)
28
			meanVote /= nbVote;
29
 
30
		Panel ratePanel = new HorizontalPanel();
31
		Rating rating = new Rating(meanVote, 5);
32
		rating.setReadOnly(true);
33
 
34
		ratePanel.add(new HTML("Moyenne: "));
35
		ratePanel.add(rating);
36
		ratePanel.add(new HTML("&nbsp;&nbsp;Nb votes: "
37
				+ validationDatas.size()));
38
 
39
		mainPanel.add(ratePanel);
40
 
41
		initWidget(mainPanel);
42
 
43
	}
44
}