Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 84 Rev 97
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
2
 
2
 
3
import org.tela_botanica.client.interfaces.Rafraichissable;
3
import org.tela_botanica.client.interfaces.Rafraichissable;
4
import org.tela_botanica.client.observation.ObservationMediateur;
4
import org.tela_botanica.client.observation.ObservationMediateur;
-
 
5
 
-
 
6
import com.google.gwt.user.client.DOM;
-
 
7
import com.google.gwt.user.client.Event;
5
 
8
import com.google.gwt.user.client.Window;
-
 
9
import com.google.gwt.user.client.ui.Image;
6
import com.google.gwt.user.client.ui.Image;
10
import com.gwtext.client.core.Ext;
7
import com.gwtext.client.widgets.Panel;
11
import com.gwtext.client.widgets.Panel;
8
 
12
 
9
/**
13
/**
10
 * Un panneau affichant la repartition d'une plante
14
 * Un panneau affichant la repartition d'une plante
11
 * 
15
 * 
12
 * @author David Delon
16
 * @author David Delon
13
 * 
17
 * 
14
 */
18
 */
15
public class InformationRepartitionVue extends Panel implements Rafraichissable {
19
public class InformationRepartitionVue extends Panel implements Rafraichissable {
16
 
20
 
17
	/**
21
	/**
18
	 * Le médiateur associé
22
	 * Le médiateur associé
19
	 */
23
	 */
20
	
24
	
21
	private ObservationMediateur observationMediateur = null;
25
	private ObservationMediateur observationMediateur = null;
22
	
26
	
23
	
27
	
24
	/**
28
	/**
25
	 * l'image à afficher
29
	 * l'image à afficher
26
	 */
30
	 */
27
	private Image image = new Image();
31
	private Image image = new Image();
-
 
32
	
-
 
33
	private String urlImage = "" ;
-
 
34
	
28
	
35
	com.gwtext.client.widgets.Window imgZoom = new com.gwtext.client.widgets.Window("Agrandissement") ;
29
	
36
	
30
	/**
37
	/**
31
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
38
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
32
	 */
39
	 */
33
	
40
	
34
	@SuppressWarnings("unused")
41
	@SuppressWarnings("unused")
35
	private InformationRepartitionVue() {
42
	private InformationRepartitionVue() {
36
		super();
43
		super();
37
	}
44
	}
38
 
45
 
39
	/**
46
	/**
40
	 * Constructeur avec argument
47
	 * Constructeur avec argument
41
	 * @param obs le médiateur à associer
48
	 * @param obs le médiateur à associer
42
	 */
49
	 */
43
	
50
	
44
	
51
	
45
	public InformationRepartitionVue(ObservationMediateur obs) {
52
	public InformationRepartitionVue(ObservationMediateur obs) {
46
		
53
		
47
			
54
			
48
		this.observationMediateur = obs;
55
		this.observationMediateur = obs;
-
 
56
		
-
 
57
		imgZoom.setCloseAction(com.gwtext.client.widgets.Window.HIDE) ;
-
 
58
		image = new Image() {
-
 
59
 
-
 
60
			public void onBrowserEvent(Event event) {
-
 
61
 
-
 
62
				// lors du double clic
-
 
63
				if (Event.ONDBLCLICK == DOM.eventGetType(event)) {
-
 
64
 
-
 
65
					// on notifie le médiateur
-
 
66
					agrandirImage() ;
-
 
67
				}
-
 
68
			}
-
 
69
			
-
 
70
		};
-
 
71
		
-
 
72
		image.sinkEvents(Event.ONDBLCLICK);
-
 
73
		
49
		
74
		this.setCls("x-image-info-rep") ;
50
		image.setPixelSize(150, 150);
75
		image.setPixelSize(150, 150);
51
		add(image);
76
		add(image);
52
		
77
		
53
		// on ajoute les listeners
78
		// on ajoute les listeners
54
		ajouterListeners();
79
		ajouterListeners();
55
 
80
 
56
	}
81
	}
57
 
82
 
58
 
83
 
59
	/**
84
	/**
60
	 * Affichage carte de repartition
85
	 * Affichage carte de repartition
61
	 * 
86
	 * 
62
	 */
87
	 */
63
	
88
	
64
	public void rafraichir(Object nouvelleDonnees,boolean repandreRaffraichissement) {
89
	public void rafraichir(Object nouvelleDonnees,boolean repandreRaffraichissement) {
65
 
90
 
66
		// si on recoit une String contenant une URL
91
		// si on recoit une String contenant une URL
67
		if (nouvelleDonnees instanceof String) {
92
		if (nouvelleDonnees instanceof String) {
68
			
93
			
69
			String urlImage=(String) nouvelleDonnees;
94
			urlImage=(String) nouvelleDonnees;
70
			
95
			
71
			if (urlImage.length()==0) {
96
			if (urlImage.length()==0) {
72
				raz() ;
97
				raz() ;
73
			}
98
			}
74
			else {
99
			else {
75
				image.setUrl(urlImage);
100
				image.setUrl(urlImage);
76
			}
101
			}
77
		}
102
		}
78
				
103
				
79
	}
104
	}
-
 
105
	
-
 
106
	public void agrandirImage() {
-
 
107
		
-
 
108
		if(!imgZoom.isVisible())
-
 
109
		{
-
 
110
			String urlAgrandie = urlImage.replace("min", "max") ;
-
 
111
	
-
 
112
			imgZoom.setHtml("<img src=\""+urlAgrandie+"\" />") ;
-
 
113
			imgZoom.setPagePosition( Window.getClientWidth()/2, Window.getClientHeight()/5) ;
-
 
114
			imgZoom.setAutoHeight(true) ;
-
 
115
			imgZoom.setAutoWidth(true) ;
-
 
116
			imgZoom.show(this.getElement()) ;
-
 
117
		}
-
 
118
		
-
 
119
	}
80
 
120
 
81
	
121
	
82
	/**
122
	/**
83
	 * Ajoute les listeners pour la gestions d'évènement
123
	 * Ajoute les listeners pour la gestions d'évènement
84
	 */
124
	 */
85
	public void ajouterListeners() {
125
	public void ajouterListeners() {
86
		
126
		
87
	}
127
	}
88
	
128
	
89
	public void raz() {
129
	public void raz() {
90
		image.setUrl("");
130
		image.setUrl("");
91
	}
131
	}
92
 
132
 
93
}
133
}