Subversion Repositories eFlore/Applications.cel

Rev

Rev 84 | 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;
10
import com.gwtext.client.widgets.Panel;
97 jpm 11
import com.gwtext.client.widgets.Window.CloseAction;
54 david 12
 
13
/**
14
 * Un panneau affichant une image generique provenant d eflore
15
 *
16
 * @author David Delon
17
 *
18
 */
19
public class ImageGeneriqueVue 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
	private com.gwtext.client.widgets.Window imgZoom = new com.gwtext.client.widgets.Window("Agrandissement") ;
36
 
37
 
54 david 38
	/**
39
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
40
	 */
41
 
42
	@SuppressWarnings("unused")
43
	private ImageGeneriqueVue() {
44
		super();
45
	}
46
 
47
	/**
48
	 * Constructeur avec argument
49
	 * @param obs le médiateur à associer
50
	 */
51
 
52
 
53
	public ImageGeneriqueVue(ObservationMediateur obs) {
54
 
55
 
56
		this.observationMediateur = obs;
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
 
73
		this.setCls("x-image-gen") ;
54 david 74
		image.setPixelSize(150, 150);
75
		add(image);
76
 
97 jpm 77
		image.sinkEvents(Event.ONDBLCLICK);
78
 
54 david 79
		// on ajoute les listeners
80
		ajouterListeners();
81
 
82
	}
83
 
84
 
85
	/**
86
	 * Affichage image generique
87
	 *
88
	 */
89
 
90
	public void rafraichir(Object nouvelleDonnees,boolean repandreRaffraichissement) {
91
 
92
		// si on recoit une String contenant une URL
93
		if (nouvelleDonnees instanceof String) {
94
 
97 jpm 95
			urlImage=(String) nouvelleDonnees;
54 david 96
 
97
			if (urlImage.length()==0) {
84 jpm 98
				raz() ;
54 david 99
			}
100
			else {
101
				image.setUrl(urlImage);
102
			}
103
		}
84 jpm 104
 
105
		observationMediateur.deMasquerChargementInfosObservations() ;
54 david 106
 
107
	}
97 jpm 108
 
109
	public void agrandirImage() {
110
 
111
		if(!imgZoom.isVisible())
112
		{
113
			String urlAgrandie = urlImage.replace("min", "max") ;
114
			imgZoom.setHtml("<img src=\""+urlAgrandie+"\" />") ;
115
			imgZoom.setPagePosition( Window.getClientWidth()/2, Window.getClientHeight()/5) ;
116
			imgZoom.setAutoHeight(true) ;
117
			imgZoom.setAutoWidth(true) ;
118
			imgZoom.show(this.getElement()) ;
119
		}
54 david 120
 
97 jpm 121
 
122
	}
123
 
54 david 124
 
125
	/**
126
	 * Ajoute les listeners pour la gestions d'évènement
127
	 */
128
	public void ajouterListeners() {
129
 
130
	}
131
 
84 jpm 132
	public void raz() {
133
		image.setUrl("");
134
	}
135
 
54 david 136
 
137
}