Subversion Repositories eFlore/Archives.cel-v2

Rev

Rev 12 | Rev 18 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 aperonnet 1
package org.tela_botanica.client.modeles;
2
 
12 aperonnet 3
import java.util.HashMap;
4
import java.util.Iterator;
5
import java.util.Set;
6
 
7
import com.google.gwt.json.client.JSONObject;
8
 
9
/**
10
 *
11
 * Classe representant une image du carnet,
12
 * elle ne contient pas d'image à proprement parler mais
13
 * plutôt les informations associées ainsi que l'url distante
14
 *
15
 */
16
public class ImageCarnet extends HashMap {
4 aperonnet 17
 
12 aperonnet 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 = " " ;
4 aperonnet 33
 
12 aperonnet 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
	*/
81
 
82
	public ImageCarnet(JSONObject image)
83
	{
84
		Set im = image.keySet() ;
85
 
86
		for (Iterator iterator = im.iterator(); iterator.hasNext();) {
87
 
88
			String key = (String) iterator.next();
89
			if(image.get(key).isString() != null)
90
			{
91
				String valeur = image.get(key).isString().stringValue() ;
92
				this.put(key, valeur) ;
93
			}
16 aperonnet 94
			else
95
			{
96
				String valeur = " " ;
97
				this.put(key, valeur) ;
98
			}
12 aperonnet 99
 
100
		}
101
 
102
	}
103
 
16 aperonnet 104
	public String toString()
105
	{
106
		String valeur = " ";
107
 
108
		for (Iterator iterator = this.keySet().iterator(); iterator.hasNext();) {
109
 
110
 
111
			String key = (String) iterator.next();
112
			if(this.get(key) != null)
113
			{
114
				valeur += "cle : "+key+" valeur :"+(String)this.get(key)+"\n" ;
115
			}
116
 
117
		}
118
 
119
		return valeur ;
120
	}
121
 
12 aperonnet 122
	public String renvoyerValeurCorrecte(String cle)
4 aperonnet 123
	{
12 aperonnet 124
		if(this.containsKey((cle)))
125
		{
126
			String valeur = (String)this.get(cle) ;
127
			if(valeur.equals("null"))
128
			{
129
				return " " ;
130
			}
131
			else
132
			{
133
				return valeur ;
134
			}
135
		}
136
		else
137
		{
138
			return " " ;
139
		}
4 aperonnet 140
	}
141
 
12 aperonnet 142
 
143
	public String getOrdre() {
144
 
145
		return renvoyerValeurCorrecte("ci_ordre") ;
146
	}
147
 
148
	public String getBaseUrl()
149
	{
16 aperonnet 150
		return "http://162.38.234.9/Documents/images_serveur/" ;
12 aperonnet 151
	}
152
 
4 aperonnet 153
	public String getUrl() {
12 aperonnet 154
 
155
		return getBaseUrl()+(String)this.get("ci_id_image")+".jpg" ;
4 aperonnet 156
	}
12 aperonnet 157
 
158
	public String getSUrl() {
159
 
160
		return getBaseUrl()+(String)this.get("ci_id_image")+"_S.jpg" ;
161
	}
162
 
163
	public String getMUrl() {
164
 
165
		return getBaseUrl()+(String)this.get("ci_id_image")+"_M.jpg" ;
166
	}
167
 
4 aperonnet 168
 
12 aperonnet 169
 
170
	public String getDate() {
171
 
172
		return renvoyerValeurCorrecte("ci_meta_date_time") ;
4 aperonnet 173
	}
174
 
12 aperonnet 175
 
176
	public Object getIptcCity() {
177
 
178
		return renvoyerValeurCorrecte("ci_meta_iptc_city") ;
4 aperonnet 179
	}
180
 
12 aperonnet 181
 
182
	public String getMake() {
183
 
184
		return renvoyerValeurCorrecte("ci_meta_make") ;
185
	}
186
 
187
 
188
	public String getModel() {
189
 
190
		return renvoyerValeurCorrecte("ci_meta_model") ;
191
	}
16 aperonnet 192
 
193
	public String[][] getMetadonnesIptc() {
194
 
195
		String[][] metaIptc = new String[12][2] ;
196
		int elem = 0 ;
197
 
198
		for (Iterator it = this.keySet().iterator(); it.hasNext();)
199
		{
200
 
201
			String key = (String)it.next();
202
 
203
				// on filtre le "ci"
204
				String type[] = key.split("_",3) ;
205
 
206
 
207
				// si c'est une metadonnee exif ou iptc
208
				if(type[1].equals("meta"))
209
				{
210
					String[] genre =  type[2].split("_",2) ;
211
					if(genre[0].equals("iptc"))
212
					{
213
						String nom = genre[1] ;
214
						metaIptc[elem][0] = nom ;
215
						metaIptc[elem][1] = renvoyerValeurCorrecte(key) ;
216
						elem++ ;
217
					}
218
 
219
				}
220
 
221
		}
222
 
223
		return metaIptc ;
224
	}
225
 
226
	public Object[][] getMetadonnesExif() {
227
 
228
		String[][] metaExif = new String[31][2] ;
229
		int elem = 0 ;
230
 
231
		for (Iterator it = this.keySet().iterator(); it.hasNext();)
232
		{
233
 
234
			String key = (String)it.next();
235
 
236
				// on filtre le "ci"
237
				String type[] = key.split("_",3) ;
238
 
239
 
240
				// si c'est une metadonnee exif ou iptc
241
				if(type[1].equals("meta"))
242
				{
243
					String[] genre =  type[2].split("_",2) ;
244
					if(genre[0].equals("exif"))
245
					{
246
						String nom = genre[1] ;
247
						metaExif[elem][0] = nom ;
248
						metaExif[elem][1] = renvoyerValeurCorrecte(key) ;
249
						elem++ ;
250
					}
251
 
252
				}
253
 
254
		}
255
 
256
		return metaExif ;
257
 
258
	}
4 aperonnet 259
}