Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 407 → Rev 408

/trunk/src/org/tela_botanica/client/vues/image/ZoomImageVue.java
4,7 → 4,14
import org.tela_botanica.client.image.ImageMediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;
 
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.LoadEvent;
import com.google.gwt.event.dom.client.LoadHandler;
import com.google.gwt.event.dom.client.MouseWheelEvent;
import com.google.gwt.event.dom.client.MouseWheelHandler;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
96,6 → 103,8
* Booleen d'initalisation général
*/
private boolean initialise = false;
private Panel infosTaxon = new Panel();
 
/**
* Booleen d'initalisation du conteneur d'image
103,17 → 112,7
private boolean conteneurInitialise = false;
private ToolTip tp = new ToolTip("<div class=\"x-tooltip-help\"> Double cliquez pour revenir à la vue précédente, utilisez la roulette ou les boutons fléchés pour faire défiler les images </div>") ;
 
/**
* true pour animer les transitions des animations
*/
private boolean animerTransition = false;
/**
* duree des animation
*/
private float dureeAnimation = (float) 0.15 ;
/**.
* boolean de gestion du double clic
*/
122,23 → 121,7
private ToolbarButton modeZoom = null;
private ToolbarTextItem valeurZoom = new ToolbarTextItem("x 1");
private int sourisX = 0;
private int sourisY = 0;
private int sourisXFin = 0;
private int sourisYFin = 0;
private float niveauZoom = 1;
private float pasZoom = new Float(0.1);
 
private int maxZoom = 10;
private float minZoom = new Float(0.5);
 
