Subversion Repositories eFlore/Archives.cel-v2

Rev

Rev 45 | Rev 47 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 45 Rev 46
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
2
 
2
 
3
import org.tela_botanica.client.image.ImageMediateur;
3
import org.tela_botanica.client.image.ImageMediateur;
4
import org.tela_botanica.client.interfaces.Rafraichissable;
4
import org.tela_botanica.client.interfaces.Rafraichissable;
5
 
5
 
6
import com.google.gwt.user.client.Event;
6
import com.google.gwt.user.client.Event;
7
import com.google.gwt.user.client.ui.ClickListener;
7
import com.google.gwt.user.client.ui.ClickListener;
8
import com.google.gwt.user.client.ui.Image;
8
import com.google.gwt.user.client.ui.Image;
9
import com.google.gwt.user.client.ui.MouseListener;
9
import com.google.gwt.user.client.ui.MouseListener;
10
import com.google.gwt.user.client.ui.MouseListenerAdapter;
10
import com.google.gwt.user.client.ui.MouseListenerAdapter;
11
import com.google.gwt.user.client.ui.Widget;
11
import com.google.gwt.user.client.ui.Widget;
12
import com.gwtext.client.core.EventObject;
12
import com.gwtext.client.core.EventObject;
13
import com.gwtext.client.widgets.Panel;
13
import com.gwtext.client.widgets.Panel;
14
 
14
 
