Subversion Repositories eFlore/Archives.cel-v2

Rev

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

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