| 476 | 
           benjamin | 
           1 | 
           package org.tela_botanica.del.client.composants.images;
  | 
        
        
           | 200 | 
           gduche | 
           2 | 
              | 
        
        
           | 577 | 
           gduche | 
           3 | 
           import org.tela_botanica.del.client.i18n.I18n;
  | 
        
        
           | 200 | 
           gduche | 
           4 | 
           import com.google.gwt.core.client.GWT;
  | 
        
        
           | 437 | 
           aurelien | 
           5 | 
           import com.google.gwt.event.dom.client.LoadEvent;
  | 
        
        
            | 
            | 
           6 | 
           import com.google.gwt.event.dom.client.LoadHandler;
  | 
        
        
           | 1556 | 
           aurelien | 
           7 | 
           import com.google.gwt.event.logical.shared.ResizeEvent;
  | 
        
        
            | 
            | 
           8 | 
           import com.google.gwt.event.logical.shared.ResizeHandler;
  | 
        
        
           | 200 | 
           gduche | 
           9 | 
           import com.google.gwt.uibinder.client.UiBinder;
  | 
        
        
            | 
            | 
           10 | 
           import com.google.gwt.uibinder.client.UiField;
  | 
        
        
           | 1556 | 
           aurelien | 
           11 | 
           import com.google.gwt.user.client.Timer;
  | 
        
        
            | 
            | 
           12 | 
           import com.google.gwt.user.client.Window;
  | 
        
        
           | 200 | 
           gduche | 
           13 | 
           import com.google.gwt.user.client.ui.Composite;
  | 
        
        
           | 575 | 
           gduche | 
           14 | 
           import com.google.gwt.user.client.ui.HTML;
  | 
        
        
           | 200 | 
           gduche | 
           15 | 
           import com.google.gwt.user.client.ui.Image;
  | 
        
        
            | 
            | 
           16 | 
           import com.google.gwt.user.client.ui.Widget;
  | 
        
        
            | 
            | 
           17 | 
              | 
        
        
           | 308 | 
           gduche | 
           18 | 
           public class DetailImageVue extends Composite implements DetailImagePresenteur.Vue {
  | 
        
        
           | 200 | 
           gduche | 
           19 | 
              | 
        
        
            | 
            | 
           20 | 
           	// Gestion d'UiBinder
  | 
        
        
            | 
            | 
           21 | 
           	interface Binder extends UiBinder<Widget, DetailImageVue> {
  | 
        
        
            | 
            | 
           22 | 
           	}
  | 
        
        
            | 
            | 
           23 | 
              | 
        
        
            | 
            | 
           24 | 
           	private static Binder binder = GWT.create(Binder.class);
  | 
        
        
            | 
            | 
           25 | 
              | 
        
        
            | 
            | 
           26 | 
           	@UiField
  | 
        
        
            | 
            | 
           27 | 
           	protected Image photoPrincipale;
  | 
        
        
            | 
            | 
           28 | 
              | 
        
        
            | 
            | 
           29 | 
           	@UiField
  | 
        
        
           | 575 | 
           gduche | 
           30 | 
           	protected HTML texteAlternatif;
  | 
        
        
           | 200 | 
           gduche | 
           31 | 
              | 
        
        
           | 308 | 
           gduche | 
           32 | 
           	public DetailImageVue() {
  | 
        
        
           | 200 | 
           gduche | 
           33 | 
           		initWidget(binder.createAndBindUi(this));
  | 
        
        
           | 437 | 
           aurelien | 
           34 | 
           		photoPrincipale.addLoadHandler(new LoadHandler() {
  | 
        
        
            | 
            | 
           35 | 
           			@Override
  | 
        
        
            | 
            | 
           36 | 
           			public void onLoad(LoadEvent event) {
  | 
        
        
           | 1556 | 
           aurelien | 
           37 | 
           				setTailleOptimale();
  | 
        
        
           | 437 | 
           aurelien | 
           38 | 
           			}
  | 
        
        
            | 
            | 
           39 | 
           		});
  | 
        
        
           | 1556 | 
           aurelien | 
           40 | 
              | 
        
        
            | 
            | 
           41 | 
           		Window.addResizeHandler(new ResizeHandler() {
  | 
        
        
            | 
            | 
           42 | 
              | 
        
        
            | 
            | 
           43 | 
           			Timer resizeTimer = new Timer() {
  | 
        
        
            | 
            | 
           44 | 
           			    @Override
  | 
        
        
            | 
            | 
           45 | 
           			    public void run() {
  | 
        
        
            | 
            | 
           46 | 
           			    	setTailleOptimale();
  | 
        
        
            | 
            | 
           47 | 
           			    }
  | 
        
        
            | 
            | 
           48 | 
           			};
  | 
        
        
            | 
            | 
           49 | 
              | 
        
        
            | 
            | 
           50 | 
           			@Override
  | 
        
        
            | 
            | 
           51 | 
           			public void onResize(ResizeEvent event) {
  | 
        
        
            | 
            | 
           52 | 
           				resizeTimer.cancel();
  | 
        
        
            | 
            | 
           53 | 
           			    resizeTimer.schedule(250);
  | 
        
        
            | 
            | 
           54 | 
           			}
  | 
        
        
            | 
            | 
           55 | 
           		});
  | 
        
        
           | 200 | 
           gduche | 
           56 | 
           	}
  | 
        
        
           | 308 | 
           gduche | 
           57 | 
              | 
        
        
           | 436 | 
           benjamin | 
           58 | 
           	public void chargerImage(org.tela_botanica.del.client.modeles.Image imageCourante) {
  | 
        
        
            | 
            | 
           59 | 
           		setUrlImage(imageCourante.getUrlFormat("L"));
  | 
        
        
            | 
            | 
           60 | 
           		setTitle(imageCourante.getUrlFormat("L"));
  | 
        
        
           | 1393 | 
           aurelien | 
           61 | 
           		setTexteAlternatif("<strong> "+I18n.getVocabulary().imageNumero()+""+ imageCourante.getIdImage() +" - "+ imageCourante.getObservation().getNomRetenuFormateReferentiel() + " "  + I18n.getVocabulary().par() + " " + imageCourante.getObservation().getAuteur() + "</strong><br />"
  | 
        
        
           | 577 | 
           gduche | 
           62 | 
           				+ I18n.getVocabulary().publiee() + " "+ imageCourante.getObservation().getDateReleve() + " - " + imageCourante.getObservation().getLocaliteAvecIdFormatee());
  | 
        
        
           | 436 | 
           benjamin | 
           63 | 
           	}
  | 
        
        
            | 
            | 
           64 | 
              | 
        
        
           | 308 | 
           gduche | 
           65 | 
           	public void setUrlImage(String urlImage) {
  | 
        
        
           | 436 | 
           benjamin | 
           66 | 
           		photoPrincipale.setUrl(urlImage);
  | 
        
        
           | 308 | 
           gduche | 
           67 | 
           	}
  | 
        
        
            | 
            | 
           68 | 
              | 
        
        
            | 
            | 
           69 | 
           	public void setTexteAlternatif(String texteAlternatif) {
  | 
        
        
           | 575 | 
           gduche | 
           70 | 
           		this.texteAlternatif.setHTML(texteAlternatif);
  | 
        
        
           | 308 | 
           gduche | 
           71 | 
           	}
  | 
        
        
           | 1556 | 
           aurelien | 
           72 | 
              | 
        
        
            | 
            | 
           73 | 
           	public void setTailleOptimale() {
  | 
        
        
           | 1563 | 
           aurelien | 
           74 | 
              | 
        
        
           | 1556 | 
           aurelien | 
           75 | 
           		double fenetreH = Window.getClientHeight();
  | 
        
        
            | 
            | 
           76 | 
           		double fenetreW = Window.getClientWidth();
  | 
        
        
            | 
            | 
           77 | 
              | 
        
        
            | 
            | 
           78 | 
           		double photoH = photoPrincipale.getHeight();
  | 
        
        
            | 
            | 
           79 | 
           		double photoW = photoPrincipale.getWidth();
  | 
        
        
            | 
            | 
           80 | 
              | 
        
        
           | 1563 | 
           aurelien | 
           81 | 
           		double rapport = 0;
  | 
        
        
           | 1556 | 
           aurelien | 
           82 | 
           		double reduction = 150;
  | 
        
        
            | 
            | 
           83 | 
              | 
        
        
           | 1563 | 
           aurelien | 
           84 | 
           		if(photoH > (fenetreH - reduction) || photoW > (fenetreW - reduction)) {
  | 
        
        
            | 
            | 
           85 | 
              | 
        
        
            | 
            | 
           86 | 
           			if(photoH >= (fenetreH - reduction)) {
  | 
        
        
           | 1556 | 
           aurelien | 
           87 | 
           				rapport = photoW/photoH;
  | 
        
        
            | 
            | 
           88 | 
           				photoH = fenetreH-reduction;
  | 
        
        
            | 
            | 
           89 | 
           				photoW = photoH*rapport;
  | 
        
        
           | 1563 | 
           aurelien | 
           90 | 
           			}
  | 
        
        
            | 
            | 
           91 | 
              | 
        
        
            | 
            | 
           92 | 
           			if(photoW >= (fenetreW - reduction)) {
  | 
        
        
           | 1556 | 
           aurelien | 
           93 | 
           				rapport = photoH/photoW;
  | 
        
        
            | 
            | 
           94 | 
           				photoW = fenetreW-reduction;
  | 
        
        
            | 
            | 
           95 | 
           				photoH = photoW*rapport;
  | 
        
        
            | 
            | 
           96 | 
           			}
  | 
        
        
            | 
            | 
           97 | 
           		}
  | 
        
        
            | 
            | 
           98 | 
              | 
        
        
            | 
            | 
           99 | 
           		setWidth(photoW+"px");
  | 
        
        
            | 
            | 
           100 | 
           		setHeight(photoH+"px");
  | 
        
        
            | 
            | 
           101 | 
           	}
  | 
        
        
           | 200 | 
           gduche | 
           102 | 
           }
  |