Subversion Repositories eFlore/Archives.cel-v2

Rev

Rev 30 | Rev 43 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30 Rev 36
Line 8... Line 8...
8
 
8
 
9
/**
9
/**
10
 * 
10
 * 
11
 * Classe representant une image du carnet,
11
 * Classe representant une image du carnet,
12
 * elle ne contient pas d'image à proprement parler mais
12
 * elle ne contient pas d'image à proprement parler mais
-
 
13
 * plutôt les informations associées ainsi que l'url distante.
13
 * plutôt les informations associées ainsi que l'url distante 
14
 * C'est une table de hachage qui contient des paires propriété/valeur 
14
 * 
15
 * 
15
 */
16
 */
Line -... Line 17...
-
 
17
public class ImageCarnet extends HashMap {
-
 
18
	
-
 
19
 
-
 
20
	/**
16
public class ImageCarnet extends HashMap {
21
	 * Constructeur avec un objet JSON
17
	
22
	 * @param image
-
 
23
	 */
18
 
24
	public ImageCarnet(JSONObject image)
Line -... Line 25...
-
 
25
	{	
19
	public ImageCarnet(JSONObject image)
26
		// l'objet JSON est une table de hachage
Line -... Line 27...
-
 
27
		Set im = image.keySet() ;
20
	{	
28
		
21
		Set im = image.keySet() ;
29
		// on la parcourt pour chaque clé
22
		
30
		for (Iterator iterator = im.iterator(); iterator.hasNext();) {
23
		for (Iterator iterator = im.iterator(); iterator.hasNext();) {
31
			
24
			
32
			// si elle est associée à une valeur, on l'ajoute
25
			String key = (String) iterator.next();
33
			String key = (String) iterator.next();
26
			if(image.get(key).isString() != null)
34
			if(image.get(key).isString() != null)
27
			{
35
			{
-
 
36
				String valeur = image.get(key).isString().stringValue() ;
28
				String valeur = image.get(key).isString().stringValue() ;
37
				this.put(key, valeur) ;
29
				this.put(key, valeur) ;
38
			}
30
			}
39
			else
Line 31... Line 40...
31
			else
40
			{
Line 32... Line 41...
32
			{
41
				// sinon on ajoute la clé avec une valeur vide
Line -... Line 42...
-
 
42
				String valeur = " " ;
-
 
43
				this.put(key, valeur) ;
-
 
44
			}
33
				String valeur = " " ;
45
			
34
				this.put(key, valeur) ;
46
		}
35
			}
47
 
Line 36... Line 48...
36
			
48
	}
Line 54... Line 66...
54
		}
66
		}
Line 55... Line 67...
55
		
67
		
56
		return valeur ;
68
		return valeur ;
Line -... Line 69...
-
 
69
	}
-
 
70
	
-
 
71
	/**
-
 
72
	 * Pour éviter que l'on traite des valeurs nulles à l'affichage
-
 
73
	 * on passe par cette fonction qui retire les charactères nuls qui font planter
-
 
74
	 * l'affichage, il ne faut pas utiliser get directement 
-
 
75
	 * @param cle
57
	}
76
	 * @return la valeur associée à la clé
58
	
77
	 */
59
	public String renvoyerValeurCorrecte(String cle)
78
	public String renvoyerValeurCorrecte(String cle)
60
	{
79
	{
61
		if(this.containsKey((cle)))
80
		if(this.containsKey((cle)))
62
		{
81
		{
63
			String valeur = (String)this.get(cle) ;
82
			String valeur = (String)this.get(cle) ;
64
			if(valeur.equals("null") || valeur == null)
83
			if(valeur.equals("null") || valeur == null)
65
			{
84
			{
66
				return "null" ;
85
				return " " ;
67
			}			
86
			}			
68
			else
87
			else
69
			{
88
			{
Line 73... Line 92...
73
				return valeur ;
92
				return valeur ;
74
			}
93
			}
75
		}
94
		}
76
		else
95
		else
77
		{
96
		{
78
			return "null" ;
97
			return " " ;
79
		}
98
		}
80
	}
99
	}