15
public class BarreNotationVue extends Panel implements Rafraichissable {
15
public class BarreNotationVue extends Panel implements Rafraichissable {
16
 
16
 
17
	private ImageMediateur iMediateur = null ;
17
	private ImageMediateur iMediateur = null ;
18
	private int noteEnCours = 0 ;
18
	private int noteEnCours = 0 ;
19
	private int noteMax = 0 ;
19
	private int noteMax = 0 ;
20
	private int noteCurseur = 0 ;
20
	private int noteCurseur = 0 ;
-
 
21
	private boolean estNote = false ;
21
	private Image[] etoiles = null ;
22
	private Image[] etoiles = null ;
22
	
23
	
23
	private BarreNotationVue()
24
	private BarreNotationVue()
24
	{
25
	{
25
		super() ;
26
		super() ;
26
	}
27
	}
27
	
28
	
28
	public BarreNotationVue(ImageMediateur im, int noteMax)
29
	public BarreNotationVue(ImageMediateur im, int noteMax)
29
	{
30
	{
30
		super("Notation") ;
-
 
31
		iMediateur = im ;
31
		iMediateur = im ;
32
		setNoteMax(noteMax) ;
32
		setNoteMax(noteMax) ;
33
		this.setSize(200, 300) ;
33
		this.setSize(200, 100) ;
-
 
34
		this.setBodyBorder(false) ;
-
 
35
		this.setBorder(false) ;
34
		
36
		
35
		ajouterListeners() ;
37
		ajouterListeners() ;
36
		
38
		
37
	}
39
	}
38
	
40
	
39
	public void ajouterListeners()
41
	public void ajouterListeners()
40
	{
42
	{
41
		for (int i = 0; i < etoiles.length; i++) {
43
		for (int i = 0; i < etoiles.length; i++) {
42
			
44
			
43
			noteCurseur = i ;
45
			noteCurseur = i ;
44
			
46
			
45
			etoiles[i].addMouseListener(new MouseListenerAdapter() {
47
			etoiles[i].addMouseListener(new MouseListenerAdapter() {
46
 
48
 
47
 
49
 
48
				public void onMouseEnter(Widget sender) {
50
				public void onMouseEnter(Widget sender) {
49
					
51
					
50
					Image enCours = (Image)sender ;
52
					Image enCours = (Image)sender ;
51
					int nEnCours = 0 ;
53
					int nEnCours = 0 ;
52
					
54
					
53
					for(int i = 0 ; etoiles[i] != enCours ; i++)
55
					for(int i = 0 ; etoiles[i] != enCours ; i++)
54
					{
56
					{
55
						etoiles[i].setUrl("etoile_curseur.jpg") ;
57
						etoiles[i].setUrl("etoile_curseur.jpg") ;
56
						nEnCours = i ;
58
						nEnCours = i ;
57
					}
59
					}
58
						enCours.setUrl("etoile_curseur.jpg") ;
60
						enCours.setUrl("etoile_curseur.jpg") ;
59
					
61
					
60
				}
62
				}
61
 
63
 
62
				public void onMouseLeave(Widget sender) {
64
				public void onMouseLeave(Widget sender) {
63
				
65
				
64
					noter() ;
66
					afficherNote() ;
65
				}
67
				}
66
 
68
 
67
				
69
				
68
			}) ;
70
			}) ;
69
			
71
			
70
			etoiles[i].addClickListener(new ClickListener() {
72
			etoiles[i].addClickListener(new ClickListener() {
71
 
73
 
72
				public void onClick(Widget sender) {
74
				public void onClick(Widget sender) {
73
					
75
					
74
					int i = 0 ;
76
					int i = 0 ;
75
					
77
					
76
					while(etoiles[i] != (Image)sender)
78
					while(etoiles[i] != (Image)sender)
77
					{
79
					{
78
						i++ ;
80
						i++ ;
79
					}			
81
					}			
80
					
-
 
81
					noteEnCours = i ;
82
					
82
					noter() ;
83
					noter(i) ;
83
					System.out.println("Nouvelle note : "+noteEnCours);
84
					System.out.println("Nouvelle note : "+noteEnCours);
84
					
85
					
85
				}
86
				}
86
				
87
				
87
				
88
				
88
			}) ;
89
			}) ;
89
		}
90
		}
90
		
91
		
91
	}
92
	}
92
	
93
	
93
	
94
	
94
	public void rafraichir(Object nouvelleDonnees,
95
	public void rafraichir(Object nouvelleDonnees,
95
			boolean repandreRaffraichissement) {
96
			boolean repandreRaffraichissement) {
96
		// TODO Auto-generated method stub
-
 
-
 
97
		
-
 
98
		if(nouvelleDonnees instanceof String[])
-
 
99
		{
-
 
100
			estNote = false ;
-
 
101
			
-
 
102
			String[] note = (String[])nouvelleDonnees ;
-
 
103
			int noteInt = Integer.parseInt(note[0]) ;
-
 
104
			
-
 
105
			System.out.println("Note reçue : "+noteInt);
-
 
106
			if(noteInt != -1)
-
 
107
			{
-
 
108
				noter(noteInt) ;
-
 
109
			}
-
 
110
			else
-
 
111
			{
-
 
112
				noteEnCours = 0 ;
-
 
113
				afficherNote() ;
-
 
114
			}
-
 
115
			
-
 
116
		}
-
 
117
		
-
 
118
	}
-
 
119
	
-
 
120
	public void noter(int note)
-
 
121
	{
-
 
122
		noteEnCours = note ;
-
 
123
		estNote = true ;
97
		
124
		afficherNote() ;
98
	}
125
	}
99
	
126
	
100
	public void setNoteMax(int nMax)
127
	public void setNoteMax(int nMax)
101
	{
128
	{
102
		noteMax = nMax ;
129
		noteMax = nMax ;
103
		etoiles = new Image[noteMax] ;
130
		etoiles = new Image[noteMax] ;
104
		
131
		
105
		for(int i = 0 ; i < noteMax ; i++)
132
		for(int i = 0 ; i < noteMax ; i++)
106
		{
133
		{
107
			etoiles[i] = new Image("etoile_vide.jpg") ;
134
			etoiles[i] = new Image("etoile_vide.jpg") ;
108
			this.add(etoiles[i]) ;
135
			this.add(etoiles[i]) ;
109
		}
136
		}
110
	}
137
	}
111
	
138
	
112
	public void noter()
139
	public void afficherNote()
113
	{
140
	{
114
		for(int j = 0 ; j <= noteEnCours ; j++)
141
		if(estNote)
-
 
142
		{
-
 
143
			for(int i = 0 ; i <= noteEnCours ; i++)
115
		{
144
			{
-
 
145
				etoiles[i].setUrl("etoile_notee.jpg") ;
-
 
146
			}
-
 
147
			
-
 
148
			for (int j = noteEnCours + 1 ; j < noteMax ; j++) 
-
 
149
			{						
-
 
150
				etoiles[j].setUrl("etoile_vide.jpg") ;						
116
			etoiles[j].setUrl("etoile_notee.jpg") ;
151
			}
-
 
152
		}
117
		}
153
		else
118
		
154
		{
-
 
155
			for(int i = 0 ; i < noteMax ; i++)
119
		for (int j = noteEnCours + 1 ; j <= noteMax ; j++) {						
156
			{
-
 
157
				etoiles[i].setUrl("etoile_vide.jpg") ;
120
			etoiles[j].setUrl("etoile_vide.jpg") ;						
158
			}
-
 
159
		}
-
 
160
		
-
 
161
		
-
 
162
	}
-
 
163
	
-
 
164
	public String getNote()
-
 
165
	{
121
		}
166
		return ""+noteEnCours ;
122
	}
-
 
123
 
167
	}
124
 
168
 
125
}
169
}