Changeset 129 for ether_megapoli
- Timestamp:
- 07/25/11 21:20:23 (13 years ago)
- 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 1 1 package com.ether; 2 2 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; 3 import org.jetbrains.annotations.NotNull; 4 5 import javax.imageio.ImageIO; 6 import javax.swing.*; 7 import java.awt.*; 10 8 import java.awt.image.BufferedImage; 11 9 import java.awt.image.ColorModel; 12 10 import java.awt.image.PixelGrabber; 13 14 import java x.swing.ImageIcon;11 import java.io.File; 12 import java.io.IOException; 15 13 16 14 /** … … 18 16 * @date may 2011 19 17 */ 20 public abstract class ImageHelper { 18 // TODO : range this class !!!! 19 public abstract class ImageHelper 20 { 21 21 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 } 53 93 54 94 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 } 67 133 68 134 } -
ether_megapoli/trunk/common/implementation/com/ether/ParameterConstants.java
r89 r129 11 11 public static final String PARAMETER_DATE_BEGIN = "dateBegin"; 12 12 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"; 14 15 } -
ether_megapoli/trunk/common/implementation/com/ether/WebException.java
r89 r129 3 3 /** 4 4 * @author vmipsl 5 * @date 02 feb 2011 5 * @date 02 feb 2011 6 6 */ 7 public class WebException 8 7 public class WebException 8 extends FormattedException 9 9 { 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 ); 16 13 } 17 14 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 ); 20 18 } 21 19 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 } 25 24 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 } 29 29 30 public static enum WebCode implements Code 30 public WebException( final Enum<? extends Code> code, final String string ) 31 31 { 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; 40 47 } 41 48 } -
ether_megapoli/trunk/common/implementation/com/medias/Context.java
r89 r129 1 1 package com.medias; 2 2 3 import org.apache.struts.Globals; 4 import org.jetbrains.annotations.NotNull; 5 3 6 import javax.servlet.http.HttpServletRequest; 4 7 import javax.servlet.http.HttpSession; 5 8 import java.util.Calendar; 6 9 import java.util.Date; … … 13 16 * Date: 27 janv. 2005 14 17 * Time: 15:45:10 15 * 18 * <p/> 16 19 * Permet d'accéder au contexte courant pour chaque page de l'appli 17 20 */ … … 23 26 24 27 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 } 41 135 42 136 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 } 49 146 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 } 59 169 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 } 133 176 } -
ether_megapoli/trunk/common/test/com/ether/TestHelper.java
r89 r129 13 13 public abstract class TestHelper<BEAN> 14 14 { 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; 19 20 } 20 21 21 protected abstract void beforeBeanTest() throws Exception; 22 protected abstract void beforeBeanTest() 23 throws Exception; 22 24 23 protected abstract void afterBeanTest() throws Exception; 25 protected abstract void afterBeanTest() 26 throws Exception; 24 27 25 28 @Before 26 public final void beforeTest() throws Exception 29 public final void beforeTest() 30 throws Exception 27 31 { 28 Assert.assertNotNull(getApplicationContext());29 Assert.assertNotNull(getBean());30 32 Assert.assertNotNull( getApplicationContext() ); 33 Assert.assertNotNull( getBean() ); 34 beforeBeanTest(); 31 35 } 32 36 33 37 @After 34 public final void afterTest() throws Exception 38 public final void afterTest() 39 throws Exception 35 40 { 36 37 41 afterBeanTest(); 42 _bean = null; 38 43 } 39 44 40 45 @AfterClass 41 public static void afterAllTest() throws Exception 46 public static void afterAllTest() 47 throws Exception 42 48 { 43 44 45 if (_applicationContext != null) _applicationContext.close();46 47 48 49 50 49 try 50 { 51 if( _applicationContext != null ) _applicationContext.close(); 52 } 53 finally 54 { 55 _applicationContext = null; 56 } 51 57 } 52 58 53 59 /** 54 60 * Builds context names from 2 context name arrays. 55 * 56 * @param baseContextNames : the base context names.61 * 62 * @param baseContextNames : the base context names. 57 63 * @param otherContextNames : the other context names. 58 64 * @return a context name array. 59 65 */ 60 66 protected static String[] buildContextNames( 61 final String[] baseContextNames, final String... otherContextNames)67 final String[] baseContextNames, final String... otherContextNames ) 62 68 { 63 64 69 int contextNameSize = baseContextNames == null ? 0 : baseContextNames.length; 70 contextNameSize += otherContextNames == null ? 0 : otherContextNames.length; 65 71 66 72 final String[] contextNames = new String[contextNameSize]; 67 73 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 ); 70 76 71 if (otherContextNames != null)72 73 if (baseContextNames != null)74 System.arraycopy(otherContextNames, 0, contextNames, baseContextNames.length, otherContextNames.length);75 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 } 78 84 79 85 return contextNames; 80 86 } 81 87 82 88 protected final ApplicationContext getApplicationContext() 83 89 { 84 if (_applicationContext == null)85 86 90 if( _applicationContext == null ) 91 { 92 final String[] contextNames; 87 93 88 if (_otherContextNames != null)89 90 if (_beanContextName != null)91 contextNames = buildContextNames(_otherContextNames, _beanContextName);92 93 contextNames = buildContextNames(_otherContextNames);94 95 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 } 99 105 100 _applicationContext = new ClassPathXmlApplicationContext(contextNames);101 106 _applicationContext = new ClassPathXmlApplicationContext( contextNames ); 107 } 102 108 103 109 return _applicationContext; 104 110 } 105 111 106 @SuppressWarnings({ "unchecked"})112 @SuppressWarnings({"unchecked"}) 107 113 protected final BEAN getBean() 108 114 { 109 if (_bean == null)110 _bean = (BEAN) getApplicationContext().getBean(_beanName);115 if( _bean == null ) 116 _bean = (BEAN) getApplicationContext().getBean( _beanName ); 111 117 112 118 return _bean; 113 119 } 114 120 115 121 private static final Log LOGGER = LogFactory.getLog( TestHelper.class ); 116 122 117 123 private static AbstractApplicationContext _applicationContext; 118 124 -
ether_megapoli/trunk/domain/interface/com/ether/Data.java
r89 r129 1 1 package com.ether; 2 2 3 import org.jetbrains.annotations.NotNull; 4 3 5 import java.util.Date; 4 5 import org.jetbrains.annotations.NotNull;6 6 7 7 /** … … 9 9 * @date may 2011 10 10 */ 11 public class Data { 11 // TODO : see if necessary, otherwise remove this class 12 public class Data 13 { 12 14 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 35 39 } -
ether_megapoli/trunk/persistence/implementation/com/ether/dao/ValueDAOImpl.java
r89 r129 1 1 package com.ether.dao; 2 2 3 import java.util.Date;4 import java.util.List;5 3 import com.ether.Data; 4 import com.ether.Pair; 5 import com.ether.PersistenceException; 6 6 import com.medias.database.objects.Valeur; 7 7 import org.hibernate.criterion.DetachedCriteria; … … 12 12 import org.jetbrains.annotations.Nullable; 13 13 14 import com.ether.Data; 15 import com.ether.PersistenceException; 14 import java.util.ArrayList; 15 import java.util.Date; 16 import java.util.List; 16 17 17 18 /** … … 19 20 * @date 07 apr 2011 20 21 */ 21 public class ValueDAOImpl extends DomainAccessObjectImpl<Valeur, Integer> 22 implements ValueDAO 22 public class ValueDAOImpl 23 extends DomainAccessObjectImpl<Valeur, Integer> 24 implements ValueDAO 23 25 { 24 protected ValueDAOImpl() { 25 super(Valeur.class); 26 protected ValueDAOImpl() 27 { 28 super( Valeur.class ); 26 29 } 27 30 28 29 public List<Data> getValuesByPlateformByParameterByPeriod(@NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd) 30 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 ) ); 36 39 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 ) ); 45 44 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" ) ) ) ); 47 48 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 } 50 63 } -
ether_megapoli/trunk/persistence/implementation/hibernate-domain.cfg.xml
r89 r129 6 6 <hibernate-configuration> 7 7 <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"/>--> 34 34 </session-factory> 35 35 </hibernate-configuration> -
ether_megapoli/trunk/persistence/interface/com/ether/dao/ValueDAO.java
r89 r129 4 4 import java.util.List; 5 5 6 import com.ether.Pair; 6 7 import com.medias.database.objects.Valeur; 7 8 import org.jetbrains.annotations.NotNull; … … 19 20 { 20 21 @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; 22 23 } -
ether_megapoli/trunk/service/implementation/com/ether/EtherPlotServiceImpl.java
r119 r129 1 1 package com.ether; 2 2 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; 3 import gov.noaa.pmel.sgt.JPane; 4 import gov.noaa.pmel.sgt.dm.SGTData; 5 import gov.noaa.pmel.sgt.swing.JPlotLayout; 8 6 import org.apache.commons.logging.Log; 9 7 import org.apache.commons.logging.LogFactory; 10 8 import org.jetbrains.annotations.NotNull; 11 9 import org.jetbrains.annotations.Nullable; 12 import org.springframework.beans.factory.annotation.Required;13 import org.springframework.transaction.annotation.Transactional;14 10 15 import com.ether.dao.ParameterDAO; 16 import com.ether.dao.PlateformDAO; 17 import com.ether.dao.ValueDAO; 11 import javax.swing.*; 12 import java.awt.*; 13 import java.awt.image.BufferedImage; 14 import java.util.Calendar; 15 import java.util.Locale; 16 import java.util.ResourceBundle; 18 17 19 18 /** 20 19 * @author vmipsl 21 * @date 0 7 mar 201120 * @date 05 july 2011 22 21 */ 23 public class EtherServiceImpl implements EtherService 22 public class EtherPlotServiceImpl 23 implements EtherPlotService 24 24 { 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() ) ); 39 39 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 ); 73 44 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(); 89 56 } 90 57 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 ) 95 65 { 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; 106 91 } 107 92 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() ); 108 104 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; 113 130 } 114 131 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 ) 117 141 { 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; 119 161 } 120 162 121 @Required122 p ublic void setValueDAO(final ValueDAO valueDAO)163 // TODO : move this function in a more generally class 164 private ResourceBundle getBundle( @Nullable final Locale locale ) 123 165 { 124 _valueDAO = valueDAO; 166 if( null != locale ) 167 return ResourceBundle.getBundle( "ApplicationResources", locale ); 168 else 169 return ResourceBundle.getBundle( "ApplicationResources" ); 125 170 } 126 171 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; 133 183 } -
ether_megapoli/trunk/service/implementation/com/ether/EtherServiceImpl.java
r89 r129 55 55 @Nullable 56 56 @Transactional(readOnly = true) 57 public List< Data> getValuesByPlateformByParameterByPeriod(57 public List<Pair<Double, Date>> getValuesByPlateformByParameterByPeriod( 58 58 @NotNull final Integer plateformId, 59 59 @NotNull final Integer parameterId, … … 106 106 } 107 107 108 109 108 @Required 110 109 public void setPlateformDAO(final PlateformDAO plateformDAO) -
ether_megapoli/trunk/service/implementation/com/ether/TimeSeriesPlot.java
r119 r129 1 package com.ether .com.ether.graph;1 package com.ether; 2 2 3 import gov.noaa.pmel.sgt.LineAttribute;4 3 import gov.noaa.pmel.sgt.beans.DataGroup; 5 import gov.noaa.pmel.sgt.beans.DataModel;6 4 import gov.noaa.pmel.sgt.beans.Label; 7 5 import gov.noaa.pmel.sgt.beans.Legend; 8 import gov.noaa.pmel.sgt.beans.Page;9 6 import gov.noaa.pmel.sgt.beans.PanelHolder; 10 7 import gov.noaa.pmel.sgt.beans.PanelModel; 11 import gov.noaa.pmel.sgt.dm.SGTData;12 import org.jetbrains.annotations.NotNull;13 8 import org.jetbrains.annotations.Nullable; 14 9 15 10 import javax.swing.*; 16 11 import java.awt.*; 12 import java.util.Map; 17 13 18 14 /** … … 21 17 */ 22 18 public class TimeSeriesPlot 23 extends JFrame19 extends EtherPlot 24 20 { 21 25 22 public void createTimeSeriesPlot() 23 throws ServiceException 26 24 { 27 25 // Enable WindowEvents. Set the layout of the content pane to a BorderLayout. … … 29 27 getContentPane().setLayout( new BorderLayout() ); 30 28 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 { 41 88 try 42 89 { 43 _panelModel =PanelModel.loadFromXML( getClass().getResource( FILE_NAME ).openStream() );90 return PanelModel.loadFromXML( getClass().getResource( FILE_NAME ).openStream() ); 44 91 } 45 92 catch( Exception e ) 46 93 { 47 e.printStackTrace(); 48 System.exit( 1 ); 94 throw new ServiceException( ServiceException.ServiceCode.PANEL_MODEL_NOT_FOUND, e ); 49 95 } 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 else68 _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 );72 96 } 73 97 74 @Nullable75 public String getTitle()76 {77 return _title;78 }79 80 public void setTitle( @Nullable final String title )81 {82 _title = title;83 }84 85 @NotNull86 public SGTData getData()87 {88 return _data;89 }90 91 public void setData( @NotNull final SGTData data )92 {93 _data = data;94 }95 96 @NotNull97 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 to110 * 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 is115 * 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 @Nullable126 private String _title;127 @NotNull128 private SGTData _data;129 @NotNull130 private LineAttribute _lineAttribute = new LineAttribute( LineAttribute.SOLID, Color.red );131 132 // Labels used in the megapoli.xml133 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 139 98 } -
ether_megapoli/trunk/service/implementation/service-context.xml
r89 r129 17 17 </bean> 18 18 19 <bean id="etherPlotService" class="com.ether.EtherPlotServiceImpl"></bean> 20 19 21 </beans> -
ether_megapoli/trunk/service/interface/com/ether/EtherPlotService.java
r119 r129 1 1 package com.ether; 2 2 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; 3 import gov.noaa.pmel.sgt.JPane; 4 import gov.noaa.pmel.sgt.dm.SGTData; 8 5 import org.jetbrains.annotations.NotNull; 9 6 import org.jetbrains.annotations.Nullable; 10 7 8 import java.awt.image.BufferedImage; 9 import java.util.Locale; 10 11 11 /** 12 12 * @author vmipsl 13 * @date 0 7 mar 201113 * @date 05 july 2011 14 14 */ 15 public interface EtherService extends Service 15 public interface EtherPlotService 16 extends Service 16 17 { 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 ); 22 20 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 ); 25 23 26 @N ullable27 Plateforme getPlateformById( @Nullable final Integer plateformId ) throws ServiceException;24 @NotNull 25 public JPane createCenterPane( @NotNull final SGTData data ); 28 26 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 31 30 } -
ether_megapoli/trunk/service/interface/com/ether/EtherService.java
r89 r129 22 22 23 23 @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; 25 25 26 26 @Nullable -
ether_megapoli/trunk/service/interface/com/ether/ServiceException.java
r89 r129 25 25 PLATEFORM_NOT_FOUND, 26 26 PARAMETER_NOT_FOUND, 27 VALUE_NOT_FOUND, 27 VALUE_NOT_FOUND, 28 PANEL_MODEL_NOT_FOUND; 28 29 } 29 30 } -
ether_megapoli/trunk/service/test/com/ether/SGTTest.java
r89 r129 1 1 package com.ether; 2 2 3 import com.ether.com.ether.graph.TimeSeriesPlot; 3 import com.ether.annotation.ControllerMethod; 4 import com.ether.annotation.Mandatory; 5 import com.ether.annotation.ParamName; 4 6 import com.ether.tutorial.src.tutorial.Example1; 5 7 import com.ether.tutorial.src.tutorial.SBExample1; 6 8 import com.ether.tutorial.src.tutorial.SBExample2; 7 9 import com.ether.tutorial.src.tutorial.SBExample3; 10 import com.keypoint.PngEncoder; 11 import com.keypoint.PngEncoderB; 12 import gov.noaa.pmel.sgt.JPane; 8 13 import gov.noaa.pmel.sgt.LineAttribute; 9 14 import gov.noaa.pmel.sgt.dm.SGTMetaData; … … 11 16 import gov.noaa.pmel.sgt.swing.JPlotLayout; 12 17 import gov.noaa.pmel.util.GeoDateArray; 18 import net.sf.json.JSONObject; 19 import org.jetbrains.annotations.NotNull; 13 20 import org.jetbrains.annotations.Nullable; 14 21 import org.junit.Test; 15 22 23 import javax.imageio.ImageIO; 24 import javax.servlet.ServletException; 25 import javax.servlet.http.HttpServletRequest; 26 import javax.servlet.http.HttpServletResponse; 16 27 import javax.swing.*; 17 28 import java.awt.*; 29 import java.awt.image.BufferedImage; 30 import java.awt.image.RenderedImage; 31 import java.io.File; 32 import java.io.FileInputStream; 33 import java.io.IOException; 18 34 import java.text.ParseException; 19 import java.util. List;35 import java.util.Date; 20 36 21 37 /** … … 176 192 final LineAttribute lineAttribute = createLineAttribute( markPoint ); 177 193 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 ); 188 206 189 207 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(); 191 219 } 192 220 … … 266 294 // } 267 295 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; 268 794 } -
ether_megapoli/trunk/web/WEB-INF/classes/hibernate-domain.cfg.xml
r89 r129 6 6 <hibernate-configuration> 7 7 <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"/>--> 34 34 </session-factory> 35 35 </hibernate-configuration> -
ether_megapoli/trunk/web/WEB-INF/web.xml
r120 r129 1 1 <?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"> 3 4 <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" 4 5 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"> 6 7 7 8 <display-name>Megapoli</display-name> 8 9 9 10 11 10 <welcome-file-list> 11 <welcome-file>/init.jsp</welcome-file> 12 </welcome-file-list> 12 13 13 14 15 14 <context-param> 15 <param-name>contextConfigLocation</param-name> 16 <param-value> 16 17 classpath:dao-context.xml, 17 18 classpath:service-context.xml, … … 20 21 classpath:json/json-context.xml 21 22 </param-value> 22 23 </context-param> 23 24 24 25 26 25 <listener> 26 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 27 </listener> 27 28 28 29 30 31 32 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>--> 33 34 34 35 36 37 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>--> 38 39 39 40 41 42 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>--> 43 44 44 45 46 47 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>--> 48 49 49 50 51 52 53 54 55 56 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 57 58 </param-value> 58 59 59 </init-param> 60 </servlet> 60 61 61 62 63 64 62 <servlet-mapping> 63 <servlet-name>visualization</servlet-name> 64 <url-pattern>/visualization</url-pattern> 65 </servlet-mapping> 65 66 66 67 68 69 70 71 72 73 74 75 76 77 78 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> 79 80 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> 84 101 85 102 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 --> 91 108 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> 92 115 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 110 121 </web-app> -
ether_megapoli/trunk/web/resources/css/visu_parameter_by_pf.css
r89 r129 12 12 .containerPlateform:hover, .containerParameter:hover 13 13 { 14 #text-decoration: underline;14 text-decoration: underline; 15 15 background: #70739C; 16 16 color: #FFFFFF; -
ether_megapoli/trunk/web/resources/js/DomHelper.js
r89 r129 160 160 { 161 161 Element.addClassName(this.domCell, className); 162 } ,162 } 163 163 }); 164 164 … … 283 283 var link = new Element('a', {href: url}).update(text); 284 284 return link; 285 } ,286 287 }); 285 } 286 287 }); -
ether_megapoli/trunk/web/resources/templates/templateEther.jsp
r89 r129 11 11 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 12 12 13 < html>14 < head>13 <HTML> 14 <HEAD> 15 15 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> 16 16 <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> … … 46 46 --> 47 47 </script> 48 </ head>49 50 < body>48 </HEAD> 49 50 <BODY> 51 51 <a name="top"></a> 52 52 … … 218 218 </div> 219 219 220 </ body>221 </ html>220 </BODY> 221 </HTML> 222 222 <!-- /*** ****************** FIN TEMPLATE ETHER ******************** **/ --> -
ether_megapoli/trunk/web/src/ApplicationResources.properties
r89 r129 84 84 #data.upload.coordinator=En tant que coordinateur du projet, vous pouvez : 85 85 #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>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\:{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> 87 87 data.upload.deleteSet=Supprimer ce jeu de donn\u00E9es. 88 88 data.upload.deleteFile=Supprimer ce fichier. … … 107 107 108 108 data.upload.metadata=M\u00E9tadonn\u00E9es 109 data.upload.metadata.inc=\u00E0 compl\u00E9ter 110 data.upload.metadata.comp=complet 109 111 data.upload.metadata.link=Mettre \u00E0 jour les m\u00E9tadonn\u00E9es 110 112 data.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. 113 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. 112 114 data.upload.metadata.presentation=PRESENTATION GENERALE 113 data.upload.metadata.presentation.link=Pr ï¿œsentation gï¿œnï¿œrale115 data.upload.metadata.presentation.link=Pr\u00E9sentation g\u00E9n\u00E9rale 114 116 data.upload.metadata.presentation.nom=Nom du jeu 115 117 data.upload.metadata.presentation.def=Description … … 139 141 data.upload.metadata.integration.size=Taille totale des fichiers d\u00E9j\u00E0 trait\u00E9s 140 142 data.upload.metadata.contenu_actuel=CONTENU ACTUEL 141 data.upload.metadata.contact=Contact 143 data.upload.metadata.contact=Contact 142 144 data.upload.metadata.contact.nom=Nom 143 145 data.upload.metadata.contact.prenom=Pr\u00E9nom … … 148 150 data.upload.metadata.parametres=Param\u00E8tres 149 151 data.upload.metadata.param=Param\u00E8tre 150 data.upload.metadata.param.nom=D\u00E9signation 152 data.upload.metadata.param.cat=Cat\u00E9gorie 153 data.upload.metadata.param.nom=Nom 151 154 data.upload.metadata.param.abrev=Abr\u00E9viation 152 155 data.upload.metadata.param.unite=Unit\u00E9 de mesure … … 165 168 data.upload.metadata.plat.img=Illustrations 166 169 data.upload.metadata.plat.img.show=Afficher l'illustration 167 data.upload.metadata.plat.latlon.format=<i>(En degr\u00E9s d\u00E9cimaux)</i> 170 data.upload.metadata.plat.lat.format=<i>(En degr\u00E9s d\u00E9cimaux [-90,90])</i> 171 data.upload.metadata.plat.lon.format=<i>(En degr\u00E9s d\u00E9cimaux [-180,180])</i> 168 172 data.upload.metadata.plat.latmin=Latitude minimale 169 173 data.upload.metadata.plat.lonmin=Longitude minimale … … 172 176 data.upload.metadata.plat.lonmax=Longitude maximale 173 177 data.upload.metadata.plat.altmax=Altitude maximale 178 data.upload.metadata.nomoth=ou autre 174 179 data.upload.plat.optional=<i>(Obligatoire pour les plates-formes fixes)</i> 175 180 data.upload.metadata.time.date=Date … … 193 198 data.access.jeux=Les jeux de donn\u00E9es 194 199 data.access.jeux2=Jeux associ\u00E9s 200 data.access.jeux3=jeu 201 data.access.jeux4=jeux 195 202 data.access.param=Les param\u00E8tres 196 203 data.access.param1=Param\u00E8tre 197 data.access.param2=param\u00E8tre s204 data.access.param2=param\u00E8tre{0} 198 205 data.access.param3=Param\u00E8tres associ\u00E9s 199 206 data.access.param4=D\u00E9tail du param\u00E8tre 200 207 data.access.capt=Les capteurs 201 208 data.access.capt1=Capteur 202 data.access.capt2=capteur s209 data.access.capt2=capteur{0} 203 210 data.access.capt3=Capteurs associ\u00E9s 204 211 data.access.capt4=D\u00E9tail du capteur 205 212 data.access.plat=Les plates-formes 206 213 data.access.plat1=Plate-forme 207 data.access.plat2=plate s-formes214 data.access.plat2=plate{0}-forme{0} 208 215 data.access.plat3=Plates-formes associ\u00E9es 209 216 data.access.plat4=D\u00E9tail de la plate-forme … … 239 246 data.access.metadata.presentation.contact.role.scientifique=Responsable scientifique 240 247 data.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> 248 data.access.metadata.file=fichier{0} trait\u00E9{0} 249 data.access.metadata.file.sameDate=le {0} 250 data.access.metadata.file.differentDate=entre le {0} et le {1} 245 251 data.access.metadata.title=M\u00E9tadonn\u00E9es pour le jeu 246 252 data.access.metadata.intro= … … 248 254 data.access.metadata.datefin=Date de la derni\u00E8re mesure 249 255 data.access.metadata.heure=\u00E0 250 data.access.metadata.nbfichiers=com.medias.Nombre de fichiers 256 data.access.metadata.nbfichiers=com.medias.Nombre de fichiers trait?s 257 data.access.metadata.fichierslink=acc\u00E8s aux donn\u00E9es brutes 251 258 data.access.metadata.nbmesures=com.medias.Nombre de mesures 252 259 data.access.metadata.plat.type=Type de plate-forme 253 260 data.access.metadata.param.cat=Cat\u00E9gorie GCMD 254 data.access.files.zero=Aucun fichier valid\u00E9 pour ce jeu261 data.access.files.zero=Aucun fichier trait\u00E9 pour ce jeu 255 262 app.access.back=Retour \u00E0 la liste des jeux 256 263 app.access.plat.back=Liste des plates-formes … … 267 274 data.access.metadata.unavailable=M\u00E9tadonn\u00E9es non disponibles 268 275 data.access.files.dowload.com.medias.zip=T\u00E9l\u00E9charger tous les fichiers du jeu {0} 276 data.access.files=Fichiers trait\u00E9s 277 data.access.files2=Fichiers trait\u00E9s pour le jeu {0} 278 data.access.files3=fichier{0} trait\u00E9{0} 269 279 270 280 data.download=T\u00E9l\u00E9chargement … … 297 307 com.medias.mail.content4=\n\nVous pouvez consulter le d\u00E9tail ici\: " 298 308 com.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 " 309 com.medias.mail.content6=\nVotre mot de passe est \: 310 com.medias.mail.content7=\n\n1) Cliquez sur le lien "M\u00E9tadonn\u00E9es" pour compl\u00E9ter les m\u00E9tadonn\u00E9es correspondant au jeu " 311 com.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\: 312 com.medias.mail.content9=).\n\nA bient\u00F4t,\n\n 313 com.medias.mail.content10=est " 314 315 unit.deg=\u00B0 303 316 304 317 # ===================================== ERRORS ========================================== … … 322 335 errors.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> 323 336 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>337 errors.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> 338 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\:{0}?subject\=[MEGAPOLI]">webmaster</a>. <br> 326 339 errors.logon.login=Veuillez saisir votre login (normalement : votre com.medias.mail).<br> 327 340 errors.logon.pwd=Veuillez saisir votre mot de passe.<br> 328 341 329 errors.upload.file=Vous devez s\u00E9lectionner un fichier !<br>342 errors.upload.file=Vous devez s\u00E9lectionner un fichier\!<br> 330 343 errors.upload.failed=Echec du d\u00E9p\u00F4t...<br> 331 344 errors.upload.metadata.presentation.nom=Veuillez donner un nom au jeu de donn\u00E9es\!<br> … … 338 351 errors.upload.prepareTree.failed=Echec de chargement de la page de d\u00E9p\u00F4t<br>Veuillez r\u00E9essayer 339 352 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>353 errors.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> 341 354 errors.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>355 errors.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> 356 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\:{0}?subject\=[MEGAPOLI]">webmaster</a> pour lui signaler le probl\u00E8me.<br> 357 errors.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> 358 errors.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> 346 359 347 360 errors.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>361 errors.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> 362 errors.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> 363 errors.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> 364 errors.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> 365 errors.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> 366 errors.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> 367 errors.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> 355 368 356 369 errors.upload.updateMetadata.failed.contact_pi=Il ne peut y avoir qu'un seul contact scientifique pour un jeu de donn\u00E9es … … 371 384 errors.upload.updateMetadata.failed.lonbound=Vous devez saisir une longitude maximale sup\u00E9rieure ou \u00E9gale \u00E0 la longitude minimale 372 385 errors.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>386 errors.zipgame.failed=Echec lors de la cr\u00E9ation de l'archive 387 errors.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> 375 388 376 389 errors.access.requete.fail=La requ\u00EAte n'a pas aboutie 377 378 390 379 391 ################################################################ … … 405 417 data.visualization.button.download.info=(fichier .tgz) 406 418 data.visualization.loading.data=Chargement des donn\u00E9es 419 data.visualization.quicklook=Quicklook 407 420 408 421 simulation.visualization=Visualisation des simulations 422 423 ####################### PLOT ####################### 424 plot.published=Publi\u00E9 le 425 plot.dataNumber=Nombre de donn\u00E9es extraites : -
ether_megapoli/trunk/web/src/ApplicationResources_en.properties
r89 r129 404 404 data.visualization.button.download.info=(file .tgz) 405 405 data.visualization.loading.data=Data downloading 406 data.visualization.quicklook=Quicklook 406 407 407 408 simulation.visualization=Simulations visualization 409 410 ####################### PLOT ####################### 411 plot.published=Published 412 plot.dataNumber=Number of extracted datas : -
ether_megapoli/trunk/web/src/com/ether/Controller.java
r89 r129 6 6 import com.medias.database.objects.Parametre; 7 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 8 import net.sf.json.JSONObject; 11 9 import org.apache.commons.logging.Log; 12 10 import org.apache.commons.logging.LogFactory; 13 11 import org.jetbrains.annotations.NotNull; 14 import org.jetbrains.annotations.Nullable;15 12 import org.springframework.beans.factory.annotation.Required; 16 13 import org.springframework.web.servlet.ModelAndView; 17 import com.ether.tutorial.src.tutorial.Example1;18 14 19 15 import javax.servlet.http.HttpServletRequest; 20 16 import 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;27 17 import java.util.HashMap; 28 18 import java.util.List; … … 33 23 * @date 17 feb 2011 34 24 */ 35 public class Controller extends ControllerEther 25 public class Controller 26 extends ControllerEther 36 27 { 37 28 /** *********************************************************** **/ … … 39 30 /** *********************************************************** **/ 40 31 // 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 ) 42 33 throws WebException 43 34 { 44 return new ModelAndView( "index");35 return new ModelAndView( "index" ); 45 36 } 46 37 … … 59 50 60 51 final Map<String, Object> model = new HashMap<String, Object>(); 61 model.put( "plateforms", getJsonHelper().toJSON( plateforms) );52 model.put( "plateforms", getJsonHelper().toJSON( plateforms ) ); 62 53 return model; 63 54 } … … 65 56 /** *********************************************************** **/ 66 57 /** *********************** CALLS ***************************** **/ 67 /** ********************************************************** ***/58 /** ********************************************************** **/ 68 59 @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 ) 70 61 throws ServiceException, WebException 71 62 { 72 final List<Parametre> parametersByPlateform = _etherService.getParametersByPlateformId( plateformId);63 final List<Parametre> parametersByPlateform = _etherService.getParametersByPlateformId( plateformId ); 73 64 74 65 final JSONObject result = new JSONObject(); 75 result.put( ParameterConstants.PARAMETER_PARAMETERS, getJsonHelper().toJSON( parametersByPlateform) );66 result.put( ParameterConstants.PARAMETER_PARAMETERS, getJsonHelper().toJSON( parametersByPlateform ) ); 76 67 return result; 77 68 } 78 69 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, ParseException86 {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, ParseException135 // {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 the179 // * "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 file188 // */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 data192 // * 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 the197 // * layout. Coastlines are handled differently by JPlotLayout. Coastlines198 // * are not used to compute the X and Y ranges and are always clipped to199 // * 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 be205 // * executed.206 // */207 // layout_.setBatch(false);208 // }209 210 70 @Required 211 public void setEtherService( @NotNull final EtherService etherService)71 public void setEtherService( @NotNull final EtherService etherService ) 212 72 { 213 73 _etherService = etherService; -
ether_megapoli/trunk/web/src/com/ether/ControllerPlot.java
r119 r129 1 1 package com.ether; 2 2 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; 3 import com.medias.Context; 4 import gov.noaa.pmel.sgt.dm.SGTMetaData; 5 import gov.noaa.pmel.sgt.dm.SimpleLine; 6 import gov.noaa.pmel.util.GeoDateArray; 11 7 import org.apache.commons.logging.Log; 12 8 import org.apache.commons.logging.LogFactory; 13 9 import 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; 10 import org.springframework.context.ApplicationContext; 11 import org.springframework.web.context.support.WebApplicationContextUtils; 18 12 13 import javax.imageio.ImageIO; 14 import javax.servlet.ServletConfig; 15 import javax.servlet.ServletException; 16 import javax.servlet.http.HttpServlet; 19 17 import javax.servlet.http.HttpServletRequest; 20 18 import javax.servlet.http.HttpServletResponse; 21 import javax.swing.*; 22 import java.awt.*; 23 import java.io.FileWriter; 19 import java.awt.image.BufferedImage; 24 20 import java.io.IOException; 25 21 import java.text.ParseException; 26 22 import java.util.Date; 27 import java.util.HashMap;28 23 import java.util.List; 29 import java.util.Map;30 24 31 25 /** 32 26 * @author vmipsl 33 * @date 17 feb201127 * @date 17 june 2011 34 28 */ 35 public class Controller extends ControllerEther 29 public class ControllerPlot 30 extends HttpServlet 36 31 { 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 43 34 { 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 } 45 46 } 46 47 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 50 58 { 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 } 52 109 } 53 110 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 ) 57 113 { 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; 63 122 } 64 123 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 ) 71 126 { 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; 77 135 } 78 136 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 ); 91 138 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; 220 142 221 143 private EtherService _etherService; 144 private EtherPlotService _etherPlotService; 145 222 146 } -
ether_megapoli/trunk/web/visualization/visu_parameter_by_pf-script.jsp
r89 r129 1 1 <script type="text/javascript"> 2 var InterfaceVisualization = Class.create( {3 2 var InterfaceVisualization = Class.create( { 3 4 4 initialize: function( jsonPlateforms ) 5 5 { 6 6 // Values 7 this.parent = $("txt");8 this.superParent = $( "pageContent"); // need to resize in function of containerParameters9 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" ); 12 12 this.jsonPlateforms = jsonPlateforms || null; 13 14 15 16 17 this.notice = Dom.getContainer("notice");18 19 20 21 this.containerPlateforms = Dom.getContainer("containerPlateforms");22 this.containerParameters = Dom.getContainer("containerParameters");23 this.containerButtons = Dom.getContainer("containerButtons");24 25 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 *********** **/ 26 26 // Create loading object for plateforms 27 27 var param = new Object(); 28 28 param.id = "loadingForPlateforms"; 29 29 param.parent = this.containerPlateforms; 30 this.loadingPlateforms = new Loading( param);30 this.loadingPlateforms = new Loading( param ); 31 31 this.loadingPlateforms.display(); 32 32 … … 35 35 param.id = "loadingForParameters"; 36 36 param.parent = this.containerParameters; 37 this.loadingParameters = new Loading( param);38 this.loadingParameters.display(); 39 40 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 )} ); 44 44 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 46 54 this.createCalendar(); 47 55 this.displayPlateforms(); 48 56 }, 49 57 50 58 // 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 "¶meterId=" + 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 } ); 71 66 }, 72 67 … … 77 72 this.displayParameters(); 78 73 }, 79 74 80 75 handleValuesByPlateformByParameterByPeriod: function( result ) 81 76 { 82 77 // this.notice.style.visibility = "hidden"; 83 78 84 this.jsonValues = result.responseText.evalJSON().values; 85 alert("values : "+this.jsonValues.size()); 79 this.jsonEncodedImage = result.responseText.evalJSON().encodedImage; 80 81 86 82 }, 87 83 … … 89 85 createCalendar: function() 90 86 { 91 92 93 94 95 96 97 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 102 98 displayPlateforms: function() 103 99 { 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 ) ); 107 103 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 110 106 // Select the first plateform by default 111 107 if( this.jsonPlateforms && this.jsonPlateforms[0] ) 112 108 { 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; 116 112 } 117 113 }, … … 119 115 displayParameters: function() 120 116 { 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 ) ); 124 120 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 127 123 this.resizeContainers(); 128 124 }, 129 125 130 126 // EVENTS ******************************************************** 131 127 onSelectPlateform: function( objPlateform ) … … 136 132 // Unselect old plateform 137 133 if( this.selectedPlateform ) 138 134 this.selectedPlateform.unselect(); 139 135 140 136 this.selectedPlateform = objPlateform; … … 143 139 // Unselect old parameter 144 140 if( this.selectedParameter ) 145 146 147 this.requestParametersByPlateform(); 148 149 }, 150 141 this.selectedParameter = false; 142 143 this.requestParametersByPlateform(); 144 this.testAllFields(); 145 }, 146 151 147 onSelectParameter: function( objParameter ) 152 148 { … … 156 152 // Unselect old parameter 157 153 if( this.selectedParameter ) 158 154 this.selectedParameter.unselect(); 159 155 160 156 this.selectedParameter = objParameter; … … 162 158 this.testAllFields(); 163 159 }, 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() 182 180 }, 183 181 184 182 onClickVisualize: function() 185 183 { 186 this.displayLoading(); 187 this.requestValuesByPlateformByParameterByPeriod(); 184 // var url = "visualization/plotEther?plateformId=" + this.selectedPlateform.getId() 185 // + "¶meterId=" + this.selectedParameter.getId() 186 // + "&dateBegin=" + this.beginDate 187 // + "&dateEnd=" + this.endDate; 188 var url = "visualization/plotEther?plateformId=33" 189 + "¶meterId=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(); 188 197 }, 189 198 190 199 onClickDownload: function() 191 200 { 192 if(this.testAllFields())193 alert("ok");194 195 alert("non ok");201 if( this.testAllFields() ) 202 alert( "ok" ); 203 else 204 alert( "non ok" ); 196 205 }, 197 206 … … 199 208 resizeContainers: function() 200 209 { 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 = " "; 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 = " "; 278 this.notice.style.visibility = "hidden"; 279 }, 280 281 displayLoading: function() 282 { 283 this.notice.innerHTML = " "; 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 = " "; 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 = " "; 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 = " "; 293 this.notice.style.visibility = "hidden"; 294 }, 295 296 displayLoading: function() 297 { 298 this.notice.innerHTML = " "; 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 = " "; 309 } 310 } ); 296 311 297 312 </script> -
ether_megapoli/trunk/web/visualization/visu_parameter_by_pf.jsp
r89 r129 1 1 <!-- /*** ****************** VISU ******************** **/ --> 2 <%@ page import="com.medias.Context" %>2 <%@ page import="com.medias.Context" %> 3 3 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" %> 8 8 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 9 9 <%@ taglib prefix="ether" tagdir="/WEB-INF/tags" %> … … 11 11 <tiles:insert page="/resources/templates/templateEther.jsp" flush="true"> 12 12 13 14 <bean:message key="app.title" /> - <bean:message key="app.welcome"/>15 13 <tiles:put name="title" type="string"> 14 <bean:message key="app.title"/> - <bean:message key="app.welcome"/> 15 </tiles:put> 16 16 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> 21 23 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=''/> 32 39 33 40 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> 38 44 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>44 45 45 <div id="containerPlateforms"></div> 46 </div> 46 <tiles:put name="body" type="string"> 47 47 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"> </div> 74 <div id="containerButtons" class="buttons span-7"></div> 75 </div> 76 </div> 52 77 </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>57 78 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"> </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"/>"; 67 89 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> 81 94 82 95 </tiles:insert>
Note: See TracChangeset
for help on using the changeset viewer.