Changeset 129


Ignore:
Timestamp:
07/25/11 21:20:23 (13 years ago)
Author:
vmipsl
Message:

Commit intermédiaire : plot dynamique (version instable et pas clean)

Location:
ether_megapoli/trunk
Files:
4 added
24 edited
3 copied
1 moved

Legend:

Unmodified
Added
Removed
  • ether_megapoli/trunk/common/implementation/com/ether/ImageHelper.java

    r89 r129  
    11package com.ether; 
    22 
    3 import java.awt.Graphics; 
    4 import java.awt.GraphicsConfiguration; 
    5 import java.awt.GraphicsDevice; 
    6 import java.awt.GraphicsEnvironment; 
    7 import java.awt.HeadlessException; 
    8 import java.awt.Image; 
    9 import java.awt.Transparency; 
     3import org.jetbrains.annotations.NotNull; 
     4 
     5import javax.imageio.ImageIO; 
     6import javax.swing.*; 
     7import java.awt.*; 
    108import java.awt.image.BufferedImage; 
    119import java.awt.image.ColorModel; 
    1210import java.awt.image.PixelGrabber; 
    13  
    14 import javax.swing.ImageIcon; 
     11import java.io.File; 
     12import java.io.IOException; 
    1513 
    1614/** 
     
    1816 * @date may 2011 
    1917 */ 
    20 public abstract class ImageHelper { 
     18// TODO : range this class !!!! 
     19public abstract class ImageHelper 
     20{ 
    2121 
    22         public static BufferedImage createBufferedImage(Image image) { 
    23             if(image == null) return null; 
    24             if (image instanceof BufferedImage) return (BufferedImage) image; 
    25              
    26             image = new ImageIcon(image).getImage(); 
    27             boolean hasAlpha = hasAlpha(image); 
    28             BufferedImage bimage = null; 
    29             GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 
    30              
    31             try { 
    32                 int transparency = Transparency.OPAQUE; 
    33                 if (hasAlpha) 
    34                     transparency = Transparency.BITMASK; 
    35                 GraphicsDevice gs = ge.getDefaultScreenDevice(); 
    36                 GraphicsConfiguration gc = gs.getDefaultConfiguration(); 
    37                 bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency); 
    38             } catch (HeadlessException e) { 
    39                 // erreur pas d'ecran 
    40             } 
    41             if (bimage == null) { 
    42                 int type = BufferedImage.TYPE_INT_RGB; 
    43                 if (hasAlpha) 
    44                     type = BufferedImage.TYPE_INT_ARGB; 
    45                 bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); 
    46             } 
    47              
    48             Graphics g = bimage.createGraphics(); 
    49             g.drawImage(image, 0, 0, null); 
    50             g.dispose(); 
    51             return bimage; 
    52         } 
     22    public static BufferedImage createBufferedImage( final JFrame frame ) 
     23    { 
     24        if( frame == null ) return null; 
     25 
     26        boolean hasAlpha = false; 
     27        BufferedImage bimage = null; 
     28        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 
     29 
     30        try 
     31        { 
     32            int transparency = Transparency.OPAQUE; 
     33            if( hasAlpha ) 
     34                transparency = Transparency.BITMASK; 
     35            final GraphicsDevice gs = ge.getDefaultScreenDevice(); 
     36            final GraphicsConfiguration gc = gs.getDefaultConfiguration(); 
     37            bimage = gc.createCompatibleImage( frame.getWidth(), frame.getHeight(), transparency ); 
     38        } 
     39        catch( HeadlessException e ) 
     40        { 
     41            // erreur pas d'ecran 
     42        } 
     43        if( bimage == null ) 
     44        { 
     45            int type = BufferedImage.TYPE_INT_RGB; 
     46            if( hasAlpha ) 
     47                type = BufferedImage.TYPE_INT_ARGB; 
     48            bimage = new BufferedImage( frame.getWidth(), frame.getHeight(), type ); 
     49        } 
     50 
     51        final Graphics g = bimage.createGraphics(); 
     52        g.drawImage( bimage, 0, 0, null ); 
     53        g.dispose(); 
     54        return bimage; 
     55    } 
     56 
     57    public static BufferedImage createBufferedImage( Image image ) 
     58    { 
     59        if( image == null ) return null; 
     60        if( image instanceof BufferedImage ) return (BufferedImage) image; 
     61 
     62        image = new ImageIcon( image ).getImage(); 
     63        boolean hasAlpha = hasAlpha( image ); 
     64        BufferedImage bimage = null; 
     65        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 
     66 
     67        try 
     68        { 
     69            int transparency = Transparency.OPAQUE; 
     70            if( hasAlpha ) 
     71                transparency = Transparency.BITMASK; 
     72            GraphicsDevice gs = ge.getDefaultScreenDevice(); 
     73            GraphicsConfiguration gc = gs.getDefaultConfiguration(); 
     74            bimage = gc.createCompatibleImage( image.getWidth( null ), image.getHeight( null ), transparency ); 
     75        } 
     76        catch( HeadlessException e ) 
     77        { 
     78            // erreur pas d'ecran 
     79        } 
     80        if( bimage == null ) 
     81        { 
     82            int type = BufferedImage.TYPE_INT_RGB; 
     83            if( hasAlpha ) 
     84                type = BufferedImage.TYPE_INT_ARGB; 
     85            bimage = new BufferedImage( image.getWidth( null ), image.getHeight( null ), type ); 
     86        } 
     87 
     88        Graphics g = bimage.createGraphics(); 
     89        g.drawImage( image, 0, 0, null ); 
     90        g.dispose(); 
     91        return bimage; 
     92    } 
    5393 
    5494 
    55         private static boolean hasAlpha(Image image) { 
    56             if (image instanceof BufferedImage) { 
    57                 BufferedImage bimage = (BufferedImage) image; 
    58                 return bimage.getColorModel().hasAlpha(); 
    59             } 
    60             PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false); 
    61             try { 
    62                 pg.grabPixels(); 
    63             } catch (InterruptedException e) { return false;} 
    64             ColorModel cm = pg.getColorModel(); 
    65             return cm.hasAlpha(); 
    66         } 
     95    private static boolean hasAlpha( Image image ) 
     96    { 
     97        if( image instanceof BufferedImage ) 
     98        { 
     99            BufferedImage bimage = (BufferedImage) image; 
     100            return bimage.getColorModel().hasAlpha(); 
     101        } 
     102        PixelGrabber pg = new PixelGrabber( image, 0, 0, 1, 1, false ); 
     103        try 
     104        { 
     105            pg.grabPixels(); 
     106        } 
     107        catch( InterruptedException e ) 
     108        { 
     109            return false; 
     110        } 
     111        ColorModel cm = pg.getColorModel(); 
     112        return cm.hasAlpha(); 
     113    } 
     114 
     115    public static void writeJFrameToFile( @NotNull final JFrame frame, @NotNull final String fileName ) 
     116    { 
     117        final BufferedImage image = new BufferedImage( frame.getWidth(), frame.getHeight(), BufferedImage.TYPE_INT_RGB ); 
     118 
     119        final Graphics2D g2 = image.createGraphics(); 
     120        frame.paint( g2 ); 
     121        g2.dispose(); 
     122 
     123        try 
     124        { 
     125            final File out = new File( fileName ); 
     126            ImageIO.write( image, "JPEG", out ); 
     127        } 
     128        catch( IOException e ) 
     129        { 
     130            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates. 
     131        } 
     132    } 
    67133 
    68134} 
  • ether_megapoli/trunk/common/implementation/com/ether/ParameterConstants.java

    r89 r129  
    1111         public static final String PARAMETER_DATE_BEGIN = "dateBegin"; 
    1212         public static final String PARAMETER_DATE_END = "dateEnd"; 
    13          public static final String PARAMETER_VALUES = "values";          
     13         public static final String PARAMETER_VALUES = "values"; 
     14    public static final String PARAMETER_IMAGE = "encodedImage"; 
    1415} 
  • ether_megapoli/trunk/common/implementation/com/ether/WebException.java

    r89 r129  
    33/** 
    44 * @author vmipsl 
    5  * @date 02 feb 2011  
     5 * @date 02 feb 2011 
    66 */ 
    7 public class WebException  
    8         extends FormattedException 
     7public class WebException 
     8        extends FormattedException 
    99{ 
    10     public WebException(final Enum<? extends Code> code) { 
    11         super(code); 
    12         } 
    13  
    14         public WebException(final Enum<? extends Code> code, final Throwable cause, final Object... parameters) { 
    15         this(code, cause.getMessage(), cause, parameters); 
     10    public WebException( final Enum<? extends Code> code ) 
     11    { 
     12        super( code ); 
    1613    } 
    1714 
    18     protected WebException(final Enum<? extends Code> code, final String message, final Throwable cause, final Object... parameters) { 
    19         super(prefix(code, message), cause, parameters); 
     15    public WebException( final Enum<? extends Code> code, final Throwable cause, final Object... parameters ) 
     16    { 
     17        this( code, cause.getMessage(), cause, parameters ); 
    2018    } 
    2119 
    22         public WebException(final Throwable cause) { 
    23                 super(cause); 
    24         } 
     20    protected WebException( final Enum<? extends Code> code, final String message, final Throwable cause, final Object... parameters ) 
     21    { 
     22        super( prefix( code, message ), cause, parameters ); 
     23    } 
    2524 
    26         public WebException( final Enum<? extends Code> code, final String string) { 
    27                 super(code, string); 
    28         } 
     25    public WebException( final Throwable cause ) 
     26    { 
     27        super( cause ); 
     28    } 
    2929 
    30         public static enum WebCode implements Code  
     30    public WebException( final Enum<? extends Code> code, final String string ) 
    3131    { 
    32                 UNKNOWN,  
    33                 PERSISTENCE,  
    34                 SERVICE_PROBLEM, 
    35                 PLATEFORME_ID_NOT_FOUND, 
    36                 IO_EXCEPTION_ERROR_TO_GET_OUTPUTSTREAM, 
    37                 ERROR_UNSUPPORTED_UTF8_ENCODING, 
    38                 ERROR_NO_REQUEST_HANDLING_METHOD, 
    39                 ERROR_NUMBER_OF_PARAM_TYPES_NOT_EQUAL_TO_PARAM_ANNOTATIONS, 
     32        super( code, string ); 
     33    } 
     34 
     35    public static enum WebCode 
     36            implements Code 
     37    { 
     38        UNKNOWN, 
     39        PERSISTENCE, 
     40        SERVICE_PROBLEM, 
     41        PLATEFORME_ID_NOT_FOUND, 
     42        IO_EXCEPTION_ERROR_TO_GET_OUTPUTSTREAM, 
     43        ERROR_UNSUPPORTED_UTF8_ENCODING, 
     44        ERROR_NO_REQUEST_HANDLING_METHOD, 
     45        ERROR_NUMBER_OF_PARAM_TYPES_NOT_EQUAL_TO_PARAM_ANNOTATIONS, 
     46        FILE_NOT_FOUND; 
    4047    } 
    4148} 
  • ether_megapoli/trunk/common/implementation/com/medias/Context.java

    r89 r129  
    11package com.medias; 
    22 
     3import org.apache.struts.Globals; 
     4import org.jetbrains.annotations.NotNull; 
     5 
    36import javax.servlet.http.HttpServletRequest; 
    4  
     7import javax.servlet.http.HttpSession; 
    58import java.util.Calendar; 
    69import java.util.Date; 
     
    1316 * Date: 27 janv. 2005 
    1417 * Time: 15:45:10 
    15  * 
     18 * <p/> 
    1619 * Permet d'accéder au contexte courant pour chaque page de l'appli 
    1720 */ 
     
    2326 
    2427 
    25         /** 
    26          * Permet d'obtenir la langue courante. 
    27          * @param request : la requête courante 
    28          * @return la langue courante. 
    29          */ 
    30         public static String getLangue(HttpServletRequest request) { 
    31                 String lang=(String) request.getSession().getAttribute("lang"); 
    32                 if (lang == null) { 
    33                     // Pour initialiser la langue en Anglais 
    34                     lang=request.getLocale().getLanguage(); 
    35                      
    36                     // Pour initialiser la langue en Français 
    37                     //lang = Locale.FRENCH.getLanguage(); 
    38                 } 
    39                 return lang; 
    40         } 
     28    /** 
     29     * Permet d'obtenir la langue courante. 
     30     * 
     31     * @param request : la requête courante 
     32     * @return la langue courante. 
     33     */ 
     34    public static String getLangue( HttpServletRequest request ) 
     35    { 
     36        String lang = (String) request.getSession().getAttribute( "lang" ); 
     37        if( lang == null ) 
     38        { 
     39            // Pour initialiser la langue en Anglais 
     40            lang = request.getLocale().getLanguage(); 
     41 
     42            // Pour initialiser la langue en Français 
     43            //lang = Locale.FRENCH.getLanguage(); 
     44        } 
     45        return lang; 
     46    } 
     47 
     48    /** 
     49     * Return the current Locale 
     50     * 
     51     * @param request 
     52     * @return 
     53     */ 
     54    public static Locale getLocale( @NotNull final HttpServletRequest request ) 
     55    { 
     56        final HttpSession session = request.getSession( true ); 
     57        Locale locale = (Locale) session.getAttribute( Globals.LOCALE_KEY ); 
     58        if( locale == null ) 
     59            locale = request.getLocale(); 
     60 
     61        if( request.getParameter( "locale" ) != null ) 
     62            locale = new Locale( request.getParameter( "locale" ) ); 
     63 
     64        return locale; 
     65    } 
     66 
     67    public static String getLastModified( HttpServletRequest request, 
     68                                          javax.servlet.ServletContext application ) 
     69    { 
     70        Date d = new java.util.Date( new java.io.File( 
     71                application.getRealPath( request.getServletPath() ) ).lastModified() ); 
     72        return d.toString(); 
     73    } 
     74 
     75    /** 
     76     * Permet d'obtenir la date courante, sous la forme YYYYMMDD 
     77     * 
     78     * @return la date courante 
     79     */ 
     80    public static String getSimpleDate() 
     81    { 
     82        java.util.Calendar c = java.util.Calendar.getInstance(); 
     83        String t = "0" + ( c.get( Calendar.MONTH ) + 1 ); 
     84        return c.get( Calendar.YEAR ) + t.substring( t.length() - 2 ) + c.get( Calendar.DAY_OF_MONTH ); 
     85    } 
     86 
     87    /** 
     88     * Désigne l'adresse com.medias.mail du webmaster 
     89     */ 
     90    public static String getWebmaster( HttpServletRequest request ) 
     91    { 
     92        String webmaster = (String) request.getSession().getServletContext().getAttribute( "APP_WEBMASTER" ); 
     93        return webmaster; 
     94    } 
     95 
     96    /** 
     97     * Permet de définir le nom de la racine à partir de laquelle les paths sont calculés. 
     98     * 
     99     * @return le nom de la racine. 
     100     */ 
     101    public static String getWebroot( HttpServletRequest request ) 
     102    { 
     103        String path = request.getSession().getServletContext().getRealPath( "" ); 
     104        return path.substring( path.lastIndexOf( "/" ) + 1 ); 
     105    } 
     106 
     107    /** 
     108     * Permet d'obtenir l'uri de la page courante. 
     109     * 
     110     * @param request : la requête courante 
     111     * @return l'uri de la page courante 
     112     */ 
     113    public static String getPageURI( HttpServletRequest request ) 
     114    { 
     115        return request.getRequestURI().substring( request.getRequestURI().indexOf( '/' ) + 1 ); 
     116    } 
     117 
     118    /** 
     119     * Permet d'obtenir l'URI relative de la page courante. 
     120     * Cette méthode est en particulier utilisée pour retomber sur la page courante lorsqu'on 
     121     * change de langue. 
     122     * 
     123     * @param request 
     124     * @return 
     125     */ 
     126    public static String getRelativePageURI( HttpServletRequest request ) 
     127    { 
     128        String pageUri = getPageURI( request ); 
     129        if( pageUri.indexOf( '/' ) != -1 ) 
     130        { 
     131            pageUri = pageUri.substring( pageUri.indexOf( '/' ) ); 
     132        } 
     133        return pageUri; 
     134    } 
    41135 
    42136 
    43         public static String getLastModified(HttpServletRequest request, 
    44                                              javax.servlet.ServletContext application) { 
    45                 Date d =new java.util.Date(new java.io.File( 
    46                     application.getRealPath(request.getServletPath())).lastModified()); 
    47                 return d.toString(); 
    48         } 
     137    public static String getRelativePath( HttpServletRequest request ) 
     138    { 
     139        String uri = getPageURI( request ); 
     140        if( uri.indexOf( '/' ) != -1 ) 
     141        { 
     142            uri = uri.substring( uri.indexOf( '/' ), uri.lastIndexOf( '/' ) ); 
     143        } 
     144        return uri; 
     145    } 
    49146 
    50         /** 
    51          * Permet d'obtenir la date courante, sous la forme YYYYMMDD 
    52          * @return la date courante 
    53          */ 
    54         public static String getSimpleDate() { 
    55                 java.util.Calendar c = java.util.Calendar.getInstance(); 
    56                 String t= "0"+(c.get(Calendar.MONTH)+1); 
    57                 return c.get(Calendar.YEAR)+t.substring(t.length()-2)+c.get(Calendar.DAY_OF_MONTH); 
    58         } 
     147    public static String getAnInternationalizeString( String bundle, String key ) 
     148    { 
     149        ResourceBundle resourceBundle = null; 
     150        String lang = Constantes.lang; 
     151        String message = null; 
     152        if( lang.trim().equals( "en" ) ) 
     153        { 
     154            resourceBundle = ResourceBundle.getBundle( bundle, Locale.ENGLISH ); 
     155            message = resourceBundle.getString( key ); 
     156        } 
     157        else 
     158        { 
     159            resourceBundle = ResourceBundle.getBundle( bundle, Locale.FRENCH ); 
     160            message = resourceBundle.getString( key ); 
     161        } 
     162        if( message == null ) 
     163        { 
     164            resourceBundle = ResourceBundle.getBundle( bundle, Locale.FRENCH ); 
     165            message = resourceBundle.getString( key ); 
     166        } 
     167        return message; 
     168    } 
    59169 
    60         /** 
    61          * Désigne l'adresse com.medias.mail du webmaster 
    62          */ 
    63         public static String getWebmaster(HttpServletRequest request) { 
    64                 String webmaster = (String)request.getSession().getServletContext().getAttribute("APP_WEBMASTER"); 
    65                 return webmaster; 
    66         } 
    67          
    68         /** 
    69          * Permet de définir le nom de la racine à partir de laquelle les paths sont calculés. 
    70          * @return le nom de la racine. 
    71          */ 
    72         public static String getWebroot(HttpServletRequest request) { 
    73                 String path = request.getSession().getServletContext().getRealPath(""); 
    74                 return path.substring(path.lastIndexOf("/")+1); 
    75         } 
    76  
    77         /** 
    78          * Permet d'obtenir l'uri de la page courante. 
    79          * @param request : la requête courante 
    80          * @return l'uri de la page courante 
    81          */ 
    82   public static String getPageURI(HttpServletRequest request) { 
    83           return request.getRequestURI().substring(request.getRequestURI().indexOf('/')+1); 
    84   } 
    85  
    86         /** 
    87          * Permet d'obtenir l'URI relative de la page courante. 
    88          * Cette méthode est en particulier utilisée pour retomber sur la page courante lorsqu'on 
    89          * change de langue. 
    90          * @param request 
    91          * @return 
    92          */ 
    93         public static String getRelativePageURI(HttpServletRequest request) { 
    94                 String pageUri = getPageURI(request); 
    95                 if (pageUri.indexOf('/') != -1) { 
    96                     pageUri = pageUri.substring(pageUri.indexOf('/')); 
    97         } 
    98                 return pageUri; 
    99         } 
    100  
    101  
    102         public static String getRelativePath(HttpServletRequest request) { 
    103                 String uri = getPageURI(request); 
    104                 if (uri.indexOf('/') != -1) { 
    105                     uri = uri.substring(uri.indexOf('/'),uri.lastIndexOf('/')); 
    106                 } 
    107                 return uri; 
    108         } 
    109          
    110         public static String getAnInternationalizeString(String bundle, String key) { 
    111                 ResourceBundle resourceBundle = null; 
    112                 String lang = Constantes.lang; 
    113                 String message = null; 
    114                 if (lang.trim().equals("en")) { 
    115                         resourceBundle = ResourceBundle.getBundle(bundle, Locale.ENGLISH); 
    116                         message = resourceBundle.getString(key); 
    117                 } else { 
    118                         resourceBundle = ResourceBundle.getBundle(bundle, Locale.FRENCH); 
    119                         message = resourceBundle.getString(key); 
    120                 } 
    121                 if (message == null) { 
    122                         resourceBundle = ResourceBundle.getBundle(bundle, Locale.FRENCH); 
    123                         message = resourceBundle.getString(key); 
    124                 } 
    125                 return message; 
    126         } 
    127          
    128         public static String getString(String bundle, String key) { 
    129                 ResourceBundle resourceBundle = ResourceBundle.getBundle(bundle); 
    130                 String message = resourceBundle.getString(key); 
    131                 return message; 
    132         } 
     170    public static String getString( String bundle, String key ) 
     171    { 
     172        ResourceBundle resourceBundle = ResourceBundle.getBundle( bundle ); 
     173        String message = resourceBundle.getString( key ); 
     174        return message; 
     175    } 
    133176} 
  • ether_megapoli/trunk/common/test/com/ether/TestHelper.java

    r89 r129  
    1313public abstract class TestHelper<BEAN> 
    1414{ 
    15     protected TestHelper(final String beanContextName, final String beanName, final String[] otherContextNames) { 
    16         _beanContextName = beanContextName; 
    17         _beanName = beanName; 
    18         _otherContextNames = otherContextNames; 
     15    protected TestHelper( final String beanContextName, final String beanName, final String[] otherContextNames ) 
     16    { 
     17        _beanContextName = beanContextName; 
     18        _beanName = beanName; 
     19        _otherContextNames = otherContextNames; 
    1920    } 
    2021 
    21     protected abstract void beforeBeanTest() throws Exception; 
     22    protected abstract void beforeBeanTest() 
     23            throws Exception; 
    2224 
    23     protected abstract void afterBeanTest() throws Exception; 
     25    protected abstract void afterBeanTest() 
     26            throws Exception; 
    2427 
    2528    @Before 
    26     public final void beforeTest() throws Exception 
     29    public final void beforeTest() 
     30            throws Exception 
    2731    { 
    28         Assert.assertNotNull(getApplicationContext()); 
    29         Assert.assertNotNull(getBean()); 
    30         beforeBeanTest(); 
     32        Assert.assertNotNull( getApplicationContext() ); 
     33        Assert.assertNotNull( getBean() ); 
     34        beforeBeanTest(); 
    3135    } 
    3236 
    3337    @After 
    34     public final void afterTest() throws Exception 
     38    public final void afterTest() 
     39            throws Exception 
    3540    { 
    36         afterBeanTest(); 
    37         _bean = null; 
     41        afterBeanTest(); 
     42        _bean = null; 
    3843    } 
    39      
     44 
    4045    @AfterClass 
    41     public static void afterAllTest() throws Exception 
     46    public static void afterAllTest() 
     47            throws Exception 
    4248    { 
    43         try 
    44         { 
    45             if (_applicationContext != null) _applicationContext.close(); 
    46         } 
    47         finally 
    48         { 
    49             _applicationContext = null; 
    50         } 
     49        try 
     50        { 
     51            if( _applicationContext != null ) _applicationContext.close(); 
     52        } 
     53        finally 
     54        { 
     55            _applicationContext = null; 
     56        } 
    5157    } 
    5258 
    5359    /** 
    5460     * Builds context names from 2 context name arrays. 
    55      *  
    56      * @param baseContextNames : the base context names. 
     61     * 
     62     * @param baseContextNames  : the base context names. 
    5763     * @param otherContextNames : the other context names. 
    5864     * @return a context name array. 
    5965     */ 
    6066    protected static String[] buildContextNames( 
    61             final String[] baseContextNames, final String... otherContextNames) 
     67            final String[] baseContextNames, final String... otherContextNames ) 
    6268    { 
    63         int contextNameSize = baseContextNames == null ? 0 : baseContextNames.length; 
    64         contextNameSize += otherContextNames == null ? 0 : otherContextNames.length; 
     69        int contextNameSize = baseContextNames == null ? 0 : baseContextNames.length; 
     70        contextNameSize += otherContextNames == null ? 0 : otherContextNames.length; 
    6571 
    66         final String[] contextNames = new String[contextNameSize]; 
     72        final String[] contextNames = new String[contextNameSize]; 
    6773 
    68         if (baseContextNames != null) 
    69             System.arraycopy(baseContextNames, 0, contextNames, 0, baseContextNames.length); 
     74        if( baseContextNames != null ) 
     75            System.arraycopy( baseContextNames, 0, contextNames, 0, baseContextNames.length ); 
    7076 
    71         if (otherContextNames != null) 
    72         { 
    73             if (baseContextNames != null) 
    74                 System.arraycopy(otherContextNames, 0, contextNames, baseContextNames.length, otherContextNames.length); 
    75             else 
    76                 System.arraycopy(otherContextNames, 0, contextNames, 0, otherContextNames.length); 
    77         } 
     77        if( otherContextNames != null ) 
     78        { 
     79            if( baseContextNames != null ) 
     80                System.arraycopy( otherContextNames, 0, contextNames, baseContextNames.length, otherContextNames.length ); 
     81            else 
     82                System.arraycopy( otherContextNames, 0, contextNames, 0, otherContextNames.length ); 
     83        } 
    7884 
    79         return contextNames; 
     85        return contextNames; 
    8086    } 
    8187 
    8288    protected final ApplicationContext getApplicationContext() 
    8389    { 
    84         if (_applicationContext == null) 
    85         { 
    86             final String[] contextNames; 
     90        if( _applicationContext == null ) 
     91        { 
     92            final String[] contextNames; 
    8793 
    88             if (_otherContextNames != null) 
    89             { 
    90                 if (_beanContextName != null) 
    91                     contextNames = buildContextNames(_otherContextNames, _beanContextName); 
    92                 else 
    93                     contextNames = buildContextNames(_otherContextNames); 
    94             } 
    95             else 
    96             { 
    97                 contextNames = new String[] { _beanContextName }; 
    98             } 
     94            if( _otherContextNames != null ) 
     95            { 
     96                if( _beanContextName != null ) 
     97                    contextNames = buildContextNames( _otherContextNames, _beanContextName ); 
     98                else 
     99                    contextNames = buildContextNames( _otherContextNames ); 
     100            } 
     101            else 
     102            { 
     103                contextNames = new String[]{_beanContextName}; 
     104            } 
    99105 
    100             _applicationContext = new ClassPathXmlApplicationContext(contextNames); 
    101         } 
     106            _applicationContext = new ClassPathXmlApplicationContext( contextNames ); 
     107        } 
    102108 
    103         return _applicationContext; 
     109        return _applicationContext; 
    104110    } 
    105111 
    106     @SuppressWarnings({ "unchecked" }) 
     112    @SuppressWarnings({"unchecked"}) 
    107113    protected final BEAN getBean() 
    108114    { 
    109         if (_bean == null) 
    110             _bean = (BEAN) getApplicationContext().getBean(_beanName); 
     115        if( _bean == null ) 
     116            _bean = (BEAN) getApplicationContext().getBean( _beanName ); 
    111117 
    112         return _bean; 
     118        return _bean; 
    113119    } 
    114120 
    115121    private static final Log LOGGER = LogFactory.getLog( TestHelper.class ); 
    116      
     122 
    117123    private static AbstractApplicationContext _applicationContext; 
    118124 
  • ether_megapoli/trunk/domain/interface/com/ether/Data.java

    r89 r129  
    11package com.ether; 
    22 
     3import org.jetbrains.annotations.NotNull; 
     4 
    35import java.util.Date; 
    4  
    5 import org.jetbrains.annotations.NotNull; 
    66 
    77/** 
     
    99 * @date may 2011 
    1010 */ 
    11 public class Data { 
     11// TODO : see if necessary, otherwise remove this class 
     12public class Data 
     13{ 
    1214 
    13         @NotNull 
    14         public double getValue() { 
    15                 return value; 
    16         } 
    17          
    18         public void setValue(@NotNull final double value) { 
    19                 this.value = value; 
    20         } 
    21          
    22         @NotNull 
    23         public Date getDate() { 
    24                 return date; 
    25         } 
    26          
    27         public void setDate(@NotNull final Date date) { 
    28                 this.date = date; 
    29         } 
    30          
    31         @NotNull 
    32         private double value;           // corresponding to valeurVal from class Valeur 
    33         @NotNull 
    34         private Date date;                      // corresponding to mesureDate from class Mesure 
     15    public double getValue() 
     16    { 
     17        return _value; 
     18    } 
     19 
     20    public void setValue( final double value ) 
     21    { 
     22        _value = value; 
     23    } 
     24 
     25    @NotNull 
     26    public Date getDate() 
     27    { 
     28        return _date; 
     29    } 
     30 
     31    public void setDate( @NotNull final Date date ) 
     32    { 
     33        _date = date; 
     34    } 
     35 
     36    private double _value;         // corresponding to valeurVal from class Valeur 
     37    @NotNull 
     38    private Date _date;            // corresponding to mesureDate from class Mesure 
    3539} 
  • ether_megapoli/trunk/persistence/implementation/com/ether/dao/ValueDAOImpl.java

    r89 r129  
    11package com.ether.dao; 
    22 
    3 import java.util.Date; 
    4 import java.util.List; 
    5  
     3import com.ether.Data; 
     4import com.ether.Pair; 
     5import com.ether.PersistenceException; 
    66import com.medias.database.objects.Valeur; 
    77import org.hibernate.criterion.DetachedCriteria; 
     
    1212import org.jetbrains.annotations.Nullable; 
    1313 
    14 import com.ether.Data; 
    15 import com.ether.PersistenceException; 
     14import java.util.ArrayList; 
     15import java.util.Date; 
     16import java.util.List; 
    1617 
    1718/** 
     
    1920 * @date 07 apr 2011 
    2021 */ 
    21 public class ValueDAOImpl extends DomainAccessObjectImpl<Valeur, Integer> 
    22         implements ValueDAO 
     22public class ValueDAOImpl 
     23        extends DomainAccessObjectImpl<Valeur, Integer> 
     24        implements ValueDAO 
    2325{ 
    24     protected ValueDAOImpl() { 
    25         super(Valeur.class); 
     26    protected ValueDAOImpl() 
     27    { 
     28        super( Valeur.class ); 
    2629    } 
    2730 
    28         @Nullable 
    29         public List<Data> getValuesByPlateformByParameterByPeriod(@NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd)  
    30                 throws PersistenceException 
    31         { 
    32                 final DetachedCriteria criteria = DetachedCriteria.forClass(Valeur.class, "value") 
    33                         .add(Restrictions.eq("value.parametre.id", parameterId)) 
    34                         .createCriteria("mesure", "measure") 
    35                         .add(Restrictions.eq("measure.plateforme.id", plateformId)); 
     31    @Nullable 
     32    public List<Pair<Double, Date>> getValuesByPlateformByParameterByPeriod( @NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd ) 
     33            throws PersistenceException 
     34    { 
     35        final DetachedCriteria criteria = DetachedCriteria.forClass( Valeur.class, "value" ) 
     36                .add( Restrictions.eq( "value.parametre.id", parameterId ) ) 
     37                .createCriteria( "mesure", "measure" ) 
     38                .add( Restrictions.eq( "measure.plateforme.id", plateformId ) ); 
    3639 
    37                 if(null != dateBegin) 
    38                         criteria.add(Restrictions.ge("measure.mesureDate", dateBegin)); 
    39                 if(null != dateEnd) 
    40                         criteria.add(Restrictions.le("measure.mesureDate", dateEnd)); 
    41                  
    42                 criteria.setProjection( Projections.distinct( Projections.projectionList() 
    43                                         .add( Projections.property( "value.valeurVal" ) ) 
    44                                         .add( Projections.property( "measure.mesureDate" ) ) ) ); 
     40        if( null != dateBegin ) 
     41            criteria.add( Restrictions.ge( "measure.mesureDate", dateBegin ) ); 
     42        if( null != dateEnd ) 
     43            criteria.add( Restrictions.le( "measure.mesureDate", dateEnd ) ); 
    4544 
    46         criteria.addOrder( Order.asc("measure.mesureDate") ); 
     45        criteria.setProjection( Projections.distinct( Projections.projectionList() 
     46                .add( Projections.property( "value.valeurVal" ) ) 
     47                .add( Projections.property( "measure.mesureDate" ) ) ) ); 
    4748 
    48                 return selectAllByCriteria(Data.class, criteria); 
    49         } 
     49        criteria.addOrder( Order.asc( "measure.mesureDate" ) ); 
     50 
     51        final List<Object[]> objects = selectAllByCriteria( Object[].class, criteria ); 
     52        final List<Pair<Double, Date>> result = new ArrayList<Pair<Double, Date>>(); 
     53        for( final Object[] value : objects ) 
     54        { 
     55            final Pair<Double, Date> item = new Pair<Double, Date>(); 
     56            item.setFirstValue( (Double) value[0] ); 
     57            item.setSecondValue( (Date) value[1] ); 
     58            result.add( item ); 
     59        } 
     60 
     61        return result; 
     62    } 
    5063} 
  • ether_megapoli/trunk/persistence/implementation/hibernate-domain.cfg.xml

    r89 r129  
    66<hibernate-configuration> 
    77        <session-factory> 
    8         <mapping resource="com/medias/objects/Adresse.hbm.xml"/> 
    9         <mapping resource="com/medias/objects/Bilan.hbm.xml"/> 
    10         <mapping resource="com/medias/objects/Capteur.hbm.xml"/> 
    11         <mapping resource="com/medias/objects/Categorie.hbm.xml"/> 
    12         <mapping resource="com/medias/objects/CategorieParam.hbm.xml"/> 
    13         <mapping resource="com/medias/objects/Commentaire.hbm.xml"/> 
    14         <mapping resource="com/medias/objects/DeltaMesure.hbm.xml"/> 
    15         <mapping resource="com/medias/objects/Fabriquant.hbm.xml"/> 
    16         <mapping resource="com/medias/objects/Fichier.hbm.xml"/> 
    17         <mapping resource="com/medias/objects/Flag.hbm.xml"/> 
    18         <mapping resource="com/medias/objects/Jeu.hbm.xml"/> 
    19         <mapping resource="com/medias/objects/Langue.hbm.xml"/> 
    20         <mapping resource="com/medias/objects/Localisation.hbm.xml"/> 
    21         <mapping resource="com/medias/objects/Mesure.hbm.xml"/> 
    22         <mapping resource="com/medias/objects/Organisme.hbm.xml"/> 
    23         <mapping resource="com/medias/objects/Parametre.hbm.xml"/> 
    24         <mapping resource="com/medias/objects/Personne.hbm.xml"/> 
    25         <mapping resource="com/medias/objects/Plateforme.hbm.xml"/> 
    26         <mapping resource="com/medias/objects/RequeteNbvalsJeu.hbm.xml"/> 
    27         <mapping resource="com/medias/objects/RequetePlatLoc.hbm.xml"/> 
    28         <mapping resource="com/medias/objects/Sequence.hbm.xml"/> 
    29         <mapping resource="com/medias/objects/TypeCapteur.hbm.xml"/> 
    30         <mapping resource="com/medias/objects/TypePlateforme.hbm.xml"/> 
    31         <mapping resource="com/medias/objects/Unite.hbm.xml"/> 
    32         <mapping resource="com/medias/objects/Valeur.hbm.xml"/> 
    33         <mapping resource="com/medias/objects/Zone.hbm.xml"/> 
     8        <!--<mapping resource="com/medias/objects/Adresse.hbm.xml"/>--> 
     9        <!--<mapping resource="com/medias/objects/Bilan.hbm.xml"/>--> 
     10        <!--<mapping resource="com/medias/objects/Capteur.hbm.xml"/>--> 
     11        <!--<mapping resource="com/medias/objects/Categorie.hbm.xml"/>--> 
     12        <!--<mapping resource="com/medias/objects/CategorieParam.hbm.xml"/>--> 
     13        <!--<mapping resource="com/medias/objects/Commentaire.hbm.xml"/>--> 
     14        <!--<mapping resource="com/medias/objects/DeltaMesure.hbm.xml"/>--> 
     15        <!--<mapping resource="com/medias/objects/Fabriquant.hbm.xml"/>--> 
     16        <!--<mapping resource="com/medias/objects/Fichier.hbm.xml"/>--> 
     17        <!--<mapping resource="com/medias/objects/Flag.hbm.xml"/>--> 
     18        <!--<mapping resource="com/medias/objects/Jeu.hbm.xml"/>--> 
     19        <!--<mapping resource="com/medias/objects/Langue.hbm.xml"/>--> 
     20        <!--<mapping resource="com/medias/objects/Localisation.hbm.xml"/>--> 
     21        <!--<mapping resource="com/medias/objects/Mesure.hbm.xml"/>--> 
     22        <!--<mapping resource="com/medias/objects/Organisme.hbm.xml"/>--> 
     23        <!--<mapping resource="com/medias/objects/Parametre.hbm.xml"/>--> 
     24        <!--<mapping resource="com/medias/objects/Personne.hbm.xml"/>--> 
     25        <!--<mapping resource="com/medias/objects/Plateforme.hbm.xml"/>--> 
     26        <!--<mapping resource="com/medias/objects/RequeteNbvalsJeu.hbm.xml"/>--> 
     27        <!--<mapping resource="com/medias/objects/RequetePlatLoc.hbm.xml"/>--> 
     28        <!--<mapping resource="com/medias/objects/Sequence.hbm.xml"/>--> 
     29        <!--<mapping resource="com/medias/objects/TypeCapteur.hbm.xml"/>--> 
     30        <!--<mapping resource="com/medias/objects/TypePlateforme.hbm.xml"/>--> 
     31        <!--<mapping resource="com/medias/objects/Unite.hbm.xml"/>--> 
     32        <!--<mapping resource="com/medias/objects/Valeur.hbm.xml"/>--> 
     33        <!--<mapping resource="com/medias/objects/Zone.hbm.xml"/>--> 
    3434        </session-factory> 
    3535</hibernate-configuration> 
  • ether_megapoli/trunk/persistence/interface/com/ether/dao/ValueDAO.java

    r89 r129  
    44import java.util.List; 
    55 
     6import com.ether.Pair; 
    67import com.medias.database.objects.Valeur; 
    78import org.jetbrains.annotations.NotNull; 
     
    1920{ 
    2021        @Nullable 
    21         List<Data> getValuesByPlateformByParameterByPeriod(@NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd) throws PersistenceException; 
     22        List<Pair<Double, Date>> getValuesByPlateformByParameterByPeriod(@NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd) throws PersistenceException; 
    2223} 
  • ether_megapoli/trunk/service/implementation/com/ether/EtherPlotServiceImpl.java

    r119 r129  
    11package com.ether; 
    22 
    3 import java.util.Date; 
    4 import java.util.List; 
    5  
    6 import com.medias.database.objects.Parametre; 
    7 import com.medias.database.objects.Plateforme; 
     3import gov.noaa.pmel.sgt.JPane; 
     4import gov.noaa.pmel.sgt.dm.SGTData; 
     5import gov.noaa.pmel.sgt.swing.JPlotLayout; 
    86import org.apache.commons.logging.Log; 
    97import org.apache.commons.logging.LogFactory; 
    108import org.jetbrains.annotations.NotNull; 
    119import org.jetbrains.annotations.Nullable; 
    12 import org.springframework.beans.factory.annotation.Required; 
    13 import org.springframework.transaction.annotation.Transactional; 
    1410 
    15 import com.ether.dao.ParameterDAO; 
    16 import com.ether.dao.PlateformDAO; 
    17 import com.ether.dao.ValueDAO; 
     11import javax.swing.*; 
     12import java.awt.*; 
     13import java.awt.image.BufferedImage; 
     14import java.util.Calendar; 
     15import java.util.Locale; 
     16import java.util.ResourceBundle; 
    1817 
    1918/** 
    2019 * @author vmipsl 
    21  * @date 07 mar 2011  
     20 * @date 05 july 2011 
    2221 */ 
    23 public class EtherServiceImpl implements EtherService 
     22public class EtherPlotServiceImpl 
     23        implements EtherPlotService 
    2424{ 
    25         @Nullable 
    26         @Transactional(readOnly = true) 
    27         public List<Parametre> getParametersByPlateformId(@NotNull final Integer plateformId) 
    28                 throws ServiceException 
    29         { 
    30                 try 
    31                 { 
    32                     return _parameterDAO.getParametersByPlateformId(plateformId); 
    33                 } 
    34                 catch (PersistenceException e) 
    35                 { 
    36                     throw new ServiceException(ServiceException.ServiceCode.PARAMETER_NOT_FOUND, e); 
    37                 } 
    38         } 
     25    /** 
     26     * Create the main JPane with the 3 jPanes 
     27     * 
     28     * @param megapoliPlot 
     29     * @param locale 
     30     * @return 
     31     * @throws WebException 
     32     */ 
     33    @NotNull 
     34    public BufferedImage createJPane( @NotNull final MegapoliPlot megapoliPlot, @Nullable final Locale locale ) 
     35    { 
     36        JPane jPane = new JPane( "Main jPane", new Dimension( MAIN_WIDTH, MAIN_HEIGHT ) ); 
     37        if( null != megapoliPlot.getWidth() && null != megapoliPlot.getHeight() ) 
     38            jPane = new JPane( "Main jPane", new Dimension( megapoliPlot.getWidth(), megapoliPlot.getHeight() ) ); 
    3939 
    40         @Nullable 
    41         @Transactional(readOnly = true) 
    42         public List<Plateforme> getAllPlateforms() 
    43                 throws ServiceException 
    44         { 
    45                 try 
    46                 { 
    47                     return _plateformDAO.getAllPlateforms(); 
    48                 } 
    49                 catch (PersistenceException e) 
    50                 { 
    51                     throw new ServiceException(ServiceException.ServiceCode.PLATEFORM_NOT_FOUND, e); 
    52                 } 
    53         } 
    54      
    55         @Nullable 
    56         @Transactional(readOnly = true) 
    57         public List<Data> getValuesByPlateformByParameterByPeriod( 
    58                         @NotNull final Integer plateformId, 
    59                         @NotNull final Integer parameterId,  
    60                         @Nullable final Date dateBegin,  
    61                         @Nullable final Date dateEnd)  
    62                 throws ServiceException 
    63         { 
    64                 try 
    65                 { 
    66                     return _valueDAO.getValuesByPlateformByParameterByPeriod(plateformId, parameterId, dateBegin, dateEnd); 
    67                 } 
    68                 catch (PersistenceException e) 
    69                 { 
    70                     throw new ServiceException(ServiceException.ServiceCode.VALUE_NOT_FOUND, e); 
    71                 } 
    72         } 
     40        jPane.setLayout( new BorderLayout() ); 
     41        jPane.setBackground( Color.white ); 
     42        jPane.setBorder( BorderFactory.createLineBorder( Color.black, 2 ) ); 
     43        jPane.setOpaque( true ); 
    7344 
    74     @Nullable 
    75         @Transactional(readOnly = true) 
    76     public Plateforme getPlateformById( @Nullable final Integer plateformId ) 
    77             throws ServiceException 
    78     { 
    79         if(null == plateformId) 
    80             return null; 
    81         try 
    82         { 
    83             return _plateformDAO.getPlateformById( plateformId ); 
    84         } 
    85         catch (PersistenceException e) 
    86         { 
    87             throw new ServiceException(ServiceException.ServiceCode.PLATEFORM_NOT_FOUND, e); 
    88         } 
     45        final JPane jPaneTop = createTopPane( megapoliPlot ); 
     46        jPane.add( jPaneTop, BorderLayout.NORTH ); 
     47//        final JPane jPaneCenter = createCenterPane( megapoliPlot.getData() ); 
     48        final JPane jPaneCenter = createTopPane( megapoliPlot ); 
     49        jPane.add( jPaneCenter, BorderLayout.CENTER ); 
     50        final JPane jPaneBottom = createBottomPane( megapoliPlot.getData().getYArray().length, locale ); 
     51        jPane.add( jPaneBottom, BorderLayout.SOUTH ); 
     52 
     53        final JPanelToImageManager jPanelToImageManager = new JPanelToImageManager( jPane ); 
     54 
     55        return jPanelToImageManager.saveAsImage(); 
    8956    } 
    9057 
    91     @Nullable 
    92     @Transactional(readOnly = true) 
    93     public Parametre getParameterById( @Nullable final Integer parameterId ) 
    94             throws ServiceException 
     58    /** 
     59     * Create the top JPane with the logos and title 
     60     * 
     61     * @param megapoliPlot@return 
     62     */ 
     63    @NotNull 
     64    public JPane createTopPane( @Nullable final MegapoliPlot megapoliPlot ) 
    9565    { 
    96         if(null == parameterId) 
    97             return null; 
    98         try 
    99         { 
    100             return _parameterDAO.getParameterById( parameterId ); 
    101         } 
    102         catch (PersistenceException e) 
    103         { 
    104             throw new ServiceException(ServiceException.ServiceCode.PARAMETER_NOT_FOUND, e); 
    105         } 
     66        // Logos 
     67        final ImageIcon logoMegapoli = new ImageIcon( megapoliPlot.getLogoMegapoli() ); 
     68        final JLabel jLabelLogoMegapoli = new JLabel( logoMegapoli ); 
     69 
     70        final ImageIcon logoEther = new ImageIcon( megapoliPlot.getLogoEther() ); 
     71        final JLabel jLabelLogoEther = new JLabel( logoEther ); 
     72 
     73        // Max height 
     74        final Integer maxHeights = Math.max( logoMegapoli.getIconHeight(), logoEther.getIconHeight() ); 
     75 
     76        // jPane 
     77        final JPane jPaneTop = new JPane( "Top jPane", new Dimension( 0, maxHeights ) ); 
     78        jPaneTop.setLayout( new BorderLayout() ); 
     79 
     80        jPaneTop.add( jLabelLogoMegapoli, BorderLayout.LINE_START ); 
     81        jPaneTop.add( jLabelLogoEther, BorderLayout.LINE_END ); 
     82 
     83 
     84        // Title 
     85        final JLabel jLabelTitle = new JLabel( megapoliPlot.getTitle(), JLabel.CENTER ); 
     86        final Font police = new Font( "Arial", Font.BOLD, FONT_SIZE ); 
     87        jLabelTitle.setFont( police ); 
     88        jPaneTop.add( jLabelTitle, BorderLayout.CENTER ); 
     89 
     90        return jPaneTop; 
    10691    } 
    10792 
     93    /** 
     94     * Create the center JPane with the graph 
     95     * 
     96     * @param data 
     97     * @return 
     98     */ 
     99    @NotNull 
     100    public JPane createCenterPane( @NotNull final SGTData data ) 
     101    { 
     102        final JPane jPaneCenter = new JPane( "Center jPane", new Dimension( 0, 1000 ) ); 
     103        jPaneCenter.setLayout( new BorderLayout() ); 
    108104 
    109     @Required 
    110     public void setPlateformDAO(final PlateformDAO plateformDAO) 
    111     { 
    112         _plateformDAO = plateformDAO; 
     105        // Graph 
     106        final JPlotLayout jPlotLayout = new JPlotLayout( false, true, false, "Trajectory data", null, false ); 
     107        jPlotLayout.setTitles( "title1", "title2", "title3" ); 
     108        jPlotLayout.addData( data, data.getTitle() ); 
     109//        jPlotLayout.setSize( 800, 800 ); 
     110        jPlotLayout.setVisible( true ); 
     111 
     112        jPlotLayout.addNotify(); 
     113        jPlotLayout.validate(); 
     114 
     115        // TODO : remove this change to bufferedImage to insert directly the jPlotLayout !!!! 
     116        final BufferedImage bufferedImage = new BufferedImage( jPlotLayout.getWidth(), jPlotLayout.getHeight(), BufferedImage.TYPE_INT_RGB ); 
     117        final Graphics2D graphics2D = bufferedImage.createGraphics(); 
     118        jPlotLayout.draw( graphics2D ); 
     119 
     120        final ImageIcon imageIcon = new ImageIcon( bufferedImage ); 
     121        final JLabel jLabel = new JLabel( imageIcon ); 
     122        jLabel.setBorder( BorderFactory.createLineBorder( Color.blue, 2 ) ); 
     123        jPaneCenter.add( jLabel, BorderLayout.CENTER ); 
     124 
     125//        final JLabel jj = new JLabel("pif"); 
     126//        jj.setBorder( BorderFactory.createLineBorder( Color.red, 2 ) ); 
     127//        jPaneCenter.add( jj, BorderLayout.CENTER ); 
     128 
     129        return jPaneCenter; 
    113130    } 
    114131 
    115     @Required 
    116     public void setParameterDAO(final ParameterDAO parameterDAO) 
     132    /** 
     133     * Create the bottom JPane with the text "published .. (date)" 
     134     * 
     135     * @param dataNumber : the number of datas extracted from the base 
     136     * @param locale 
     137     * @return 
     138     */ 
     139    @NotNull 
     140    public JPane createBottomPane( @Nullable final Integer dataNumber, @Nullable final Locale locale ) 
    117141    { 
    118         _parameterDAO = parameterDAO; 
     142        final ResourceBundle bundle = getBundle( locale ); 
     143 
     144        final JPane jPaneBottom = new JPane(); 
     145        jPaneBottom.setLayout( new BorderLayout() ); 
     146 
     147        // Published 
     148        final Calendar calendar = Calendar.getInstance(); 
     149        final String messagePublished = bundle.getString( "plot.published" ); 
     150        final JLabel jLabel = new JLabel( messagePublished + " " + DateHelper.formatDate( calendar.getTime(), DateHelper.ENGLISH_DATE_PATTERN ) + " " ); 
     151        jPaneBottom.add( jLabel, BorderLayout.EAST ); 
     152 
     153        if( null != dataNumber ) 
     154        { 
     155            final String messageDataNumber = bundle.getString( "plot.dataNumber" ); 
     156            final JLabel jLabelDataNumber = new JLabel( messageDataNumber + " " + dataNumber ); 
     157            jPaneBottom.add( jLabelDataNumber, BorderLayout.WEST ); 
     158        } 
     159 
     160        return jPaneBottom; 
    119161    } 
    120162 
    121     @Required 
    122     public void setValueDAO(final ValueDAO valueDAO) 
     163    // TODO : move this function in a more generally class 
     164    private ResourceBundle getBundle( @Nullable final Locale locale ) 
    123165    { 
    124         _valueDAO = valueDAO; 
     166        if( null != locale ) 
     167            return ResourceBundle.getBundle( "ApplicationResources", locale ); 
     168        else 
     169            return ResourceBundle.getBundle( "ApplicationResources" ); 
    125170    } 
    126171 
    127     private static final Log LOGGER = LogFactory.getLog( EtherServiceImpl.class ); 
    128      
    129      
    130     private PlateformDAO _plateformDAO; 
    131     private ParameterDAO _parameterDAO; 
    132     private ValueDAO _valueDAO;     
     172    public static final int TOP_HEIGHT = 110; 
     173    public static final int CENTER_HEIGHT = 400; 
     174    public static final int BOTTOM_HEIGHT = 50; 
     175 
     176    private static final Log LOGGER = LogFactory.getLog( EtherPlotServiceImpl.class ); 
     177 
     178    // Dimensions of the jPanes 
     179    private static final int MAIN_WIDTH = 800; 
     180    private static final int MAIN_HEIGHT = 800; 
     181 
     182    private static final int FONT_SIZE = 20; 
    133183} 
  • ether_megapoli/trunk/service/implementation/com/ether/EtherServiceImpl.java

    r89 r129  
    5555        @Nullable 
    5656        @Transactional(readOnly = true) 
    57         public List<Data> getValuesByPlateformByParameterByPeriod( 
     57        public List<Pair<Double, Date>> getValuesByPlateformByParameterByPeriod( 
    5858                        @NotNull final Integer plateformId, 
    5959                        @NotNull final Integer parameterId,  
     
    106106    } 
    107107 
    108  
    109108    @Required 
    110109    public void setPlateformDAO(final PlateformDAO plateformDAO) 
  • ether_megapoli/trunk/service/implementation/com/ether/TimeSeriesPlot.java

    r119 r129  
    1 package com.ether.com.ether.graph; 
     1package com.ether; 
    22 
    3 import gov.noaa.pmel.sgt.LineAttribute; 
    43import gov.noaa.pmel.sgt.beans.DataGroup; 
    5 import gov.noaa.pmel.sgt.beans.DataModel; 
    64import gov.noaa.pmel.sgt.beans.Label; 
    75import gov.noaa.pmel.sgt.beans.Legend; 
    8 import gov.noaa.pmel.sgt.beans.Page; 
    96import gov.noaa.pmel.sgt.beans.PanelHolder; 
    107import gov.noaa.pmel.sgt.beans.PanelModel; 
    11 import gov.noaa.pmel.sgt.dm.SGTData; 
    12 import org.jetbrains.annotations.NotNull; 
    138import org.jetbrains.annotations.Nullable; 
    149 
    1510import javax.swing.*; 
    1611import java.awt.*; 
     12import java.util.Map; 
    1713 
    1814/** 
     
    2117 */ 
    2218public class TimeSeriesPlot 
    23         extends JFrame 
     19        extends EtherPlot 
    2420{ 
     21 
    2522    public void createTimeSeriesPlot() 
     23            throws ServiceException 
    2624    { 
    2725        // Enable WindowEvents. Set the layout of the content pane to a BorderLayout. 
     
    2927        getContentPane().setLayout( new BorderLayout() ); 
    3028 
    31         /** 
    32          * Add the page object to graphicPanel and set dataModel. 
    33          */ 
    34         _graphicPanel.add( _page, BorderLayout.CENTER ); 
    35         _page.setDataModel( _dataModel ); 
    36         /** 
    37          * Create panelModel by de-serializing an existing PanelModel.  The 
    38          * file SBExample1.xml, was created using gov.noaa.pmel.sgt.beans.PanelModelEditor. 
    39          * Exit on error. 
    40          */ 
     29        // Add the page object to graphicPanel 
     30        getjPanel().add( getPage(), BorderLayout.CENTER ); 
     31 
     32        // DATA MODEL 
     33        getPage().setDataModel( getDataModel() ); 
     34 
     35        // PANEL MODEL 
     36        final PanelModel panelModel = extractPanelModel(); 
     37        setPanelModel( panelModel ); 
     38        getPage().setPanelModel( getPanelModel() ); 
     39 
     40        // PANEL HOLDER 
     41        final PanelHolder panelHolder = panelModel.findPanelHolder( PANEL_GRAPH ); 
     42        if( null != panelHolder ) 
     43        { 
     44            changeTitle( getTitle(), panelHolder.getLabels() ); 
     45            changeLogos( panelHolder.getLabels() ); 
     46 
     47 
     48            final DataGroup dataGroup = panelHolder.findDataGroup( DATA_GROUP ); 
     49            final Legend timeLegend = panelHolder.findLegend( LEGEND ); 
     50            getDataModel().addData( getData(), getLineAttribute(), panelHolder, dataGroup, timeLegend ); 
     51        } 
     52        else 
     53            getDataModel().addData( getData(), getLineAttribute(), panelHolder, null, null ); 
     54 
     55//        final PanelHolder panelHolderImage = panelModel.findPanelHolder( PANEL_IMAGE ); 
     56//        getDataModel().addData( getData(), getLineAttribute(), panelHolderImage, null, null); 
     57 
     58        // Add the graphic to the content pane of the JFrame. 
     59        getContentPane().add( getjPanel(), BorderLayout.CENTER ); 
     60    } 
     61 
     62    private void changeTitle( @Nullable final String title, @Nullable final Map panelHolderLabels ) 
     63    { 
     64        if( null != title && null != panelHolderLabels && null != panelHolderLabels.get( LABEL_TITLE ) ) 
     65        { 
     66            final Label labelTitle = (Label) panelHolderLabels.get( LABEL_TITLE ); 
     67            labelTitle.setText( title ); 
     68        } 
     69    } 
     70 
     71 
     72    private void changeLogos( @Nullable final Map panelHolderLabels ) 
     73    { 
     74        if( null != getLogoMegapoli() && null != panelHolderLabels && null != panelHolderLabels.get( LABEL_LOGO_MEGAPOLI ) ) 
     75        { 
     76            final Label labelLogoMegapoli = (Label) panelHolderLabels.get( LABEL_LOGO_MEGAPOLI ); 
     77            labelLogoMegapoli.setText( getLogoMegapoli() ); 
     78        } 
     79    } 
     80 
     81    /** 
     82     * Create panelModel by de-serializing an existing PanelModel. 
     83     * The file megapoli.xml was created using gov.noaa.pmel.sgt.beans.PanelModelEditor. 
     84     */ 
     85    private PanelModel extractPanelModel() 
     86            throws ServiceException 
     87    { 
    4188        try 
    4289        { 
    43             _panelModel = PanelModel.loadFromXML( getClass().getResource( FILE_NAME ).openStream() ); 
     90            return PanelModel.loadFromXML( getClass().getResource( FILE_NAME ).openStream() ); 
    4491        } 
    4592        catch( Exception e ) 
    4693        { 
    47             e.printStackTrace(); 
    48             System.exit( 1 ); 
     94            throw new ServiceException( ServiceException.ServiceCode.PANEL_MODEL_NOT_FOUND, e ); 
    4995        } 
    50         /** 
    51          * Set panelModel. 
    52          */ 
    53         _page.setPanelModel( _panelModel ); 
    54  
    55         final PanelHolder time = _panelModel.findPanelHolder( PANEL_GRAPH ); 
    56         if( null != time ) 
    57         { 
    58             if( null != _title && null != time.getLabels() && null != time.getLabels().get( LABEL_TITLE ) ) 
    59             { 
    60                 final Label labelTitle = (Label) time.getLabels().get( LABEL_TITLE ); 
    61                 labelTitle.setText( _title ); 
    62             } 
    63             final DataGroup timeData = time.findDataGroup( DATA_GROUP ); 
    64             final Legend timeLegend = time.findLegend( LEGEND ); 
    65             _dataModel.addData( _data, _lineAttribute, time, timeData, timeLegend ); 
    66         } 
    67         else 
    68             _dataModel.addData( _data, _lineAttribute, time, null, null ); 
    69  
    70         // Add the graphic to the content pane of the JFrame. 
    71         getContentPane().add( _graphicPanel, BorderLayout.CENTER ); 
    7296    } 
    7397 
    74     @Nullable 
    75     public String getTitle() 
    76     { 
    77         return _title; 
    78     } 
    79  
    80     public void setTitle( @Nullable final String title ) 
    81     { 
    82         _title = title; 
    83     } 
    84  
    85     @NotNull 
    86     public SGTData getData() 
    87     { 
    88         return _data; 
    89     } 
    90  
    91     public void setData( @NotNull final SGTData data ) 
    92     { 
    93         _data = data; 
    94     } 
    95  
    96     @NotNull 
    97     public LineAttribute getLineAttribute() 
    98     { 
    99         return _lineAttribute; 
    100     } 
    101  
    102     public void setLineAttribute( @NotNull final LineAttribute lineAttribute ) 
    103     { 
    104         _lineAttribute = lineAttribute; 
    105     } 
    106  
    107     /** 
    108      * Instantiate the three primary SGT Bean objects. 
    109      * Page -       Main SGT JavaBean used with PanelModel and DataModel to 
    110      * create a graphic. 
    111      * <p/> 
    112      * PanelModel - A model that supports the Panel structure of a plot. 
    113      * DataModel -  A model that supplies the relationship between SGTData objects, 
    114      * its Attribute and the Panel and DataGroup in which it is 
    115      * displayed and the Legend. 
    116      */ 
    117     private Page _page = new Page(); 
    118     private PanelModel _panelModel = new PanelModel(); 
    119     private DataModel _dataModel = new DataModel(); 
    120     /** 
    121      * The JPanel that will be used to contain the graphic. 
    122      */ 
    123     private JPanel _graphicPanel = new JPanel( new BorderLayout() ); 
    124  
    125     @Nullable 
    126     private String _title; 
    127     @NotNull 
    128     private SGTData _data; 
    129     @NotNull 
    130     private LineAttribute _lineAttribute = new LineAttribute( LineAttribute.SOLID, Color.red ); 
    131  
    132     // Labels used in the megapoli.xml 
    133     private static final String FILE_NAME = "megapoli.xml"; 
    134     private static final String PANEL_GRAPH = "Panel_graph"; 
    135     private static final String LABEL_TITLE = "Label_title"; 
    136     private static final String DATA_GROUP = "DataGroup"; 
    137     private static final String LEGEND = "Legend"; 
    138  
    13998} 
  • ether_megapoli/trunk/service/implementation/service-context.xml

    r89 r129  
    1717        </bean> 
    1818 
     19    <bean id="etherPlotService" class="com.ether.EtherPlotServiceImpl"></bean> 
     20 
    1921</beans> 
  • ether_megapoli/trunk/service/interface/com/ether/EtherPlotService.java

    r119 r129  
    11package com.ether; 
    22 
    3 import java.util.Date; 
    4 import java.util.List; 
    5  
    6 import com.medias.database.objects.Parametre; 
    7 import com.medias.database.objects.Plateforme; 
     3import gov.noaa.pmel.sgt.JPane; 
     4import gov.noaa.pmel.sgt.dm.SGTData; 
    85import org.jetbrains.annotations.NotNull; 
    96import org.jetbrains.annotations.Nullable; 
    107 
     8import java.awt.image.BufferedImage; 
     9import java.util.Locale; 
     10 
    1111/** 
    1212 * @author vmipsl 
    13  * @date 07 mar 2011  
     13 * @date 05 july 2011 
    1414 */ 
    15 public interface EtherService extends Service 
     15public interface EtherPlotService 
     16        extends Service 
    1617{ 
    17         @Nullable 
    18         List<Parametre> getParametersByPlateformId(@NotNull final Integer plateformId) throws ServiceException; 
    19          
    20         @Nullable 
    21         List<Plateforme> getAllPlateforms() throws ServiceException; 
     18    @NotNull 
     19    public BufferedImage createJPane( @NotNull final MegapoliPlot megapoliPlot, @Nullable final Locale locale ); 
    2220 
    23         @Nullable 
    24     List<Data> getValuesByPlateformByParameterByPeriod(@NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd) throws ServiceException; 
     21    @NotNull 
     22    public JPane createTopPane( @Nullable final MegapoliPlot megapoliPlot ); 
    2523 
    26     @Nullable 
    27     Plateforme getPlateformById( @Nullable final Integer plateformId ) throws ServiceException; 
     24    @NotNull 
     25    public JPane createCenterPane( @NotNull final SGTData data ); 
    2826 
    29     @Nullable 
    30     Parametre getParameterById( @Nullable final Integer parameterId ) throws ServiceException; 
     27    @NotNull 
     28    public JPane createBottomPane( @Nullable final Integer dataNumber, @Nullable final Locale locale ); 
     29 
    3130} 
  • ether_megapoli/trunk/service/interface/com/ether/EtherService.java

    r89 r129  
    2222 
    2323        @Nullable 
    24     List<Data> getValuesByPlateformByParameterByPeriod(@NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd) throws ServiceException; 
     24    List<Pair<Double, Date>> getValuesByPlateformByParameterByPeriod(@NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd) throws ServiceException; 
    2525 
    2626    @Nullable 
  • ether_megapoli/trunk/service/interface/com/ether/ServiceException.java

    r89 r129  
    2525        PLATEFORM_NOT_FOUND, 
    2626        PARAMETER_NOT_FOUND, 
    27         VALUE_NOT_FOUND,         
     27        VALUE_NOT_FOUND, 
     28        PANEL_MODEL_NOT_FOUND; 
    2829    } 
    2930} 
  • ether_megapoli/trunk/service/test/com/ether/SGTTest.java

    r89 r129  
    11package com.ether; 
    22 
    3 import com.ether.com.ether.graph.TimeSeriesPlot; 
     3import com.ether.annotation.ControllerMethod; 
     4import com.ether.annotation.Mandatory; 
     5import com.ether.annotation.ParamName; 
    46import com.ether.tutorial.src.tutorial.Example1; 
    57import com.ether.tutorial.src.tutorial.SBExample1; 
    68import com.ether.tutorial.src.tutorial.SBExample2; 
    79import com.ether.tutorial.src.tutorial.SBExample3; 
     10import com.keypoint.PngEncoder; 
     11import com.keypoint.PngEncoderB; 
     12import gov.noaa.pmel.sgt.JPane; 
    813import gov.noaa.pmel.sgt.LineAttribute; 
    914import gov.noaa.pmel.sgt.dm.SGTMetaData; 
     
    1116import gov.noaa.pmel.sgt.swing.JPlotLayout; 
    1217import gov.noaa.pmel.util.GeoDateArray; 
     18import net.sf.json.JSONObject; 
     19import org.jetbrains.annotations.NotNull; 
    1320import org.jetbrains.annotations.Nullable; 
    1421import org.junit.Test; 
    1522 
     23import javax.imageio.ImageIO; 
     24import javax.servlet.ServletException; 
     25import javax.servlet.http.HttpServletRequest; 
     26import javax.servlet.http.HttpServletResponse; 
    1627import javax.swing.*; 
    1728import java.awt.*; 
     29import java.awt.image.BufferedImage; 
     30import java.awt.image.RenderedImage; 
     31import java.io.File; 
     32import java.io.FileInputStream; 
     33import java.io.IOException; 
    1834import java.text.ParseException; 
    19 import java.util.List; 
     35import java.util.Date; 
    2036 
    2137/** 
     
    176192        final LineAttribute lineAttribute = createLineAttribute( markPoint ); 
    177193 
    178         TimeSeriesPlot timeSeriesFrame = new TimeSeriesPlot(); 
    179         timeSeriesFrame.setTitle( "Keroppi title" ); 
    180         timeSeriesFrame.setData( data ); 
    181         timeSeriesFrame.setLineAttribute( lineAttribute ); 
    182  
    183         timeSeriesFrame.createTimeSeriesPlot(); 
    184  
    185         timeSeriesFrame.pack(); 
    186         timeSeriesFrame.setResizable( false ); 
    187         timeSeriesFrame.setVisible( true ); 
     194        final TimeSeriesPlot timeSeriesPlot = new TimeSeriesPlot(); 
     195        timeSeriesPlot.setTitle( "Keroppi title" ); 
     196        timeSeriesPlot.setLogoMegapoli( "keroppi1.jpg" ); 
     197        timeSeriesPlot.setData( data ); 
     198        timeSeriesPlot.setLineAttribute( lineAttribute ); 
     199 
     200//        getEtherPlotService().createTimeSeriesPlot( timeSeriesPlot ); 
     201        timeSeriesPlot.createTimeSeriesPlot(); 
     202 
     203        timeSeriesPlot.pack(); 
     204        timeSeriesPlot.setResizable( false ); 
     205        timeSeriesPlot.setVisible( true ); 
    188206 
    189207        Thread.sleep( 100 ); 
    190         copyToFile( timeSeriesFrame, "service/test/test_TimeSeriesFrame.jpg" ); 
     208        copyToFile( timeSeriesPlot, "service/test/test_TimeSeriesFrameeee.jpg" ); 
     209 
     210        final Image image = timeSeriesPlot.createImage( 400, 400 ); 
     211 
     212//        BufferedImage bufferedImage = toBufferedImage( image ); 
     213//        BASE64Encoder encoder = new BASE64Encoder(); 
     214//        encoder.encode( bufferedImage ); 
     215 
     216        PngEncoder pngEncoder = new PngEncoder(); 
     217        pngEncoder.setImage( image ); 
     218        byte[] bytes = pngEncoder.pngEncode(); 
    191219    } 
    192220 
     
    266294//        } 
    267295 
     296    @Test 
     297    public void doGetImage() 
     298            throws Exception 
     299    { 
     300        // Appel .jsp 
     301        // <img src="plotEther?agentId=15" width="150px" height="150px"/> 
     302        final FileInputStream fichierKer = new FileInputStream( "/home_local/workspaces/Megapoli/service/test/kerropi1.jpg" ); 
     303        final BufferedImage bImageKer = ImageIO.read( fichierKer ); 
     304 
     305        if( bImageKer != null ) 
     306        { 
     307            final PngEncoderB pngEncoderB = new PngEncoderB(); 
     308            pngEncoderB.setImage( bImageKer ); 
     309 
     310//            ImageIO.write( bImageKer, "png", response.getOutputStream() ); 
     311        } 
     312    } 
     313 
     314    @Test 
     315    public void doGetImage_withFrame() 
     316            throws Exception 
     317    { 
     318        final GeoDateArray dateArray = createTimeArray( 10, null ); 
     319        final double[] dataArray = createDataArray( 10, 5 ); 
     320 
     321        final SimpleLine data = new SimpleLine( dateArray, dataArray, "legend" ); 
     322        SGTMetaData meta = new SGTMetaData( "Longitude", "degrees East", false, false ); 
     323        data.setXMetaData( meta ); 
     324 
     325        meta = new SGTMetaData( "parameterName", "parameterUnit", false, false ); 
     326        data.setYMetaData( meta ); 
     327 
     328        final JFrame frame = new JFrame( "Frame principale" ); 
     329        final JPane jPane = new JPane(); 
     330 
     331        final JLabel jlbHelloWorld = new JLabel( "Hello World" ); 
     332        jPane.add( jlbHelloWorld, BorderLayout.SOUTH ); 
     333 
     334        final ImageIcon ic = new ImageIcon( "/home_local/workspaces/Megapoli/service/test/kerropi1.jpg" ); 
     335        final JLabel jLabel = new JLabel( ic ); 
     336        jPane.add( jLabel, BorderLayout.EAST ); 
     337 
     338        final JPlotLayout jPlotLayout = new JPlotLayout( false, true, false, "Trajectory data", null, false ); 
     339        jPlotLayout.setTitles( "title1", "title2", "title3" ); 
     340        jPlotLayout.addData( data, data.getTitle() ); 
     341        jPlotLayout.setVisible( true ); 
     342        jPane.add( jPlotLayout, BorderLayout.EAST ); 
     343 
     344        jPane.setVisible( true ); 
     345        frame.setContentPane( jPane ); 
     346 
     347        frame.setSize( 700, 550 ); 
     348        frame.setEnabled( false ); 
     349        frame.pack(); 
     350        frame.setVisible( true ); 
     351 
     352 
     353        final BufferedImage bufferedImage = new BufferedImage( jPlotLayout.getWidth(), jPlotLayout.getHeight(), BufferedImage.TYPE_INT_RGB ); 
     354        final Graphics2D graphics2D = bufferedImage.createGraphics(); 
     355        graphics2D.setBackground( Color.WHITE ); 
     356        jPlotLayout.getComponent().addNotify(); 
     357        jPlotLayout.getComponent().validate(); 
     358 
     359        jPlotLayout.draw( graphics2D ); 
     360 
     361        try 
     362        { 
     363            final File outFile = new File( "/home_local/workspaces/Megapoli/service/test/keroppi_out.jpg" ); 
     364            ImageIO.write( bufferedImage, "jpg", outFile ); 
     365        } 
     366        catch( Exception e ) 
     367        { 
     368        } 
     369    } 
     370 
     371 
     372    protected GeoDateArray createTimeArray( @NotNull final Integer size, @Nullable String day ) 
     373            throws ParseException 
     374    { 
     375        if( null == day ) 
     376            day = "2009-07-13"; 
     377 
     378        final Date[] dates = new Date[size]; 
     379        for( int i = 0; i < size; i++ ) 
     380        { 
     381            final String dateString = day + ' ' + i + ":32"; 
     382            final Date date = DateHelper.parseDate( dateString, DateHelper.ENGLISH_DATE_PATTERN ); 
     383            dates[i] = date; 
     384        } 
     385        return new GeoDateArray( dates ); 
     386    } 
     387 
     388    @NotNull 
     389    protected double[] createDataArray( @NotNull final Integer size, @NotNull final Integer begin ) 
     390            throws ParseException 
     391    { 
     392        final double[] datas = new double[size]; 
     393        for( int i = 0; i < size; i++ ) 
     394        { 
     395            datas[i] = Double.valueOf( i + begin ); 
     396        } 
     397        return datas; 
     398    } 
     399 
     400    private TimeSeriesPlot createPlot() 
     401            throws ParseException, ServiceException 
     402    { 
     403        final String parameterName = "OZONE"; 
     404        final String parameterUnit = "ppbv"; 
     405        final boolean startToZero = true; 
     406        final boolean markPoint = false; 
     407 
     408        final GeoDateArray dateArray = createTimeArray( 10, null ); 
     409        final double[] dataArray = createDataArray( 10, 5 ); 
     410 
     411        final SimpleLine data = new SimpleLine( dateArray, dataArray, "legend" ); 
     412        SGTMetaData meta = new SGTMetaData( "Longitude", "degrees East", false, false ); 
     413        data.setXMetaData( meta ); 
     414 
     415        meta = new SGTMetaData( parameterName, parameterUnit, false, false ); 
     416        data.setYMetaData( meta ); 
     417 
     418        final LineAttribute lineAttribute = new LineAttribute( LineAttribute.SOLID, Color.red ); 
     419 
     420        final TimeSeriesPlot timeSeriesPlot = new TimeSeriesPlot(); 
     421        timeSeriesPlot.setTitle( "Keroppi title" ); 
     422        timeSeriesPlot.setLogoMegapoli( "keroppi1.jpg" ); 
     423        timeSeriesPlot.setData( data ); 
     424        timeSeriesPlot.setLineAttribute( lineAttribute ); 
     425 
     426        timeSeriesPlot.createTimeSeriesPlot(); 
     427        return timeSeriesPlot; 
     428    } 
     429 
     430    private JPlotLayout createLayout( @Nullable final String plateformName, @Nullable final String parameterName ) 
     431    { 
     432        final JFrame frame = new JFrame( "Frame principale" ); 
     433        final JPanel panel = new JPanel( new BorderLayout() ); 
     434 
     435        final JLabel jlbHelloWorld = new JLabel( "Hello World" ); 
     436        panel.add( jlbHelloWorld, BorderLayout.SOUTH ); 
     437 
     438        final ImageIcon ic = new ImageIcon( "kerropi1.jpg" ); 
     439        final JLabel jLabel = new JLabel( ic ); 
     440        panel.add( jLabel, BorderLayout.EAST ); 
     441 
     442        final JPlotLayout jPlotLayout = new JPlotLayout( false, false, false, "Trajectory data", null, false ); 
     443        jPlotLayout.setTitles( plateformName, parameterName, "title3" ); 
     444//              jPlotLayout.setTitleHeightP(0.2, 0.2); 
     445        jPlotLayout.setVisible( true ); 
     446        panel.add( jPlotLayout, BorderLayout.NORTH ); 
     447 
     448        panel.setVisible( true ); 
     449        frame.setContentPane( panel ); 
     450 
     451        frame.setSize( MAIN_WIDTH, 550 ); 
     452        frame.setVisible( true ); 
     453 
     454        return jPlotLayout; 
     455    } 
     456 
     457    public void doGet_Layout( final HttpServletResponse response, final SimpleLine data ) 
     458            throws ServletException, IOException 
     459    { 
     460        try 
     461        { 
     462            final JPlotLayout jPlotLayout = new JPlotLayout( false, true, false, "Trajectory data", null, false ); 
     463            jPlotLayout.setTitles( "title1", "title2", "title3" ); 
     464            jPlotLayout.addData( data, data.getTitle() ); 
     465            jPlotLayout.setVisible( true ); 
     466 
     467            jPlotLayout.addNotify(); 
     468            jPlotLayout.validate(); 
     469 
     470            final BufferedImage bufferedImage = new BufferedImage( jPlotLayout.getWidth(), jPlotLayout.getHeight(), BufferedImage.TYPE_INT_RGB ); 
     471            final Graphics2D graphics2D = bufferedImage.createGraphics(); 
     472            graphics2D.setBackground( Color.red ); 
     473            jPlotLayout.draw( graphics2D ); 
     474 
     475            ImageIO.write( bufferedImage, "png", response.getOutputStream() ); 
     476        } 
     477 
     478        catch( Exception e ) 
     479        { 
     480            e.printStackTrace(); 
     481        } 
     482    } 
     483 
     484 
     485 
     486    @ControllerMethod(jsonResult = true) 
     487    public JSONObject searchDatasByPlateformByParameterByPeriod( 
     488            @Mandatory @ParamName(ParameterConstants.PARAMETER_PLATEFORM_ID) final Integer plateformId, 
     489            @Mandatory @ParamName(ParameterConstants.PARAMETER_PARAMETER_ID) final Integer parameterId, 
     490            @ParamName(ParameterConstants.PARAMETER_DATE_BEGIN) final String dateBegin, 
     491            @ParamName(ParameterConstants.PARAMETER_DATE_END) final String dateEnd ) 
     492            throws ServiceException, WebException, ParseException 
     493    { 
     494//        final String pofBegin = "2009-07-13 13:00"; 
     495//        final String pofEnd = "2009-07-13 14:00"; 
     496//        final Date formatedDateBegin = DateHelper.parseDate( pofBegin, DateHelper.ENGLISH_DATE_PATTERN ); 
     497//        final Date formatedDateEnd = DateHelper.parseDate( pofEnd, DateHelper.ENGLISH_DATE_PATTERN ); 
     498 
     499//        final Plateforme plateform = _etherService.getPlateformById( plateformId ); 
     500//        final Parametre parameter = _etherService.getParameterById( parameterId ); 
     501//        final List<Data> values = _etherService.getValuesByPlateformByParameterByPeriod( plateformId, parameterId, formatedDateBegin, formatedDateEnd ); 
     502 
     503        //JPlotLayout layout = createLayout( plateform.getPlateformeNom(), parameter.getParametreNom() ); 
     504        final TimeSeriesPlot timeSeriesPlot = createPlot(); 
     505        final Image image = timeSeriesPlot.createImage( 400, 400 ); 
     506 
     507//        BufferedImage bufferedImage = toBufferedImage( image ); 
     508//        BASE64Encoder encoder = new BASE64Encoder(); 
     509//        encoder.encode( bufferedImage ); 
     510 
     511        PngEncoder pngEncoder = new PngEncoder(); 
     512        pngEncoder.setImage( image ); 
     513        byte[] bytes = pngEncoder.pngEncode(); 
     514 
     515        //final BufferedImage bufferedImage = ImageHelper.createBufferedImage( timeSeriesPlot ); 
     516        final BufferedImage bufferedImage = new BufferedImage( 400, 400, BufferedImage.TYPE_INT_RGB ); 
     517        final Graphics2D g2 = bufferedImage.createGraphics(); 
     518        timeSeriesPlot.paint( g2 ); 
     519        g2.dispose(); 
     520 
     521        final PngEncoderB pngEncoderB = new PngEncoderB(); 
     522        pngEncoderB.setImage( bufferedImage ); 
     523        final byte[] bytesB = pngEncoderB.pngEncode(); 
     524 
     525        final JSONObject result = new JSONObject(); 
     526        result.put( ParameterConstants.PARAMETER_IMAGE, bytesB ); 
     527        return result; 
     528//        return new JSONObject(); 
     529    } 
     530 
     531//    public void searchDatasByPlateformByParameterByPeriod( final HttpServletRequest request, final HttpServletResponse response ) 
     532//            throws ParseException, ServiceException, IOException 
     533//    { 
     534//        final TimeSeriesPlot timeSeriesPlot = createPlot(); 
     535//        final Image image = timeSeriesPlot.createImage( 400, 400 ); 
     536// 
     537//        //final BufferedImage bufferedImage = ImageHelper.createBufferedImage( timeSeriesPlot ); 
     538//        final BufferedImage bufferedImage = new BufferedImage( 400, 400, BufferedImage.TYPE_INT_RGB ); 
     539//        final Graphics2D g2 = bufferedImage.createGraphics(); 
     540//        timeSeriesPlot.paint( g2 ); 
     541//        g2.dispose(); 
     542// 
     543//        final PngEncoderB pngEncoderB = new PngEncoderB(); 
     544//        pngEncoderB.setImage( bufferedImage ); 
     545//        final byte[] bytesB = pngEncoderB.pngEncode(); 
     546// 
     547//        ImageIO.write( (RenderedImage) image, "png", response.getOutputStream() ); 
     548//    } 
     549// 
     550//    private TimeSeriesPlot createPlot() 
     551//            throws ParseException, ServiceException 
     552//    { 
     553// 
     554//        final String parameterName = "OZONE"; 
     555//        final String parameterUnit = "ppbv"; 
     556//        final boolean startToZero = true; 
     557//        final boolean markPoint = false; 
     558// 
     559//        final GeoDateArray dateArray = createTimeArray( 10, null ); 
     560//        final double[] dataArray = createDataArray( 10, 5 ); 
     561// 
     562//        final SimpleLine data = new SimpleLine( dateArray, dataArray, "legend" ); 
     563//        SGTMetaData meta = new SGTMetaData( "Longitude", "degrees East", false, false ); 
     564//        data.setXMetaData( meta ); 
     565// 
     566//        meta = new SGTMetaData( parameterName, parameterUnit, false, false ); 
     567//        data.setYMetaData( meta ); 
     568// 
     569//        final LineAttribute lineAttribute = new LineAttribute( LineAttribute.SOLID, Color.red ); 
     570// 
     571//        final TimeSeriesPlot timeSeriesPlot = new TimeSeriesPlot(); 
     572//        timeSeriesPlot.setTitle( "Keroppi title" ); 
     573//        timeSeriesPlot.setLogoMegapoli( "keroppi1.jpg" ); 
     574//        timeSeriesPlot.setData( data ); 
     575//        timeSeriesPlot.setLineAttribute( lineAttribute ); 
     576// 
     577//        timeSeriesPlot.createTimeSeriesPlot(); 
     578//        return timeSeriesPlot; 
     579//    } 
     580// 
     581//    private JPlotLayout createLayout( @Nullable final String plateformName, @Nullable final String parameterName ) 
     582//    { 
     583//        final JFrame frame = new JFrame( "Frame principale" ); 
     584//        final JPanel panel = new JPanel( new BorderLayout() ); 
     585// 
     586//        final JLabel jlbHelloWorld = new JLabel( "Hello World" ); 
     587//        panel.add( jlbHelloWorld, BorderLayout.SOUTH ); 
     588// 
     589//        final ImageIcon ic = new ImageIcon( "kerropi1.jpg" ); 
     590//        final JLabel jLabel = new JLabel( ic ); 
     591//        panel.add( jLabel, BorderLayout.EAST ); 
     592// 
     593//        final JPlotLayout jPlotLayout = new JPlotLayout( false, false, false, "Trajectory data", null, false ); 
     594//        jPlotLayout.setTitles( plateformName, parameterName, "title3" ); 
     595////            jPlotLayout.setTitleHeightP(0.2, 0.2); 
     596//        jPlotLayout.setVisible( true ); 
     597//        panel.add( jPlotLayout, BorderLayout.NORTH ); 
     598// 
     599//        panel.setVisible( true ); 
     600//        frame.setContentPane( panel ); 
     601// 
     602//        frame.setSize( 700, 550 ); 
     603//        frame.setVisible( true ); 
     604// 
     605//        return jPlotLayout; 
     606//    } 
     607 
     608//    @ControllerMethod(jsonResult = true) 
     609//    public JSONObject searchDatasByPlateformByParameterByPeriod( 
     610//              @Mandatory @ParamName(ParameterConstants.PARAMETER_PLATEFORM_ID) final Integer plateformId, 
     611//              @Mandatory @ParamName(ParameterConstants.PARAMETER_PARAMETER_ID) final Integer parameterId, 
     612//              @ParamName(ParameterConstants.PARAMETER_DATE_BEGIN) final String dateBegin, 
     613//              @ParamName(ParameterConstants.PARAMETER_DATE_END) final String dateEnd) 
     614//      throws ServiceException, WebException, ParseException 
     615//    { 
     616//      final long time1 = Calendar.getInstance().getTimeInMillis(); 
     617//      LOGGER.error("Date Controller begin : "+Calendar.getInstance().getTime()); 
     618////            final Date formatedDateBegin = DateHelper.parseDate(dateBegin, DateHelper.ENGLISH_DATE_PATTERN_SHORT); 
     619////            final Date formatedDateEnd = DateHelper.parseDate(dateEnd, DateHelper.ENGLISH_DATE_PATTERN_SHORT); 
     620// 
     621//      final Date formatedDateBegin = null; 
     622//      final Date formatedDateEnd = null; 
     623// 
     624//      final long time2 = Calendar.getInstance().getTimeInMillis(); 
     625//      LOGGER.error("Date Controller before request : "+Calendar.getInstance().getTime()+", Duration : "+(time2-time1)); 
     626//              final List<Data> values = _etherService.getValuesByPlateformByParameterByPeriod(plateformId, parameterId, formatedDateBegin, formatedDateEnd); 
     627//      final long time3 = Calendar.getInstance().getTimeInMillis(); 
     628//      LOGGER.error("Date Controller after request : "+Calendar.getInstance().getTime()+", Duration : "+(time3-time2)); 
     629// 
     630//      final JSONObject result = new JSONObject(); 
     631//      result.put( ParameterConstants.PARAMETER_VALUES, values ); 
     632//      final long time4 = Calendar.getInstance().getTimeInMillis(); 
     633//      LOGGER.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); 
     634//      LOGGER.error("Date Controller before return Result : "+Calendar.getInstance().getTime()+", Duration : "+(time4-time3)+", Total : "+(time4-time1)+", Taille : "+values.size()); 
     635//      LOGGER.error("plateformId : "+plateformId+", parameterId : "+parameterId); 
     636//      LOGGER.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); 
     637//      return result; 
     638//    } 
     639 
     640//      private void createPlot() { 
     641//              JPlotLayout layout_ = new JPlotLayout(false, false, false, 
     642//                              "Trajectory data", null, false); 
     643//              /* 
     644//               * Batch changes to layout. 
     645//               */ 
     646//              layout_.setBatch(true); 
     647//              /* 
     648//               * Set the titles. 
     649//               */ 
     650//              layout_.setTitles( 
     651//                              "Steller's Sea Lion Climate Research Profiling Floats", 
     652//                              "Trajectories", ""); 
     653//              /* 
     654//               * Change the title sizes from the defaults. (0.25, 0.15) 
     655//               */ 
     656//              layout_.setTitleHeightP(0.2, 0.2); 
     657//              /* 
     658//               * Use a BorderLayout for the JFrame and and the JPlotLayout to the 
     659//               * "Center". Pack the frame and make it visible. 
     660//               */ 
     661//              JFrame pif = new JFrame(); 
     662//              pif.getContentPane().setLayout(new BorderLayout()); 
     663//              pif.getContentPane().add(layout_, BorderLayout.CENTER); 
     664//              pif.pack(); 
     665//              pif.setVisible(true); 
     666//              /* 
     667//               * Read trajectory data from local file 
     668//               */ 
     669//              SGTData data = readTrajectory("service/implementation/com/ether/tutorial/data/trajectory"); 
     670//              /* 
     671//               * Add the trajectory data to the plot using the data title as the data 
     672//               * description. The description is used in the LineKey. 
     673//               */ 
     674//              layout_.addData(data, data.getTitle()); 
     675//              /* 
     676//               * Read the North Pacific hi-resolution coastline and add it to the 
     677//               * layout. Coastlines are handled differently by JPlotLayout. Coastlines 
     678//               * are not used to compute the X and Y ranges and are always clipped to 
     679//               * the axes. 
     680//               */ 
     681//              // SGTLine coastLine = getCoastLine("support/npac_hi_rez", 120000); 
     682//              // layout_.setCoastLine(coastLine); 
     683//              /* 
     684//               * Turn batching off. All batched changes to the JPlotLayout will now be 
     685//               * executed. 
     686//               */ 
     687//              layout_.setBatch(false); 
     688//      } 
     689 
     690 
     691//    public void doGet_OK( final HttpServletRequest request, final HttpServletResponse response ) 
     692//            throws ServletException, IOException 
     693//    { 
     694//        final JFrame frame = new JFrame( "Frame principale" ); 
     695//        final JPanel panel = new JPanel( new BorderLayout() ); 
     696// 
     697//        final JLabel jlbHelloWorld = new JLabel( "Hello World" ); 
     698//        panel.add( jlbHelloWorld, BorderLayout.SOUTH ); 
     699// 
     700//        final ImageIcon ic = new ImageIcon( "/home_local/workspaces/Megapoli/kerropi1.jpg" ); 
     701//        final JLabel jLabel = new JLabel( ic ); 
     702//        panel.add( jLabel, BorderLayout.EAST ); 
     703// 
     704//        final JPlotLayout jPlotLayout = new JPlotLayout( false, false, false, "Trajectory data", null, false ); 
     705//        jPlotLayout.setTitles( "title1", "title2", "title3" ); 
     706//        jPlotLayout.setVisible( true ); 
     707//        panel.add( jPlotLayout, BorderLayout.NORTH ); 
     708// 
     709//        panel.setVisible( true ); 
     710//        frame.setContentPane( panel ); 
     711// 
     712//        frame.setSize( MAIN_WIDTH, 550 ); 
     713//        frame.setVisible( true ); 
     714// 
     715//        final BufferedImage bufferedImage = new BufferedImage( frame.getWidth(), frame.getHeight(), BufferedImage.TYPE_INT_RGB ); 
     716// 
     717//        final Graphics2D g2 = bufferedImage.createGraphics(); 
     718//        frame.paint( g2 ); 
     719//        g2.dispose(); 
     720// 
     721//        try 
     722//        { 
     723//            final File out = new File( "/home_local/workspaces/Megapoli/test_JPlotLayout.jpg" ); 
     724//            ImageIO.write( bufferedImage, "JPEG", out ); 
     725//        } 
     726//        catch( Exception e ) 
     727//        { 
     728//        } 
     729//        ImageIO.write( bufferedImage, "JPEG", response.getOutputStream() ); 
     730//    } 
     731// 
     732//    public void doGet_OKK( final HttpServletRequest request, final HttpServletResponse response ) 
     733//            throws ServletException, IOException 
     734//    { 
     735//        try 
     736//        { 
     737//            final GeoDateArray dateArray = createTimeArray( 10, null ); 
     738//            final double[] dataArray = createDataArray( 10, 5 ); 
     739// 
     740//            final SimpleLine data = new SimpleLine( dateArray, dataArray, "legend" ); 
     741//            SGTMetaData meta = new SGTMetaData( "Longitude", "degrees East", false, false ); 
     742//            data.setXMetaData( meta ); 
     743// 
     744//            meta = new SGTMetaData( "parameterName", "parameterUnit", false, false ); 
     745//            data.setYMetaData( meta ); 
     746// 
     747//            final JPane jPane = new JPane(); 
     748// 
     749//            final JLabel jlbHelloWorld = new JLabel( "Hello World" ); 
     750//            jPane.add( jlbHelloWorld, BorderLayout.SOUTH ); 
     751// 
     752//            final ImageIcon ic = new ImageIcon( "/home_local/workspaces/Megapoli/kerropi1.jpg" ); 
     753//            final JLabel jLabel = new JLabel( ic ); 
     754//            jPane.add( jLabel, BorderLayout.EAST ); 
     755// 
     756//            final JPlotLayout jPlotLayout = new JPlotLayout( false, true, false, "Trajectory data", null, false ); 
     757//            jPlotLayout.setTitles( "title1", "title2", "title3" ); 
     758//            jPlotLayout.addData( data, data.getTitle() ); 
     759//            jPlotLayout.setVisible( true ); 
     760//            jPane.add( jPlotLayout, BorderLayout.EAST ); 
     761// 
     762//            jPane.setVisible( true ); 
     763// 
     764// 
     765//            final BufferedImage bufferedImage = new BufferedImage( jPlotLayout.getWidth(), jPlotLayout.getHeight(), BufferedImage.TYPE_INT_RGB ); 
     766//            final Graphics2D graphics2D = bufferedImage.createGraphics(); 
     767//            graphics2D.setBackground( Color.WHITE ); 
     768//            jPlotLayout.getComponent().addNotify(); 
     769//            jPlotLayout.getComponent().validate(); 
     770// 
     771//            jPlotLayout.draw( graphics2D ); 
     772// 
     773//            try 
     774//            { 
     775//                final File outFile = new File( "/home_local/workspaces/Megapoli/keroppi_out.jpg" ); 
     776//                ImageIO.write( bufferedImage, "jpg", outFile ); 
     777//            } 
     778//            catch( Exception e ) 
     779//            { 
     780//                throw new IOException( e ); 
     781//            } 
     782//            ImageIO.write( bufferedImage, "png", response.getOutputStream() ); 
     783//        } 
     784//        catch( Exception e ) 
     785//        { 
     786//            throw new IOException( e ); 
     787//        } 
     788//    } 
     789 
     790 
     791    // Dimensions of the jPanes 
     792    private static final int MAIN_WIDTH = 1000; 
     793    private static final int MAIN_HEIGHT = 1000; 
    268794} 
  • ether_megapoli/trunk/web/WEB-INF/classes/hibernate-domain.cfg.xml

    r89 r129  
    66<hibernate-configuration> 
    77        <session-factory> 
    8         <mapping resource="com/medias/objects/Adresse.hbm.xml"/> 
    9         <mapping resource="com/medias/objects/Bilan.hbm.xml"/> 
    10         <mapping resource="com/medias/objects/Capteur.hbm.xml"/> 
    11         <mapping resource="com/medias/objects/Categorie.hbm.xml"/> 
    12         <mapping resource="com/medias/objects/CategorieParam.hbm.xml"/> 
    13         <mapping resource="com/medias/objects/Commentaire.hbm.xml"/> 
    14         <mapping resource="com/medias/objects/DeltaMesure.hbm.xml"/> 
    15         <mapping resource="com/medias/objects/Fabriquant.hbm.xml"/> 
    16         <mapping resource="com/medias/objects/Fichier.hbm.xml"/> 
    17         <mapping resource="com/medias/objects/Flag.hbm.xml"/> 
    18         <mapping resource="com/medias/objects/Jeu.hbm.xml"/> 
    19         <mapping resource="com/medias/objects/Langue.hbm.xml"/> 
    20         <mapping resource="com/medias/objects/Localisation.hbm.xml"/> 
    21         <mapping resource="com/medias/objects/Mesure.hbm.xml"/> 
    22         <mapping resource="com/medias/objects/Organisme.hbm.xml"/> 
    23         <mapping resource="com/medias/objects/Parametre.hbm.xml"/> 
    24         <mapping resource="com/medias/objects/Personne.hbm.xml"/> 
    25         <mapping resource="com/medias/objects/Plateforme.hbm.xml"/> 
    26         <mapping resource="com/medias/objects/RequeteNbvalsJeu.hbm.xml"/> 
    27         <mapping resource="com/medias/objects/RequetePlatLoc.hbm.xml"/> 
    28         <mapping resource="com/medias/objects/Sequence.hbm.xml"/> 
    29         <mapping resource="com/medias/objects/TypeCapteur.hbm.xml"/> 
    30         <mapping resource="com/medias/objects/TypePlateforme.hbm.xml"/> 
    31         <mapping resource="com/medias/objects/Unite.hbm.xml"/> 
    32         <mapping resource="com/medias/objects/Valeur.hbm.xml"/> 
    33         <mapping resource="com/medias/objects/Zone.hbm.xml"/> 
     8        <!--<mapping resource="com/medias/objects/Adresse.hbm.xml"/>--> 
     9        <!--<mapping resource="com/medias/objects/Bilan.hbm.xml"/>--> 
     10        <!--<mapping resource="com/medias/objects/Capteur.hbm.xml"/>--> 
     11        <!--<mapping resource="com/medias/objects/Categorie.hbm.xml"/>--> 
     12        <!--<mapping resource="com/medias/objects/CategorieParam.hbm.xml"/>--> 
     13        <!--<mapping resource="com/medias/objects/Commentaire.hbm.xml"/>--> 
     14        <!--<mapping resource="com/medias/objects/DeltaMesure.hbm.xml"/>--> 
     15        <!--<mapping resource="com/medias/objects/Fabriquant.hbm.xml"/>--> 
     16        <!--<mapping resource="com/medias/objects/Fichier.hbm.xml"/>--> 
     17        <!--<mapping resource="com/medias/objects/Flag.hbm.xml"/>--> 
     18        <!--<mapping resource="com/medias/objects/Jeu.hbm.xml"/>--> 
     19        <!--<mapping resource="com/medias/objects/Langue.hbm.xml"/>--> 
     20        <!--<mapping resource="com/medias/objects/Localisation.hbm.xml"/>--> 
     21        <!--<mapping resource="com/medias/objects/Mesure.hbm.xml"/>--> 
     22        <!--<mapping resource="com/medias/objects/Organisme.hbm.xml"/>--> 
     23        <!--<mapping resource="com/medias/objects/Parametre.hbm.xml"/>--> 
     24        <!--<mapping resource="com/medias/objects/Personne.hbm.xml"/>--> 
     25        <!--<mapping resource="com/medias/objects/Plateforme.hbm.xml"/>--> 
     26        <!--<mapping resource="com/medias/objects/RequeteNbvalsJeu.hbm.xml"/>--> 
     27        <!--<mapping resource="com/medias/objects/RequetePlatLoc.hbm.xml"/>--> 
     28        <!--<mapping resource="com/medias/objects/Sequence.hbm.xml"/>--> 
     29        <!--<mapping resource="com/medias/objects/TypeCapteur.hbm.xml"/>--> 
     30        <!--<mapping resource="com/medias/objects/TypePlateforme.hbm.xml"/>--> 
     31        <!--<mapping resource="com/medias/objects/Unite.hbm.xml"/>--> 
     32        <!--<mapping resource="com/medias/objects/Valeur.hbm.xml"/>--> 
     33        <!--<mapping resource="com/medias/objects/Zone.hbm.xml"/>--> 
    3434        </session-factory> 
    3535</hibernate-configuration> 
  • ether_megapoli/trunk/web/WEB-INF/web.xml

    r120 r129  
    11<?com.medias.xml version="1.0" encoding="UTF-8"?> 
    2 <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> 
     2<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
     3        "http://java.sun.com/dtd/web-app_2_3.dtd"> 
    34<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" 
    4         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    5         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 
     5         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     6         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 
    67 
    7         <display-name>Megapoli</display-name> 
     8    <display-name>Megapoli</display-name> 
    89 
    9         <welcome-file-list> 
    10                 <welcome-file>/init.jsp</welcome-file> 
    11         </welcome-file-list> 
     10    <welcome-file-list> 
     11        <welcome-file>/init.jsp</welcome-file> 
     12    </welcome-file-list> 
    1213 
    13         <context-param> 
    14                 <param-name>contextConfigLocation</param-name> 
    15                 <param-value> 
     14    <context-param> 
     15        <param-name>contextConfigLocation</param-name> 
     16        <param-value> 
    1617            classpath:dao-context.xml, 
    1718            classpath:service-context.xml, 
     
    2021            classpath:json/json-context.xml 
    2122        </param-value> 
    22         </context-param> 
     23    </context-param> 
    2324 
    24         <listener> 
    25                 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    26         </listener> 
     25    <listener> 
     26        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
     27    </listener> 
    2728 
    28         <!-- TAGLIBS --> 
    29         <!--<taglib>--> 
    30                 <!--<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>--> 
    31                 <!--<taglib-location>/WEB-INF/tags/htmlJsp.tag</taglib-location>--> 
    32         <!--</taglib>--> 
     29    <!-- TAGLIBS --> 
     30    <!--<taglib>--> 
     31    <!--<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>--> 
     32    <!--<taglib-location>/WEB-INF/tags/htmlJsp.tag</taglib-location>--> 
     33    <!--</taglib>--> 
    3334 
    34         <!--<taglib>--> 
    35                 <!--<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>--> 
    36                 <!--<taglib-location>/WEB-INF/tags/htmlResourceJsp.tag</taglib-location>--> 
    37         <!--</taglib>--> 
     35    <!--<taglib>--> 
     36    <!--<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>--> 
     37    <!--<taglib-location>/WEB-INF/tags/htmlResourceJsp.tag</taglib-location>--> 
     38    <!--</taglib>--> 
    3839 
    39         <!--<taglib>--> 
    40                 <!--<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>--> 
    41                 <!--<taglib-location>/WEB-INF/tags/htmlCss.tag</taglib-location>--> 
    42         <!--</taglib>--> 
     40    <!--<taglib>--> 
     41    <!--<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>--> 
     42    <!--<taglib-location>/WEB-INF/tags/htmlCss.tag</taglib-location>--> 
     43    <!--</taglib>--> 
    4344 
    44         <!--<taglib>--> 
    45                 <!--<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>--> 
    46                 <!--<taglib-location>/WEB-INF/tags/htmlJs.tag</taglib-location>--> 
    47         <!--</taglib>--> 
     45    <!--<taglib>--> 
     46    <!--<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>--> 
     47    <!--<taglib-location>/WEB-INF/tags/htmlJs.tag</taglib-location>--> 
     48    <!--</taglib>--> 
    4849 
    49         <!--SERVLETS --> 
    50         <servlet> 
    51                 <servlet-name>visualization</servlet-name> 
    52                 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
    53                 <init-param> 
    54                         <param-name>contextConfigLocation</param-name> 
    55                         <param-value> 
    56                                 /WEB-INF/servlet-context.xml 
     50    <!--SERVLETS --> 
     51    <servlet> 
     52        <servlet-name>visualization</servlet-name> 
     53        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     54        <init-param> 
     55            <param-name>contextConfigLocation</param-name> 
     56            <param-value> 
     57                /WEB-INF/servlet-context.xml 
    5758            </param-value> 
    58                 </init-param> 
    59         </servlet> 
     59        </init-param> 
     60    </servlet> 
    6061 
    61         <servlet-mapping> 
    62                 <servlet-name>visualization</servlet-name> 
    63                 <url-pattern>/visualization</url-pattern> 
    64         </servlet-mapping> 
     62    <servlet-mapping> 
     63        <servlet-name>visualization</servlet-name> 
     64        <url-pattern>/visualization</url-pattern> 
     65    </servlet-mapping> 
    6566 
    66         <servlet> 
    67                 <servlet-name>action</servlet-name> 
    68                 <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> 
    69                 <init-param> 
    70                         <param-name>debug</param-name> 
    71                         <param-value>3</param-value> 
    72                 </init-param> 
    73                 <init-param> 
    74                         <param-name>config</param-name> 
    75                         <param-value>/WEB-INF/struts-config.xml</param-value> 
    76                 </init-param> 
    77                 <load-on-startup>0</load-on-startup> 
    78         </servlet> 
     67    <servlet> 
     68        <servlet-name>action</servlet-name> 
     69        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> 
     70        <init-param> 
     71            <param-name>debug</param-name> 
     72            <param-value>3</param-value> 
     73        </init-param> 
     74        <init-param> 
     75            <param-name>config</param-name> 
     76            <param-value>/WEB-INF/struts-config.xml</param-value> 
     77        </init-param> 
     78        <load-on-startup>0</load-on-startup> 
     79    </servlet> 
    7980 
    80         <servlet-mapping> 
    81                 <servlet-name>action</servlet-name> 
    82                 <url-pattern>*.do</url-pattern> 
    83         </servlet-mapping> 
     81    <servlet-mapping> 
     82        <servlet-name>action</servlet-name> 
     83        <url-pattern>*.do</url-pattern> 
     84    </servlet-mapping> 
     85 
     86    <servlet> 
     87        <servlet-name>plotEther</servlet-name> 
     88        <servlet-class>com.ether.ControllerPlot</servlet-class> 
     89    </servlet> 
     90 
     91    <servlet-mapping> 
     92        <servlet-name>plotEther</servlet-name> 
     93        <url-pattern>/visualization/plotEther</url-pattern> 
     94    </servlet-mapping> 
     95 
     96    <servlet> 
     97        <servlet-name>MegapoliInitialisation</servlet-name> 
     98        <servlet-class>org.medias.megapoli.utils.MegapoliInitialisation</servlet-class> 
     99        <load-on-startup>0</load-on-startup> 
     100    </servlet> 
    84101 
    85102 
    86         <servlet> 
    87                 <servlet-name>MegapoliInitialisation</servlet-name> 
    88                 <servlet-class>org.medias.megapoli.utils.MegapoliInitialisation</servlet-class> 
    89                 <load-on-startup>0</load-on-startup> 
    90         </servlet> 
     103    <!-- taglib> <taglib-uri>/tlds/struts-logic.tld</taglib-uri> <taglib-location>/tlds/struts-logic.tld</taglib-location> 
     104         </taglib> <taglib> <taglib-uri>/tlds/struts-html.tld</taglib-uri> <taglib-location>/tlds/struts-html.tld</taglib-location> 
     105         </taglib> <taglib> <taglib-uri>/tlds/struts-bean.tld</taglib-uri> <taglib-location>/tlds/struts-bean.tld</taglib-location> 
     106         </taglib> <taglib> <taglib-uri>/tlds/struts-nested.tld</taglib-uri> <taglib-location>/tlds/struts-nested.tld</taglib-location> 
     107         </taglib --> 
    91108 
     109    <resource-ref> 
     110        <description>postgreSQL Datasource</description> 
     111        <res-ref-name>megapoli/jdbc</res-ref-name> 
     112        <res-type>javax.sql.DataSource</res-type> 
     113        <res-auth>Container</res-auth> 
     114    </resource-ref> 
    92115 
    93         <!-- taglib> <taglib-uri>/tlds/struts-logic.tld</taglib-uri> <taglib-location>/tlds/struts-logic.tld</taglib-location>  
    94                 </taglib> <taglib> <taglib-uri>/tlds/struts-html.tld</taglib-uri> <taglib-location>/tlds/struts-html.tld</taglib-location>  
    95                 </taglib> <taglib> <taglib-uri>/tlds/struts-bean.tld</taglib-uri> <taglib-location>/tlds/struts-bean.tld</taglib-location>  
    96                 </taglib> <taglib> <taglib-uri>/tlds/struts-nested.tld</taglib-uri> <taglib-location>/tlds/struts-nested.tld</taglib-location>  
    97                 </taglib --> 
    98                  
    99         <resource-ref> 
    100                 <description>postgreSQL Datasource</description> 
    101                 <res-ref-name>megapoli/jdbc</res-ref-name> 
    102                 <res-type>javax.sql.DataSource</res-type> 
    103                 <res-auth>Container</res-auth> 
    104         </resource-ref> 
    105          
    106         <session-config> 
    107                 <session-timeout>60</session-timeout> <!-- minute --> 
    108         </session-config> 
    109          
     116    <session-config> 
     117        <session-timeout>60</session-timeout> 
     118        <!-- minute --> 
     119    </session-config> 
     120 
    110121</web-app> 
  • ether_megapoli/trunk/web/resources/css/visu_parameter_by_pf.css

    r89 r129  
    1212.containerPlateform:hover, .containerParameter:hover 
    1313{ 
    14 #       text-decoration: underline; 
     14        text-decoration: underline; 
    1515        background: #70739C; 
    1616        color: #FFFFFF; 
  • ether_megapoli/trunk/web/resources/js/DomHelper.js

    r89 r129  
    160160    { 
    161161        Element.addClassName(this.domCell, className); 
    162     }, 
     162    } 
    163163}); 
    164164 
     
    283283        var link = new Element('a', {href: url}).update(text); 
    284284        return link; 
    285     }, 
    286  
    287 }); 
     285    } 
     286 
     287}); 
  • ether_megapoli/trunk/web/resources/templates/templateEther.jsp

    r89 r129  
    1111<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    1212 
    13 <html> 
    14 <head> 
     13<HTML> 
     14<HEAD> 
    1515    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> 
    1616    <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> 
     
    4646        --> 
    4747        </script> 
    48 </head> 
    49  
    50 <body> 
     48</HEAD> 
     49 
     50<BODY> 
    5151        <a name="top"></a> 
    5252 
     
    218218</div> 
    219219 
    220 </body> 
    221 </html> 
     220</BODY> 
     221</HTML> 
    222222<!-- /*** ****************** FIN TEMPLATE ETHER ******************** **/ --> 
  • ether_megapoli/trunk/web/src/ApplicationResources.properties

    r89 r129  
    8484#data.upload.coordinator=En tant que coordinateur du projet, vous pouvez : 
    8585#data.upload.member=Vous \u00EAtes membre du projet. 
    86 data.upload.howto=Pour d\u00E9poser de nouvelles donn\u00E9es sur le serveur, veuillez suivre la d\u00E9marche suivante \: <ul><li>Mettez \u00E0 jour le fichier de m\u00E9tadonn\u00E9es associ\u00E9 au jeu de donn\u00E9es (cliquez sur le lien correspondant dans l'arborescence pour acc\u00E9der au formulaire),</li><li>T\u00E9l\u00E9chargez vos fichiers de donn\u00E9es, dans le dossier correspondant au jeu de donn\u00E9es ad\u00E9quat,</li><li>Envoyez un com.medias.mail au <a href\="mailto\:vincent.pignot@aero.obs-mip.fr?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler ce nouveau d\u00E9p\u00F4t \: il lancera alors la proc\u00E9dure d'int\u00E9gration des donn\u00E9es.</li></ul> 
     86data.upload.howto=Pour d\u00E9poser de nouvelles donn\u00E9es sur le serveur, veuillez suivre la d\u00E9marche suivante \: <ul><li>Mettez \u00E0 jour le fichier de m\u00E9tadonn\u00E9es associ\u00E9 au jeu de donn\u00E9es (cliquez sur le lien correspondant dans l'arborescence pour acc\u00E9der au formulaire),</li><li>T\u00E9l\u00E9chargez vos fichiers de donn\u00E9es, dans le dossier correspondant au jeu de donn\u00E9es ad\u00E9quat,</li><li>Envoyez un com.medias.mail au <a href\="mailto\:{0}?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler ce nouveau d\u00E9p\u00F4t \: il lancera alors la proc\u00E9dure d'int\u00E9gration des donn\u00E9es.</li></ul> 
    8787data.upload.deleteSet=Supprimer ce jeu de donn\u00E9es. 
    8888data.upload.deleteFile=Supprimer ce fichier. 
     
    107107 
    108108data.upload.metadata=M\u00E9tadonn\u00E9es 
     109data.upload.metadata.inc=\u00E0 compl\u00E9ter 
     110data.upload.metadata.comp=complet 
    109111data.upload.metadata.link=Mettre \u00E0 jour les m\u00E9tadonn\u00E9es 
    110112data.upload.metadata.title=M\u00E9tadonn\u00E9es pour le jeu 
    111 data.upload.metadata.intro=Veuillez s'il vous pla\u00EEt compl\u00E9ter ce formulaire le plus pr\u00E9cis\u00E9ment possible. Il permettra aux int\u00E9grateurs de recueillir les informations dont ils ont besoin pour enregistrer les donn\u00E9es dans la base.  
     113data.upload.metadata.intro=Veuillez s'il vous pla\u00EEt compl\u00E9ter ce formulaire le plus pr\u00E9cis\u00E9ment possible. Il permettra aux int\u00E9grateurs de recueillir les informations dont ils ont besoin pour enregistrer les donn\u00E9es dans la base. 
    112114data.upload.metadata.presentation=PRESENTATION GENERALE 
    113 data.upload.metadata.presentation.link=Prï¿œsentation gï¿œnï¿œrale 
     115data.upload.metadata.presentation.link=Pr\u00E9sentation g\u00E9n\u00E9rale 
    114116data.upload.metadata.presentation.nom=Nom du jeu 
    115117data.upload.metadata.presentation.def=Description 
     
    139141data.upload.metadata.integration.size=Taille totale des fichiers d\u00E9j\u00E0 trait\u00E9s 
    140142data.upload.metadata.contenu_actuel=CONTENU ACTUEL 
    141 data.upload.metadata.contact=Contact  
     143data.upload.metadata.contact=Contact 
    142144data.upload.metadata.contact.nom=Nom 
    143145data.upload.metadata.contact.prenom=Pr\u00E9nom 
     
    148150data.upload.metadata.parametres=Param\u00E8tres 
    149151data.upload.metadata.param=Param\u00E8tre 
    150 data.upload.metadata.param.nom=D\u00E9signation 
     152data.upload.metadata.param.cat=Cat\u00E9gorie 
     153data.upload.metadata.param.nom=Nom 
    151154data.upload.metadata.param.abrev=Abr\u00E9viation 
    152155data.upload.metadata.param.unite=Unit\u00E9 de mesure 
     
    165168data.upload.metadata.plat.img=Illustrations 
    166169data.upload.metadata.plat.img.show=Afficher l'illustration 
    167 data.upload.metadata.plat.latlon.format=<i>(En degr\u00E9s d\u00E9cimaux)</i> 
     170data.upload.metadata.plat.lat.format=<i>(En degr\u00E9s d\u00E9cimaux [-90,90])</i> 
     171data.upload.metadata.plat.lon.format=<i>(En degr\u00E9s d\u00E9cimaux [-180,180])</i> 
    168172data.upload.metadata.plat.latmin=Latitude minimale 
    169173data.upload.metadata.plat.lonmin=Longitude minimale 
     
    172176data.upload.metadata.plat.lonmax=Longitude maximale 
    173177data.upload.metadata.plat.altmax=Altitude maximale 
     178data.upload.metadata.nomoth=ou autre 
    174179data.upload.plat.optional=<i>(Obligatoire pour les plates-formes fixes)</i> 
    175180data.upload.metadata.time.date=Date 
     
    193198data.access.jeux=Les jeux de donn\u00E9es 
    194199data.access.jeux2=Jeux associ\u00E9s 
     200data.access.jeux3=jeu 
     201data.access.jeux4=jeux 
    195202data.access.param=Les param\u00E8tres 
    196203data.access.param1=Param\u00E8tre 
    197 data.access.param2=param\u00E8tres 
     204data.access.param2=param\u00E8tre{0} 
    198205data.access.param3=Param\u00E8tres associ\u00E9s 
    199206data.access.param4=D\u00E9tail du param\u00E8tre 
    200207data.access.capt=Les capteurs 
    201208data.access.capt1=Capteur 
    202 data.access.capt2=capteurs 
     209data.access.capt2=capteur{0} 
    203210data.access.capt3=Capteurs associ\u00E9s 
    204211data.access.capt4=D\u00E9tail du capteur 
    205212data.access.plat=Les plates-formes 
    206213data.access.plat1=Plate-forme 
    207 data.access.plat2=plates-formes 
     214data.access.plat2=plate{0}-forme{0} 
    208215data.access.plat3=Plates-formes associ\u00E9es 
    209216data.access.plat4=D\u00E9tail de la plate-forme 
     
    239246data.access.metadata.presentation.contact.role.scientifique=Responsable scientifique 
    240247data.access.metadata.presentation.contact.role.technique=Responsable technique 
    241 data.access.metadata.file=<i>{0} fichiers valid\u00E9s</i> 
    242 data.access.metadata.file.one=<i>{0} fichier valid\u00E9</i> 
    243 data.access.metadata.file.sameDate=<i>le {0}</i> 
    244 data.access.metadata.file.differentDate=<i>entre le {0} et le {1}</i> 
     248data.access.metadata.file=fichier{0} trait\u00E9{0} 
     249data.access.metadata.file.sameDate=le {0} 
     250data.access.metadata.file.differentDate=entre le {0} et le {1} 
    245251data.access.metadata.title=M\u00E9tadonn\u00E9es pour le jeu 
    246252data.access.metadata.intro= 
     
    248254data.access.metadata.datefin=Date de la derni\u00E8re mesure 
    249255data.access.metadata.heure=\u00E0 
    250 data.access.metadata.nbfichiers=com.medias.Nombre de fichiers 
     256data.access.metadata.nbfichiers=com.medias.Nombre de fichiers trait?s 
     257data.access.metadata.fichierslink=acc\u00E8s aux donn\u00E9es brutes 
    251258data.access.metadata.nbmesures=com.medias.Nombre de mesures 
    252259data.access.metadata.plat.type=Type de plate-forme 
    253260data.access.metadata.param.cat=Cat\u00E9gorie GCMD 
    254 data.access.files.zero=Aucun fichier valid\u00E9 pour ce jeu 
     261data.access.files.zero=Aucun fichier trait\u00E9 pour ce jeu 
    255262app.access.back=Retour \u00E0 la liste des jeux 
    256263app.access.plat.back=Liste des plates-formes 
     
    267274data.access.metadata.unavailable=M\u00E9tadonn\u00E9es non disponibles 
    268275data.access.files.dowload.com.medias.zip=T\u00E9l\u00E9charger tous les fichiers du jeu {0} 
     276data.access.files=Fichiers trait\u00E9s 
     277data.access.files2=Fichiers trait\u00E9s pour le jeu {0} 
     278data.access.files3=fichier{0} trait\u00E9{0} 
    269279 
    270280data.download=T\u00E9l\u00E9chargement 
     
    297307com.medias.mail.content4=\n\nVous pouvez consulter le d\u00E9tail ici\: " 
    298308com.medias.mail.content5=".\nVotre nom d'utilisateur est \: 
    299 com.medias.mail.content6=,\nVotre mot de passe est \: 
    300 com.medias.mail.content7=\n\n1) V\u00E9rifiez si les informations de m\u00E9tadonn\u00E9es associ\u00E9es au jeu " 
    301 com.medias.mail.content8=" sont correctes (en cliquant sur le lien "M\u00E9tadonn\u00E9es"),\n2) Chargez vos fichiers de donn\u00E9es associ\u00E9es au jeu. Pour cela, cliquez sur le bouton juste en dessous du lien "M\u00E9tadonn\u00E9es", choisissez un fichier, puis cliquez sur "D\u00E9poser". En cas de probl\u00E8me, veuillez contacter le webmaster (mailto\:vincent.pignot@aero.obs-mip.fr).\n\nA bient\u00F4t,\n\n 
    302 com.medias.mail.content9=est " 
     309com.medias.mail.content6=\nVotre mot de passe est \: 
     310com.medias.mail.content7=\n\n1) Cliquez sur le lien "M\u00E9tadonn\u00E9es" pour compl\u00E9ter les m\u00E9tadonn\u00E9es correspondant au jeu " 
     311com.medias.mail.content8=" ou v\u00E9rifiez si les informations d\u00E9j\u00E0 renseign\u00E9es sont correctes,\n2) Chargez vos fichiers de donn\u00E9es associ\u00E9es au jeu. Pour cela, cliquez sur le bouton juste en dessous du lien "M\u00E9tadonn\u00E9es", choisissez un fichier, puis cliquez sur "D\u00E9poser". En cas de probl\u00E8me, veuillez contacter le webmaster (mailto\: 
     312com.medias.mail.content9=).\n\nA bient\u00F4t,\n\n 
     313com.medias.mail.content10=est " 
     314 
     315unit.deg=\u00B0 
    303316 
    304317# ===================================== ERRORS ========================================== 
     
    322335errors.init.failed=Echec \u00E0 l'initialisation de l'application \: vous ne pourrez pas d\u00E9poser de nouveaux fichiers de donn\u00E9es sur le serveur \!<br> 
    323336 
    324 errors.logon.failed=Echec de l'op\u00E9ration d'authentification.<br> Veuillez contacter le <a href\="mailto\:vincent.pignot@aero.obs-mip.fr?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
    325 errors.logon.notFound=Ce login et/ou ce mot de passe sont inconnus.<br> Si vous voulez vous enregistrer pour obtenir l'acc\u00E8s aux zones prot\u00E9g\u00E9es du site, veuillez \u00E9crire un com.medias.mail au <a href\="mailto\:vincent.pignot@aero.obs-mip.fr?subject\=[MEGAPOLI]">webmaster</a>. <br> 
     337errors.logon.failed=Echec de l'op\u00E9ration d'authentification.<br> Veuillez contacter le <a href\="mailto\:{0}?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
     338errors.logon.notFound=Ce login et/ou ce mot de passe sont inconnus.<br> Si vous voulez vous enregistrer pour obtenir l'acc\u00E8s aux zones prot\u00E9g\u00E9es du site, veuillez \u00E9crire un com.medias.mail au <a href\="mailto\:{0}?subject\=[MEGAPOLI]">webmaster</a>. <br> 
    326339errors.logon.login=Veuillez saisir votre login (normalement : votre com.medias.mail).<br> 
    327340errors.logon.pwd=Veuillez saisir votre mot de passe.<br> 
    328341 
    329 errors.upload.file=Vous devez s\u00E9lectionner un fichier!<br> 
     342errors.upload.file=Vous devez s\u00E9lectionner un fichier\!<br> 
    330343errors.upload.failed=Echec du d\u00E9p\u00F4t...<br> 
    331344errors.upload.metadata.presentation.nom=Veuillez donner un nom au jeu de donn\u00E9es\!<br> 
     
    338351errors.upload.prepareTree.failed=Echec de chargement de la page de d\u00E9p\u00F4t<br>Veuillez r\u00E9essayer 
    339352 
    340 errors.upload.newSet.failed=Echec \u00E0 la cr\u00E9ation du jeu... <br> Veuillez contacter le <a href\="mailto\:vincent.pignot@aero.obs-mip.fr?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
     353errors.upload.newSet.failed=Echec \u00E0 la cr\u00E9ation du jeu... <br> Veuillez contacter le <a href\="mailto\:{0}?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
    341354errors.upload.newSet.failed2=Le jeu {0} existe d\u00E9j\u00E0, veuillez saisir un autre nom.<br> 
    342 errors.upload.newSet.updateAnnu.failed=Echec \u00E0 l'enregistrement des contacts... <br> Veuillez contacter le <a href\="mailto\:vincent.pignot@aero.obs-mip.fr?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
    343 errors.upload.newSet.senMails.failed=Echec \u00E0 l'envoi des mails de confirmation pour la cr\u00E9ation du jeu... <br> Veuillez contacter le <a href\="mailto\:vincent.pignot@aero.obs-mip.fr?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
    344 errors.upload.deleteSet.failed=Echec \u00E0 la suppression du jeu... <br> Veuillez contacter le <a href\="mailto\:vincent.pignot@aero.obs-mip.fr?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
    345 errors.upload.deleteFile.failed=Echec \u00E0 la suppression du fichier... <br> Veuillez contacter le <a href\="mailto\:vincent.pignot@aero.obs-mip.fr?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
     355errors.upload.newSet.updateAnnu.failed=Echec \u00E0 l'enregistrement des contacts... <br> Veuillez contacter le <a href\="mailto\:{0}?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
     356errors.upload.newSet.senMails.failed=Echec \u00E0 l'envoi des mails de confirmation pour la cr\u00E9ation du jeu... <br> Veuillez contacter le <a href\="mailto\:{0}?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
     357errors.upload.deleteSet.failed=Echec \u00E0 la suppression du jeu... <br> Veuillez contacter le <a href\="mailto\:{0}?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
     358errors.upload.deleteFile.failed=Echec \u00E0 la suppression du fichier... <br> Veuillez contacter le <a href\="mailto\:{0}?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
    346359 
    347360errors.upload.metadata.notfound=Le fichier n'a pas \u00E9t\u00E9 trouv\u00E9...<br> 
    348 errors.upload.updateMetadata.failed=Echec de la mise \u00E0 jour de la m\u00E9tadonn\u00E9e...<br> Veuillez contacter le <a href\="mailto\:vincent.pignot@aero.obs-mip.fr?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
    349 errors.upload.metadata.addPlat.failed=Echec \u00E0 l'ajout d'une nouvelle plate-forme...<br> Veuillez contacter le <a href\="mailto\:vincent.pignot@aero.obs-mip.fr?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
    350 errors.upload.metadata.deletePlat.failed=Echec \u00E0 la suppression de la plate-forme...<br> Veuillez contacter le <a href\="mailto\:vincent.pignot@aero.obs-mip.fr?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
    351 errors.upload.metadata.addParam.failed=Echec \u00E0 l'ajout d'un nouveau param\u00E8tre...<br> Veuillez contacter le <a href\="mailto\:vincent.pignot@aero.obs-mip.fr?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
    352 errors.upload.metadata.deleteParam.failed=Echec \u00E0 la suppression du param\u00E8tre...<br> Veuillez contacter le <a href\="mailto\:vincent.pignot@aero.obs-mip.fr?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
    353 errors.upload.metadata.addCapt.failed=Echec \u00E0 l'ajout d'un nouveau capteur...<br> Veuillez contacter le <a href\="mailto\:vincent.pignot@aero.obs-mip.fr?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
    354 errors.upload.metadata.deleteCapt.failed=Echec \u00E0 la suppression du capteur...<br> Veuillez contacter le <a href\="mailto\:vincent.pignot@aero.obs-mip.fr?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
     361errors.upload.updateMetadata.failed=Echec de la mise \u00E0 jour de la m\u00E9tadonn\u00E9e...<br> Veuillez contacter le <a href\="mailto\:{0}?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
     362errors.upload.metadata.addPlat.failed=Echec \u00E0 l'ajout d'une nouvelle plate-forme...<br> Veuillez contacter le <a href\="mailto\:{0}?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
     363errors.upload.metadata.deletePlat.failed=Echec \u00E0 la suppression de la plate-forme...<br> Veuillez contacter le <a href\="mailto\:{0}?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
     364errors.upload.metadata.addParam.failed=Echec \u00E0 l'ajout d'un nouveau param\u00E8tre...<br> Veuillez contacter le <a href\="mailto\:{0}?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
     365errors.upload.metadata.deleteParam.failed=Echec \u00E0 la suppression du param\u00E8tre...<br> Veuillez contacter le <a href\="mailto\:{0}?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
     366errors.upload.metadata.addCapt.failed=Echec \u00E0 l'ajout d'un nouveau capteur...<br> Veuillez contacter le <a href\="mailto\:{0}?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
     367errors.upload.metadata.deleteCapt.failed=Echec \u00E0 la suppression du capteur...<br> Veuillez contacter le <a href\="mailto\:{0}?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
    355368 
    356369errors.upload.updateMetadata.failed.contact_pi=Il ne peut y avoir qu'un seul contact scientifique pour un jeu de donn\u00E9es 
     
    371384errors.upload.updateMetadata.failed.lonbound=Vous devez saisir une longitude maximale sup\u00E9rieure ou \u00E9gale \u00E0 la longitude minimale 
    372385errors.upload.updateMetadata.failed.altbound=Vous devez saisir une altitude maximale sup\u00E9rieure ou \u00E9gale \u00E0 l'altitude minimale 
    373  
    374 errors.access.send.failed=Impossibilit\u00E9 de t\u00E9l\u00E9charger le fichier en question ... <br> Veuillez contacter le <a href\="mailto\:vincent.pignot@aero.obs-mip.fr?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
     386errors.zipgame.failed=Echec lors de la cr\u00E9ation de l'archive 
     387errors.access.send.failed=Impossibilit\u00E9 de t\u00E9l\u00E9charger le fichier en question ... <br> Veuillez contacter le <a href\="mailto\:{0}?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 
    375388 
    376389errors.access.requete.fail=La requ\u00EAte n'a pas aboutie 
    377  
    378390 
    379391################################################################ 
     
    405417data.visualization.button.download.info=(fichier .tgz) 
    406418data.visualization.loading.data=Chargement des donn\u00E9es 
     419data.visualization.quicklook=Quicklook 
    407420 
    408421simulation.visualization=Visualisation des simulations 
     422 
     423####################### PLOT ####################### 
     424plot.published=Publi\u00E9 le 
     425plot.dataNumber=Nombre de donn\u00E9es extraites : 
  • ether_megapoli/trunk/web/src/ApplicationResources_en.properties

    r89 r129  
    404404data.visualization.button.download.info=(file .tgz) 
    405405data.visualization.loading.data=Data downloading 
     406data.visualization.quicklook=Quicklook 
    406407 
    407408simulation.visualization=Simulations visualization 
     409 
     410####################### PLOT ####################### 
     411plot.published=Published 
     412plot.dataNumber=Number of extracted datas : 
  • ether_megapoli/trunk/web/src/com/ether/Controller.java

    r89 r129  
    66import com.medias.database.objects.Parametre; 
    77import com.medias.database.objects.Plateforme; 
    8 import com.sun.org.apache.xml.internal.security.utils.Base64; 
    9 import gov.noaa.pmel.sgt.swing.JPlotLayout; 
    108import net.sf.json.JSONObject; 
    119import org.apache.commons.logging.Log; 
    1210import org.apache.commons.logging.LogFactory; 
    1311import org.jetbrains.annotations.NotNull; 
    14 import org.jetbrains.annotations.Nullable; 
    1512import org.springframework.beans.factory.annotation.Required; 
    1613import org.springframework.web.servlet.ModelAndView; 
    17 import com.ether.tutorial.src.tutorial.Example1; 
    1814 
    1915import javax.servlet.http.HttpServletRequest; 
    2016import javax.servlet.http.HttpServletResponse; 
    21 import javax.swing.*; 
    22 import java.awt.*; 
    23 import java.io.FileWriter; 
    24 import java.io.IOException; 
    25 import java.text.ParseException; 
    26 import java.util.Date; 
    2717import java.util.HashMap; 
    2818import java.util.List; 
     
    3323 * @date 17 feb 2011 
    3424 */ 
    35 public class Controller extends ControllerEther 
     25public class Controller 
     26        extends ControllerEther 
    3627{ 
    3728    /** *********************************************************** **/ 
     
    3930    /** *********************************************************** **/ 
    4031    // Default view if methodName is unknown 
    41     public ModelAndView home(final HttpServletRequest request, final HttpServletResponse response) 
     32    public ModelAndView home( final HttpServletRequest request, final HttpServletResponse response ) 
    4233            throws WebException 
    4334    { 
    44         return new ModelAndView("index"); 
     35        return new ModelAndView( "index" ); 
    4536    } 
    4637 
     
    5950 
    6051        final Map<String, Object> model = new HashMap<String, Object>(); 
    61         model.put( "plateforms", getJsonHelper().toJSON(plateforms) ); 
     52        model.put( "plateforms", getJsonHelper().toJSON( plateforms ) ); 
    6253        return model; 
    6354    } 
     
    6556    /** *********************************************************** **/ 
    6657    /** *********************** CALLS ***************************** **/ 
    67     /** *********************************************************** **/ 
     58    /** ********************************************************** **/ 
    6859    @ControllerMethod(jsonResult = true) 
    69     public JSONObject searchParametersByPlateform(@Mandatory @ParamName(ParameterConstants.PARAMETER_ID) final Integer plateformId) 
     60    public JSONObject searchParametersByPlateform( @Mandatory @ParamName(ParameterConstants.PARAMETER_ID) final Integer plateformId ) 
    7061            throws ServiceException, WebException 
    7162    { 
    72         final List<Parametre> parametersByPlateform = _etherService.getParametersByPlateformId(plateformId); 
     63        final List<Parametre> parametersByPlateform = _etherService.getParametersByPlateformId( plateformId ); 
    7364 
    7465        final JSONObject result = new JSONObject(); 
    75         result.put( ParameterConstants.PARAMETER_PARAMETERS, getJsonHelper().toJSON(parametersByPlateform) ); 
     66        result.put( ParameterConstants.PARAMETER_PARAMETERS, getJsonHelper().toJSON( parametersByPlateform ) ); 
    7667        return result; 
    7768    } 
    7869 
    79     @ControllerMethod(jsonResult = true) 
    80     public JSONObject searchDatasByPlateformByParameterByPeriod( 
    81             @Mandatory @ParamName(ParameterConstants.PARAMETER_PLATEFORM_ID) final Integer plateformId, 
    82             @Mandatory @ParamName(ParameterConstants.PARAMETER_PARAMETER_ID) final Integer parameterId, 
    83             @ParamName(ParameterConstants.PARAMETER_DATE_BEGIN) final String dateBegin, 
    84             @ParamName(ParameterConstants.PARAMETER_DATE_END) final String dateEnd) 
    85             throws ServiceException, WebException, ParseException 
    86     { 
    87         final String pofBegin = "2009-07-13 13:00"; 
    88         final String pofEnd = "2009-07-13 14:00"; 
    89         final Date formatedDateBegin = DateHelper.parseDate(pofBegin, DateHelper.ENGLISH_DATE_PATTERN); 
    90         final Date formatedDateEnd = DateHelper.parseDate(pofEnd, DateHelper.ENGLISH_DATE_PATTERN); 
    91  
    92         final Plateforme plateform = _etherService.getPlateformById(plateformId); 
    93         final Parametre parameter = _etherService.getParameterById(parameterId); 
    94         final List<Data> values = _etherService.getValuesByPlateformByParameterByPeriod(plateformId, parameterId, formatedDateBegin, formatedDateEnd); 
    95  
    96         JPlotLayout layout =   createLayout(plateform.getPlateformeNom(), parameter.getParametreNom()); 
    97  
    98         return new JSONObject(); 
    99     } 
    100  
    101     private JPlotLayout createLayout(@Nullable final String plateformName, @Nullable final String parameterName) 
    102     { 
    103         final JFrame frame = new JFrame ("Frame principale"); 
    104         final JPanel panel = new JPanel(new BorderLayout()); 
    105  
    106         final JLabel jlbHelloWorld = new JLabel("Hello World"); 
    107         panel.add(jlbHelloWorld, BorderLayout.SOUTH); 
    108  
    109         final ImageIcon ic = new ImageIcon ("kerropi1.jpg"); 
    110         final JLabel jLabel = new JLabel (ic); 
    111         panel.add(jLabel, BorderLayout.EAST); 
    112  
    113         final JPlotLayout jPlotLayout = new JPlotLayout(false, false, false,"Trajectory data",null,false); 
    114         jPlotLayout.setTitles(plateformName, parameterName, "title3"); 
    115 //              jPlotLayout.setTitleHeightP(0.2, 0.2); 
    116         jPlotLayout.setVisible(true); 
    117         panel.add(jPlotLayout, BorderLayout.NORTH); 
    118  
    119         panel.setVisible(true); 
    120         frame.setContentPane(panel); 
    121  
    122         frame.setSize(700,550); 
    123         frame.setVisible(true); 
    124  
    125         return jPlotLayout; 
    126     } 
    127  
    128 //    @ControllerMethod(jsonResult = true) 
    129 //    public JSONObject searchDatasByPlateformByParameterByPeriod( 
    130 //              @Mandatory @ParamName(ParameterConstants.PARAMETER_PLATEFORM_ID) final Integer plateformId, 
    131 //              @Mandatory @ParamName(ParameterConstants.PARAMETER_PARAMETER_ID) final Integer parameterId, 
    132 //              @ParamName(ParameterConstants.PARAMETER_DATE_BEGIN) final String dateBegin, 
    133 //              @ParamName(ParameterConstants.PARAMETER_DATE_END) final String dateEnd) 
    134 //      throws ServiceException, WebException, ParseException 
    135 //    { 
    136 //      final long time1 = Calendar.getInstance().getTimeInMillis(); 
    137 //      LOGGER.error("Date Controller begin : "+Calendar.getInstance().getTime()); 
    138 ////            final Date formatedDateBegin = DateHelper.parseDate(dateBegin, DateHelper.ENGLISH_DATE_PATTERN_SHORT); 
    139 ////            final Date formatedDateEnd = DateHelper.parseDate(dateEnd, DateHelper.ENGLISH_DATE_PATTERN_SHORT); 
    140 // 
    141 //      final Date formatedDateBegin = null; 
    142 //      final Date formatedDateEnd = null; 
    143 // 
    144 //      final long time2 = Calendar.getInstance().getTimeInMillis(); 
    145 //      LOGGER.error("Date Controller before request : "+Calendar.getInstance().getTime()+", Duration : "+(time2-time1)); 
    146 //              final List<Data> values = _etherService.getValuesByPlateformByParameterByPeriod(plateformId, parameterId, formatedDateBegin, formatedDateEnd); 
    147 //      final long time3 = Calendar.getInstance().getTimeInMillis(); 
    148 //      LOGGER.error("Date Controller after request : "+Calendar.getInstance().getTime()+", Duration : "+(time3-time2)); 
    149 // 
    150 //      final JSONObject result = new JSONObject(); 
    151 //      result.put( ParameterConstants.PARAMETER_VALUES, values ); 
    152 //      final long time4 = Calendar.getInstance().getTimeInMillis(); 
    153 //      LOGGER.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); 
    154 //      LOGGER.error("Date Controller before return Result : "+Calendar.getInstance().getTime()+", Duration : "+(time4-time3)+", Total : "+(time4-time1)+", Taille : "+values.size()); 
    155 //      LOGGER.error("plateformId : "+plateformId+", parameterId : "+parameterId); 
    156 //      LOGGER.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); 
    157 //      return result; 
    158 //    } 
    159  
    160 //      private void createPlot() { 
    161 //              JPlotLayout layout_ = new JPlotLayout(false, false, false, 
    162 //                              "Trajectory data", null, false); 
    163 //              /* 
    164 //               * Batch changes to layout. 
    165 //               */ 
    166 //              layout_.setBatch(true); 
    167 //              /* 
    168 //               * Set the titles. 
    169 //               */ 
    170 //              layout_.setTitles( 
    171 //                              "Steller's Sea Lion Climate Research Profiling Floats", 
    172 //                              "Trajectories", ""); 
    173 //              /* 
    174 //               * Change the title sizes from the defaults. (0.25, 0.15) 
    175 //               */ 
    176 //              layout_.setTitleHeightP(0.2, 0.2); 
    177 //              /* 
    178 //               * Use a BorderLayout for the JFrame and and the JPlotLayout to the 
    179 //               * "Center". Pack the frame and make it visible. 
    180 //               */ 
    181 //              JFrame pif = new JFrame(); 
    182 //              pif.getContentPane().setLayout(new BorderLayout()); 
    183 //              pif.getContentPane().add(layout_, BorderLayout.CENTER); 
    184 //              pif.pack(); 
    185 //              pif.setVisible(true); 
    186 //              /* 
    187 //               * Read trajectory data from local file 
    188 //               */ 
    189 //              SGTData data = readTrajectory("service/implementation/com/ether/tutorial/data/trajectory"); 
    190 //              /* 
    191 //               * Add the trajectory data to the plot using the data title as the data 
    192 //               * description. The description is used in the LineKey. 
    193 //               */ 
    194 //              layout_.addData(data, data.getTitle()); 
    195 //              /* 
    196 //               * Read the North Pacific hi-resolution coastline and add it to the 
    197 //               * layout. Coastlines are handled differently by JPlotLayout. Coastlines 
    198 //               * are not used to compute the X and Y ranges and are always clipped to 
    199 //               * the axes. 
    200 //               */ 
    201 //              // SGTLine coastLine = getCoastLine("support/npac_hi_rez", 120000); 
    202 //              // layout_.setCoastLine(coastLine); 
    203 //              /* 
    204 //               * Turn batching off. All batched changes to the JPlotLayout will now be 
    205 //               * executed. 
    206 //               */ 
    207 //              layout_.setBatch(false); 
    208 //      } 
    209  
    21070    @Required 
    211     public void setEtherService(@NotNull final EtherService etherService) 
     71    public void setEtherService( @NotNull final EtherService etherService ) 
    21272    { 
    21373        _etherService = etherService; 
  • ether_megapoli/trunk/web/src/com/ether/ControllerPlot.java

    r119 r129  
    11package com.ether; 
    22 
    3 import com.ether.annotation.ControllerMethod; 
    4 import com.ether.annotation.Mandatory; 
    5 import com.ether.annotation.ParamName; 
    6 import com.medias.database.objects.Parametre; 
    7 import com.medias.database.objects.Plateforme; 
    8 import com.sun.org.apache.xml.internal.security.utils.Base64; 
    9 import gov.noaa.pmel.sgt.swing.JPlotLayout; 
    10 import net.sf.json.JSONObject; 
     3import com.medias.Context; 
     4import gov.noaa.pmel.sgt.dm.SGTMetaData; 
     5import gov.noaa.pmel.sgt.dm.SimpleLine; 
     6import gov.noaa.pmel.util.GeoDateArray; 
    117import org.apache.commons.logging.Log; 
    128import org.apache.commons.logging.LogFactory; 
    139import org.jetbrains.annotations.NotNull; 
    14 import org.jetbrains.annotations.Nullable; 
    15 import org.springframework.beans.factory.annotation.Required; 
    16 import org.springframework.web.servlet.ModelAndView; 
    17 import com.ether.tutorial.src.tutorial.Example1; 
     10import org.springframework.context.ApplicationContext; 
     11import org.springframework.web.context.support.WebApplicationContextUtils; 
    1812 
     13import javax.imageio.ImageIO; 
     14import javax.servlet.ServletConfig; 
     15import javax.servlet.ServletException; 
     16import javax.servlet.http.HttpServlet; 
    1917import javax.servlet.http.HttpServletRequest; 
    2018import javax.servlet.http.HttpServletResponse; 
    21 import javax.swing.*; 
    22 import java.awt.*; 
    23 import java.io.FileWriter; 
     19import java.awt.image.BufferedImage; 
    2420import java.io.IOException; 
    2521import java.text.ParseException; 
    2622import java.util.Date; 
    27 import java.util.HashMap; 
    2823import java.util.List; 
    29 import java.util.Map; 
    3024 
    3125/** 
    3226 * @author vmipsl 
    33  * @date 17 feb 2011 
     27 * @date 17 june 2011 
    3428 */ 
    35 public class Controller extends ControllerEther 
     29public class ControllerPlot 
     30        extends HttpServlet 
    3631{ 
    37     /** *********************************************************** **/ 
    38     /** *********************** VIEWS ***************************** **/ 
    39     /** *********************************************************** **/ 
    40     // Default view if methodName is unknown 
    41     public ModelAndView home(final HttpServletRequest request, final HttpServletResponse response) 
    42             throws WebException 
     32    public void init( final ServletConfig servletConfig ) 
     33            throws ServletException 
    4334    { 
    44         return new ModelAndView("index"); 
     35        try 
     36        { 
     37            final ApplicationContext appContext = WebApplicationContextUtils.getRequiredWebApplicationContext( servletConfig.getServletContext() ); 
     38            _etherService = (EtherService) appContext.getBean( "etherService", EtherService.class ); 
     39            _etherPlotService = (EtherPlotService) appContext.getBean( "etherPlotService", EtherPlotService.class ); 
     40        } 
     41        catch( Throwable tx ) 
     42        { 
     43            LOGGER.error( "Error initializing EtherService.", tx ); 
     44            throw new ServletException( "Error initializing EtherService.", tx ); 
     45        } 
    4546    } 
    4647 
    47     @ControllerMethod(view = VIEW_VISUALIZATION) 
    48     public Map<String, Object> view() 
    49             throws ServiceException 
     48    /** 
     49     * Creates an image with the plot and send it to the response 
     50     * Call by a jsp with <img src="visualization/plotEther?...."> 
     51     * 
     52     * @param request 
     53     * @param response 
     54     * @throws ServletException 
     55     */ 
     56    public void doGet( final HttpServletRequest request, final HttpServletResponse response ) 
     57            throws ServletException 
    5058    { 
    51         return new HashMap<String, Object>(); 
     59        try 
     60        { 
     61            final Integer plateformId = Integer.valueOf( request.getParameter( "plateformId" ) ); 
     62            final Integer parameterId = Integer.valueOf( request.getParameter( "parameterId" ) ); 
     63            final String dateBegin = request.getParameter( "dateBegin" ); 
     64            final String dateEnd = request.getParameter( "dateEnd" ); 
     65            final String pofBegin = "2009-07-13 13:00"; 
     66            final String pofEnd = "2009-07-14 14:00"; 
     67            final Date formatedDateBegin = DateHelper.parseDate( pofBegin, DateHelper.ENGLISH_DATE_PATTERN ); 
     68            final Date formatedDateEnd = DateHelper.parseDate( pofEnd, DateHelper.ENGLISH_DATE_PATTERN ); 
     69 
     70            //** ******************************************************************** **// 
     71            // TODO : replace List<Data> by List<value> and List<double> 
     72            //** ******************************************************************** **// 
     73            final List<Pair<Double, Date>> values = _etherService.getValuesByPlateformByParameterByPeriod( plateformId, parameterId, formatedDateBegin, formatedDateEnd ); 
     74            final double[] dataArray = extractDoubles( values ); 
     75            final Date[] dateValues = extractDates( values ); 
     76 
     77            final GeoDateArray dateArray = new GeoDateArray( dateValues ); 
     78            //** ******************************************************************** **// 
     79            //** ******************************************************************** **// 
     80 
     81 
     82            final SimpleLine data = new SimpleLine( dateArray, dataArray, "legend" ); 
     83            SGTMetaData meta = new SGTMetaData( "Longitude", "degrees East", false, false ); 
     84            data.setXMetaData( meta ); 
     85 
     86            meta = new SGTMetaData( "parameterName", "parameterUnit", false, false ); 
     87            data.setYMetaData( meta ); 
     88 
     89            final MegapoliPlot megapoliPlot = new MegapoliPlot(); 
     90            megapoliPlot.setTitle( "Mobilis LIDAR" ); 
     91            megapoliPlot.setData( data ); 
     92 
     93            final BufferedImage bufferedImage = _etherPlotService.createJPane( megapoliPlot, Context.getLocale( request ) ); 
     94 
     95            ImageIO.write( bufferedImage, "png", response.getOutputStream() ); 
     96        } 
     97        catch( IOException e ) 
     98        { 
     99            throw new ServletException( "Error : no possibity to write image in response", e ); 
     100        } 
     101        catch( ServiceException e ) 
     102        { 
     103            throw new ServletException( "Error : no possibility to extract data from base", e ); 
     104        } 
     105        catch( ParseException e ) 
     106        { 
     107            throw new ServletException( "Error : invalid dates, no parsing available", e ); 
     108        } 
    52109    } 
    53110 
    54     @ControllerMethod(view = VIEW_VISUALIZATION_PARAMETER_BY_PLATEFORM) 
    55     public Map<String, Object> viewParametersByPlateform() 
    56             throws ServiceException 
     111    // TODO : remove this code !! ultracrados ! 
     112    private double[] extractDoubles( @NotNull final List<Pair<Double, Date>> datas ) 
    57113    { 
    58         final List<Plateforme> plateforms = _etherService.getAllPlateforms(); 
    59  
    60         final Map<String, Object> model = new HashMap<String, Object>(); 
    61         model.put( "plateforms", getJsonHelper().toJSON(plateforms) ); 
    62         return model; 
     114        final double[] doubles = new double[datas.size()]; 
     115        int i = 0; 
     116        for( final Pair<Double, Date> data : datas ) 
     117        { 
     118            doubles[i] = data.getFirstValue().doubleValue(); 
     119            i++; 
     120        } 
     121        return doubles; 
    63122    } 
    64123 
    65     /** *********************************************************** **/ 
    66     /** *********************** CALLS ***************************** **/ 
    67     /** *********************************************************** **/ 
    68     @ControllerMethod(jsonResult = true) 
    69     public JSONObject searchParametersByPlateform(@Mandatory @ParamName(ParameterConstants.PARAMETER_ID) final Integer plateformId) 
    70             throws ServiceException, WebException 
     124    // TODO : remove this code !! ultracrados ! 
     125    private Date[] extractDates( @NotNull final List<Pair<Double, Date>> datas ) 
    71126    { 
    72         final List<Parametre> parametersByPlateform = _etherService.getParametersByPlateformId(plateformId); 
    73  
    74         final JSONObject result = new JSONObject(); 
    75         result.put( ParameterConstants.PARAMETER_PARAMETERS, getJsonHelper().toJSON(parametersByPlateform) ); 
    76         return result; 
     127        final Date[] dates = new Date[datas.size()]; 
     128        int i = 0; 
     129        for( final Pair<Double, Date> data : datas ) 
     130        { 
     131            dates[i] = data.getSecondValue(); 
     132            i++; 
     133        } 
     134        return dates; 
    77135    } 
    78136 
    79     @ControllerMethod(jsonResult = true) 
    80     public JSONObject searchDatasByPlateformByParameterByPeriod( 
    81             @Mandatory @ParamName(ParameterConstants.PARAMETER_PLATEFORM_ID) final Integer plateformId, 
    82             @Mandatory @ParamName(ParameterConstants.PARAMETER_PARAMETER_ID) final Integer parameterId, 
    83             @ParamName(ParameterConstants.PARAMETER_DATE_BEGIN) final String dateBegin, 
    84             @ParamName(ParameterConstants.PARAMETER_DATE_END) final String dateEnd) 
    85             throws ServiceException, WebException, ParseException 
    86     { 
    87         final String pofBegin = "2009-07-13 13:00"; 
    88         final String pofEnd = "2009-07-13 14:00"; 
    89         final Date formatedDateBegin = DateHelper.parseDate(pofBegin, DateHelper.ENGLISH_DATE_PATTERN); 
    90         final Date formatedDateEnd = DateHelper.parseDate(pofEnd, DateHelper.ENGLISH_DATE_PATTERN); 
     137    private static final Log LOGGER = LogFactory.getLog( ControllerPlot.class ); 
    91138 
    92         final Plateforme plateform = _etherService.getPlateformById(plateformId); 
    93         final Parametre parameter = _etherService.getParameterById(parameterId); 
    94         final List<Data> values = _etherService.getValuesByPlateformByParameterByPeriod(plateformId, parameterId, formatedDateBegin, formatedDateEnd); 
    95  
    96         JPlotLayout layout =   createLayout(plateform.getPlateformeNom(), parameter.getParametreNom()); 
    97  
    98         return new JSONObject(); 
    99     } 
    100  
    101     private JPlotLayout createLayout(@Nullable final String plateformName, @Nullable final String parameterName) 
    102     { 
    103         final JFrame frame = new JFrame ("Frame principale"); 
    104         final JPanel panel = new JPanel(new BorderLayout()); 
    105  
    106         final JLabel jlbHelloWorld = new JLabel("Hello World"); 
    107         panel.add(jlbHelloWorld, BorderLayout.SOUTH); 
    108  
    109         final ImageIcon ic = new ImageIcon ("kerropi1.jpg"); 
    110         final JLabel jLabel = new JLabel (ic); 
    111         panel.add(jLabel, BorderLayout.EAST); 
    112  
    113         final JPlotLayout jPlotLayout = new JPlotLayout(false, false, false,"Trajectory data",null,false); 
    114         jPlotLayout.setTitles(plateformName, parameterName, "title3"); 
    115 //              jPlotLayout.setTitleHeightP(0.2, 0.2); 
    116         jPlotLayout.setVisible(true); 
    117         panel.add(jPlotLayout, BorderLayout.NORTH); 
    118  
    119         panel.setVisible(true); 
    120         frame.setContentPane(panel); 
    121  
    122         frame.setSize(700,550); 
    123         frame.setVisible(true); 
    124  
    125         return jPlotLayout; 
    126     } 
    127  
    128 //    @ControllerMethod(jsonResult = true) 
    129 //    public JSONObject searchDatasByPlateformByParameterByPeriod( 
    130 //              @Mandatory @ParamName(ParameterConstants.PARAMETER_PLATEFORM_ID) final Integer plateformId, 
    131 //              @Mandatory @ParamName(ParameterConstants.PARAMETER_PARAMETER_ID) final Integer parameterId, 
    132 //              @ParamName(ParameterConstants.PARAMETER_DATE_BEGIN) final String dateBegin, 
    133 //              @ParamName(ParameterConstants.PARAMETER_DATE_END) final String dateEnd) 
    134 //      throws ServiceException, WebException, ParseException 
    135 //    { 
    136 //      final long time1 = Calendar.getInstance().getTimeInMillis(); 
    137 //      LOGGER.error("Date Controller begin : "+Calendar.getInstance().getTime()); 
    138 ////            final Date formatedDateBegin = DateHelper.parseDate(dateBegin, DateHelper.ENGLISH_DATE_PATTERN_SHORT); 
    139 ////            final Date formatedDateEnd = DateHelper.parseDate(dateEnd, DateHelper.ENGLISH_DATE_PATTERN_SHORT); 
    140 // 
    141 //      final Date formatedDateBegin = null; 
    142 //      final Date formatedDateEnd = null; 
    143 // 
    144 //      final long time2 = Calendar.getInstance().getTimeInMillis(); 
    145 //      LOGGER.error("Date Controller before request : "+Calendar.getInstance().getTime()+", Duration : "+(time2-time1)); 
    146 //              final List<Data> values = _etherService.getValuesByPlateformByParameterByPeriod(plateformId, parameterId, formatedDateBegin, formatedDateEnd); 
    147 //      final long time3 = Calendar.getInstance().getTimeInMillis(); 
    148 //      LOGGER.error("Date Controller after request : "+Calendar.getInstance().getTime()+", Duration : "+(time3-time2)); 
    149 // 
    150 //      final JSONObject result = new JSONObject(); 
    151 //      result.put( ParameterConstants.PARAMETER_VALUES, values ); 
    152 //      final long time4 = Calendar.getInstance().getTimeInMillis(); 
    153 //      LOGGER.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); 
    154 //      LOGGER.error("Date Controller before return Result : "+Calendar.getInstance().getTime()+", Duration : "+(time4-time3)+", Total : "+(time4-time1)+", Taille : "+values.size()); 
    155 //      LOGGER.error("plateformId : "+plateformId+", parameterId : "+parameterId); 
    156 //      LOGGER.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); 
    157 //      return result; 
    158 //    } 
    159  
    160 //      private void createPlot() { 
    161 //              JPlotLayout layout_ = new JPlotLayout(false, false, false, 
    162 //                              "Trajectory data", null, false); 
    163 //              /* 
    164 //               * Batch changes to layout. 
    165 //               */ 
    166 //              layout_.setBatch(true); 
    167 //              /* 
    168 //               * Set the titles. 
    169 //               */ 
    170 //              layout_.setTitles( 
    171 //                              "Steller's Sea Lion Climate Research Profiling Floats", 
    172 //                              "Trajectories", ""); 
    173 //              /* 
    174 //               * Change the title sizes from the defaults. (0.25, 0.15) 
    175 //               */ 
    176 //              layout_.setTitleHeightP(0.2, 0.2); 
    177 //              /* 
    178 //               * Use a BorderLayout for the JFrame and and the JPlotLayout to the 
    179 //               * "Center". Pack the frame and make it visible. 
    180 //               */ 
    181 //              JFrame pif = new JFrame(); 
    182 //              pif.getContentPane().setLayout(new BorderLayout()); 
    183 //              pif.getContentPane().add(layout_, BorderLayout.CENTER); 
    184 //              pif.pack(); 
    185 //              pif.setVisible(true); 
    186 //              /* 
    187 //               * Read trajectory data from local file 
    188 //               */ 
    189 //              SGTData data = readTrajectory("service/implementation/com/ether/tutorial/data/trajectory"); 
    190 //              /* 
    191 //               * Add the trajectory data to the plot using the data title as the data 
    192 //               * description. The description is used in the LineKey. 
    193 //               */ 
    194 //              layout_.addData(data, data.getTitle()); 
    195 //              /* 
    196 //               * Read the North Pacific hi-resolution coastline and add it to the 
    197 //               * layout. Coastlines are handled differently by JPlotLayout. Coastlines 
    198 //               * are not used to compute the X and Y ranges and are always clipped to 
    199 //               * the axes. 
    200 //               */ 
    201 //              // SGTLine coastLine = getCoastLine("support/npac_hi_rez", 120000); 
    202 //              // layout_.setCoastLine(coastLine); 
    203 //              /* 
    204 //               * Turn batching off. All batched changes to the JPlotLayout will now be 
    205 //               * executed. 
    206 //               */ 
    207 //              layout_.setBatch(false); 
    208 //      } 
    209  
    210     @Required 
    211     public void setEtherService(@NotNull final EtherService etherService) 
    212     { 
    213         _etherService = etherService; 
    214     } 
    215  
    216     private static final Log LOGGER = LogFactory.getLog( Controller.class ); 
    217  
    218     private static final String VIEW_VISUALIZATION = "visualization/visu"; 
    219     private static final String VIEW_VISUALIZATION_PARAMETER_BY_PLATEFORM = "visualization/visu_parameter_by_pf"; 
     139    // Dimensions of the jPanes 
     140    private static final int MAIN_WIDTH = 1000; 
     141    private static final int MAIN_HEIGHT = 1000; 
    220142 
    221143    private EtherService _etherService; 
     144    private EtherPlotService _etherPlotService; 
     145 
    222146} 
  • ether_megapoli/trunk/web/visualization/visu_parameter_by_pf-script.jsp

    r89 r129  
    11<script type="text/javascript"> 
    2 var InterfaceVisualization = Class.create({ 
    3          
     2var InterfaceVisualization = Class.create( { 
     3 
    44    initialize: function( jsonPlateforms ) 
    55    { 
    66        // Values 
    7         this.parent  = $("txt"); 
    8         this.superParent = $("pageContent"); // need to resize in function of containerParameters 
    9         this.generalContainerPlateforms = $("generalContainerPlateforms"); 
    10         this.generalContainerParameters = $("generalContainerParameters"); 
    11         this.generalContainerCalendar = $("generalContainerCalendar"); 
     7        this.parent = $( "txt" ); 
     8        this.superParent = $( "pageContent" ); // need to resize in function of containerParameters 
     9        this.generalContainerPlateforms = $( "generalContainerPlateforms" ); 
     10        this.generalContainerParameters = $( "generalContainerParameters" ); 
     11        this.generalContainerCalendar = $( "generalContainerCalendar" ); 
    1212        this.jsonPlateforms = jsonPlateforms || null; 
    13                 this.selectedPlateform = false; 
    14                 this.selectedParameter = false; 
    15                 this.beginDate = false; 
    16                 this.endDate = false; 
    17                 this.notice = Dom.getContainer("notice"); 
    18  
    19                 /** *********** CONTAINERS *********** **/ 
    20         // Create container for plateforms 
    21         this.containerPlateforms = Dom.getContainer("containerPlateforms"); 
    22                 this.containerParameters = Dom.getContainer("containerParameters"); 
    23                 this.containerButtons = Dom.getContainer("containerButtons"); 
    24                  
    25                 /** *********** LOADING *********** **/ 
     13        this.selectedPlateform = false; 
     14        this.selectedParameter = false; 
     15        this.beginDate = false; 
     16        this.endDate = false; 
     17        this.notice = Dom.getContainer( "notice" ); 
     18 
     19        /** *********** CONTAINERS *********** **/ 
     20        // Create container for plateforms 
     21        this.containerPlateforms = Dom.getContainer( "containerPlateforms" ); 
     22        this.containerParameters = Dom.getContainer( "containerParameters" ); 
     23        this.containerButtons = Dom.getContainer( "containerButtons" ); 
     24 
     25        /** *********** LOADING *********** **/ 
    2626        // Create loading object for plateforms 
    2727        var param = new Object(); 
    2828        param.id = "loadingForPlateforms"; 
    2929        param.parent = this.containerPlateforms; 
    30         this.loadingPlateforms = new Loading(param); 
     30        this.loadingPlateforms = new Loading( param ); 
    3131        this.loadingPlateforms.display(); 
    3232 
     
    3535        param.id = "loadingForParameters"; 
    3636        param.parent = this.containerParameters; 
    37         this.loadingParameters = new Loading(param); 
    38         this.loadingParameters.display();         
    39  
    40                 /** *********** BUTTONS *********** **/ 
    41         this.visualizeButton = new Button({value:interfaceTexts["data.visualization.button.visualize"], parent:this.containerButtons, id:"button_visualize", onClick:this.onClickVisualize.bind(this)}); 
    42         this.visualizeButton.disable(); 
    43         this.downloadButton = new Button({value:interfaceTexts["data.visualization.button.download"], parent:this.containerButtons, id:"button_download", onClick:this.onClickDownload.bind(this)}); 
     37        this.loadingParameters = new Loading( param ); 
     38        this.loadingParameters.display(); 
     39 
     40        /** *********** BUTTONS *********** **/ 
     41        this.visualizeButton = new Button( {value:interfaceTexts["data.visualization.button.visualize"], parent:this.containerButtons, id:"button_visualize", onClick:this.onClickVisualize.bind( this )} ); 
     42        this.visualizeButton.enable(); 
     43        this.downloadButton = new Button( {value:interfaceTexts["data.visualization.button.download"], parent:this.containerButtons, id:"button_download", onClick:this.onClickDownload.bind( this )} ); 
    4444        this.downloadButton.disable(); 
    45          
     45 
     46 
     47        /** *********** WINDOW FOR THE PLOT *********** **/ 
     48        this.plotWindow = new Window( {className: "dialog", zIndex: 100, 
     49            resizable: true, draggable:true, wiredDrag: true, 
     50            showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff } ); 
     51        this.plotWindow.setTitle( interfaceTexts["app.title"] + "-" + interfaceTexts["data.visualization.quicklook"] ); 
     52 
     53 
    4654        this.createCalendar(); 
    4755        this.displayPlateforms(); 
    4856    }, 
    49      
     57 
    5058    // REQUESTS ******************************************************** 
    51         requestParametersByPlateform: function() 
    52     { 
    53         if(this.selectedPlateform) 
    54                         new Ajax.Request("visualization?methodName=searchParametersByPlateform&id=" + this.selectedPlateform.getId(), 
    55                 { 
    56                     onSuccess:this.handleParametersBySelectedPlateform.bind(this) 
    57                 }); 
    58     }, 
    59  
    60         requestValuesByPlateformByParameterByPeriod: function() 
    61     { 
    62         if(this.selectedPlateform) 
    63                         new Ajax.Request("visualization?methodName=searchDatasByPlateformByParameterByPeriod" + 
    64                                         "&plateformId=" + this.selectedPlateform.getId() +  
    65                                         "&parameterId=" + this.selectedParameter.getId() + 
    66                                         "&dateBegin=" + this.beginDate + 
    67                                         "&dateEnd=" + this.endDate, 
    68                 { 
    69                     onSuccess:this.handleValuesByPlateformByParameterByPeriod.bind(this) 
    70                 }); 
     59    requestParametersByPlateform: function() 
     60    { 
     61        if( this.selectedPlateform ) 
     62            new Ajax.Request( "visualization?methodName=searchParametersByPlateform&id=" + this.selectedPlateform.getId(), 
     63            { 
     64                onSuccess:this.handleParametersBySelectedPlateform.bind( this ) 
     65            } ); 
    7166    }, 
    7267 
     
    7772        this.displayParameters(); 
    7873    }, 
    79      
     74 
    8075    handleValuesByPlateformByParameterByPeriod: function( result ) 
    8176    { 
    8277//              this.notice.style.visibility = "hidden";         
    8378 
    84         this.jsonValues = result.responseText.evalJSON().values; 
    85         alert("values : "+this.jsonValues.size()); 
     79        this.jsonEncodedImage = result.responseText.evalJSON().encodedImage; 
     80 
     81 
    8682    }, 
    8783 
     
    8985    createCalendar: function() 
    9086    { 
    91             // Embedded Calendar 
    92                 this.calendar = Calendar.setup( 
    93         { 
    94                 dateField: 'embeddedDateField', 
    95             endDateField: 'embeddedEndDateField', 
    96             parentElement: 'embeddedCalendar', 
    97             clickToDateField: true, 
    98             selectHandler: this.onClickCalendar.bind(this) 
    99                 }) 
    100     }, 
    101      
     87        // Embedded Calendar 
     88        this.calendar = Calendar.setup( 
     89        { 
     90            dateField: 'embeddedDateField', 
     91            endDateField: 'embeddedEndDateField', 
     92            parentElement: 'embeddedCalendar', 
     93            clickToDateField: true, 
     94            selectHandler: this.onClickCalendar.bind( this ) 
     95        } ) 
     96    }, 
     97 
    10298    displayPlateforms: function() 
    10399    { 
    104         this.plateforms = new ListPlatforms(this.jsonPlateforms, new Object()); 
    105  
    106         this.plateforms.addOpenListener(this.onSelectPlateform.bind(this)); 
     100        this.plateforms = new ListPlatforms( this.jsonPlateforms, new Object() ); 
     101 
     102        this.plateforms.addOpenListener( this.onSelectPlateform.bind( this ) ); 
    107103        this.loadingPlateforms.hide(); 
    108         this.plateforms.displayWithPairImpair(this.containerPlateforms, "NoPlateform", interfaceTexts["data.visualization.noPlateform"]); 
    109                          
     104        this.plateforms.displayWithPairImpair( this.containerPlateforms, "NoPlateform", interfaceTexts["data.visualization.noPlateform"] ); 
     105 
    110106        // Select the first plateform by default 
    111107        if( this.jsonPlateforms && this.jsonPlateforms[0] ) 
    112108        { 
    113             var plateformToSelect = this.plateforms.getItemById(this.jsonPlateforms[0].id); 
    114             this.onSelectPlateform(plateformToSelect.divItem); 
    115             this.selectedPlateform = plateformToSelect.divItem;             
     109            var plateformToSelect = this.plateforms.getItemById( this.jsonPlateforms[0].id ); 
     110            this.onSelectPlateform( plateformToSelect.divItem ); 
     111            this.selectedPlateform = plateformToSelect.divItem; 
    116112        } 
    117113    }, 
     
    119115    displayParameters: function() 
    120116    { 
    121         this.parameters = new ListParameters(this.jsonParameters, new Object()); 
    122          
    123                 this.parameters.addOpenListener(this.onSelectParameter.bind(this)); 
     117        this.parameters = new ListParameters( this.jsonParameters, new Object() ); 
     118 
     119        this.parameters.addOpenListener( this.onSelectParameter.bind( this ) ); 
    124120        this.loadingParameters.hide(); 
    125         this.parameters.displayWithPairImpair(this.containerParameters, "NoParameter", interfaceTexts["data.visualization.noParameter"]); 
    126          
     121        this.parameters.displayWithPairImpair( this.containerParameters, "NoParameter", interfaceTexts["data.visualization.noParameter"] ); 
     122 
    127123        this.resizeContainers(); 
    128124    }, 
    129      
     125 
    130126    // EVENTS ******************************************************** 
    131127    onSelectPlateform: function( objPlateform ) 
     
    136132        // Unselect old plateform 
    137133        if( this.selectedPlateform ) 
    138                 this.selectedPlateform.unselect(); 
     134            this.selectedPlateform.unselect(); 
    139135 
    140136        this.selectedPlateform = objPlateform; 
     
    143139        // Unselect old parameter 
    144140        if( this.selectedParameter ) 
    145                 this.selectedParameter = false; 
    146          
    147                 this.requestParametersByPlateform();         
    148                 this.testAllFields(); 
    149     }, 
    150      
     141            this.selectedParameter = false; 
     142 
     143        this.requestParametersByPlateform(); 
     144        this.testAllFields(); 
     145    }, 
     146 
    151147    onSelectParameter: function( objParameter ) 
    152148    { 
     
    156152        // Unselect old parameter 
    157153        if( this.selectedParameter ) 
    158                 this.selectedParameter.unselect(); 
     154            this.selectedParameter.unselect(); 
    159155 
    160156        this.selectedParameter = objParameter; 
     
    162158        this.testAllFields(); 
    163159    }, 
    164      
    165     onClickCalendar: function(calendar) 
    166     { 
    167                 if (!calendar.dateField) return false 
    168  
    169                 if(calendar.clickToDateField) 
    170                 { 
    171                         Element.update(calendar.dateField, calendar.date.print(calendar.dateFormat)) 
    172                         this.beginDate = calendar.date.print(calendar.dateFormat); 
    173                 } else { 
    174                         Element.update(calendar.endDateField, calendar.date.print(calendar.dateFormat)) 
    175                         this.endDate = calendar.date.print(calendar.dateFormat); 
    176                 } 
    177                 calendar.setClickToDateField(!calendar.clickToDateField); 
    178                 this.testCalendarPeriod(calendar.dateField.innerHTML,calendar.endDateField.innerHTML); 
    179  
    180                 // Call the close handler, if necessary 
    181                 if (calendar.shouldClose) calendar.callCloseHandler() 
     160 
     161    onClickCalendar: function( calendar ) 
     162    { 
     163        if( !calendar.dateField ) return false 
     164 
     165        if( calendar.clickToDateField ) 
     166        { 
     167            Element.update( calendar.dateField, calendar.date.print( calendar.dateFormat ) ) 
     168            this.beginDate = calendar.date.print( calendar.dateFormat ); 
     169        } 
     170        else 
     171        { 
     172            Element.update( calendar.endDateField, calendar.date.print( calendar.dateFormat ) ) 
     173            this.endDate = calendar.date.print( calendar.dateFormat ); 
     174        } 
     175        calendar.setClickToDateField( !calendar.clickToDateField ); 
     176        this.testCalendarPeriod( calendar.dateField.innerHTML, calendar.endDateField.innerHTML ); 
     177 
     178        // Call the close handler, if necessary 
     179        if( calendar.shouldClose ) calendar.callCloseHandler() 
    182180    }, 
    183181 
    184182    onClickVisualize: function() 
    185183    { 
    186         this.displayLoading(); 
    187                 this.requestValuesByPlateformByParameterByPeriod(); 
     184//        var url = "visualization/plotEther?plateformId=" + this.selectedPlateform.getId() 
     185//                + "&parameterId=" + this.selectedParameter.getId() 
     186//                + "&dateBegin=" + this.beginDate 
     187//                + "&dateEnd=" + this.endDate; 
     188        var url = "visualization/plotEther?plateformId=33" 
     189                + "&parameterId=10" 
     190                + "&dateBegin=" + this.beginDate 
     191                + "&dateEnd=" + this.endDate; 
     192 
     193        this.plotWindow.getContent().innerHTML = '<img src=' + url + '/>'; 
     194        this.plotWindow.height = this.plotWindow.getContent().firstChild.height; 
     195        this.plotWindow.width = this.plotWindow.getContent().firstChild.width; 
     196        this.plotWindow.show(); 
    188197    }, 
    189198 
    190199    onClickDownload: function() 
    191200    { 
    192         if(this.testAllFields()) 
    193                 alert("ok"); 
    194         else 
    195                 alert("non ok"); 
     201        if( this.testAllFields() ) 
     202            alert( "ok" ); 
     203        else 
     204            alert( "non ok" ); 
    196205    }, 
    197206 
     
    199208    resizeContainers: function() 
    200209    { 
    201         var titleSize = 85; 
    202                 var parentHeight = this.superParent.offsetHeight - titleSize; 
    203         var containerPlateformsHeight = this.generalContainerParameters.offsetHeight; 
    204         var containerParametersHeight = this.generalContainerParameters.offsetHeight; 
    205                  
    206         var containerPlateforms = this.containerPlateforms.offsetHeight; 
    207         var containerParameters = this.containerParameters.offsetHeight; 
    208         var containerCalendarHeight = this.generalContainerCalendar.offsetHeight; 
    209          
    210         var maxHeight = Math.max(containerPlateforms, containerParameters, containerCalendarHeight); 
    211  
    212          
    213         if(maxHeight > parentHeight) 
    214         { 
    215                 this.superParent.style.height = maxHeight + 110 + "px"; 
    216                 this.generalContainerPlateforms.style.height = maxHeight + 10 + "px"; 
    217                 this.generalContainerParameters.style.height = maxHeight + 10 + "px"; 
    218         } else if(maxHeight == containerCalendarHeight) { 
    219                 this.superParent.style.height = containerCalendarHeight + titleSize + 25 + "px"; 
    220                 this.generalContainerPlateforms.style.height = containerCalendarHeight + "px"; 
    221                 this.generalContainerParameters.style.height = containerCalendarHeight + "px"; 
    222         } 
    223     }, 
    224      
    225         testCalendarPeriod: function(beginDate, endDate) 
    226         {        
    227                 if(!beginDate || !endDate) 
    228                         return false; 
    229  
    230                 var matchFormat = /^(\d{4})-(\d{2})-(\d{2})$/i; 
    231                 var testBeginDate = beginDate.match(matchFormat); 
    232                 var testEndDate = endDate.match(matchFormat); 
    233                 if(!testEndDate || !testEndDate) 
    234                         return; 
    235  
    236                 this.resizeContainers(); 
    237  
    238                 var datesOk = beginDate <= endDate;  
    239                 if(!datesOk) 
    240                         this.displayNotice(); 
    241                 else 
    242                         this.hideNotice(); 
    243                  
    244                 if(!datesOk || !this.selectedPlateform || !this.selectedParameter){ 
    245                         this.visualizeButton.disable(); 
    246                         this.downloadButton.disable(); 
    247                         return false; 
    248                 } else { 
    249                         this.visualizeButton.enable(); 
    250                 this.downloadButton.enable(); 
    251                 return true; 
    252                 } 
    253         }, 
    254          
    255         testAllFields: function() 
    256         { 
    257                 if(!this.selectedPlateform || !this.selectedParameter || !this.beginDate || !this.endDate) 
    258                 { 
    259                         this.visualizeButton.disable(); 
    260                         this.downloadButton.disable(); 
    261                 } 
    262  
    263                 return this.testCalendarPeriod(this.beginDate, this.endDate); 
    264         }, 
    265          
    266         displayNotice: function() 
    267         { 
    268                 this.notice.innerHTML = "&nbsp"; 
    269         this.notice.removeClassName("loading"); 
    270                 this.notice.addClassName("error"); 
    271                 this.notice.innerHTML = interfaceTexts["data.visualization.Unvalid_Period"]; 
    272                 this.notice.style.visibility = "visible"; 
    273         }, 
    274          
    275         hideNotice: function() 
    276         { 
    277                 this.notice.innerHTML = "&nbsp"; 
    278                 this.notice.style.visibility = "hidden"; 
    279         }, 
    280          
    281         displayLoading: function() 
    282         { 
    283                 this.notice.innerHTML = "&nbsp"; 
    284         this.notice.removeClassName("error"); 
    285                 this.notice.style.visibility = "visible";        
    286         this.notice.addClassName("loading"); 
    287         var image = new Element('img', {src: 'resources/icons/loading_datas.gif'}); 
    288         this.notice.appendChild(image); 
    289         }, 
    290          
    291         hideLoading: function() 
    292         { 
    293                 this.notice.innerHTML = "&nbsp"; 
    294         } 
    295 }); 
     210        var titleSize = 85; 
     211        var parentHeight = this.superParent.offsetHeight - titleSize; 
     212        var containerPlateformsHeight = this.generalContainerParameters.offsetHeight; 
     213        var containerParametersHeight = this.generalContainerParameters.offsetHeight; 
     214 
     215        var containerPlateforms = this.containerPlateforms.offsetHeight; 
     216        var containerParameters = this.containerParameters.offsetHeight; 
     217        var containerCalendarHeight = this.generalContainerCalendar.offsetHeight; 
     218 
     219        var maxHeight = Math.max( containerPlateforms, containerParameters, containerCalendarHeight ); 
     220 
     221 
     222        if( maxHeight > parentHeight ) 
     223        { 
     224            this.superParent.style.height = maxHeight + 110 + "px"; 
     225            this.generalContainerPlateforms.style.height = maxHeight + 10 + "px"; 
     226            this.generalContainerParameters.style.height = maxHeight + 10 + "px"; 
     227        } else if( maxHeight == containerCalendarHeight ) 
     228        { 
     229            this.superParent.style.height = containerCalendarHeight + titleSize + 25 + "px"; 
     230            this.generalContainerPlateforms.style.height = containerCalendarHeight + "px"; 
     231            this.generalContainerParameters.style.height = containerCalendarHeight + "px"; 
     232        } 
     233    }, 
     234 
     235    testCalendarPeriod: function( beginDate, endDate ) 
     236    { 
     237        if( !beginDate || !endDate ) 
     238            return false; 
     239 
     240        var matchFormat = /^(\d{4})-(\d{2})-(\d{2})$/i; 
     241        var testBeginDate = beginDate.match( matchFormat ); 
     242        var testEndDate = endDate.match( matchFormat ); 
     243        if( !testEndDate || !testEndDate ) 
     244            return; 
     245 
     246        this.resizeContainers(); 
     247 
     248        var datesOk = beginDate <= endDate; 
     249        if( !datesOk ) 
     250            this.displayNotice(); 
     251        else 
     252            this.hideNotice(); 
     253 
     254        if( !datesOk || !this.selectedPlateform || !this.selectedParameter ) 
     255        { 
     256            this.visualizeButton.disable(); 
     257            this.downloadButton.disable(); 
     258            return false; 
     259        } 
     260        else 
     261        { 
     262            this.visualizeButton.enable(); 
     263            this.downloadButton.enable(); 
     264            return true; 
     265        } 
     266    }, 
     267 
     268    testAllFields: function() 
     269    { 
     270        return true; 
     271 
     272        if( !this.selectedPlateform || !this.selectedParameter || !this.beginDate || !this.endDate ) 
     273        { 
     274            this.visualizeButton.disable(); 
     275            this.downloadButton.disable(); 
     276        } 
     277 
     278        return this.testCalendarPeriod( this.beginDate, this.endDate ); 
     279    }, 
     280 
     281    displayNotice: function() 
     282    { 
     283        this.notice.innerHTML = "&nbsp"; 
     284        this.notice.removeClassName( "loading" ); 
     285        this.notice.addClassName( "error" ); 
     286        this.notice.innerHTML = interfaceTexts["data.visualization.Unvalid_Period"]; 
     287        this.notice.style.visibility = "visible"; 
     288    }, 
     289 
     290    hideNotice: function() 
     291    { 
     292        this.notice.innerHTML = "&nbsp"; 
     293        this.notice.style.visibility = "hidden"; 
     294    }, 
     295 
     296    displayLoading: function() 
     297    { 
     298        this.notice.innerHTML = "&nbsp"; 
     299        this.notice.removeClassName( "error" ); 
     300        this.notice.style.visibility = "visible"; 
     301        this.notice.addClassName( "loading" ); 
     302        var image = new Element( 'img', {src: 'resources/icons/loading_datas.gif'} ); 
     303        this.notice.appendChild( image ); 
     304    }, 
     305 
     306    hideLoading: function() 
     307    { 
     308        this.notice.innerHTML = "&nbsp"; 
     309    } 
     310} ); 
    296311 
    297312</script> 
  • ether_megapoli/trunk/web/visualization/visu_parameter_by_pf.jsp

    r89 r129  
    11<!-- /*** ****************** VISU ******************** **/ --> 
    2 <%@ page import="com.medias.Context"%> 
     2<%@ page import="com.medias.Context" %> 
    33 
    4 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 
    5 <%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles"%> 
    6 <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean"%> 
    7 <%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html"%> 
     4<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> 
     5<%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %> 
     6<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %> 
     7<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %> 
    88<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
    99<%@ taglib prefix="ether" tagdir="/WEB-INF/tags" %> 
     
    1111<tiles:insert page="/resources/templates/templateEther.jsp" flush="true"> 
    1212 
    13         <tiles:put name="title" type="string"> 
    14                 <bean:message key="app.title" /> - <bean:message key="app.welcome" /> 
    15         </tiles:put> 
     13    <tiles:put name="title" type="string"> 
     14        <bean:message key="app.title"/> - <bean:message key="app.welcome"/> 
     15    </tiles:put> 
    1616 
    17         <tiles:put name="insertCss" type="string"> 
    18                 <ether:htmlCss cssFile="calendarview-1.2/calendarview"/> 
    19                 <ether:htmlCss cssFile="visu_parameter_by_pf"/> 
    20         </tiles:put> 
     17    <tiles:put name="insertCss" type="string"> 
     18        <ether:htmlCss cssFile="calendarview-1.2/calendarview"/> 
     19        <ether:htmlCss cssFile="visu_parameter_by_pf"/> 
     20        <ether:htmlCss cssFile="windows_js_1.3/themes/default"/> 
     21        <ether:htmlCss cssFile="windows_js_1.3/themes/mac_os_x"/> 
     22    </tiles:put> 
    2123 
    22         <tiles:put name="insertJsOrJsp" type="string"> 
    23                 <ether:htmlResourceJsp jspFile="etherHead"/> 
    24                 <ether:htmlJsp jspFile="visu_parameter_by_pf-script"/> 
    25                 <ether:htmlJsp jspFile="visu_parameter_by_pf-classes"/> 
    26                 <ether:htmlJs jsFile="Button"/>          
    27                 <ether:htmlJs jsFile="calendarview-1.2/javascripts/calendarview"/>               
    28         </tiles:put> 
    29          
    30         <bean:define type="java.lang.String" id="relativePath" value="<%=Context.getRelativePath(request)%>" /> 
    31         <tiles:put name="nav" value=''/> 
     24    <tiles:put name="insertJsOrJsp" type="string"> 
     25        <ether:htmlResourceJsp jspFile="etherHead"/> 
     26        <ether:htmlJsp jspFile="visu_parameter_by_pf-script"/> 
     27        <ether:htmlJsp jspFile="visu_parameter_by_pf-classes"/> 
     28        <ether:htmlJs jsFile="Button"/> 
     29        <ether:htmlJs jsFile="calendarview-1.2/javascripts/calendarview"/> 
     30 
     31        <ether:htmlJs jsFile="library/windows_js_1.3/javascripts/debug"/> 
     32        <ether:htmlJs jsFile="library/windows_js_1.3/javascripts/effects"/> 
     33        <ether:htmlJs jsFile="library/windows_js_1.3/javascripts/window"/> 
     34        <ether:htmlJs jsFile="library/windows_js_1.3/javascripts/window_ext"/> 
     35    </tiles:put> 
     36 
     37    <bean:define type="java.lang.String" id="relativePath" value="<%=Context.getRelativePath(request)%>"/> 
     38    <tiles:put name="nav" value=''/> 
    3239 
    3340 
    34         <tiles:put name="bodytitle" type="string"> 
    35                 <bean:message key="data.visualization.parameter_pf.title" /> 
    36         </tiles:put> 
    37          
     41    <tiles:put name="bodytitle" type="string"> 
     42        <bean:message key="data.visualization.parameter_pf.title"/> 
     43    </tiles:put> 
    3844 
    39         <tiles:put name="body" type="string"> 
    40          
    41     <div class="span-24"> 
    42                 <div id="generalContainerPlateforms" class="span-7 colborder"> 
    43                 <div id="messages"><bean:message key="data.visualization.selectPf"/></div> 
    4445 
    45                                 <div id="containerPlateforms"></div> 
    46                 </div> 
     46    <tiles:put name="body" type="string"> 
    4747 
    48         <div id="generalContainerParameters" class="span-7 colborder">         
    49             <div id="messages"><bean:message key="data.visualization.selectParameter"/></div> 
    50              
    51                         <div id="containerParameters"></div>             
     48        <div class="span-24"> 
     49            <div id="generalContainerPlateforms" class="span-7 colborder"> 
     50                <div id="messages"><bean:message key="data.visualization.selectPf"/></div> 
     51 
     52                <div id="containerPlateforms"></div> 
     53            </div> 
     54 
     55            <div id="generalContainerParameters" class="span-7 colborder"> 
     56                <div id="messages"><bean:message key="data.visualization.selectParameter"/></div> 
     57 
     58                <div id="containerParameters"></div> 
     59            </div> 
     60 
     61            <div id="generalContainerCalendar" class="span-9 last"> 
     62                <div id="messages"><bean:message key="data.visualization.selectTime"/></div> 
     63                <div id="embeddedCalendar" class="embeddedCalendar"></div> 
     64 
     65                <div class="dateField leftField"><bean:message key="data.visualization.BeginDate"/></div> 
     66                <div id="embeddedDateField" class="dateField rightField"><bean:message 
     67                        key="data.visualization.selectDate"/></div> 
     68                <div class="dateField leftField"><bean:message key="data.visualization.EndDate"/></div> 
     69                <div id="embeddedEndDateField" class="dateField rightField"><bean:message 
     70                        key="data.visualization.selectDate"/></div> 
     71 
     72                <div class="errorAndButtons"> 
     73                    <div id="notice" style="visibility:hidden" class="error span-6">&nbsp;</div> 
     74                    <div id="containerButtons" class="buttons span-7"></div> 
     75                </div> 
     76            </div> 
    5277        </div> 
    53          
    54         <div id="generalContainerCalendar" class="span-9 last"> 
    55             <div id="messages"><bean:message key="data.visualization.selectTime"/></div> 
    56                                 <div id="embeddedCalendar" class="embeddedCalendar"></div> 
    5778 
    58                                 <div class="dateField leftField"><bean:message key="data.visualization.BeginDate"/></div><div id="embeddedDateField" class="dateField rightField"><bean:message key="data.visualization.selectDate"/></div> 
    59                                 <div class="dateField leftField"><bean:message key="data.visualization.EndDate"/></div><div id="embeddedEndDateField" class="dateField rightField"><bean:message key="data.visualization.selectDate"/></div> 
    60          
    61                                 <div class="errorAndButtons"> 
    62                                         <div id="notice" style="visibility:hidden" class="error span-6">&nbsp;</div> 
    63                                         <div id="containerButtons" class="buttons span-7"></div> 
    64                                 </div>                           
    65         </div> 
    66     </div> 
     79        <script type="text/javascript"> 
     80            var interfaceTexts = $A(); 
     81            interfaceTexts["app.title"] = '<bean:message key="app.title"/>'; 
     82            interfaceTexts["data.visualization.noPlateform"] = '<bean:message key="data.visualization.noPf"/>'; 
     83            interfaceTexts["data.visualization.noParameter"] = '<bean:message key="data.visualization.noParameter"/>'; 
     84            interfaceTexts["data.visualization.button.visualize"] = '<bean:message key="data.visualization.button.visualize"/>'; 
     85            interfaceTexts["data.visualization.button.download"] = '<bean:message key="data.visualization.button.download"/>'; 
     86            interfaceTexts["data.visualization.loading.data"] = '<bean:message key="data.visualization.loading.data"/>'; 
     87            interfaceTexts["data.visualization.Unvalid_Period"] = "<bean:message key="data.visualization.Unvalid_Period"/>"; 
     88            interfaceTexts["data.visualization.quicklook"] = "<bean:message key="data.visualization.quicklook"/>"; 
    6789 
    68         <script type="text/javascript"> 
    69                 var interfaceTexts = $A(); 
    70                 interfaceTexts["data.visualization.noPlateform"] = '<bean:message key="data.visualization.noPf"/>'; 
    71                 interfaceTexts["data.visualization.noParameter"] = '<bean:message key="data.visualization.noParameter"/>'; 
    72                 interfaceTexts["data.visualization.button.visualize"] = '<bean:message key="data.visualization.button.visualize"/>'; 
    73                 interfaceTexts["data.visualization.button.download"] = '<bean:message key="data.visualization.button.download"/>'; 
    74                 interfaceTexts["data.visualization.loading.data"] = '<bean:message key="data.visualization.loading.data"/>'; 
    75                 interfaceTexts["data.visualization.Unvalid_Period"] = "<bean:message key="data.visualization.Unvalid_Period"/>"; 
    76                  
    77                 var interfaceVisualization = new InterfaceVisualization(${plateforms}); 
    78         </script> 
    79          
    80         </tiles:put> 
     90            var interfaceVisualization = new InterfaceVisualization( ${plateforms} ); 
     91        </script> 
     92 
     93    </tiles:put> 
    8194 
    8295</tiles:insert> 
Note: See TracChangeset for help on using the changeset viewer.