Ignore:
Timestamp:
04/26/10 19:12:49 (14 years ago)
Author:
cbipsl
Message:

maj eccad V3.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ether_eccad/trunk/ECCAD_INTERFACE/WEB-INF/src/org/medias/eccad/metier/generationRaster/InformationLegend.java

    r68 r70  
    77import org.medias.eccad.helpers.LoggerPerso; 
    88import org.medias.eccad.helpers.SpringBeanFactory; 
    9 import org.medias.eccad.metier.generationRaster.colorMap.ColorMapping; 
    10 import org.medias.eccad.metier.statistique.ServiceStatistique; 
    119import org.medias.eccad.modele.ColorTab; 
    1210import org.medias.eccad.modele.Legende; 
    1311import org.medias.eccad.persistance.dao.CodeDAO; 
    14 import org.medias.eccad.persistance.dao.ColorTabDAO; 
    1512import org.medias.eccad.persistance.dao.GrilleDAO; 
    1613import org.medias.eccad.persistance.dao.ParametreDAO; 
     
    2522        } 
    2623         
    27         public List<String> getLegendValeur(ColorTab colortab) { 
     24        public List<String> getLegendValeur(ColorTab colortab, String unit) { 
    2825                int taille = colortab.getLength(); 
    2926                float tableau_valeur[] = colortab.getTab_min(); 
    3027                float valeur; 
    31                  
    3228                List<String> liste = new LinkedList<String>(); 
    3329                 
     
    3632                        valeur = tableau_valeur[i]; 
    3733                        liste.add(Float.toString(valeur)); 
     34                } 
     35                if (unit.equals("%")) { 
     36                        liste.add(Float.toString(colortab.getMax())); 
     37                } else { 
     38                        liste.add("\u2265 "+Float.toString(colortab.getMax()));                  
    3839                } 
    3940                 
     
    4546         * Cette fonction a pour vocation d'obtenir les informations suplémentaires à afficher sous la légende (par exemple les unités) 
    4647         * @param id_grille l'identifiant de la grille 
     48         * @param fonction la fonction permettant de déterminer le mode d'affichage choisi 
    4749         * @return la chaine de caractÚre représentant les informations 
    4850         */ 
    49         public String getInfoSup(long id_grille) { 
    50                 String information; 
    51                 information = "Unit : "; 
     51        public String getInfoSup(long id_grille, String fonction) { 
     52                String information = ""; 
    5253                ParametreDAO paramDAO = (ParametreDAO) xmlbean.getBean("parametreDAO"); 
    5354                try { 
     
    5556                } catch (PersistanceException e) { 
    5657                        e.printStackTrace(); 
    57                         information += "none"; 
     58                        information += "No unit"; 
    5859                } 
    59                  
     60                // Cas particulier: les totaux -> on change l'unité si besoin 
     61                if (fonction != null && (fonction.equals("totalDay") || fonction.equals("totalMonth") 
     62                                || fonction.equals("totalYear") || fonction.equals("totalPeriod"))) { 
     63                        if (information.equals("pers/km2")) { 
     64                                information = "pers"; 
     65                        } else if (information.equals("kg(X).m-2.s-1")) { 
     66                                if (fonction.equals("totalDay")) { 
     67                                        information = "Tg(X)/day";                                       
     68                                } else if (fonction.equals("totalMonth")) { 
     69                                        information = "Tg(X)/month"; 
     70                                } else if (fonction.equals("totalYear")) { 
     71                                        information = "Tg(X)/year"; 
     72                                } else { 
     73                                        information = "Tg(X)/period"; 
     74                                } 
     75                        } 
     76                } 
    6077                return information; 
    6178        } 
     
    6784         * @return 
    6885         */ 
    69         public Legende getLegendText(long id_grille, ColorTab colortab) { 
     86        public Legende getLegendText(long id_grille, ColorTab colortab, String unit) { 
    7087                GrilleDAO grille = (GrilleDAO) xmlbean.getBean("grilleDAO"); 
    7188                CodeDAO codedao = (CodeDAO) xmlbean.getBean("codeDAO"); 
     
    7592                try { 
    7693                        codif = grille.getCodification(id_grille); 
     94//                      LoggerPerso.log(ServiceRaster.class, LoggerPerso.WARN, "type codification :" + codif); 
    7795                } 
    7896                catch (PersistanceException perse) { 
    7997                        LoggerPerso.log(ServiceRaster.class, LoggerPerso.WARN, "erreur récupération codif grille " + id_grille, perse); 
    80                         return new Legende(getLegendValeur(colortab), Legende.TYPE_VALUE); 
     98                        return new Legende(getLegendValeur(colortab,unit), Legende.TYPE_VALUE); 
    8199                } 
    82100                 
     
    84102                        if (codif.equals("coded")) { 
    85103                                legende = new Legende(codedao.getListCodeByGrille(id_grille), Legende.TYPE_CODED); 
    86                         } 
    87                         else { 
    88                                 legende = new Legende(getLegendValeur(colortab), Legende.TYPE_VALUE); 
     104                        } else { 
     105                                legende = new Legende(getLegendValeur(colortab,unit), Legende.TYPE_VALUE); 
    89106                        } 
    90107                } 
    91108                catch (PersistanceException perse) { 
    92109                        LoggerPerso.log(ServiceRaster.class, LoggerPerso.WARN, "erreur récupération liste des légendes de la grille " + id_grille, perse); 
    93                         return legende = new Legende(getLegendValeur(colortab), Legende.TYPE_VALUE); 
     110                        return legende = new Legende(getLegendValeur(colortab,unit), Legende.TYPE_VALUE); 
    94111                } 
    95112                 
     
    102119                int taille = colortab.getLength(); 
    103120                float tableau_valeur[] = colortab.getTab_min(); 
    104                  
     121 
    105122                // on prend n-1 valeur ^^ 
    106123                for (int i=1; i<taille; i++) { 
    107                         valeur = tableau_valeur[i]; 
    108                         valeur = (valeur *(max-min))+min; 
     124                        valeur = (tableau_valeur[i] *(max-min))+min; 
    109125                        liste.add(fixeDecimal(Float.toString(valeur))); 
    110126                } 
     127                valeur = (colortab.getMax() *(max-min))+min; 
     128                liste.add(fixeDecimal(Float.toString(valeur))); 
    111129                return new Legende(liste , Legende.TYPE_VALUE); 
    112130        } 
     
    115133 
    116134        private String fixeDecimal(String entree) { 
    117                 LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "-------------Legende------------------------******------>entree "+entree); 
     135//              LoggerPerso.log(this.getClass(), LoggerPerso.DEBUG, "-------------Legende------------------------******------>entree "+entree); 
    118136                if (entree == null) 
    119137                        return "nc"; 
    120138                int index = entree.lastIndexOf("."); 
    121139                int indexE = entree.lastIndexOf("E"); 
    122                 LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "entree  --lll-->2 "+indexE+"  "+index+"  "+entree.length()); 
    123                 if ( indexE == -1 && index != -1 && entree.length() >= index + 5) 
     140//              LoggerPerso.log(this.getClass(), LoggerPerso.DEBUG, "entree  --lll-->2 "+indexE+"  "+index+"  "+entree.length()); 
     141                if ( indexE == -1 && index != -1 && entree.length() >= index + 5) { 
    124142                        entree = entree.substring(0, entree.lastIndexOf(".")+5); 
    125                 if ( indexE != -1 && index != -1 && entree.length() >= index + 5) 
     143                } 
     144                else if ( indexE != -1 && index != -1 && entree.length() >= index + 5) 
    126145                { 
    127146                        String aEntree = entree; 
    128                         LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "aEntree "+aEntree.lastIndexOf("E")+"  "+aEntree.length()+"    "+aEntree.lastIndexOf("E")+"  "+aEntree.length()); 
     147//                      LoggerPerso.log(this.getClass(), LoggerPerso.DEBUG, "aEntree "+aEntree.lastIndexOf("E")+"  "+aEntree.length()+"    "+aEntree.lastIndexOf("E")+"  "+aEntree.length()); 
    129148                        aEntree=aEntree.substring(aEntree.lastIndexOf("E"), aEntree.lastIndexOf("E")+aEntree.length()-aEntree.lastIndexOf("E")); 
    130                         entree = entree.substring(0, entree.lastIndexOf(".")+5)+aEntree; 
     149                        //entree = entree.substring(0, entree.lastIndexOf(".")+5)+aEntree; 
     150                        entree = entree.substring(0, 3)+aEntree; 
    131151                } 
    132                         LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "entree "+entree); 
     152//              LoggerPerso.log(this.getClass(), LoggerPerso.DEBUG, "entree "+entree); 
    133153                return entree; 
    134154        } 
Note: See TracChangeset for help on using the changeset viewer.