Subversion Repositories eFlore/Archives.cel-v2

Rev

Rev 16 | Rev 22 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16 Rev 18
1
package org.tela_botanica.client.modeles;
1
package org.tela_botanica.client.modeles;
2
 
2
 
3
import java.util.HashMap;
3
import java.util.HashMap;
4
import java.util.Iterator;
4
import java.util.Iterator;
5
import java.util.Set;
5
import java.util.Set;
6
 
6
 
7
import com.google.gwt.json.client.JSONObject;
7
import com.google.gwt.json.client.JSONObject;
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
 * 
14
 * 
15
 */
15
 */
16
public class ImageCarnet extends HashMap {
16
public class ImageCarnet extends HashMap {
17
	
17
	
18
	/*
18
	/*
19
	// infos sur l'image
19
	// infos sur l'image
20
	private String url = " " ;
20
	private String url = " " ;
21
	private String ordre = " " ;
21
	private String ordre = " " ;
22
	private String utilisateur = " " ;
22
	private String utilisateur = " " ;
23
	private boolean publiable = false ;
23
	private boolean publiable = false ;
24
	private String height = "0" ;
24
	private String height = "0" ;
25
	private String width = "0" ;
25
	private String width = "0" ;
26
	private String make = " " ;
26
	private String make = " " ;
27
	private String model = " " ;
27
	private String model = " " ;
28
	private String xResolution = "0" ;
28
	private String xResolution = "0" ;
29
	private String yResolution = "0" ;
29
	private String yResolution = "0" ;
30
	private String date = " " ;
30
	private String date = " " ;
31
	private String GPS = " " ;
31
	private String GPS = " " ;
32
	private String comment = " " ;
32
	private String comment = " " ;
33
	
33
	
34
	// metadonnees exif
34
	// metadonnees exif
35
	private String exifExposureTime = " " ;
35
	private String exifExposureTime = " " ;
36
	private String exifFNumber = " " ;
36
	private String exifFNumber = " " ;
37
	private String exifVersion = " " ;
37
	private String exifVersion = " " ;
38
	private String exifCompressedBitsPerPixel = " " ;
38
	private String exifCompressedBitsPerPixel = " " ;
39
	private String exifShutterSpeedValue = " " ;
39
	private String exifShutterSpeedValue = " " ;
40
	private String exifApertureValue = " " ;
40
	private String exifApertureValue = " " ;
41
	private String exifExposureBiasValue = " " ;
41
	private String exifExposureBiasValue = " " ;
42
	private String exifMaxApertureValue = " " ;
42
	private String exifMaxApertureValue = " " ;
43
	private String exifMeteringMode = " " ;
43
	private String exifMeteringMode = " " ;
44
	private String exifLightSource = " " ;
44
	private String exifLightSource = " " ;
45
	private String exifFlash = "  " ;
45
	private String exifFlash = "  " ;
46
	private String exifFocalLength = " " ;
46
	private String exifFocalLength = " " ;
47
	private String exifFlashPixVersion = " " ;
47
	private String exifFlashPixVersion = " " ;
48
	private String exifColorSpace = " " ;
48
	private String exifColorSpace = " " ;
49
	private String exifInteroperabilityOffset = " " ;
49
	private String exifInteroperabilityOffset = " " ;
50
	private String exifFocalPlaneXResolution = " " ;
50
	private String exifFocalPlaneXResolution = " " ;
51
	private String exifFocalPlaneYResolution = " " ;
51
	private String exifFocalPlaneYResolution = " " ;
52
	private String exifFocalPlaneResolutionUnit = " " ;
52
	private String exifFocalPlaneResolutionUnit = " " ;
53
	private String exifSensingMethod = " " ;
53
	private String exifSensingMethod = " " ;
54
	private String exifFileSource = " " ;
54
	private String exifFileSource = " " ;
55
	private String exifCustomRendered = " " ;
55
	private String exifCustomRendered = " " ;
56
	private String exifExposureMode = " " ;
56
	private String exifExposureMode = " " ;
57
	private String exifWhiteBalance = " " ;
57
	private String exifWhiteBalance = " " ;
58
	private String exifDigitalZoomRatio = " " ;
58
	private String exifDigitalZoomRatio = " " ;
59
	private String exifSceneCaptureType = " " ;
59
	private String exifSceneCaptureType = " " ;
60
	private String exifGainControl = " " ;
60
	private String exifGainControl = " " ;
61
	private String exifContrast = " " ;
61
	private String exifContrast = " " ;
62
	private String exifSaturation = " " ;
62
	private String exifSaturation = " " ;
63
	private String exifSharpness = " " ;
63
	private String exifSharpness = " " ;
64
	private String exifSubjectDistanceRange = " " ;
64
	private String exifSubjectDistanceRange = " " ;
65
	private String exifAutres = " " ;
65
	private String exifAutres = " " ;
66
	
66
	
67
	// metadonnes iptc
67
	// metadonnes iptc
68
	private String iptcMotsCles = " " ;
68
	private String iptcMotsCles = " " ;
69
	private String iptcByLine = " " ;
69
	private String iptcByLine = " " ;
70
	private String iptcByLineTitle = " " ;
70
	private String iptcByLineTitle = " " ;
71
	private String iptcCity = " " ;
71
	private String iptcCity = " " ;
72
	private String iptcSubLocation = " " ;
72
	private String iptcSubLocation = " " ;
73
	private String iptcProvinceState = " " ;
73
	private String iptcProvinceState = " " ;
74
	private String iptcCountryPrimaryLocationCode = " " ;
74
	private String iptcCountryPrimaryLocationCode = " " ;
75
	private String iptcHeadline = " " ;
75
	private String iptcHeadline = " " ;
76
	private String iptcCredit = " " ;
76
	private String iptcCredit = " " ;
77
	private String iptcCopyrightNotice = " " ;
77
	private String iptcCopyrightNotice = " " ;
78
	private String iptcContact = " " ;
78
	private String iptcContact = " " ;
79
	private String iptcAutres = " " ;
79
	private String iptcAutres = " " ;
80
	*/
80
	*/
81
 
81
 
82
	public ImageCarnet(JSONObject image)
82
	public ImageCarnet(JSONObject image)
83
	{	
83
	{	
84
		Set im = image.keySet() ;
84
		Set im = image.keySet() ;
85
		
85
		
86
		for (Iterator iterator = im.iterator(); iterator.hasNext();) {
86
		for (Iterator iterator = im.iterator(); iterator.hasNext();) {
87
			
87
			
88
			String key = (String) iterator.next();
88
			String key = (String) iterator.next();
89
			if(image.get(key).isString() != null)
89
			if(image.get(key).isString() != null)
90
			{
90
			{
91
				String valeur = image.get(key).isString().stringValue() ;
91
				String valeur = image.get(key).isString().stringValue() ;
92
				this.put(key, valeur) ;
92
				this.put(key, valeur) ;
93
			}
93
			}
94
			else
94
			else
95
			{
95
			{
96
				String valeur = " " ;
96
				String valeur = " " ;
97
				this.put(key, valeur) ;
97
				this.put(key, valeur) ;
98
			}
98
			}
99
			
99
			
100
		}
100
		}
101
 
101
 
102
	}
102
	}
103
	
103
	
104
	public String toString()
104
	public String toString()
105
	{
105
	{
106
		String valeur = " ";
106
		String valeur = " ";
107
		
107
		
108
		for (Iterator iterator = this.keySet().iterator(); iterator.hasNext();) {
108
		for (Iterator iterator = this.keySet().iterator(); iterator.hasNext();) {
109
			
109
			
110
			
110
			
111
			String key = (String) iterator.next();
111
			String key = (String) iterator.next();
112
			if(this.get(key) != null)
112
			if(this.get(key) != null)
113
			{
113
			{
114
				valeur += "cle : "+key+" valeur :"+(String)this.get(key)+"\n" ;
114
				valeur += "cle : "+key+" valeur :"+(String)this.get(key)+"\n" ;
115
			}
115
			}
116
			
116
			
117
		}
117
		}
118
		
118
		
119
		return valeur ;
119
		return valeur ;
120
	}
120
	}
121
	
121
	
122
	public String renvoyerValeurCorrecte(String cle)
122
	public String renvoyerValeurCorrecte(String cle)
123
	{
123
	{
124
		if(this.containsKey((cle)))
124
		if(this.containsKey((cle)))
125
		{
125
		{
126
			String valeur = (String)this.get(cle) ;
126
			String valeur = (String)this.get(cle) ;
127
			if(valeur.equals("null"))
127
			if(valeur.equals("null"))
128
			{
128
			{
129
				return " " ;
129
				return " " ;
130
			}
130
			}
131
			else
131
			else
132
			{
132
			{
133
				return valeur ;
133
				return valeur ;
134
			}
134
			}
135
		}
135
		}
136
		else
136
		else
137
		{
137
		{
138
			return " " ;
138
			return " " ;
139
		}
139
		}
140
	}
140
	}
141
 
141
 
142
	
142
	
143
	public String getOrdre() {
143
	public String getOrdre() {
144
		
144
		
145
		return renvoyerValeurCorrecte("ci_ordre") ;
145
		return renvoyerValeurCorrecte("ci_ordre") ;
146
	}
146
	}
147
	
147
	
148
	public String getBaseUrl()
148
	public String getBaseUrl()
149
	{
149
	{
150
		return "http://162.38.234.9/Documents/images_serveur/" ;
150
		return "http://162.38.234.9/Documents/images_serveur/" ;
151
	}
151
	}
152
 
152
 
153
	public String getUrl() {
153
	public String getUrl() {
154
		
154
		
155
		return getBaseUrl()+(String)this.get("ci_id_image")+".jpg" ;
155
		return getBaseUrl()+(String)this.get("ci_id_image")+".jpg" ;
156
	}
156
	}
157
	
157
	
158
	public String getSUrl() {
158
	public String getSUrl() {
159
		
159
		
160
		return getBaseUrl()+(String)this.get("ci_id_image")+"_S.jpg" ;
160
		return getBaseUrl()+(String)this.get("ci_id_image")+"_S.jpg" ;
161
	}
161
	}
162
	
162
	
163
	public String getMUrl() {
163
	public String getMUrl() {
164
		
164
		
165
		return getBaseUrl()+(String)this.get("ci_id_image")+"_M.jpg" ;
165
		return getBaseUrl()+(String)this.get("ci_id_image")+"_M.jpg" ;
166
	}
166
	}
167
	
167
	
168
 
168
 
169
 
169
 
170
	public String getDate() {
170
	public String getDate() {
171
		
171
		
172
		return renvoyerValeurCorrecte("ci_meta_date_time") ;
172
		return renvoyerValeurCorrecte("ci_meta_date_time") ;
173
	}
173
	}
174
 
174
 
175
 
175
 
176
	public Object getIptcCity() {
176
	public Object getIptcCity() {
177
		
177
		
178
		return renvoyerValeurCorrecte("ci_meta_iptc_city") ;
178
		return renvoyerValeurCorrecte("ci_meta_iptc_city") ;
179
	}
179
	}
180
 
180
 
181
 
181
 
182
	public String getMake() {
182
	public String getMake() {
183
		
183
		
184
		return renvoyerValeurCorrecte("ci_meta_make") ;
184
		return renvoyerValeurCorrecte("ci_meta_make") ;
185
	}
185
	}
186
 
186
 
187
 
187
 
188
	public String getModel() {
188
	public String getModel() {
189
		
189
		
190
		return renvoyerValeurCorrecte("ci_meta_model") ;
190
		return renvoyerValeurCorrecte("ci_meta_model") ;
191
	}
191
	}
192
	
192
	
193
	public String[][] getMetadonnesIptc() {
193
	public String[][] getMetadonnesIptc() {
194
		
194
		
195
		String[][] metaIptc = new String[12][2] ;
195
		String[][] metaIptc = new String[12][2] ;
196
		int elem = 0 ;
196
		int elem = 0 ;
197
		
197
		
198
		for (Iterator it = this.keySet().iterator(); it.hasNext();) 
198
		for (Iterator it = this.keySet().iterator(); it.hasNext();) 
199
		{
199
		{
200
						
200
						
201
			String key = (String)it.next();
201
			String key = (String)it.next();
202
			
202
			
203
				// on filtre le "ci"
203
				// on filtre le "ci"
204
				String type[] = key.split("_",3) ;
204
				String type[] = key.split("_",3) ;
205
				
205
				
206
				
206
				
207
				// si c'est une metadonnee exif ou iptc
207
				// si c'est une metadonnee exif ou iptc
208
				if(type[1].equals("meta"))
208
				if(type[1].equals("meta"))
209
				{
209
				{
210
					String[] genre =  type[2].split("_",2) ;
210
					String[] genre =  type[2].split("_",2) ;
211
					if(genre[0].equals("iptc"))
211
					if(genre[0].equals("iptc"))
212
					{
212
					{
213
						String nom = genre[1] ;
213
						String nom = genre[1] ;
214
						metaIptc[elem][0] = nom ;
214
						metaIptc[elem][0] = nom ;
215
						metaIptc[elem][1] = renvoyerValeurCorrecte(key) ;
215
						metaIptc[elem][1] = renvoyerValeurCorrecte(key) ;
216
						elem++ ;	
216
						elem++ ;	
217
					}
217
					}
218
					
218
					
219
				}	
219
				}	
220
							    	
220
							    	
221
		}
221
		}
222
		
222
		
223
		return metaIptc ;
223
		return metaIptc ;
224
	}
224
	}
225
	
225
	
226
	public Object[][] getMetadonnesExif() {
226
	public Object[][] getMetadonnesExif() {
227
		
227
		
228
		String[][] metaExif = new String[31][2] ;
228
		String[][] metaExif = new String[31][2] ;
229
		int elem = 0 ;
229
		int elem = 0 ;
230
		
230
		
231
		for (Iterator it = this.keySet().iterator(); it.hasNext();) 
231
		for (Iterator it = this.keySet().iterator(); it.hasNext();) 
232
		{
232
		{
233
						
233
						
234
			String key = (String)it.next();
234
			String key = (String)it.next();
235
			
235
			
236
				// on filtre le "ci"
236
				// on filtre le "ci"
237
				String type[] = key.split("_",3) ;
237
				String type[] = key.split("_",3) ;
238
				
238
				
239
				
239
				
240
				// si c'est une metadonnee exif ou iptc
240
				// si c'est une metadonnee exif ou iptc
241
				if(type[1].equals("meta"))
241
				if(type[1].equals("meta"))
242
				{
242
				{
243
					String[] genre =  type[2].split("_",2) ;
243
					String[] genre =  type[2].split("_",2) ;
244
					if(genre[0].equals("exif"))
244
					if(genre[0].equals("exif"))
245
					{
245
					{
246
						String nom = genre[1] ;
246
						String nom = genre[1] ;
247
						metaExif[elem][0] = nom ;
247
						metaExif[elem][0] = nom ;
248
						metaExif[elem][1] = renvoyerValeurCorrecte(key) ;
248
						metaExif[elem][1] = renvoyerValeurCorrecte(key) ;
249
						elem++ ;	
249
						elem++ ;	
250
					}
250
					}
251
					
251
					
252
				}	
252
				}	
253
							    	
253
							    	
254
		}
254
		}
255
		
255
		
256
		return metaExif ;
256
		return metaExif ;
257
	
257
	
258
	}
258
	}
-
 
259
	
-
 
260
	public Object[][] getInfoGenerales() {
-
 
261
		
-
 
262
		String[][] metaGen = new String[2][2] ;
-
 
263
		
-
 
264
		metaGen[0][0] = "ci_meta_comment" ;
-
 
265
		metaGen[0][1] = (String)this.get("ci_meta_comment") ;
-
 
266
		
-
 
267
		metaGen[1][0] = "ci_meta_date" ;
-
 
268
		metaGen[1][1] = (String)this.get("ci_meta_date") ;
-
 
269
		
-
 
270
		return metaGen ;
-
 
271
	}
-
 
272
	
-
 
273
	public void miseAJourInfoGenerales(String commentaires, String date)
-
 
274
	{
-
 
275
		if(this.containsKey("ci_meta_comment"))
-
 
276
		{
-
 
277
			put("ci_meta_comment",commentaires) ;
-
 
278
		}
-
 
279
		
-
 
280
		if(this.containsKey("ci_meta_date"))
-
 
281
		{
-
 
282
			put("ci_meta_date",date) ;
-
 
283
		}
-
 
284
	}
259
}
285
}