Subversion Repositories eFlore/Applications.cel

Rev

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