Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 139 → Rev 140

/trunk/src/org/tela_botanica/client/vues/GalerieImageVue.java
5,7 → 5,9
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.interfaces.VueListable;
 
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HTML;
import com.gwtext.client.core.EventCallback;
import com.gwtext.client.core.EventObject;
62,6 → 64,10
* Booleen indiquant si la galerie est instanciée ou pas
*/
private boolean estInstancie = false;
private boolean garderRatio = false;
private int tailleOr = 100 ;
 
/**
* Constructeur sans argument, privé car ne doit pas être utilisé
97,14 → 103,16
public void onAfterLayout(Container c) {
ExtElement lienUpload = Ext.get("lienUpload");
lienUpload.addListener("click", new EventCallback() {
 
public void execute(EventObject e) {
if(lienUpload != null) {
lienUpload.addListener("click", new EventCallback() {
public void execute(EventObject e) {
getIMediateur().uploaderImages();
}
getIMediateur().uploaderImages();
}
}) ;
}) ;
}
}
 
});
247,7 → 255,7
new String[] {
"<tpl for='.'>",
"<div class='thumb-wrap' id='{num_image}'>",
"<div class='thumb'><img src='{url_image_M}' title='{num_image}'></div>",
"<div class='thumb'><img src='{url_image_M}' width='{taille_x_s} px' height='{taille_y_s} px' title='{num_image}'></div>",
"<span>{nom}</span></div>", "</tpl>",
"<div class='x-clear'></div>" });
// pour des raisons de performances on compile le template en une
260,7 → 268,22
 
public void prepareData(Data data) {
data.setProperty("shortName", Format.ellipsis(data
.getProperty("num_image"), 15));
.getProperty("num_image"), 15));
int[] XY = {data.getPropertyAsInt("taille_x") ,data.getPropertyAsInt("taille_y")} ;
int[] XYresize ;
if(garderRatio) {
XYresize = calculerDimensions(XY);
}
else {
XYresize = new int[2] ;
XYresize[0] = XYresize[1] = tailleOr ;
}
data.setProperty("taille_x_s", XYresize[0]);
data.setProperty("taille_y_s", XYresize[1]);
}
};
281,8 → 304,10
FieldDef defUrlImageS = new StringFieldDef("url_image_S");
FieldDef defUrlImageM = new StringFieldDef("url_image_M");
FieldDef defUrlImage = new StringFieldDef("url_image");
FieldDef defTailleX = new IntegerFieldDef("taille_x");
FieldDef defTailleY = new IntegerFieldDef("taille_y");
FieldDef[] defTab = { defNumImage, defDatImage, defLieImage,
defAppImage, defUrlImageS, defUrlImageM, defUrlImage };
defAppImage, defUrlImageS, defUrlImageM, defUrlImage,defTailleX,defTailleY};
RecordDef rd = new RecordDef(defTab);
st = new Store(rd);
dView.setStore(st);
349,6 → 374,13
// et on rafrachit la vue
dView.refresh();
}
else
{
st.removeAll();
st.load();
dView.setStore(st);
dView.refresh();
}
 
}
 
390,5 → 422,27
iMediateur.changerTaillePage(nouvelleTaillePage) ;
}
public int[] calculerDimensions(int[] tailleXY) {
float[] tailleXYf = {new Float(tailleXY[0]),new Float(tailleXY[1])} ;
float tailleOr = this.tailleOr ;
float maxTaille = Math.max(tailleXYf[1],tailleXYf[0]) ;
float[] XYresize = new float[2];
if(maxTaille == tailleXY[0]) {
float rapport = tailleXYf[1]/tailleXYf[0] ;
XYresize[0] = tailleOr ;
XYresize[1] = tailleOr*rapport ;
}else {
float rapport = tailleXYf[0]/tailleXYf[1] ;
XYresize[1] = tailleOr ;
XYresize[0] = tailleOr*rapport ;
}
int[] res = {Math.round(XYresize[0]),Math.round(XYresize[1])} ;
return res;
}
 
}