protected boolean scroll = false;
/**
197,9 → 180,15
//setTopToolbar(tb);
infosTaxon = new Panel();
infosTaxon.setHeader(false);
//infosTaxon.setBorder(false);
infosTaxon.setHeight("30px");
this.add(prev, new BorderLayoutData(RegionPosition.WEST));
this.add(imageConteneur, new BorderLayoutData(RegionPosition.CENTER));
this.add(suiv, new BorderLayoutData(RegionPosition.EAST));
this.add(infosTaxon, new BorderLayoutData(RegionPosition.SOUTH));
 
imageConteneur.setMaskDisabled(true);
this.setBorder(false);
232,7 → 221,9
// si on reçoit une string
if (nouvelleDonnees instanceof String[] && initialise
&& conteneurInitialise) {
String[] infos = (String[]) nouvelleDonnees;
// c'est l'url de l'image qu'on associe à la vue
if (infos[0] != null && infos[1] != null && infos[2] != null && infos[3] != null) {
getImage().setUrl(infos[0]);
242,8 → 233,16
setTailleImage(x, y);
setIdImage(infos[3]) ;
String infosTaxon = "" ;
if(infos.length == 5 && infos[4] != null) {
infosTaxon = infos[4];
}
setInfosTaxon(infosTaxon);
 
//verifierEtRetaillerImage();
verifierEtRetaillerImage();
}
} else {
// sinon on met une image vide
286,62 → 285,10
* Ajoute les listeners pour la gestions d'évènement
*/
public void ajouterListeners() {
modeZoom.addListener(new ButtonListenerAdapter() {
 
public void onClick(Button button, EventObject e) {
// TODO Auto-generated method stub
if(modeZoom.isPressed()) {
modeZoom.toggle(false);
} else {
modeZoom.toggle(true);
}
}
public void onToggle(Button button, boolean pressed) {
if(pressed) {
scroll = true;
image.addStyleName("img-curseur-depl");
} else {
scroll = false;
image.removeStyleName("img-curseur-depl");
niveauZoom = 1;
verifierEtRetaillerImage();
Ext.get(image.getElement()).center(imageConteneur.getElement());
}
}
});
image.addLoadListener(new LoadListener() {
 
public void onError(Widget sender) {
// TODO Auto-generated method stub
}
 
public void onLoad(Widget sender) {
/*int max = Math.min(imageConteneur.getHeight(), imageConteneur.getWidth());
int[] tailleImage = calculerDimensions(getTailleImage(), max, max);
ExtElement imgElement = Ext.get(image.getElement());
if(animerTransition) {
AnimationConfig a = new AnimationConfig() ;
a.setDuration((float) dureeAnimation);
imgElement.setHeight(tailleImage[1], a);
imgElement.setWidth(tailleImage[0], a);
} else {
imgElement.setHeight(tailleImage[1], false);
imgElement.setWidth(tailleImage[0], false);
}*/
verifierEtRetaillerImage();
Ext.get(image.getElement()).center(imageConteneur.getElement());
demasquerChargement();
}
image.addClickHandler(new ClickHandler() {
});
image.addClickListener(new ClickListener() {
 
public void onClick(Widget sender) {
public void onClick(ClickEvent event) {
if(!scroll) {
if(enClic) {
getIMediateur().doubleClicZoomImage();
357,101 → 304,48
}
}
}
});
image.addMouseWheelListener(new MouseWheelListener() {
image.addLoadHandler(new LoadHandler() {
public void onLoad(LoadEvent event) {
 
public void onMouseWheel(Widget sender, MouseWheelVelocity velocity) {
if(velocity.getDeltaY() > 0) {
if(scroll) {
zoomOut();
} else {
suiv.click();
}
} else {
if(scroll) {
zoomIn();
} else {
prev.click();
}
}
verifierEtRetaillerImage();
Ext.get(image.getElement()).center(imageConteneur.getElement());
demasquerChargement();
}
});
image.addMouseListener(new MouseListener() {
 
public void onMouseDown(Widget sender, int x, int y) {
if(scroll) {
Event.getCurrentEvent().preventDefault();
scroll = true;
sourisX = x;
sourisY = y;
image.addStyleName("img-curseur-depl");
}
}
 
public void onMouseEnter(Widget sender) {
// TODO Auto-generated method stub
image.addMouseWheelHandler(new MouseWheelHandler() {
public void onMouseWheel(MouseWheelEvent event) {
if(event.isNorth()) {
masquerChargement();
getIMediateur().clicBoutonZoomImage("suiv");
} else {
masquerChargement();
getIMediateur().clicBoutonZoomImage("prev");
}
}
 
public void onMouseLeave(Widget sender) {
// TODO Auto-generated method stub
}
 
public void onMouseMove(Widget sender, int x, int y) {
sourisXFin = x;
sourisYFin = y;
Event.getCurrentEvent().preventDefault();
}
 
public void onMouseUp(Widget sender, int x, int y) {
if(scroll) {
Event.getCurrentEvent().preventDefault();
if(sourisX - sourisXFin > 0) {
Ext.get(image.getElement()).move(Direction.LEFT, sourisX - sourisXFin, false);
}
if(sourisXFin - sourisX > 0) {
Ext.get(image.getElement()).move(Direction.RIGHT, sourisXFin - sourisX, false);
}
if(sourisY - sourisYFin > 0) {
Ext.get(image.getElement()).move(Direction.UP, sourisY - sourisYFin, false);
}
if(sourisYFin - sourisY > 0) {
Ext.get(image.getElement()).move(Direction.DOWN, sourisYFin - sourisY, false);
}
}
}
});
// gestion du clic sur le bouton précedent
prev.addClickListener(new ClickListener() {
prev.addClickHandler(new ClickHandler() {
 
// en cas de clic
public void onClick(Widget sender) {
public void onClick(ClickEvent event) {
// on notifie le médiateur
masquerChargement();
getIMediateur().clicBoutonZoomImage("prev");
}
 
});
 
// gestion du clic sur le bouton suivant
suiv.addClickListener(new ClickListener() {
suiv.addClickHandler(new ClickHandler() {
 
// en cas de clic
public void onClick(Widget sender) {
public void onClick(ClickEvent event) {
// on notifie le médiateur
masquerChargement();
getIMediateur().clicBoutonZoomImage("suiv");
488,94 → 382,34
* echeant
*/
public void verifierEtRetaillerImage() {
// si l'image est nulle
if (image == null) {
// on ne fait rien
return;
}
 
// on prend la taille originale de l'image
/*int originalX = getTailleImage()[0];
int originalY = getTailleImage()[1];
 
// on la transforme en float (la division entre entier donne de curieux
// résultats)
float fOriginalX = (new Float(originalX)).floatValue();
float fOriginalY = (new Float(originalY)).floatValue();
 
// et on fait le rapport longueur sur hauteur (pour connaitre le ratio)
float rapportTaille = fOriginalX / fOriginalY;
 
// la nouvelle taille est pour le moment égale à l'ancienne
int nouvelleTailleX = originalX;
int nouvelleTailleY = originalY;
 
// on prend la taille du conteneur
int tailleConteneurX = imageConteneur.getWidth();
int tailleConteneurY = imageConteneur.getHeight();*/
 
// si celle-ci est égale à 0 (conteneur mal initialisé)
/*
* if(imageConteneur.getHeight() == 0 && tailleConteneurX == 0) { // on
* essaie de la calculer en fonction de la taille du parent et des
* frères tailleConteneurY = this.getHeight() ; tailleConteneurX =
* this.getWidth() - prev.getOffsetWidth() * 2 ;
* }
*/
/*
// si l'image ne rentre pas telle quelle (longueur ou hauteur trop
// grande)
if (originalY > tailleConteneurY || originalX > tailleConteneurX) {
// si la longueur de l'image est la plus grande des deux
if (originalX > originalY) {
// on prend la longueur comme taille de référence, qu'on met à
// la longueur du conteneur
nouvelleTailleX = tailleConteneurX;
// et on recalcule la hauteur, par rapport à la nouvelle
// longueur, en gardant le format de 'limage
nouvelleTailleY = (int) Math.floor(nouvelleTailleX * 1
/ rapportTaille);
} else {
// si la hauteur est la plus grande, on fait le même genre
// d'opération en prenant la hauteur comme référence
nouvelleTailleY = tailleConteneurY;
nouvelleTailleX = (int) Math.floor(nouvelleTailleY
* rapportTaille);
}
}
*/
// on modifie enfin la taille de l'image pour qu'elle soit affichée
int max = Math.min(imageConteneur.getHeight(), imageConteneur.getWidth());
int[] tailleImage = new int[2];
ExtElement imgElement = Ext.get(image.getElement());
if(max == imageConteneur.getHeight()) {
//tailleImage[0] = getTailleImage()[0];
//tailleImage[1] = max;
imgElement.setHeight(max, false);
if(Ext.isIE()) {
image.setHeight(calculerDimensions(getTailleImage(),max,max)[1]+"px");
image.setWidth(calculerDimensions(getTailleImage(),max,max)[0]+"px");
} else {
//tailleImage[1] = getTailleImage()[0];
//tailleImage[0] = max;
imgElement.setWidth(max, false);
if(max == imageConteneur.getHeight()) {
tailleImage[0] = getTailleImage()[0];
tailleImage[1] = max;
image.setHeight(max+"px");
} else {
tailleImage[1] = getTailleImage()[0];
tailleImage[0] = max;
image.setWidth(max+"px");
}
}
//int[] tailleImage = calculerDimensions(getTailleImage(), max, max);
//imgElement.
/*if(animerTransition) {
AnimationConfig a = new AnimationConfig() ;
a.setDuration((float) dureeAnimation);
imgElement.setHeight(tailleImage[1], a);
imgElement.setWidth(tailleImage[0], a);
} else {
imgElement.setHeight(tailleImage[1], false);
imgElement.setWidth(tailleImage[0], false);
}*/
String strZoom = ""+niveauZoom+"";
strZoom = strZoom.substring(0,3);
valeurZoom.setText("x "+strZoom);
}
public int[] calculerDimensions(int[] tailleXY, double tailleMax, double tailleConteneur) {
595,7 → 429,7
XYresize[0] = tailleOr*rapport ;
}
int[] res = {(int)Math.round(XYresize[0]*niveauZoom),(int) Math.round(XYresize[1]*niveauZoom)} ;
int[] res = {(int)Math.round(XYresize[0]),(int) Math.round(XYresize[1])} ;
return res;
}
696,6 → 530,16
{
idImage = id ;
}
public void setInfosTaxon(String nomTaxon) {
if(nomTaxon != null && !nomTaxon.equals("")) {
nomTaxon = getNomsObservationsFormatees(nomTaxon);
}
infosTaxon.setHtml("<div id='infos_taxon'><span class='texte_info_taxon'>"+nomTaxon+"</span></div>");
infosTaxon.doLayout();
}
 
/**
* renvoie la taille originale de l'image
708,6 → 552,14
return taille;
}
public boolean estPortrait() {
return imageHeight > imageWidth;
}
public boolean estPaysage() {
return !estPortrait();
}
/**
* Accesseur pour le conteneur de l'image
* @return le conteur de l'image
718,73 → 570,58
 
}
private void zoomOut() {
if(niveauZoom >= minZoom) {
niveauZoom -= pasZoom;
if(niveauZoom <= minZoom) {
niveauZoom = minZoom;
private String getNomsObservationsFormatees(String nomObs) {
String htmlInfobulle = "";
String[][] obs = getObservationsAssociees(nomObs);
for(int i = 0; i < obs.length; i++) {
if(obs[i].length == 3 && obs[i][1] != null && !obs[i][1].equals("")) {
htmlInfobulle += ", "+obs[i][1];
}
verifierEtRetaillerImage();
gererDecalage(false);
}
htmlInfobulle = htmlInfobulle.replaceFirst(", ", "");
return htmlInfobulle;
}
 
private void zoomIn() {
if(niveauZoom < maxZoom ) {
niveauZoom += pasZoom;
if(niveauZoom >= maxZoom) {
niveauZoom = maxZoom;
}
verifierEtRetaillerImage();
gererDecalage(true);
private String[][] getObservationsAssociees(String nomObs) {
if(nomObs.trim().equals("")) {
return new String[0][0];
}
String[] obsTab = nomObs.split(";;");
String[][] obsAnalysees = new String[obsTab.length][3];
for(int i = 0; i < obsTab.length; i++) {
obsAnalysees[i] = obsTab[i].split("#");
}
return obsAnalysees;
}
private void gererDecalage(boolean in) {
private boolean[] estAssocieeTransmise(String nomObs) {
float nZoom = niveauZoom;
String[][] obs = getObservationsAssociees(nomObs);
boolean[] associeesTranmises = {false, false};
if(niveauZoom < 1) {
nZoom = 1/niveauZoom;
if(obs.length > 0) {
associeesTranmises[0] = true;
}
if(!in) {
int diffX = imageConteneur.getWidth()/2 - sourisX;
int diffY = imageConteneur.getHeight()/2 - sourisY;
for(int i = 0; i < obs.length; i++) {
if(diffX > 0) {
Ext.get(image.getElement()).move(Direction.RIGHT, (int)((diffX/maxZoom)/nZoom), false);
if(obs[i].length == 3 && obs[i][2] != null && obs[i][2].equals("1")) {
associeesTranmises[1] = true;
}
if(-diffX > 0) {
Ext.get(image.getElement()).move(Direction.LEFT, (int)(-(diffX/maxZoom)/nZoom), false);
}
if(diffY > 0) {
Ext.get(image.getElement()).move(Direction.DOWN, (int)((diffY/maxZoom)/nZoom), false);
}
if(-diffY > 0) {
Ext.get(image.getElement()).move(Direction.UP, (int)(-(diffY/maxZoom)/nZoom), false);
}
} else {
int diffX = imageConteneur.getWidth()/2;
int diffY = imageConteneur.getHeight()/2;
if(diffX > 0) {
Ext.get(image.getElement()).move(Direction.LEFT, (int)((diffX/maxZoom)/nZoom), false);
}
if(-diffX > 0) {
Ext.get(image.getElement()).move(Direction.RIGHT, (int)((-diffX/maxZoom)/nZoom), false);
}
if(diffY > 0) {
Ext.get(image.getElement()).move(Direction.UP, (int)((diffY/maxZoom)/nZoom), false);
}
if(-diffY > 0) {
Ext.get(image.getElement()).move(Direction.DOWN, (int)(-(diffY/maxZoom)/nZoom), false);
}
}
return associeesTranmises;
}
}
/trunk/src/org/tela_botanica/client/vues/image/MiniListeObservationVue.java
63,7 → 63,7
private SimpleStore store = null ;
private MiniBarrePaginationVue pgBar = new MiniBarrePaginationVue(iMediateur) ;
private MiniBarrePaginationVue pgBar = new MiniBarrePaginationVue(this) ;
private Toolbar bt = new Toolbar() ;
79,7 → 79,16
int pageEnCours = 0;
int nbElements = 0;
int taillePage = 50;
/**
* Nombre de pages totales
*/
private int pageMax = 1 ;
/**
* Constructeur avec arguments
* @param im le médiateur à associer à la vue
*/
89,6 → 98,53
this.setId("x-view-mini-obs") ;
// on construit le modèle de colonnes
 
// Le store suivant est ensuite remplacé par le store contenant les données obtenus depuis le serveur (cf rafraichir)
Renderer colRend = new Renderer() {
 
public String render(Object value, CellMetadata cellMetadata,
Record record, int rowIndex, int colNum, Store store) {
if(value == null || value.equals("null") || value.equals("000null") || value.equals("0000-00-00 00:00:00")) {
return "" ;
}
else
{
}
return value.toString() ;
}
} ;
Renderer dateRend = new Renderer() {
 
public String render(Object value, CellMetadata cellMetadata,
Record record, int rowIndex, int colNum, Store store) {
if(value == null || value.equals("null") || value.equals("000null") || value.equals("0000-00-00 00:00:00")) {
return "" ;
}
else
{
String dateEntiere = value.toString() ;
String[] dateEtHeure = dateEntiere.split(" ", 2);
if(verifierFormatDate(dateEtHeure[0])) {
String[] dateFormateeTab = dateEtHeure[0].split("-",3);
return dateFormateeTab[2]+"/"+dateFormateeTab[1]+"/"+dateFormateeTab[0] ;
}
}
return value.toString() ;
}
} ;
// on crée un store simple contenant un petit set de données et deux colonnes
store = new SimpleStore(new String[]{"transmis","id_obs","plante","date","lieu"}, getObs());
ColumnConfig[] columns = {
107,10 → 163,10
}
}),
new ColumnConfig("Numero", "id_obs", 50, true),
new ColumnConfig("Taxon", "plante", 145, true),
new ColumnConfig("Date", "date", 68, true),
new ColumnConfig("Lieu", "lieu", 145, true) } ;
new ColumnConfig("Numero", "id_obs", 50, true, colRend),
new ColumnConfig("Taxon", "plante", 145, true, colRend),
new ColumnConfig("Date", "date", 68, true, dateRend),
new ColumnConfig("Lieu", "lieu", 145, true, colRend) } ;
ColumnModel columnModel = new ColumnModel(columns);
165,21 → 221,6
// on configure le drag 'n drop
configDragAndDrop() ;
this.addListener(new ContainerListenerAdapter() {
public void onRender(Component c) {
obtenirMiniListeObservations() ;
}
public void onAfterLayout(Container c)
{
obtenirMiniListeObservations() ;
}
}) ;
this.addGridListener(new GridListenerAdapter() {
 
public void onContextMenu(EventObject e) {
198,6 → 239,8
}
}) ;
obtenirNombreMiniListeObservations();
}
/**
260,6 → 303,9
if(this.getView() != null)
{
ListeObservation data = (ListeObservation)nouvelleDonnees ;
//Window.alert(data.size()+"");
String[][] listeObs = new String[data.size()][5] ;
int i = 0 ;
287,12 → 333,12
public void onShow(Component c)
{
obtenirMiniListeObservations() ;
obtenirNombreMiniListeObservations() ;
}
public void onAfterLayout(Container c)
{
obtenirMiniListeObservations() ;
obtenirNombreMiniListeObservations() ;
}
}) ;
300,6 → 346,25
}
// Si on reçoit un tableau d'entiers
// c'est un tableau d'un seul entier qui est le nombre d'observation correspondant aux critères
if(nouvelleDonnees instanceof int[])
{
int[] pages = (int[])nouvelleDonnees ;
// on calcule le nombre de pages nécessaires et on les met à jour dans le modèle
pageMax = calculerNbPages(pages[0]) ;
nbElements = pages[0];
// et on notifie de le mediateur du changement des valeurs
changerPageMaxEtCourante(pageMax,pageEnCours,taillePage,nbElements) ;
masquerChargement();
obtenirMiniListeObservations();
}
redimensionner();
deMasquerChargement() ;
}
306,9 → 371,14
private void obtenirMiniListeObservations()
{
iMediateur.obtenirMiniListeObservations(this) ;
iMediateur.obtenirMiniListeObservations(this, taillePage, pageEnCours) ;
}
private void obtenirNombreMiniListeObservations()
{
iMediateur.obtenirNombreMiniListeObservations(this) ;
}
/**
* Renvoie le faux set de données pour le store
* @return un tableau à deux colonnes int - String
336,6 → 406,8
liaison = true ;
selecteurMode.removeClass("x-selec-consult") ;
selecteurMode.setCls("x-selec-liaison") ;
getBarrePagination().disable();
doLayout();
}
else
{
342,7 → 414,8
liaison = false ;
selecteurMode.removeClass("x-selec-liaison") ;
selecteurMode.setCls("x-selec-consult") ;
getBarrePagination().enable();
doLayout();
}
masquerChargement() ;
382,8 → 455,15
public String getIdSelectionnees() {
Record[] sels = getSelectionModel().getSelections() ;
String id = sels[0].getAsString("id_obs") ;
String id = "";
for(int i = 0; i < sels.length; i++) {
id += ","+sels[i].getAsString("id_obs") ;
}
id = id.replaceFirst(",", "");
return id ;
}
404,13 → 484,18
public void redimensionner() {
if(getView() != null) {
this.setWidth("100%");
getView().setForceFit(true);
doLayout();
int taille = 400;
if(Window.getClientHeight() > 800 ) {
taille = Window.getClientHeight() - 350;
}
setHeight(taille);
getView().setForceFit(true);
doLayout();
}
else {
Window.alert("null");
 
}
}
445,7 → 530,6
liObs.showAt(e.getXY());
}
 
@Override
public void changerNumeroPage(int pageCourante) {
pageEnCours = pageCourante ;
452,15 → 536,97
masquerChargement();
 
// On lance le chargerment des observations
iMediateur.obtenirMiniListeObservations(this);
iMediateur.obtenirNombreMiniListeObservations(this);
pgBar.changerPageCourante(pageCourante);
}
/**
* Appelle le modèle pour qu'il change la taille de page utilisée
* @param nouvelleTaillePage la nouvelle taille de page
*/
public void changerTaillePage(int nouvelleTaillePage)
{
taillePage = nouvelleTaillePage ;
pageEnCours = calculerPageCourante(nbElements) ;
 
masquerChargement();
 
// On lance le chargerment des observations
iMediateur.obtenirNombreMiniListeObservations(this);
// et on met à jour la taille de page dans les barres d'outils
pgBar.selectionnerTaillePage(nouvelleTaillePage);
}
/**
* Met à jour les barre d'outils avec des nouvelles valeurs
* @param pageMax le nombre de pages
* @param pageEncours la page en cours
* @param taillePage la taille de page
* @param nbElement le nombre d'élements par page
*/
public void changerPageMaxEtCourante(int pageMax, int pageEncours, int taillePage, int nbElement)
{
int[] pages = {pageMax,pageEncours, taillePage, nbElement} ;
pgBar.rafraichir(pages, false) ;
}
/**
* Calcule le nombre de pages nécessaires pour afficher un nombre d'élements donnés en fonction de la taille de page
* en cours
* @param nbElements le nombre d'élements total
* @return le nombre de pages
*/
public int calculerNbPages(int nbElements)
{
// A cause de la betise de java pour les conversion implicite on fait quelques conversions manuellement
// pour eviter qu'il arrondisse mal la division
// nombre de pages = (nombre d'element / taille de la page) arrondie à l'entier superieur
double nPage = (1.0*nbElements)/(1.0*taillePage) ;
double nPageRound = Math.ceil(nPage) ;
Double nPageInt = new Double(nPageRound) ;
// on convertit en entier
return nPageInt.intValue() ;
}
 
@Override
public void changerTaillePage(int nouvelleTaillePage) {
// TODO Auto-generated method stub
/**
* Recalcule la page en cours lors du changement du nombre d'élements
* @param nbElements le nombre d'élements total
* @return la nouvelle page encours
*/
public int calculerPageCourante(int nbElements)
{
// on calcule le nombre de page
int nouvelNbPages = calculerNbPages(nbElements) ;
// la nouvelle page en cours
double nPageCourante = (1.0*pageEnCours)/(1.0*pageMax) * (1.0*nouvelNbPages) ;
// on arrondit au supérieur
double nPageRound = Math.ceil(nPageCourante) ;
Double nPageInt = new Double(nPageRound) ;
// on convertit en entier
return Math.abs(nPageInt.intValue()) ;
}
public boolean verifierFormatDate(String date) {
String regex = "[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}" ;
if(date.matches(regex) && !date.equals("0000-00-00")) {
return true ;
}
else {
return false;
}
}
}
/trunk/src/org/tela_botanica/client/vues/image/PanneauMetadonneesVue.java
4,10 → 4,14
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.vues.ArbreMotsClesVue;
 
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Label;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.core.Ext;
import com.gwtext.client.core.NameValuePair;
import com.gwtext.client.widgets.BoxComponent;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.Component;
import com.gwtext.client.widgets.Container;
14,16 → 18,23
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.TabPanel;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.event.ContainerListener;
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
import com.gwtext.client.widgets.event.PanelListener;
import com.gwtext.client.widgets.event.PanelListenerAdapter;
import com.gwtext.client.widgets.form.DateField;
import com.gwtext.client.widgets.form.Field;
import com.gwtext.client.widgets.form.TextArea;
import com.gwtext.client.widgets.form.TextField;
import com.gwtext.client.widgets.form.event.FieldListener;
import com.gwtext.client.widgets.form.event.FieldListenerAdapter;
import com.gwtext.client.widgets.grid.GridPanel;
import com.gwtext.client.widgets.grid.GridView;
import com.gwtext.client.widgets.grid.PropertyGridPanel;
import com.gwtext.client.widgets.grid.event.GridCellListenerAdapter;
import com.gwtext.client.widgets.layout.FitLayout;
import com.gwtext.client.widgets.layout.RowLayout;
import com.gwtext.client.widgets.layout.RowLayoutData;
import com.gwtext.client.widgets.layout.VerticalLayout;
 
/**
89,6 → 100,11
private DateField dateImage = null;
/**
* La barre de recherche rapide des taxons
*/
private RechercheFiltreTaxonVue rechercheFiltreTaxonVue = null;
/**
* La mini liste des observations
*/
private MiniListeObservationVue miniListeObservation = null ;
106,6 → 122,8
* Booleen d'instanciation
*/
boolean estInstancie = false;
Timer timerRedimensionnement = null;
 
/**
* Constructeur sans argument (privé car ne doit pas être utilisé)
160,12 → 178,29
validerInfo = new Button("OK");
 
noteVue = new BarreNotationVue(im, 5);
panneauMiniListeObservation = new Panel("Observations") ;
panneauMiniListeObservation = new Panel("Observations") ;
panneauMiniListeObservation.setLayout(new FitLayout()) ;
panneauMiniListeObservation.setHeight(800) ;
miniListeObservation = new MiniListeObservationVue(im) ;
panneauMiniListeObservation.add(miniListeObservation) ;
if(!Ext.isIE()) {
panneauMiniListeObservation.setLayout(new RowLayout());
}
miniListeObservation = new MiniListeObservationVue(im);
rechercheFiltreTaxonVue = new RechercheFiltreTaxonVue(im);
rechercheFiltreTaxonVue.setTitle("Recherche dans les observations");
if(Ext.isIE()) {
panneauMiniListeObservation.add(rechercheFiltreTaxonVue);
rechercheFiltreTaxonVue.setHeight(90);
} else {
panneauMiniListeObservation.add(rechercheFiltreTaxonVue, new RowLayoutData(90));
}
rechercheFiltreTaxonVue.setWidth("100%") ;
rechercheFiltreTaxonVue.setBorder(false);
if(Ext.isIE()) {
panneauMiniListeObservation.add(miniListeObservation, new RowLayoutData(400)) ;
} else {
panneauMiniListeObservation.add(miniListeObservation, new RowLayoutData()) ;
}
 
sousPanneauInfosGenerales.add(labelComm);
sousPanneauInfosGenerales.add(commentaireGeneral);
182,6 → 217,7
 
panneauInfoGrid.add(sousPanneauInfosGenerales);
panneauInfoGrid.add(panneauMotsCles);
 
this.add(panneauMiniListeObservation) ;
this.add(panneauInfoGrid);
218,7 → 254,7
ajouterListeners();
 
// on effectue le rendu
this.doLayout(true);
//this.doLayout(true);
 
}
 
279,7 → 315,6
}
 
// lors d'un double clic d'une cellule
 
public void onCellDblClick(GridPanel grid, int rowIndex,
int colIndex, EventObject e) {
// on empeche l'édition
290,6 → 325,26
 
});
panneauMiniListeObservation.addListener(new ContainerListenerAdapter() {
public void onResize(BoxComponent component, int adjWidth, int adjHeight,
int rawWidth, int rawHeight) {
timerRedimensionnement = new Timer() {
public void run() {
int taille = 500;
if(Window.getClientHeight() > 800 ) {
taille = Window.getClientHeight() - 226;
}
panneauMiniListeObservation.setHeight(taille);
}
};
timerRedimensionnement.schedule(300);
}
});
}
 
/**
328,11 → 383,25
 
// si on reçoit un tableau d'objets
if (nouvelleDonnees instanceof Object[]) {
final Object ressourceObject = nouvelleDonnees;
if(!this.isRendered()) {
addListener(new PanelListenerAdapter() {
public void onRender(Component component) {
rafraichir(ressourceObject, false);
}
});
return ;
}
// extrait infos, exifs et iptc
Object meta[] = (Object[]) nouvelleDonnees;
String[][] exif = (String[][]) meta[0];
String[][] iptc = (String[][]) meta[1];
String[][] gen = (String[][]) meta[2];
final String[][] gen = (String[][]) meta[2];
 
NameValuePair[] exifSource = new NameValuePair[exif.length];
NameValuePair[] iptcSource = new NameValuePair[iptc.length];
356,8 → 425,8
 
// on met à jour les champs avec la bonne valeur
commentaireGeneral.setValue(gen[0][1]);
dateImage.setRawValue(gen[1][1]);
 
dateImage.setValue(gen[1][1]);
// et on met à jour les données pour l'affichage
ExifGrid.setSource(exifSource);
IptcGrid.setSource(iptcSource);
382,6 → 451,11
{
return miniListeObservation ;
}
public RechercheFiltreTaxonVue getRechercheFiltreTaxonVue()
{
return rechercheFiltreTaxonVue ;
}
 
public void redimensionner() {
/trunk/src/org/tela_botanica/client/vues/image/GalerieImageVue.java
250,7 → 250,7
new String[] {
"<tpl for='.'>",
"<div class='thumb-wrap' id='{num_image}'>",
"<div class='thumb dview-list'>{indication_transmission}{indication_liaison}<img class='miniature_galerie' src='{url_image_M}' width='{taille_x_s} px' height='{taille_y_s} px' title='{nom_original}' /></div>",
"<div class='thumb dview-list'>{indication_transmission}{indication_liaison}<img class='miniature_galerie' src='{url_image_M}' width='{taille_x_s} px' height='{taille_y_s} px' title='{infobulle}' /></div>",
"<span class='info_image'>{nom_obs_associees_formatees}</span></div>", "</tpl>",
"<div class='x-clear'></div>" });
// pour des raisons de performances on compile le template en une
281,25 → 281,27
data.setProperty("taille_y_s", XYresize[1]);
String nomObs = data.getProperty("obs_associees");
String[] obsTab = nomObs.split(";;");
 
String htmltransmis = "";
String htmllie = "";
 
if(obsTab.length >= 1) {
String[] elementsObs = obsTab[0].split("#");
if(elementsObs.length >= 3) {
nomObs = elementsObs[1];
//if(elementsObs[2] == "1") {
htmltransmis = "<img class='picto_haut_gauche' src='tela.png' />";
htmllie = "<img class='picto_haut_droite' src='chain.png' />";
//}
}
boolean associee = estAssocieeTransmise(nomObs)[0];
boolean transmise = estAssocieeTransmise(nomObs)[1];
String nomFormate = getNomsObservationsFormatees(nomObs);
if(associee) {
htmllie = "<img class='picto_haut_droite' src='chain.png' />";
}
if(transmise) {
htmltransmis = "<img class='picto_haut_gauche' src='tela.png' />";
}
 
data.setProperty("infobulle", nomFormate);
data.setProperty("indication_transmission", htmltransmis);
data.setProperty("indication_liaison", htmllie);
data.setProperty("nom_obs_associees_formatees", nomObs);
data.setProperty("nom_obs_associees_formatees", nomFormate);
}
};
503,4 → 505,58
 
});
}
private String getNomsObservationsFormatees(String nomObs) {
String htmlInfobulle = "";
String[][] obs = getObservationsAssociees(nomObs);
for(int i = 0; i < obs.length; i++) {
if(obs[i].length == 3 && obs[i][1] != null && !obs[i][1].equals("")) {
htmlInfobulle += ", "+obs[i][1];
}
}
htmlInfobulle = htmlInfobulle.replaceFirst(", ", "");
return htmlInfobulle;
}
private String[][] getObservationsAssociees(String nomObs) {
if(nomObs.trim().equals("")) {
return new String[0][0];
}
String[] obsTab = nomObs.split(";;");
String[][] obsAnalysees = new String[obsTab.length][3];
for(int i = 0; i < obsTab.length; i++) {
obsAnalysees[i] = obsTab[i].split("#");
}
return obsAnalysees;
}
private boolean[] estAssocieeTransmise(String nomObs) {
String[][] obs = getObservationsAssociees(nomObs);
boolean[] associeesTranmises = {false, false};
if(obs.length > 0) {
associeesTranmises[0] = true;
}
for(int i = 0; i < obs.length; i++) {
if(obs[i].length == 3 && obs[i][2] != null && obs[i][2].equals("1")) {
associeesTranmises[1] = true;
}
}
return associeesTranmises;
}
}
/trunk/src/org/tela_botanica/client/vues/image/ListeImageVue.java
7,6 → 7,7
import org.tela_botanica.client.vues.BarrePaginationVue;
 
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.data.FieldDef;
import com.gwtext.client.data.IntegerFieldDef;
174,21 → 175,9
return "";
}
String[] obsTab = nomObs.split(";;");
String valeurTransmis = "0";
 
if(obsTab.length >= 1) {
String[] elementsObs = obsTab[0].split("#");
if(elementsObs.length >= 3) {
nomObs = elementsObs[1];
//if(elementsObs[2] == "1") {
valeurTransmis = "1";
//}
}
}
boolean transmise = estAssocieeTransmise(nomObs)[1];
if(valeurTransmis.equals("1"))
if(transmise)
{
return "<img src=\"tela.png\"/></img>" ;
}
337,17 → 326,10
if(nomObs == null) {
return "";
}
String[] obsTab = nomObs.split(";;");
 
if(obsTab.length >= 1) {
String[] elementsObs = obsTab[0].split("#");
if(elementsObs.length >= 3) {
nomObs = elementsObs[1];
}
}
return "<div class=\"centered-list\">" + nomObs
String nomFormate = getNomsObservationsFormatees(nomObs);
return "<div class=\"centered-list\">" + nomFormate
+ "</div>";
}
 
431,8 → 413,8
 
// gestion du clic sur une ligne
public void onRowClick(GridPanel grid, int rowIndex, EventObject e) {
 
// on notifie le médiateur et on lui passe le nuémro de ligne
// on notifie le médiateur et on lui passe le numéro de ligne
getIMediateur().clicListeImage(rowIndex);
}
 
684,5 → 666,60
return res;
}
private String getNomsObservationsFormatees(String nomObs) {
String htmlInfobulle = "";
String[][] obs = getObservationsAssociees(nomObs);
for(int i = 0; i < obs.length; i++) {
if(obs[i].length == 3 && obs[i][1] != null && !obs[i][1].equals("")) {
htmlInfobulle += ", "+obs[i][1];
}
}
htmlInfobulle = htmlInfobulle.replaceFirst(", ", "");
return htmlInfobulle;
}
private String[][] getObservationsAssociees(String nomObs) {
if(nomObs.trim().equals("")) {
return new String[0][0];
}
String[] obsTab = nomObs.split(";;");
String[][] obsAnalysees = new String[obsTab.length][3];
for(int i = 0; i < obsTab.length; i++) {
obsAnalysees[i] = obsTab[i].split("#");
}
return obsAnalysees;
}
private boolean[] estAssocieeTransmise(String nomObs) {
String[][] obs = getObservationsAssociees(nomObs);
boolean[] associeesTranmises = {false, false};
if(obs.length > 0) {
associeesTranmises[0] = true;
}
for(int i = 0; i < obs.length; i++) {
if(obs[i].length == 3 && obs[i][2] != null && obs[i][2].equals("1")) {
associeesTranmises[1] = true;
}
}
return associeesTranmises;
}
 
}