Rev 16 | Rev 22 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package org.tela_botanica.client.modeles;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import com.google.gwt.json.client.JSONObject;
/**
*
* Classe representant une image du carnet,
* elle ne contient pas d'image à proprement parler mais
* plutôt les informations associées ainsi que l'url distante
*
*/
public class ImageCarnet extends HashMap {
/*
// infos sur l'image
private String url = " " ;
private String ordre = " " ;
private String utilisateur = " " ;
private boolean publiable = false ;
private String height = "0" ;
private String width = "0" ;
private String make = " " ;
private String model = " " ;
private String xResolution = "0" ;
private String yResolution = "0" ;
private String date = " " ;
private String GPS = " " ;
private String comment = " " ;
// metadonnees exif
private String exifExposureTime = " " ;
private String exifFNumber = " " ;
private String exifVersion = " " ;
private String exifCompressedBitsPerPixel = " " ;
private String exifShutterSpeedValue = " " ;
private String exifApertureValue = " " ;
private String exifExposureBiasValue = " " ;
private String exifMaxApertureValue = " " ;
private String exifMeteringMode = " " ;
private String exifLightSource = " " ;
private String exifFlash = " " ;
private String exifFocalLength = " " ;
private String exifFlashPixVersion = " " ;
private String exifColorSpace = " " ;
private String exifInteroperabilityOffset = " " ;
private String exifFocalPlaneXResolution = " " ;
private String exifFocalPlaneYResolution = " " ;
private String exifFocalPlaneResolutionUnit = " " ;
private String exifSensingMethod = " " ;
private String exifFileSource = " " ;
private String exifCustomRendered = " " ;
private String exifExposureMode = " " ;
private String exifWhiteBalance = " " ;
private String exifDigitalZoomRatio = " " ;
private String exifSceneCaptureType = " " ;
private String exifGainControl = " " ;
private String exifContrast = " " ;
private String exifSaturation = " " ;
private String exifSharpness = " " ;
private String exifSubjectDistanceRange = " " ;
private String exifAutres = " " ;
// metadonnes iptc
private String iptcMotsCles = " " ;
private String iptcByLine = " " ;
private String iptcByLineTitle = " " ;
private String iptcCity = " " ;
private String iptcSubLocation = " " ;
private String iptcProvinceState = " " ;
private String iptcCountryPrimaryLocationCode = " " ;
private String iptcHeadline = " " ;
private String iptcCredit = " " ;
private String iptcCopyrightNotice = " " ;
private String iptcContact = " " ;
private String iptcAutres = " " ;
*/
public ImageCarnet(JSONObject image)
{
Set im = image.keySet() ;
for (Iterator iterator = im.iterator(); iterator.hasNext();) {
String key = (String) iterator.next();
if(image.get(key).isString() != null)
{
String valeur = image.get(key).isString().stringValue() ;
this.put(key, valeur) ;
}
else
{
String valeur = " " ;
this.put(key, valeur) ;
}
}
}
public String toString()
{
String valeur = " ";
for (Iterator iterator = this.keySet().iterator(); iterator.hasNext();) {
String key = (String) iterator.next();
if(this.get(key) != null)
{
valeur += "cle : "+key+" valeur :"+(String)this.get(key)+"\n" ;
}
}
return valeur ;
}
public String renvoyerValeurCorrecte(String cle)
{
if(this.containsKey((cle)))
{
String valeur = (String)this.get(cle) ;
if(valeur.equals("null"))
{
return " " ;
}
else
{
return valeur ;
}
}
else
{
return " " ;
}
}
public String getOrdre() {
return renvoyerValeurCorrecte("ci_ordre") ;
}
public String getBaseUrl()
{
return "http://162.38.234.9/Documents/images_serveur/" ;
}
public String getUrl() {
return getBaseUrl()+(String)this.get("ci_id_image")+".jpg" ;
}
public String getSUrl() {
return getBaseUrl()+(String)this.get("ci_id_image")+"_S.jpg" ;
}
public String getMUrl() {
return getBaseUrl()+(String)this.get("ci_id_image")+"_M.jpg" ;
}
public String getDate() {
return renvoyerValeurCorrecte("ci_meta_date_time") ;
}
public Object getIptcCity() {
return renvoyerValeurCorrecte("ci_meta_iptc_city") ;
}
public String getMake() {
return renvoyerValeurCorrecte("ci_meta_make") ;
}
public String getModel() {
return renvoyerValeurCorrecte("ci_meta_model") ;
}
public String[][] getMetadonnesIptc() {
String[][] metaIptc = new String[12][2] ;
int elem = 0 ;
for (Iterator it = this.keySet().iterator(); it.hasNext();)
{
String key = (String)it.next();
// on filtre le "ci"
String type[] = key.split("_",3) ;
// si c'est une metadonnee exif ou iptc
if(type[1].equals("meta"))
{
String[] genre = type[2].split("_",2) ;
if(genre[0].equals("iptc"))
{
String nom = genre[1] ;
metaIptc[elem][0] = nom ;
metaIptc[elem][1] = renvoyerValeurCorrecte(key) ;
elem++ ;
}
}
}
return metaIptc ;
}
public Object[][] getMetadonnesExif() {
String[][] metaExif = new String[31][2] ;
int elem = 0 ;
for (Iterator it = this.keySet().iterator(); it.hasNext();)
{
String key = (String)it.next();
// on filtre le "ci"
String type[] = key.split("_",3) ;
// si c'est une metadonnee exif ou iptc
if(type[1].equals("meta"))
{
String[] genre = type[2].split("_",2) ;
if(genre[0].equals("exif"))
{
String nom = genre[1] ;
metaExif[elem][0] = nom ;
metaExif[elem][1] = renvoyerValeurCorrecte(key) ;
elem++ ;
}
}
}
return metaExif ;
}
public Object[][] getInfoGenerales() {
String[][] metaGen = new String[2][2] ;
metaGen[0][0] = "ci_meta_comment" ;
metaGen[0][1] = (String)this.get("ci_meta_comment") ;
metaGen[1][0] = "ci_meta_date" ;
metaGen[1][1] = (String)this.get("ci_meta_date") ;
return metaGen ;
}
public void miseAJourInfoGenerales(String commentaires, String date)
{
if(this.containsKey("ci_meta_comment"))
{
put("ci_meta_comment",commentaires) ;
}
if(this.containsKey("ci_meta_date"))
{
put("ci_meta_date",date) ;
}
}
}