Subversion Repositories eFlore/Applications.cel

Rev

Rev 97 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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