Line -... Line 100...
-
 
100
 
-
 
101
	/**
-
 
102
	 * Acesseur pour l'id de l'image
-
 
103
	 * @return l'id de l'image
81
 
104
	 */
Line 82... Line 105...
82
	public String getId() {
105
	public String getId() {
83
		
106
		
Line -... Line 107...
-
 
107
		return renvoyerValeurCorrecte("ci_id_image") ;
-
 
108
	}
-
 
109
	
-
 
110
	/**
84
		return renvoyerValeurCorrecte("ci_id_image") ;
111
	 * Acesseur pour le numero d'ordre de l'image
Line 85... Line 112...
85
	}
112
	 * @return l'ordre de l'image
86
	
113
	 */
Line -... Line 114...
-
 
114
	public String getOrdre() {
-
 
115
		
-
 
116
		return renvoyerValeurCorrecte("ci_ordre") ;
-
 
117
	}
87
	public String getOrdre() {
118
	
88
		
119
	/**
89
		return renvoyerValeurCorrecte("ci_ordre") ;
120
	 * Base de l'url serveur pour les images
90
	}
121
	 * @return url racine pour les images
Line -... Line 122...
-
 
122
	 */
-
 
123
	public String getBaseUrl()
-
 
124
	{
-
 
125
		return "http://162.38.234.9/Documents/images_serveur/" ;
91
	
126
	}
Line 92... Line 127...
92
	public String getBaseUrl()
127
 
93
	{
128
	/**
Line -... Line 129...
-
 
129
	 * Renvoie le chemin et nom du fichier grand format
-
 
130
	 * @return le chemin du fichier grand format
-
 
131
	 */
-
 
132
	public String getUrl() {
94
		return "http://162.38.234.9/Documents/images_serveur/" ;
133
		
Line 95... Line 134...
95
	}
134
		return getBaseUrl()+(String)this.get("ci_id_image")+".jpg" ;
96
 
135
	}
Line -... Line 136...
-
 
136
	
-
 
137
	/**
-
 
138
	 * Renvoie le chemin et nom du fichier petit format
-
 
139
	 * @return le chemin du fichier petit format
97
	public String getUrl() {
140
	 */
Line 98... Line 141...
98
		
141
	public String getSUrl() {
99
		return getBaseUrl()+(String)this.get("ci_id_image")+".jpg" ;
142
		
Line -... Line 143...
-
 
143
		return getBaseUrl()+(String)this.get("ci_id_image")+"_S.jpg" ;
-
 
144
	}
-
 
145
	
-
 
146
	/**
-
 
147
	 * Renvoie le chemin et nom du fichier moyen format
100
	}
148
	 * @return le chemin du fichier moyen format
-
 
149
	 */
-
 
150
	public String getMUrl() {
-
 
151
		
101
	
152
		return getBaseUrl()+(String)this.get("ci_id_image")+"_M.jpg" ;
-
 
153
	}
-
 
154
	
-
 
155
	/**
-
 
156
	 * Renvoie la taille de l'image
102
	public String getSUrl() {
157
	 * @return un tableau de deux string contenant la hauteur puis la largeur 
Line 103... Line 158...
103
		
158
	 */
104
		return getBaseUrl()+(String)this.get("ci_id_image")+"_S.jpg" ;
159
	public String[] getTailleImage()
Line -... Line 160...
-
 
160
	{
-
 
161
		String[] XY = { renvoyerValeurCorrecte("ci_meta_height") , renvoyerValeurCorrecte("ci_meta_width") } ;
-
 
162
		return XY ;
105
	}
163
	}
106
	
164
	
Line 107... Line 165...
107
	public String getMUrl() {
165
	/**		
108
		
166
	 * Renvoie la date exif associée à l'image
Line -... Line 167...
-
 
167
	 * @return la date associée à l'image
-
 
168
	 */
-
 
169
	public String getDate() {
109
		return getBaseUrl()+(String)this.get("ci_id_image")+"_M.jpg" ;
170
		
110
	}
171
		return renvoyerValeurCorrecte("ci_meta_date_time") ;
Line 111... Line 172...
111
	
172
	}
112
 
173
 
Line -... Line 174...
-
 
174
	/**
-
 
175
	 * Renvoie la ville associée à l'image
-
 
176
	 * @return la ville iptc
113
 
177
	 */
114
	public String getDate() {
178
	public Object getIptcCity() {
Line 115... Line 179...
115
		
179
		
116
		return renvoyerValeurCorrecte("ci_meta_date_time") ;
180
		return renvoyerValeurCorrecte("ci_meta_iptc_city") ;
Line -... Line 181...
-
 
181
	}
-
 
182
 
-
 
183
	/**
-
 
184
	 * Renvoie le fabricant de l'appareil
117
	}
185
	 * @return le fabricant
Line 118... Line 186...
118
 
186
	 */
119
 
187
	public String getMake() {
Line 165... Line 233...
165
		}
233
		}
Line 166... Line 234...
166
		
234
		
167
		return metaIptc ;
235
		return metaIptc ;
Line -... Line 236...
-
 
236
	}
