Changeset 184


Ignore:
Timestamp:
09/07/11 19:09:04 (13 years ago)
Author:
vmipsl
Message:

Servlet _ TimeSerie? : double axes

Location:
ether_megapoli/trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • ether_megapoli/trunk/applets/src/com/ether/AppletPlot.java

    r178 r184  
    8282        // Top Pane 
    8383        final JPane jPaneTop = _etherPlotService.createTopPane( megapoliPlot ); 
    84         add( jPaneTop, BorderLayout.NORTH ); 
     84//        add( jPaneTop, BorderLayout.NORTH ); 
    8585 
    8686        final Integer valuesNumber = megapoliPlot.getValuesNumber(); 
     
    8888        // Bottom Pane 
    8989        final JPane jPaneBottom = _etherPlotService.createBottomPane( valuesNumber, _locale ); 
    90         add( jPaneBottom, BorderLayout.PAGE_END ); 
     90//        add( jPaneBottom, BorderLayout.PAGE_END ); 
    9191 
    9292        // Actions Panel 
     
    9696        // Graph Pane 
    9797//        final JPane jPaneGraph = _etherPlotService.createTimeSeriePlot( megapoliPlot ); 
    98         final JPane jPaneGraph = makeGraph(); 
     98        final JPlotLayout jPaneGraph = makeGraph(); 
     99        jPaneGraph.setBatch( true ); 
    99100        add( jPaneGraph, BorderLayout.CENTER ); 
    100101 
     102        final JPane gridKeyPane = jPaneGraph.getKeyPane(); 
     103        gridKeyPane.setSize( new Dimension( 600, 100 ) ); 
     104        add( gridKeyPane, BorderLayout.NORTH ); 
     105 
     106        final JPanel button = makeButtonPanel( false ); 
     107        add( button,  BorderLayout.SOUTH ); 
     108        jPaneGraph.setBatch( false ); 
    101109 
    102110//        JPanel main = new JPanel(); 
     
    346354        megapoliPlot.setTitle( _title ); 
    347355        megapoliPlot.setAxeType( _axeType ); 
    348         megapoliPlot.setParameterName( parametre.getParametreNom() ); 
    349         if( null != parametre.getUnite() && null != parametre.getUnite().getUniteCode() ) 
    350             megapoliPlot.setParameterUnitCode( parametre.getUnite().getUniteCode() ); 
     356//        megapoliPlot.setParameterName( parametre.getParametreNom() ); 
     357//        if( null != parametre.getUnite() && null != parametre.getUnite().getUniteCode() ) 
     358//            megapoliPlot.setParameterUnitCode( parametre.getUnite().getUniteCode() ); 
    351359 
    352360 
  • ether_megapoli/trunk/applets/src/com/ether/AppletTimeSerie.java

    r182 r184  
    8282 
    8383        // Graph Pane 
    84         final JPane jPaneGraph = _etherPlotService.createTimeSeriePlot( megapoliPlot, 600, 600 ); 
    85         add( jPaneGraph, BorderLayout.CENTER ); 
     84        final JPane jPaneGraph; 
     85        try 
     86        { 
     87            jPaneGraph = _etherPlotService.createTimeSeriePlot( megapoliPlot, 600, 600 ); 
     88            add( jPaneGraph, BorderLayout.CENTER ); 
     89        } 
     90        catch( ServiceException e ) 
     91        { 
     92            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates. 
     93        } 
    8694    } 
    8795 
     
    126134        megapoliPlot.setTitle( _title ); 
    127135        megapoliPlot.setAxeType( _axeType ); 
    128         megapoliPlot.setParameterName( parametre.getParametreNom() ); 
    129         if( null != parametre.getUnite() && null != parametre.getUnite().getUniteCode() ) 
    130             megapoliPlot.setParameterUnitCode( parametre.getUnite().getUniteCode() ); 
     136//        megapoliPlot.setParameterName( parametre.getParametreNom() ); 
     137//        if( null != parametre.getUnite() && null != parametre.getUnite().getUniteCode() ) 
     138//            megapoliPlot.setParameterUnitCode( parametre.getUnite().getUniteCode() ); 
    131139 
    132140 
  • ether_megapoli/trunk/service/implementation/com/ether/EtherPlotContentServiceImpl.java

    r182 r184  
    11package com.ether; 
    22 
     3import com.medias.database.objects.Parametre; 
     4import com.medias.database.objects.Unite; 
     5import gov.noaa.pmel.sgt.Axis; 
    36import gov.noaa.pmel.sgt.CartesianGraph; 
    47import gov.noaa.pmel.sgt.ColorMap; 
     
    2629import gov.noaa.pmel.util.GeoDate; 
    2730import gov.noaa.pmel.util.GeoDateArray; 
    28 import gov.noaa.pmel.util.IllegalTimeValue; 
    2931import gov.noaa.pmel.util.Point2D; 
    3032import gov.noaa.pmel.util.Range2D; 
    3133import gov.noaa.pmel.util.SoTPoint; 
    3234import gov.noaa.pmel.util.SoTRange; 
    33 import gov.noaa.pmel.util.TimeRange; 
    3435import org.jetbrains.annotations.NotNull; 
    3536import org.jetbrains.annotations.Nullable; 
     37import org.springframework.beans.factory.annotation.Required; 
    3638 
    3739import javax.swing.*; 
    3840import javax.swing.border.EtchedBorder; 
    3941import java.awt.*; 
     42import java.util.ArrayList; 
     43import java.util.Calendar; 
    4044import java.util.Date; 
     45import java.util.List; 
    4146import java.util.Locale; 
    4247import java.util.ResourceBundle; 
     
    5358    @NotNull 
    5459    public JPane createTimeSeriePlot( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight ) 
     60            throws ServiceException 
    5561    { 
    5662        final JPane mainPane = new JPane( "Time Serie Pane", new Dimension( plotWidth, plotHeight ) ); 
    5763        mainPane.setLayout( new StackedLayout() ); 
    58         mainPane.setBorder( BorderFactory.createLineBorder( Color.pink ) ); 
    59  
    60         /** ***************************** **/ 
     64 
     65        final List<Pair> pIdPIdList = megapoliPlot.getpIdPIdList(); 
     66 
    6167        /** *********** LINES ************ **/ 
    62         /** ***************************** **/ 
    63         final double[] dataArray = (double[]) megapoliPlot.getData().getFirstArray(); 
    64         final Date[] dateValues = (Date[]) megapoliPlot.getData().getSecondArray(); 
    65  
    66         final SimpleLine line0 = new SimpleLine( new GeoDateArray( dateValues ), dataArray, "legend" ); 
    67         SGTMetaData meta = new SGTMetaData( "", "", false, false ); 
    68         line0.setXMetaData( meta ); 
    69  
    70         meta = new SGTMetaData( megapoliPlot.getParameterName(), megapoliPlot.getParameterUnitCode(), false, false ); 
    71         line0.setYMetaData( meta ); 
    72  
    73  
    74         SimpleLine line; 
    75         GeoDate start = null; 
    76         GeoDate stop = null; 
    77         TimeRange tr; 
    78         TestData td; 
    79         try 
    80         { 
    81             start = new GeoDate( "1992-11-01", "yyyy-MM-dd" ); 
    82             stop = new GeoDate( "1993-02-20", "yyyy-MM-dd" ); 
    83         } 
    84         catch( IllegalTimeValue e ) 
    85         { 
    86         } 
    87         tr = new TimeRange( start, stop ); 
    88         td = new TestData( TestData.TIME_SERIES, tr, 1.0f, 
    89                 TestData.RANDOM, 1.2f, 0.5f, 30.0f ); 
    90         line = (SimpleLine) td.getSGTData(); 
    91  
    92  
    93         /** ***************************** **/ 
    94         /** *********** AXIS ************ **/ 
    95         /** ***************************** **/ 
    96         final SoTRange ynRange; 
    97         final SoTRange yRange; 
    98         final SoTRange tnRange; 
    99         final String yLabel; 
    100         yRange = line.getYRange(); 
    101 //        yRange.add( line2.getYRange() ); 
    102         tnRange = line.getXRange(); 
     68        final List<SimpleLine> lines = createLines( pIdPIdList, megapoliPlot.getBeginDate(), megapoliPlot.getEndDate() ); 
     69        final SimpleLine firstLine = lines.get( 0 ); 
     70 
     71        /** *************** AXIS ************** **/ 
     72        final SoTRange xnRange = firstLine.getXRange(); 
     73        final SoTRange yRange = firstLine.getYRange(); 
     74        for( final SimpleLine line : lines ) 
     75            yRange.add( line.getYRange() ); 
     76 
     77        // TODO : automatiser le nb d'intervalles en fonction des valeurs de y 
    10378        final Integer intervalsNumber = 10; 
    104         ynRange = Graph.computeRange( yRange, intervalsNumber ); 
    105         yLabel = line.getYMetaData().getName(); 
    106  
    107  
    108         /** ***************************** **/ 
    109         /** *********** LAYERS ********** **/ 
    110         /** ***************************** **/ 
     79        final SoTRange ynRange = Graph.computeRange( yRange, intervalsNumber ); 
     80 
     81        // Origin point 
     82        final SoTPoint originPoint = new SoTPoint( ynRange.getStart(), xnRange.getStart() ); 
     83        final SoTPoint endPoint = new SoTPoint( ynRange.getStart(), xnRange.getEnd() ); 
     84 
     85        // Create the time axis, set its range in user units and its origin. 
     86        final TimeAxis xbot = new TimeAxis( "X-Axis", TimeAxis.AUTO ); 
     87        xbot.setRangeU( xnRange ); 
     88        xbot.setLocationU( originPoint ); 
     89        xbot.setLabelFont( _axisFont ); 
     90//        xbot.setMinorLabelInterval( 1 ); 
     91 
     92        // Create the vertical axis, set its range in user units and its origin. Create the axis title. 
     93        final PlainAxis yleft = new PlainAxis( "Y-Axis" ); 
     94        yleft.setRangeU( ynRange ); 
     95        yleft.setLocationU( originPoint ); 
     96        yleft.setLabelFont( _axisFont ); 
     97        final SGLabel ytitle = new SGLabel( "Y-Axis Title", firstLine.getYMetaData().getName(), new Point2D.Double( 0.0, 0.0 ) ); 
     98        ytitle.setFont( _axisFont ); 
     99        ytitle.setHeightP( _heightAxisFont ); 
     100        yleft.setTitle( ytitle ); 
     101 
     102        final PlainAxis yleft2 = new PlainAxis( "YY-Axis" ); 
     103        yleft2.setRangeU( ynRange ); 
     104        yleft2.setLocationU( endPoint ); 
     105        yleft2.setLabelFont( _axisFont ); 
     106        yleft2.setLabelPosition( Axis.POSITIVE_SIDE ); 
     107        final SGLabel ytitle2 = new SGLabel( "Y-Axis Title", "zzzz", new Point2D.Double( 0.0, 0.0 ) ); 
     108        ytitle2.setFont( _axisFont ); 
     109        ytitle2.setHeightP( _heightAxisFont ); 
     110        yleft2.setTitle( ytitle2 ); 
     111 
     112        /** ********************************** **/ 
     113        /** *********** FIRST LAYER ********** **/ 
     114        /** ********************************** **/ 
     115        // TODO : revoir les tailles ! mettre en automatique par rapport à plotWidth et plotHeight 
    111116        /* 
    112117        * xsize, ysize are the width and height in physical units 
     
    116121        * ystart, yend are the start and end points for the Y axis 
    117122        */ 
    118         final double xsize = 4.0; 
    119         final double xstart = 0.6; 
    120         final double xend = 3.25; 
    121         final double ysize = 4.0; 
    122         final double ystart = 0.6; 
    123         final double yend = 2.50; 
    124  
    125         Layer layer2; 
    126         SGLabel label, title, ytitle; 
    127         CartesianGraph graph, graph2; 
    128         LinearTransform xt, yt; 
    129         PlainAxis yleft; 
    130         TimeAxis xbot; 
    131         LineKey lkey; 
    132         GeoDate stime; 
     123        final double xsize = 5.0; 
     124        final double ysize = 3.5; 
     125        final double xstart = 0.3; 
     126        final double xend = xsize - xstart; 
     127        final double ystart = 0.5; 
     128        final double yend = ysize - ystart; 
    133129 
    134130        final Layer layer = new Layer( "First Layer", new Dimension2D( xsize, ysize ) ); 
    135  
    136         /** ***************************** **/ 
    137         /** *********** LEGENDS ********* **/ 
    138         /** ***************************** **/ 
    139         /* 
    140         * create a LineKey 
    141         * the LineKey will be a legend for the two lines created 
    142         * position the key in the upper right corner 
    143         * and add to the first layer 
    144         */ 
    145         lkey = new LineKey(); 
    146         lkey.setId( "Legend" ); 
    147         lkey.setLocationP( new Point2D.Double( xsize - 1, ysize - 1 ) ); 
    148         lkey.setVAlign( LineKey.TOP ); 
    149         lkey.setHAlign( LineKey.RIGHT ); 
    150         layer.addChild( lkey ); 
    151         /* 
    152         * add the first layer to the Pane 
    153         */ 
    154131        mainPane.add( layer ); 
    155         /* 
    156         * create first CartesianGraph and transforms 
    157         */ 
    158         graph = new CartesianGraph( "First Graph" ); 
    159         xt = new LinearTransform( new Range2D( xstart, xend ), tnRange ); 
     132 
     133        /** ************ GRAPH ********** **/ 
     134        // Create first CartesianGraph and transforms 
     135        final CartesianGraph graph = new CartesianGraph( "First Graph" ); 
     136        final LinearTransform xt = new LinearTransform( new Range2D( xstart, xend ), xnRange ); 
    160137        graph.setXTransform( xt ); 
    161         yt = new LinearTransform( new Range2D( ystart, yend ), ynRange ); 
     138        final LinearTransform yt = new LinearTransform( new Range2D( ystart, yend ), ynRange ); 
    162139        graph.setYTransform( yt ); 
    163         /* 
    164         * Create the time axis, set its range in user units 
    165         * and its origin. Add the axis to the first graph. 
    166         */ 
    167         SoTPoint point = new SoTPoint( ynRange.getStart(), tnRange.getStart() ); 
    168         xbot = new TimeAxis( "Bottom Axis", TimeAxis.MONTH_YEAR ); 
    169         xbot.setRangeU( tnRange ); 
    170         xbot.setLocationU( point ); 
    171         Font xbfont = new Font( "Helvetica", Font.ITALIC, 14 ); 
    172         xbot.setLabelFont( xbfont ); 
    173         xbot.setMinorLabelInterval( 1 ); 
     140 
    174141        graph.addXAxis( xbot ); 
    175         /* 
    176         * Create the vertical axis, set its range in user units 
    177         * and its origin.  Create the axis title and add the 
    178         * axis to the first graph. 
    179         */ 
    180         yleft = new PlainAxis( "Left Axis" ); 
    181         yleft.setRangeU( ynRange ); 
    182         yleft.setLocationU( point ); 
    183         yleft.setLabelFont( xbfont ); 
    184         ytitle = new SGLabel( "Y-Axis Title", yLabel, 
    185                 new Point2D.Double( 0.0, 0.0 ) ); 
    186         Font ytfont = new Font( "Helvetica", Font.PLAIN, 14 ); 
    187         ytitle.setFont( ytfont ); 
    188         ytitle.setHeightP( 0.2 ); 
    189         yleft.setTitle( ytitle ); 
    190142        graph.addYAxis( yleft ); 
    191         /* 
    192         * Add the first graph to the first layer. 
    193         */ 
     143        graph.addYAxis( yleft2 ); 
     144 
     145 
     146        /** *********** LINE ********* **/ 
     147        final LineAttribute attr; 
     148        final int lineAttributeStyle; 
     149        if( megapoliPlot.getAxeType().equals( AxeTypeForFixedPlateform.TIME_POINTS.toString() ) ) 
     150            lineAttributeStyle = LineAttribute.MARK; 
     151        else 
     152            lineAttributeStyle = LineAttribute.SOLID; 
     153        attr = new LineAttribute( lineAttributeStyle, 1, Color.red ); 
     154        attr.setMarkHeightP( _markHeight ); 
     155 
     156        graph.setData( firstLine, attr ); 
    194157        layer.setGraph( graph ); 
    195         /* 
    196         * Create a LineAttribute for the display of the first 
    197         * line. Associate the attribute and the line with the 
    198         * first graph.  Add the line to the LineKey. 
    199         */ 
    200         LineAttribute attr; 
    201  
    202         attr = new LineAttribute( LineAttribute.MARK, 20, Color.red ); 
    203         attr.setMarkHeightP( 0.1 ); 
    204         graph.setData( line, attr ); 
    205         lkey.addLineGraph( (LineCartesianRenderer) graph.getRenderer(), 
    206                 new SGLabel( "1st line", "Red Data", 
    207                         new Point2D.Double( 0.0, 0.0 ) ) ); 
    208         /* 
    209         * Create the second layer and add it the the Pane. 
    210         * Create the second graph and associate it with the 
    211         * second layer. 
    212         */ 
    213 //        layer2 = new Layer( "Second Layer", new Dimension2D( xsize, ysize ) ); 
    214 //        mainPane.add( layer2 ); 
    215 //        graph2 = new CartesianGraph( "Second Graph", xt, yt ); 
    216 //        layer2.setGraph( graph2 ); 
    217         /* 
    218         * Create a LineAttribute for the display of the second 
    219         * line. Associate the attribute and the line with the 
    220         * second graph.  Add the line to the LineKey. 
    221         */ 
    222 //        LineAttribute attr2; 
    223 //        attr2 = new LineAttribute( LineAttribute.MARK, 2, Color.blue ); 
    224 //        attr2.setMarkHeightP( 0.1 ); 
    225 //        graph2.setData( line2, attr2 ); 
    226 //        lkey.addLineGraph( (LineCartesianRenderer) graph2.getRenderer(), 
    227 //                new SGLabel( "2nd line", "Blue Data", 
    228 //                        new Point2D.Double( 0.0, 0.0 ) ) ); 
    229  
     158 
     159        /** *********** LEGEND ********* **/ 
     160        final LineKey lkey = new LineKey(); 
     161        if( !megapoliPlot.isLegendToHide() ) 
     162        { 
     163            lkey.setId( "Legend" ); 
     164            lkey.setLocationP( new Point2D.Double( xsize - 1, ysize - 1 ) ); 
     165            lkey.setVAlign( LineKey.TOP ); 
     166            lkey.setHAlign( LineKey.RIGHT ); 
     167            layer.addChild( lkey ); 
     168            lkey.addLineGraph( (LineCartesianRenderer) graph.getRenderer(), new SGLabel( "First line", "Red Data", new Point2D.Double( 0.0, 0.0 ) ) ); 
     169        } 
     170 
     171        /** ********************************** **/ 
     172        /** *********** OTHER LAYERS ********* **/ 
     173        /** ********************************** **/ 
     174        for( final SimpleLine line : lines.subList( 1, lines.size() ) ) 
     175        { 
     176            final Layer otherLayer = new Layer( "Other Layer", new Dimension2D( xsize, ysize ) ); 
     177            mainPane.add( otherLayer ); 
     178            final CartesianGraph otherGraph = new CartesianGraph( "Second Graph", xt, yt ); 
     179            otherLayer.setGraph( otherGraph ); 
     180 
     181            final LineAttribute otherLineAttribute = new LineAttribute( lineAttributeStyle, 2, Color.blue ); 
     182            otherLineAttribute.setMarkHeightP( _markHeight ); 
     183            otherGraph.setData( line, otherLineAttribute ); 
     184            lkey.addLineGraph( (LineCartesianRenderer) otherGraph.getRenderer(), new SGLabel( "Other line", "Other Data", new Point2D.Double( 0.0, 0.0 ) ) ); 
     185        } 
    230186        return mainPane; 
    231187    } 
    232188 
    233189    @NotNull 
    234     public JPane create2DPlot( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight ) 
    235     { 
    236         /* 
    237        * This example uses a pre-created "Layout" for raster time 
    238        * series to simplify the construction of a plot. The 
    239        * JPlotLayout can plot a single grid with 
    240        * a ColorKey, time series with a LineKey, point collection with a 
    241        * PointCollectionKey, and general X-Y plots with a 
    242        * LineKey. JPlotLayout supports zooming, object selection, and 
    243        * object editing. 
    244         */ 
     190    public JPane create2DPlot( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight, @Nullable final Locale locale ) 
     191    { 
    245192        SGTData newData; 
    246193        TestData td; 
    247         JPlotLayout rpl; 
    248         ContourLevels clevels; 
     194 
     195        final ResourceBundle bundle = WebHelper.getBundle( locale ); 
     196 
     197        final double[] parameterArray = (double[]) megapoliPlot.getData().getFirstArray(); 
     198        final double[] latitudeArray = (double[]) megapoliPlot.getData().getSecondArray(); 
     199        final double[] longitudeValues = (double[]) megapoliPlot.getData().getThirdArray(); 
     200 
     201//        final SimpleLine data = new SimpleLine( longitudeValues, latitudeArray, "legend" ); 
     202        final SimpleGrid data = new SimpleGrid( parameterArray, longitudeValues, latitudeArray, "Test Series" ); 
     203        SGTMetaData meta = new SGTMetaData( bundle.getString( "plot.longitude" ), bundle.getString( "plot.degres" ), false, true ); 
     204        // TODO : vérifier modulo = 360 
     205//        meta.setModuloValue( 360 ); 
     206        data.setXMetaData( meta ); 
     207 
     208        meta = new SGTMetaData( bundle.getString( "plot.latitude" ), bundle.getString( "plot.degres" ), false, true ); 
     209        // TODO : vérifier modulo = 360 
     210//        meta.setModuloValue( 360 ); 
     211        data.setYMetaData( meta ); 
    249212        /* 
    250213       * Create a test grid with sinasoidal-ramp data. 
    251214        */ 
     215//        Range2D xr = new Range2D( 190.0f, 250.0f, 1.0f ); 
     216//        Range2D yr = new Range2D( 0.0f, 45.0f, 1.0f ); 
    252217        Range2D xr = new Range2D( 190.0f, 250.0f, 1.0f ); 
    253218        Range2D yr = new Range2D( 0.0f, 45.0f, 1.0f ); 
    254         td = new TestData( TestData.XY_GRID, xr, yr, 
    255                 TestData.SINE_RAMP, 12.0f, 30.f, 5.0f ); 
    256         newData = td.getSGTData(); 
    257         /* 
    258        * Create the layout without a Logo image and with the 
    259        * ColorKey on a separate Pane object. 
    260         */ 
    261         rpl = new JPlotLayout( true, false, false, "JGridDemo Pane", null, true ); 
    262         rpl.setEditClasses( false ); 
    263         /* 
    264        * Create a GridAttribute for CONTOUR style. 
    265         */ 
    266         Range2D datar = new Range2D( -20.0f, 45.0f, 5.0f ); 
    267         clevels = ContourLevels.getDefault( datar ); 
    268         GridAttribute gridAttr_ = new GridAttribute( clevels ); 
    269         /* 
    270        * Create a ColorMap and change the style to RASTER_CONTOUR. 
    271         */ 
    272         ColorMap cmap = createColorMap( datar ); 
    273         gridAttr_.setColorMap( cmap ); 
    274         gridAttr_.setStyle( GridAttribute.RASTER_CONTOUR ); 
    275         /* 
    276        * Add the grid to the layout and give a label for 
    277        * the ColorKey. 
    278         */ 
    279         rpl.addData( newData, gridAttr_, "First Data" ); 
    280         /* 
    281        * Change the layout's three title lines. 
    282         */ 
    283         rpl.setTitles( "Raster Plot Demo", 
    284                 "using a JPlotLayout", 
    285                 "" ); 
    286         /* 
    287        * Resize the graph  and place in the "Center" of the frame. 
    288         */ 
    289         rpl.setSize( new Dimension( 600, 400 ) ); 
     219        newData = testDataa( xr, yr, TestData.SINE_RAMP, 12.0f, 30.f, 5.0f, parameterArray, latitudeArray, longitudeValues ); 
     220 
     221        // Create the contour levels and color map 
     222        final Range2D datar = new Range2D( -20.0f, 50.0f, 5.0f ); 
     223        final ContourLevels clevels = ContourLevels.getDefault( datar ); 
     224        final ColorMap cmap = createColorMap( datar ); 
     225 
     226        // Create a grid for contour data 
     227        final GridAttribute gridAttribute = new GridAttribute( clevels ); 
     228        gridAttribute.setColorMap( cmap ); 
     229        gridAttribute.setStyle( GridAttribute.RASTER_CONTOUR ); 
     230 
     231        // Create the plot 
     232        final JPlotLayout jPlotLayout = new JPlotLayout( true, false, false, "JPlotLayout Pane", null, true ); 
     233        jPlotLayout.setEditClasses( false ); 
     234        jPlotLayout.addData( newData, gridAttribute, "First Data" ); 
     235        jPlotLayout.setTitles( "", "", "" ); 
     236        jPlotLayout.setSize( new Dimension( plotWidth, plotHeight ) ); 
     237 
    290238        /* 
    291239       * Resize the key Pane, both the device size and the physical 
     
    296244//    rpl.setKeyBoundsP(new Rectangle2D.Double(0.01, 1.01, 5.98, 1.0)); 
    297245 
    298         return rpl; 
     246        return jPlotLayout; 
    299247    } 
    300248 
     
    606554    } 
    607555 
     556    public SGTData testDataa( Range2D range1, Range2D range2, int type, float amp, float off, float per, final double[] parameterArray, final double[] latitudeArray, final double[] longitudeValues ) 
     557    { 
     558        SimpleGrid sg; 
     559        SGTMetaData xMeta; 
     560        SGTMetaData yMeta; 
     561        SGTMetaData zMeta; 
     562 
     563        double[] axis1, axis2; 
     564        double[] values; 
     565        double[] zero; 
     566        GeoDate tzero[] = new GeoDate[1]; 
     567        int count; 
     568 
     569        zero = new double[1]; 
     570        tzero[0] = new GeoDate(); 
     571        zero[0] = 0; 
     572        tzero[0].now(); 
     573        int num1 = (int) ( ( range1.end - range1.start ) / range1.delta ) + 1; 
     574        axis1 = new double[num1]; 
     575        int num2 = (int) ( ( range2.end - range2.start ) / range2.delta ) + 1; 
     576        axis2 = new double[num2]; 
     577 
     578        for( count = 0; count < num1; count++ ) 
     579        { 
     580            axis1[count] = range1.start + count * range1.delta; 
     581        } 
     582        for( count = 0; count < num2; count++ ) 
     583        { 
     584            axis2[count] = range2.start + count * range2.delta; 
     585        } 
     586 
     587        values = getValues( axis1, num1, axis2, num2, type, amp, off, per ); 
     588 
     589        SGLabel keyLabel = new SGLabel( "Key Label", "", new Point2D.Double( 0.0, 0.0 ) ); 
     590        keyLabel.setHeightP( 0.16 ); 
     591        // 
     592        // create SimpleGrid 
     593        // 
     594        zMeta = new SGTMetaData( "ts", "m s-1" ); 
     595        keyLabel.setText( "XY test grid" ); 
     596        xMeta = new SGTMetaData( "lon", "degE" ); 
     597        yMeta = new SGTMetaData( "lat", "deg" ); 
     598//        sg = new SimpleGrid( values, axis1, axis2, "Test Series" ); 
     599        sg = new SimpleGrid( values, axis1, latitudeArray, "Test Series" ); 
     600 
     601        sg.setXMetaData( xMeta ); 
     602        sg.setYMetaData( yMeta ); 
     603        sg.setZMetaData( zMeta ); 
     604        sg.setKeyTitle( keyLabel ); 
     605        return sg; 
     606    } 
     607 
     608    private double[] getValues( double[] axis1, int num1, double[] axis2, int num2, 
     609                                int type, float amp, float off, float per ) 
     610    { 
     611        double[] values; 
     612        int count1, count2, count; 
     613        values = new double[num1 * num2]; 
     614        switch( type ) 
     615        { 
     616            default: 
     617            case TestData.RANDOM: 
     618                for( count = 0; count < num1 * num2; count++ ) 
     619                { 
     620                    values[count] = amp * Math.random() + off; 
     621                } 
     622                break; 
     623            case TestData.SINE: 
     624                count = 0; 
     625                for( count1 = 0; count1 < num1; count1++ ) 
     626                { 
     627                    for( count2 = 0; count2 < num2; count2++ ) 
     628                    { 
     629                        values[count] = amp * Math.sin( axis1[count1] / per ) * 
     630                                Math.sin( axis2[count2] / per ) + off; 
     631                        count++; 
     632                    } 
     633                } 
     634                break; 
     635            case TestData.SINE_RAMP: 
     636                count = 0; 
     637                double ax1factr = 0.08 * Math.abs( axis1[0] - axis1[num1 - 1] ) / 
     638                        Math.max( Math.abs( axis1[0] ), Math.abs( axis1[num1 - 1] ) ); 
     639                double ax2factr = 0.08 * Math.abs( axis2[0] - axis2[num2 - 1] ) / 
     640                        Math.max( Math.abs( axis2[0] ), Math.abs( axis2[num2 - 1] ) ); 
     641                for( count1 = 0; count1 < num1; count1++ ) 
     642                { 
     643                    for( count2 = 0; count2 < num2; count2++ ) 
     644                    { 
     645                        values[count] = amp * Math.sin( axis1[count1] / per ) * 
     646                                Math.sin( axis2[count2] / per ) + off + 
     647                                amp * ( ax1factr * count1 - ax2factr * count2 ); 
     648                        count++; 
     649                    } 
     650                } 
     651 
     652        } 
     653        return values; 
     654    } 
     655 
     656    /** 
     657     * This method extracts data from BD for the plateform and parameter given as parameters 
     658     * and creates the corresponded simpleLine 
     659     * 
     660     * @param pIdPIdList 
     661     * @param beginDate 
     662     * @param endDate 
     663     * @return 
     664     * @throws ServiceException 
     665     */ 
     666    @NotNull 
     667    private List<SimpleLine> createLines( @NotNull final List<Pair> pIdPIdList, @Nullable final Date beginDate, @Nullable final Date endDate ) 
     668            throws ServiceException 
     669    { 
     670        final List<SimpleLine> lines = new ArrayList<SimpleLine>( pIdPIdList.size() ); 
     671        boolean isFirstLine = true; 
     672 
     673        for( final Pair<Integer, Integer> pIdPId : pIdPIdList ) 
     674        { 
     675            final Parametre parametre = new Parametre(); 
     676            if( isFirstLine ) 
     677            { 
     678//            final Parametre parametre = _etherService.getParameterById( parameterId ); 
     679                parametre.setParametreNom( "Ozone" ); 
     680                final Unite unit = new Unite(); 
     681                unit.setUniteCode( "ppb" ); 
     682                parametre.setUnite( unit ); 
     683                if( null == parametre ) 
     684                    throw new ServiceException( ServiceException.ServiceCode.PARAMETER_IS_NULL, new Throwable( ServiceException.ServiceCode.PARAMETER_IS_NULL.toString() ) ); 
     685            } 
     686 
     687            final Integer plateformId = pIdPId.getFirstValue(); 
     688            final Integer parameterId = pIdPId.getSecondValue(); 
     689//        final Data valuesLists = _etherService.getListsByPlateformByParameterByPeriodForTimeSerie( plateformId, parameterId, beginDate, endDate ); 
     690            final Data valuesLists = createValuesTemp( 50, 5 ); 
     691 
     692            final double[] dataArray = (double[]) valuesLists.getFirstArray(); 
     693            final Date[] dateValues = (Date[]) valuesLists.getSecondArray(); 
     694 
     695            final SimpleLine line = new SimpleLine( new GeoDateArray( dateValues ), dataArray, "legend" ); 
     696            SGTMetaData meta = new SGTMetaData( "", "", false, false ); 
     697            line.setXMetaData( meta ); 
     698 
     699            if( isFirstLine ) 
     700                meta = new SGTMetaData( parametre.getParametreNom(), parametre.getUnite().getUniteCode(), false, false ); 
     701            else 
     702                meta = new SGTMetaData( "", "", false, false ); 
     703            line.setYMetaData( meta ); 
     704 
     705            lines.add( line ); 
     706            isFirstLine = false; 
     707        } 
     708        return lines; 
     709    } 
     710 
     711    // TODO : remove this method 
     712    private Data createValuesTemp( final Integer size, final Integer delta ) 
     713    { 
     714        final double[] values = new double[size]; 
     715        final Date[] dates = new Date[size]; 
     716        final Calendar cal = Calendar.getInstance(); 
     717 
     718        for( int i = 0; i < size; i++ ) 
     719        { 
     720            values[i] = (double) i * Math.random(); 
     721            cal.set( Calendar.MINUTE, (int) ( 2 + i + ( Math.random() * 8 ) ) ); 
     722            dates[i] = cal.getTime(); 
     723        } 
     724        return new Data( values, dates ); 
     725    } 
     726 
     727    @Required 
     728    public void setEtherService( final EtherService etherService ) 
     729    { 
     730        _etherService = etherService; 
     731    } 
     732 
    608733    // Dimensions of the jPanes 
    609734    protected static final int MAX_WIDTH = 800; 
     
    614739    protected static final int FONT_SIZE = 12; 
    615740    protected static final int ERROR_FONT_SIZE = 10; 
     741 
     742    protected static final Font _axisFont = new Font( "Helvetica", Font.PLAIN, 12 ); 
     743    protected static final double _heightAxisFont = 0.2; 
     744    protected static final double _markHeight = 0.1; 
     745 
     746    private EtherService _etherService; 
    616747} 
  • ether_megapoli/trunk/service/implementation/com/ether/EtherPlotServiceImpl.java

    r182 r184  
    2323        implements EtherPlotService 
    2424{ 
     25    /** 
     26     * This method returns the maximum width available to display the quicklook in terms of screenSize and default maximum width 
     27     * 
     28     * @return 
     29     */ 
    2530    public static Integer getMaxWidth() 
    2631    { 
     
    2934    } 
    3035 
     36    /** 
     37     * This method returns the maximum height available to display the quicklook in terms of screenSize and default maximum height 
     38     * 
     39     * @return 
     40     */ 
    3141    public static Integer getMaxHeight() 
    3242    { 
     
    4454    @NotNull 
    4555    public BufferedImage createMainPane( @NotNull final MegapoliPlot megapoliPlot, @Nullable final Locale locale ) 
     56            throws ServiceException 
    4657    { 
    4758        final Integer maxWidth = getMaxWidth(); 
     
    5768        jPane.add( jPaneTop, BorderLayout.NORTH ); 
    5869 
    59         final Integer valuesNumber = megapoliPlot.getValuesNumber(); 
     70        // TODO : gérer values Number 
     71        final Integer valuesNumber = 10; 
     72//        final Integer valuesNumber = megapoliPlot.getValuesNumber(); 
    6073 
    6174        // Bottom Pane 
     
    236249    @NotNull 
    237250    public BufferedImage createCenterPane( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer maxWidth, @NotNull final Integer maxHeight, @Nullable final Locale locale ) 
     251            throws ServiceException 
    238252    { 
    239253        final Integer plotWidth = Math.min( maxWidth - MARGIN_LEFT_RIGHT, maxWidth ); 
     
    245259            jPaneGraph = createTimeSeriePlot( megapoliPlot, plotWidth, plotHeight ); 
    246260        else 
    247             jPaneGraph = create2DPlot( megapoliPlot, plotWidth, plotHeight ); 
     261            jPaneGraph = create2DPlot( megapoliPlot, plotWidth, plotHeight, locale ); 
    248262 
    249263        final BufferedImage bufferedImage = new BufferedImage( jPaneGraph.getWidth(), jPaneGraph.getHeight(), BufferedImage.TYPE_INT_ARGB ); 
  • ether_megapoli/trunk/service/implementation/com/ether/MegapoliPlot.java

    r176 r184  
    11package com.ether; 
    22 
    3 import com.medias.megapoli.utils.MegapoliInitialisation; 
    43import org.jetbrains.annotations.NotNull; 
    54import org.jetbrains.annotations.Nullable; 
     5 
     6import java.util.Date; 
     7import java.util.List; 
    68 
    79/** 
     
    7577    } 
    7678 
    77     @Nullable 
    78     public String getParameterName() 
    79     { 
    80         return _parameterName; 
    81     } 
    82  
    83     public void setParameterName( @Nullable final String parameterName ) 
    84     { 
    85         _parameterName = parameterName; 
    86     } 
    87  
    88     @Nullable 
    89     public String getParameterUnitCode() 
    90     { 
    91         return _parameterUnitCode; 
    92     } 
    93  
    94     public void setParameterUnitCode( @Nullable final String parameterUnitCode ) 
    95     { 
    96         _parameterUnitCode = parameterUnitCode; 
    97     } 
     79//    @Nullable 
     80//    public String getParameterName() 
     81//    { 
     82//        return _parameterName; 
     83//    } 
     84// 
     85//    public void setParameterName( @Nullable final String parameterName ) 
     86//    { 
     87//        _parameterName = parameterName; 
     88//    } 
     89// 
     90//    @Nullable 
     91//    public String getParameterUnitCode() 
     92//    { 
     93//        return _parameterUnitCode; 
     94//    } 
     95// 
     96//    public void setParameterUnitCode( @Nullable final String parameterUnitCode ) 
     97//    { 
     98//        _parameterUnitCode = parameterUnitCode; 
     99//    } 
    98100 
    99101    @NotNull 
     
    119121    } 
    120122 
     123    @NotNull 
     124    public List<Pair> getpIdPIdList() 
     125    { 
     126        return _pIdPIdList; 
     127    } 
     128 
     129    public void setpIdPIdList( @NotNull final List<Pair> pIdPIdList ) 
     130    { 
     131        _pIdPIdList = pIdPIdList; 
     132    } 
     133 
     134    @Nullable 
     135    public Date getBeginDate() 
     136    { 
     137        return _beginDate; 
     138    } 
     139 
     140    public void setBeginDate( @Nullable final Date beginDate ) 
     141    { 
     142        _beginDate = beginDate; 
     143    } 
     144 
     145    @Nullable 
     146    public Date getEndDate() 
     147    { 
     148        return _endDate; 
     149    } 
     150 
     151    public void setEndDate( @Nullable final Date endDate ) 
     152    { 
     153        _endDate = endDate; 
     154    } 
     155 
    121156    @Nullable 
    122157    private String _title; 
     
    132167    private boolean _legendToHide = true; 
    133168    private boolean _isTimeSerie = true; 
    134     @Nullable 
    135     private String _parameterName; 
    136     @Nullable 
    137     private String _parameterUnitCode; 
     169//    @Nullable 
     170//    private String _parameterName; 
     171//    @Nullable 
     172//    private String _parameterUnitCode; 
    138173    @NotNull 
    139174    private Integer _valuesNumber; 
    140175    @NotNull 
    141176    private String _axeType; 
     177 
     178    // List of <plateformId, parameterId> to display 
     179    @NotNull 
     180    private List<Pair> _pIdPIdList; 
     181    @Nullable 
     182    private Date _beginDate; 
     183    @Nullable 
     184    private Date _endDate; 
    142185} 
  • ether_megapoli/trunk/service/implementation/service-context.xml

    r155 r184  
    33 
    44<beans> 
    5         <bean id="etherServiceTarget" class="com.ether.EtherServiceImpl"> 
    6                 <property name="plateformDAO" ref="refPlateformDAO" /> 
    7                 <property name="parameterDAO" ref="refParameterDAO" /> 
    8                 <property name="valueDAO" ref="refValueDAO" />                           
    9         </bean> 
    10         <bean id="etherService" parent="transactionProxy"> 
    11                 <property name="target"> 
    12                         <ref bean="etherServiceTarget" /> 
    13                 </property> 
    14                 <property name="transactionAttributeSource"> 
    15                         <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource" /> 
    16                 </property> 
    17         </bean> 
     5    <bean id="etherServiceTarget" class="com.ether.EtherServiceImpl"> 
     6        <property name="plateformDAO" ref="refPlateformDAO"/> 
     7        <property name="parameterDAO" ref="refParameterDAO"/> 
     8        <property name="valueDAO" ref="refValueDAO"/> 
     9    </bean> 
     10    <bean id="etherService" parent="transactionProxy"> 
     11        <property name="target"> 
     12            <ref bean="etherServiceTarget"/> 
     13        </property> 
     14        <property name="transactionAttributeSource"> 
     15            <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/> 
     16        </property> 
     17    </bean> 
    1818 
    19     <bean id="etherPlotService" class="com.ether.EtherPlotServiceImpl"></bean> 
     19    <bean id="etherPlotService" class="com.ether.EtherPlotServiceImpl"> 
     20        <property name="etherService" ref="etherService"/> 
     21    </bean> 
    2022 
    2123</beans> 
  • ether_megapoli/trunk/service/interface/com/ether/EtherPlotService.java

    r182 r184  
    1717{ 
    1818    @NotNull 
    19     public BufferedImage createMainPane( @NotNull final MegapoliPlot megapoliPlot, @Nullable final Locale locale ); 
     19    public BufferedImage createMainPane( @NotNull final MegapoliPlot megapoliPlot, @Nullable final Locale locale ) 
     20            throws ServiceException; 
    2021 
    2122    @NotNull 
     
    3233 
    3334    @NotNull 
    34     public BufferedImage createCenterPane( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer maxWidth, @NotNull final Integer maxHeight, @Nullable final Locale locale ); 
     35    public BufferedImage createCenterPane( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer maxWidth, @NotNull final Integer maxHeight, @Nullable final Locale locale ) 
     36            throws ServiceException; 
    3537 
    3638    @NotNull 
    37     public JPane createTimeSeriePlot( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight ); 
     39    public JPane createTimeSeriePlot( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight ) 
     40            throws ServiceException; 
    3841 
    3942    @NotNull 
    40     public JPane create2DPlot( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight ); 
     43    public JPane create2DPlot( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight, @Nullable final Locale locale ); 
    4144 
    4245    @NotNull 
  • ether_megapoli/trunk/service/interface/com/ether/ServiceException.java

    r129 r184  
    2525        PLATEFORM_NOT_FOUND, 
    2626        PARAMETER_NOT_FOUND, 
     27        PARAMETER_IS_NULL, 
    2728        VALUE_NOT_FOUND, 
    2829        PANEL_MODEL_NOT_FOUND; 
  • ether_megapoli/trunk/web/resources/js/DomHelper.js

    r129 r184  
    164164 
    165165 
    166 var Select = Class.create({ 
    167     initialize: function( id, className, name, disabled ) 
    168     { 
    169         this.id = id; 
    170         this.name = name; 
    171         this.valueKey = 'value'; 
    172         this.textKey = 'text'; 
    173         if( disabled ) 
    174             this.select = new Element('select', {id:id, disabled:disabled}); 
    175         else 
    176             this.select = new Element('select', {id:id}); 
    177         this.select.addClassName(className); 
    178     }, 
    179  
    180     setValueKey: function( key ) 
    181     { 
    182         this.valueKey = key; 
    183     }, 
    184  
    185     setTextKey: function( key ) 
    186     { 
    187         this.textKey = key; 
    188     }, 
    189  
    190     addOptions: function( options, selectedOption, onClickAction ) 
    191     { 
    192         options.each(function( option ) 
    193         { 
    194             this.addOption(option, selectedOption, onClickAction); 
    195         }.bind(this)); 
    196     }, 
    197  
    198     addOption: function( option, selectedOption, onClickAction ) 
    199     { 
    200         var value = this.valueKey ? option[this.valueKey] : option; 
    201         var text = this.textKey ? option[this.textKey] : option; 
    202         if( null != selectedOption && value == selectedOption ) 
    203             var option = new Element('option', {value:value, selected:"selected"}).update(text); 
    204         else 
    205             var option = new Element('option', {value:value}).update(text); 
    206  
    207         if( null != onClickAction ) 
    208             Event.observe(option, 'click', onClickAction.bind(this)); 
    209         this.select.insert(option); 
    210     }, 
    211  
    212     addToElement: function( elementId ) 
    213     { 
    214         $(elementId).insert(this.select); 
    215     } 
    216 }); 
     166//var Select = Class.create({ 
     167//    initialize: function( id, className, name, disabled ) 
     168//    { 
     169//        this.id = id; 
     170//        this.name = name; 
     171//        this.valueKey = 'value'; 
     172//        this.textKey = 'text'; 
     173//        if( disabled ) 
     174//            this.select = new Element('select', {id:id, disabled:disabled}); 
     175//        else 
     176//            this.select = new Element('select', {id:id}); 
     177//        this.select.addClassName(className); 
     178//    }, 
     179// 
     180//    setValueKey: function( key ) 
     181//    { 
     182//        this.valueKey = key; 
     183//    }, 
     184// 
     185//    setTextKey: function( key ) 
     186//    { 
     187//        this.textKey = key; 
     188//    }, 
     189// 
     190//    addOptions: function( options, selectedOption, onClickAction ) 
     191//    { 
     192//        options.each(function( option ) 
     193//        { 
     194//            this.addOption(option, selectedOption, onClickAction); 
     195//        }.bind(this)); 
     196//    }, 
     197// 
     198//    addOption: function( option, selectedOption, onClickAction ) 
     199//    { 
     200//        var value = this.valueKey ? option[this.valueKey] : option; 
     201//        var text = this.textKey ? option[this.textKey] : option; 
     202//        if( null != selectedOption && value == selectedOption ) 
     203//            var option = new Element('option', {value:value, selected:"selected"}).update(text); 
     204//        else 
     205//            var option = new Element('option', {value:value}).update(text); 
     206// 
     207//        if( null != onClickAction ) 
     208//            Event.observe(option, 'click', onClickAction.bind(this)); 
     209//        this.select.insert(option); 
     210//    }, 
     211// 
     212//    addToElement: function( elementId ) 
     213//    { 
     214//        $(elementId).insert(this.select); 
     215//    } 
     216//}); 
    217217 
    218218 
  • ether_megapoli/trunk/web/src/com/ether/Controller.java

    r178 r184  
    9191        parametersByPlateform.add( p2 ); 
    9292 
     93        if( plateformId == 1 ) 
     94        { 
     95            final Parametre p3 = new Parametre(); 
     96            p3.setParametreId( 3 ); 
     97            p3.setParametreNom( "Ethane" ); 
     98            parametersByPlateform.add( p3 ); 
     99        } 
     100        else 
     101        { 
     102            final Parametre p3 = new Parametre(); 
     103            p3.setParametreId( 3 ); 
     104            p3.setParametreNom( "Sulfate" ); 
     105            parametersByPlateform.add( p3 ); 
     106            final Parametre p4 = new Parametre(); 
     107            p4.setParametreId( 4 ); 
     108            p4.setParametreNom( "Benzene" ); 
     109            parametersByPlateform.add( p4 ); 
     110        } 
     111 
    93112        final JSONObject result = new JSONObject(); 
    94113        result.put( ParameterConstants.PARAMETER_PARAMETERS, getJsonHelper().toJSON( parametersByPlateform ) ); 
  • ether_megapoli/trunk/web/src/com/ether/ControllerPlot.java

    r178 r184  
    22 
    33import com.medias.Context; 
    4 import com.medias.database.objects.Parametre; 
    5 import com.medias.database.objects.Unite; 
    64import org.apache.commons.logging.Log; 
    75import org.apache.commons.logging.LogFactory; 
     
    1917import java.awt.image.BufferedImage; 
    2018import java.io.IOException; 
     19import java.util.ArrayList; 
    2120import java.util.Calendar; 
    2221import java.util.Date; 
     22import java.util.List; 
    2323 
    2424/** 
     
    3535        { 
    3636            final ApplicationContext appContext = WebApplicationContextUtils.getRequiredWebApplicationContext( servletConfig.getServletContext() ); 
    37             _etherService = (EtherService) appContext.getBean( "etherService", EtherService.class ); 
    3837            _etherPlotService = (EtherPlotService) appContext.getBean( "etherPlotService", EtherPlotService.class ); 
    3938        } 
     
    6059        try 
    6160        { 
    62             final Integer plateformId = Integer.valueOf( request.getParameter( "plateformId" ) ); 
    63             final Integer parameterId = Integer.valueOf( request.getParameter( "parameterId" ) ); 
    6461            final String title = request.getParameter( "title" ); 
    6562            final String axeType = request.getParameter( "axeType" ); 
     63 
     64            // TODO : utiliser JSON pour récupérer pIdPIdList 
     65            final String pIdPIdArrayString = request.getParameter( "pIdPIdList" ); 
     66            final List<Pair> pIdPIdList = extractpIdPIdListFromString( pIdPIdArrayString ); 
     67            if( null == pIdPIdList ) 
     68            { 
     69                createErrorPane( response, request, WebException.WebCode.PLATEFORM_OR_PARAMETER_IS_NULL.toString(), null ); 
     70                flagException = true; 
     71                throw new ServletException( WebException.WebCode.PLATEFORM_OR_PARAMETER_IS_NULL.toString(), null ); 
     72            } 
    6673 
    6774            // Dates 
     
    8693                } 
    8794 
    88             // Parameter 
    89 //            final Parametre parametre = _etherService.getParameterById( parameterId ); 
    90             final Parametre parametre = new Parametre(); 
    91             parametre.setParametreNom( "Ozone" ); 
    92             final Unite unit = new Unite(); 
    93             unit.setUniteCode( "ppb" ); 
    94             parametre.setUnite( unit ); 
    95             if( null == parametre ) 
    96             { 
    97                 createErrorPane( response, request, WebException.WebCode.PARAMETER_IS_NULL.toString(), null ); 
    98                 flagException = true; 
    99                 throw new ServletException( WebException.WebCode.PARAMETER_IS_NULL.toString(), null ); 
    100             } 
    101  
    10295            // Create plot 
    10396            final MegapoliPlot megapoliPlot = new MegapoliPlot(); 
    10497            megapoliPlot.setTitle( title ); 
    10598            megapoliPlot.setAxeType( axeType ); 
    106             megapoliPlot.setParameterName( parametre.getParametreNom() ); 
    107             if( null != parametre.getUnite() && null != parametre.getUnite().getUniteCode() ) 
    108                 megapoliPlot.setParameterUnitCode( parametre.getUnite().getUniteCode() ); 
    109  
     99            megapoliPlot.setpIdPIdList( pIdPIdList ); 
     100            megapoliPlot.setBeginDate( formatedDateBegin ); 
     101            megapoliPlot.setEndDate( formatedDateEnd ); 
    110102 
    111103            if( AxeTypeForFixedPlateform.TIME_LINE.name().equals( axeType ) || AxeTypeForFixedPlateform.TIME_POINTS.name().equals( axeType ) ) 
    112104            { 
    113 //                final Data valuesLists = _etherService.getListsByPlateformByParameterByPeriodForTimeSerie( plateformId, parameterId, formatedDateBegin, formatedDateEnd ); 
    114                 final double[] values = new double[50]; 
    115                 final Date[] dates = new Date[50]; 
    116                 final Calendar cal = Calendar.getInstance(); 
    117  
    118                 for( int i = 0; i < 50; i++ ) 
    119                 { 
    120                     values[i] = (double) i; 
    121                     cal.set( Calendar.MINUTE, 5 * i ); 
    122                     dates[i] = cal.getTime(); 
    123                 } 
    124                 final Data valuesLists = new Data( values, dates ); 
    125  
    126                 megapoliPlot.setData( valuesLists ); 
    127  
    128105                megapoliPlot.setTimeSerie( true ); 
    129                 megapoliPlot.setLegendToHide( true ); 
    130                 megapoliPlot.setValuesNumber( ( (double[]) valuesLists.getFirstArray() ).length ); 
     106                megapoliPlot.setLegendToHide( pIdPIdList.size() == 1 ); 
     107//                megapoliPlot.setValuesNumber( ( (double[]) valuesLists.getFirstArray() ).length ); 
    131108            } 
    132109            else 
     
    157134            ImageIO.write( bufferedImage, "png", response.getOutputStream() ); 
    158135        } 
     136        catch( ServiceException se ) 
     137        { 
     138            try 
     139            { 
     140                if( !flagException ) 
     141                    createErrorPane( response, request, se.getLocalizedMessage(), se ); 
     142            } 
     143            catch( Exception e2 ) 
     144            { 
     145                throw new ServletException( "Error : no possibity to write image in response", e2 ); 
     146            } 
     147        } 
    159148        catch( Exception e1 ) 
    160149        { 
     
    169158            } 
    170159        } 
     160    } 
     161 
     162    @Nullable 
     163    private List<Pair> extractpIdPIdListFromString( @NotNull final String pIdPIdArrayString ) 
     164    { 
     165        if( pIdPIdArrayString.isEmpty() ) 
     166            return null; 
     167 
     168        final String[] pIDPIdArray = pIdPIdArrayString.split( "," ); 
     169        final List<Pair> pIdPIdList = new ArrayList<Pair>( pIDPIdArray.length ); 
     170        for( final String pIdPId : pIDPIdArray ) 
     171        { 
     172            final String[] pIdPIdSplit = pIdPId.split( "-" ); 
     173            final Pair<Integer, Integer> pIdPIdPair = new Pair<Integer, Integer>(); 
     174            pIdPIdPair.setFirstValue( Integer.valueOf( pIdPIdSplit[0] ) ); 
     175            pIdPIdPair.setSecondValue( Integer.valueOf( pIdPIdSplit[1] ) ); 
     176            pIdPIdList.add( pIdPIdPair ); 
     177        } 
     178        return pIdPIdList; 
    171179    } 
    172180 
     
    185193    private static final Log LOGGER = LogFactory.getLog( ControllerPlot.class ); 
    186194 
    187     private EtherService _etherService; 
    188195    private EtherPlotService _etherPlotService; 
    189196 
  • ether_megapoli/trunk/web/src/com/ether/WebException.java

    r132 r184  
    33/** 
    44 * @author vmipsl 
    5  * @date 02 feb 2011  
     5 * @date 02 feb 2011 
    66 */ 
    7 public class WebException  
    8         extends FormattedException 
     7public class WebException 
     8        extends FormattedException 
    99{ 
    10     public WebException(final Enum<? extends Code> code) { 
    11         super(code); 
    12         } 
    13  
    14         public WebException(final Enum<? extends Code> code, final Throwable cause, final Object... parameters) { 
    15         this(code, cause.getMessage(), cause, parameters); 
     10    public WebException( final Enum<? extends Code> code ) 
     11    { 
     12        super( code ); 
    1613    } 
    1714 
    18     protected WebException(final Enum<? extends Code> code, final String message, final Throwable cause, final Object... parameters) { 
    19         super(prefix(code, message), cause, parameters); 
     15    public WebException( final Enum<? extends Code> code, final Throwable cause, final Object... parameters ) 
     16    { 
     17        this( code, cause.getMessage(), cause, parameters ); 
    2018    } 
    2119 
    22         public WebException(final Throwable cause) { 
    23                 super(cause); 
    24         } 
     20    protected WebException( final Enum<? extends Code> code, final String message, final Throwable cause, final Object... parameters ) 
     21    { 
     22        super( prefix( code, message ), cause, parameters ); 
     23    } 
    2524 
    26         public WebException( final Enum<? extends Code> code, final String string) { 
    27                 super(code, string); 
    28         } 
     25    public WebException( final Throwable cause ) 
     26    { 
     27        super( cause ); 
     28    } 
    2929 
    30         public static enum WebCode implements Code  
     30    public WebException( final Enum<? extends Code> code, final String string ) 
    3131    { 
    32                 ERROR_UNSUPPORTED_UTF8_ENCODING, 
    33                 ERROR_NO_REQUEST_HANDLING_METHOD, 
    34                 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        ERROR_UNSUPPORTED_UTF8_ENCODING, 
     39        ERROR_NO_REQUEST_HANDLING_METHOD, 
     40        ERROR_NUMBER_OF_PARAM_TYPES_NOT_EQUAL_TO_PARAM_ANNOTATIONS, 
    3541        INVALID_DATE, 
     42        PLATEFORM_OR_PARAMETER_IS_NULL, 
    3643        PARAMETER_IS_NULL, 
    3744    } 
  • ether_megapoli/trunk/web/visualization/visu_parameter_by_pf-script.jsp

    r178 r184  
    8484    { 
    8585        this.visualizeButton = new Button( {value:interfaceTexts["data.visualization.button.visualize"], parent:this.containerButtons, id:"button_visualize", onClick:this.onClickVisualize.bind( this )} ); 
    86 //        this.visualizeButton.disable(); 
     86        this.visualizeButton.disable(); 
    8787        this.downloadButton = new Button( {value:interfaceTexts["data.visualization.button.download"], parent:this.containerButtons, id:"button_download", onClick:this.onClickDownload.bind( this )} ); 
    8888        this.downloadButton.disable(); 
     
    294294//                + "&axeType=" + this.selectAxes.getValue(); 
    295295 
    296         var url = "visualization/plotEther?plateformId=14" 
    297                 + "&parameterId=90" 
    298                 + "&dateBegin=" + this.beginDate 
     296        // TODO : utiliser JSON pour envoyer arrayPIdPId 
     297        var arrayPIdPId = new Array(); 
     298        if( 1 < this.numberParameterToDisplay ) 
     299        { 
     300            var index = 0; 
     301            this.selectPlots.arrayOptions.each( function( option ) 
     302            { 
     303                arrayPIdPId[index] = option.itemValue; 
     304                index++; 
     305            } ); 
     306        } 
     307        else if( this.selectedPlateform && this.selectedParameter ) 
     308            arrayPIdPId[0] = this.selectedPlateform.getId() + "-" + this.selectedParameter.getId(); 
     309 
     310        var url = "visualization/plotEther?" 
     311                + "dateBegin=" + this.beginDate 
    299312                + "&dateEnd=" + this.endDate 
    300313                + "&title=" + encodeURIComponent( $( "textareaTitle" ).value ) 
     314                + "&pIdPIdList=" + arrayPIdPId 
    301315                + "&axeType=" + this.selectAxes.getValue(); 
    302316 
     
    304318 
    305319        <%--this.plotWindow.getContent().innerHTML = '<applet code="AppletTimeSerie.class" codebase="<%=request.getContextPath()%>/applets" height="400px" width="400px"> ' +--%> 
    306                 <%--'<param name="plateformId" value="14"> ' +--%> 
    307                 <%--'<param name="parameterId" value="90"> ' +--%> 
    308                 <%--'<param name="dateBegin" value=""> ' +--%> 
    309                 <%--'<param name="dateEnd" value=""> ' +--%> 
    310                 <%--'<param name="title" value="zzzz"> ' +--%> 
    311                 <%--'<param name="axeType" value="MOBILE"> ' +--%> 
    312                 <%--'</applet>';--%> 
     320        <%--'<param name="plateformId" value="14"> ' +--%> 
     321        <%--'<param name="parameterId" value="90"> ' +--%> 
     322        <%--'<param name="dateBegin" value=""> ' +--%> 
     323        <%--'<param name="dateEnd" value=""> ' +--%> 
     324        <%--'<param name="title" value="zzzz"> ' +--%> 
     325        <%--'<param name="axeType" value="MOBILE"> ' +--%> 
     326        <%--'</applet>';--%> 
    313327        this.plotWindow.setSize( <%=EtherPlotServiceImpl.getMaxWidth()%>, <%=EtherPlotServiceImpl.getMaxHeight()%> ); 
    314328        this.plotWindow.show(); 
     
    344358    testAllFields: function() 
    345359    { 
    346         if( !this.selectedPlateform || !this.selectedParameter || !this.beginDate || !this.endDate ) 
     360        if( (!this.selectedPlateform || !this.selectedParameter) && 0 == this.numberParameterToDisplay ) 
    347361        { 
    348 //            this.visualizeButton.disable(); 
     362            this.visualizeButton.disable(); 
    349363            this.downloadButton.disable(); 
    350364            return; 
     
    432446    } 
    433447 
    434 } ) 
    435         ; 
     448} ); 
    436449 
    437450</script> 
Note: See TracChangeset for help on using the changeset viewer.