Subversion Repositories eFlore/Applications.cel

Rev

Rev 84 | Rev 99 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
54 david 1
package org.tela_botanica.client.vues;
2
 
3
import org.tela_botanica.client.interfaces.Rafraichissable;
4
import org.tela_botanica.client.observation.ObservationMediateur;
5
 
97 jpm 6
import com.google.gwt.user.client.DOM;
7
import com.google.gwt.user.client.Event;
8
import com.google.gwt.user.client.Window;
54 david 9
import com.google.gwt.user.client.ui.Image;
97 jpm 10
import com.gwtext.client.core.Ext;
54 david 11
import com.gwtext.client.widgets.Panel;
12
 
13
/**
14
 * Un panneau affichant la repartition d'une plante
15
 *
16
 * @author David Delon
17
 *
18
 */
19
public class InformationRepartitionVue extends Panel implements Rafraichissable {
20
 
21
	/**
22
	 * Le médiateur associé
23
	 */
24
 
25
	private ObservationMediateur observationMediateur = null;
26
 
27
 
28
	/**
29
	 * l'image à afficher
30
	 */
31
	private Image image = new Image();
32
 
97 jpm 33
	private String urlImage = "" ;
54 david 34
 
97 jpm 35
	com.gwtext.client.widgets.Window imgZoom = new com.gwtext.client.widgets.Window("Agrandissement") ;
36
 
54 david 37
	/**
38
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
39
	 */
40
 
41
	@SuppressWarnings("unused")
42
	private InformationRepartitionVue() {
43
		super();
44
	}
45
 
46
	/**
47
	 * Constructeur avec argument
48
	 * @param obs le médiateur à associer
49
	 */
50
 
51
 
52
	public InformationRepartitionVue(ObservationMediateur obs) {
53
 
54
 
55
		this.observationMediateur = obs;
56
 
97 jpm 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
 
74
		this.setCls("x-image-info-rep") ;
54 david 75
		image.setPixelSize(150, 150);
76
		add(image);
77
 
78
		// on ajoute les listeners
79
		ajouterListeners();
80
 
81
	}
82
 
83
 
84
	/**
85
	 * Affichage carte de repartition
86
	 *
87
	 */
88
 
89
	public void rafraichir(Object nouvelleDonnees,boolean repandreRaffraichissement) {
90
 
91
		// si on recoit une String contenant une URL
92
		if (nouvelleDonnees instanceof String) {
93
 
97 jpm 94
			urlImage=(String) nouvelleDonnees;
54 david 95
 
96
			if (urlImage.length()==0) {
84 jpm 97
				raz() ;
54 david 98
			}
99
			else {
100
				image.setUrl(urlImage);
101
			}
102
		}
103
 
104
	}
97 jpm 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
	}
54 david 120
 
121
 
122
	/**
123
	 * Ajoute les listeners pour la gestions d'évènement
124
	 */
125
	public void ajouterListeners() {
126
 
127
	}
128
 
84 jpm 129
	public void raz() {
130
		image.setUrl("");
131
	}
54 david 132
 
133
}