Subversion Repositories eFlore/Archives.cel-v2

Rev

Rev 46 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
45 aperonnet 1
package org.tela_botanica.client.vues;
2
 
3
import org.tela_botanica.client.image.ImageMediateur;
4
import org.tela_botanica.client.interfaces.Rafraichissable;
5
 
6
import com.google.gwt.user.client.Event;
7
import com.google.gwt.user.client.ui.ClickListener;
8
import com.google.gwt.user.client.ui.Image;
9
import com.google.gwt.user.client.ui.MouseListener;
10
import com.google.gwt.user.client.ui.MouseListenerAdapter;
11
import com.google.gwt.user.client.ui.Widget;
12
import com.gwtext.client.core.EventObject;
13
import com.gwtext.client.widgets.Panel;
14
 
15
public class BarreNotationVue extends Panel implements Rafraichissable {
16
 
17
	private ImageMediateur iMediateur = null ;
18
	private int noteEnCours = 0 ;
19
	private int noteMax = 0 ;
20
	private int noteCurseur = 0 ;
21
	private Image[] etoiles = null ;
22
 
23
	private BarreNotationVue()
24
	{
25
		super() ;
26
	}
27
 
28
	public BarreNotationVue(ImageMediateur im, int noteMax)
29
	{
30
		super("Notation") ;
31
		iMediateur = im ;
32
		setNoteMax(noteMax) ;
33
		this.setSize(200, 300) ;
34
 
35
		ajouterListeners() ;
36
 
37
	}
38
 
39
	public void ajouterListeners()
40
	{
41
		for (int i = 0; i < etoiles.length; i++) {
42
 
43
			noteCurseur = i ;
44
 
45
			etoiles[i].addMouseListener(new MouseListenerAdapter() {
46
 
47
 
48
				public void onMouseEnter(Widget sender) {
49
 
50
					Image enCours = (Image)sender ;
51
					int nEnCours = 0 ;
52
 
53
					for(int i = 0 ; etoiles[i] != enCours ; i++)
54
					{
55
						etoiles[i].setUrl("etoile_curseur.jpg") ;
56
						nEnCours = i ;
57
					}
58
						enCours.setUrl("etoile_curseur.jpg") ;
59
 
60
				}
61
 
62
				public void onMouseLeave(Widget sender) {
63
 
64
					noter() ;
65
				}
66
 
67
 
68
			}) ;
69
 
70
			etoiles[i].addClickListener(new ClickListener() {
71
 
72
				public void onClick(Widget sender) {
73
 
74
					int i = 0 ;
75
 
76
					while(etoiles[i] != (Image)sender)
77
					{
78
						i++ ;
79
					}
80
 
81
					noteEnCours = i ;
82
					noter() ;
83
					System.out.println("Nouvelle note : "+noteEnCours);
84
 
85
				}
86
 
87
 
88
			}) ;
89
		}
90
 
91
	}
92
 
93
 
94
	public void rafraichir(Object nouvelleDonnees,
95
			boolean repandreRaffraichissement) {
96
		// TODO Auto-generated method stub
97
 
98
	}
99
 
100
	public void setNoteMax(int nMax)
101
	{
102
		noteMax = nMax ;
103
		etoiles = new Image[noteMax] ;
104
 
105
		for(int i = 0 ; i < noteMax ; i++)
106
		{
107
			etoiles[i] = new Image("etoile_vide.jpg") ;
108
			this.add(etoiles[i]) ;
109
		}
110
	}
111
 
112
	public void noter()
113
	{
114
		for(int j = 0 ; j <= noteEnCours ; j++)
115
		{
116
			etoiles[j].setUrl("etoile_notee.jpg") ;
117
		}
118
 
119
		for (int j = noteEnCours + 1 ; j <= noteMax ; j++) {
120
			etoiles[j].setUrl("etoile_vide.jpg") ;
121
		}
122
	}
123
 
124
 
125
}