-
 
237
	
-
 
238
	/**
-
 
239
	 * Renvoie un tableau nom / valeur de toutes les metadonnées Exif
168
	}
240
	 * @return les métadonnées Exif
Line 169... Line 241...
169
	
241
	 */
170
	public Object[][] getMetadonnesExif() {
242
	public String[][] getMetadonnesExif() {
Line 171... Line 243...
171
		
243
		
Line 199... Line 271...
199
		
271
		
Line 200... Line 272...
200
		return metaExif ;
272
		return metaExif ;
Line -... Line 273...
-
 
273
	
-
 
274
	}
-
 
275
	
-
 
276
	/**
201
	
277
	 * Renvoie un tableau nom / valeur contenant les infos générales
Line 202... Line 278...
202
	}
278
	 * @return les infos générales
Line 203... Line 279...
203
	
279
	 */
204
	public Object[][] getInfoGenerales() {
280
	public String[][] getInfoGenerales() {
Line 212... Line 288...
212
		metaGen[1][1] = (String)this.get("ci_meta_date") ;
288
		metaGen[1][1] = (String)this.get("ci_meta_date") ;
Line 213... Line 289...
213
		
289
		
214
		return metaGen ;
290
		return metaGen ;
Line -... Line 291...
-
 
291
	}
-
 
292
	
-
 
293
	/**
-
 
294
	 * Renvoie une string contenant les mots clés séparés par des ','
215
	}
295
	 * @return les mots clés
Line 216... Line 296...
216
	
296
	 */
217
	public String getMotsCles() {
297
	public String getMotsCles() {
Line -... Line 298...
-
 
298
		
-
 
299
		return renvoyerValeurCorrecte("ci_meta_mots_cles") ;
-
 
300
	}
-
 
301
	
-
 
302
	/**
218
		
303
	 * Met à jour le commenentaire et la date
219
		return renvoyerValeurCorrecte("ci_meta_mots_cles") ;
304
	 * @param commentaires le nouveau commentaire
220
	}
305
	 * @param date la nouvelle date
Line 221... Line 306...
221
	
306
	 */
222
	public void miseAJourInfoGenerales(String commentaires, String date)
307
	public void miseAJourInfoGenerales(String commentaires, String date)
223
	{
308
	{
-
 
309
			put("ci_meta_comment",commentaires) ;
-
 
310
		
-
 
311
			put("ci_meta_date",date) ;
-
 
312
	}
224
			put("ci_meta_comment",commentaires) ;
313
	
Line 225... Line 314...
225
		
314
	/**
Line 226... Line 315...
226
			put("ci_meta_date",date) ;
315
	 * Met à jour les mots clés