Changeset 547


Ignore:
Timestamp:
09/10/12 17:05:06 (12 years ago)
Author:
vmipsl
Message:

simulation _ plot

Location:
ether_megapoli/trunk
Files:
2 added
13 edited
1 copied

Legend:

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

    r530 r547  
    1313import java.security.NoSuchAlgorithmException; 
    1414import java.util.ArrayList; 
     15import java.util.Arrays; 
    1516import java.util.Calendar; 
    1617import java.util.List; 
     
    6061        doubleArray = list.toArray( doubleArray ); 
    6162        return ArrayUtils.toPrimitive( doubleArray ); 
     63    } 
     64 
     65    public static List<Double> convertArrayDoubleToListDouble( @NotNull final double[] array ) 
     66    { 
     67        final Double[] wrappedArray = ArrayUtils.toObject( array ); 
     68        return Arrays.asList( wrappedArray ); 
    6269    } 
    6370 
  • ether_megapoli/trunk/common/implementation/com/ether/ParameterConstants.java

    r545 r547  
    3939    public static final String PARAMETER_MODEL_ID = "modelId"; 
    4040    public static final String PARAMETER_VARIABLE_ID = "variableId"; 
     41    public static final String PARAMETER_VARIABLE_NAME = "variableName"; 
    4142} 
  • ether_megapoli/trunk/persistence/implementation/com/ether/dao/simulation/SimulationDAOImpl.java

    r544 r547  
    6464    } 
    6565 
     66    @Nullable 
     67    public String getLocationByModelId( @NotNull final Integer modelId ) 
     68            throws PersistenceException 
     69    { 
     70        final DetachedCriteria criteria = DetachedCriteria.forClass( Simulation.class ) 
     71                .add( Restrictions.idEq( modelId ) ) 
     72                .setProjection( Projections.property( "location" ) ); 
     73 
     74        return selectByCriteria( String.class, criteria ); 
     75    } 
     76 
    6677    @Override 
    6778    protected DetachedCriteria searchCriteria( @NotNull final SimulationFilter filter, final boolean isForCount ) 
  • ether_megapoli/trunk/persistence/interface/com/ether/dao/simulation/SimulationDAO.java

    r544 r547  
    2424    List<List<String>> getAllModels() 
    2525            throws PersistenceException; 
     26 
     27    String getLocationByModelId( @NotNull final Integer modelId ) 
     28            throws PersistenceException; 
    2629} 
  • ether_megapoli/trunk/service/implementation/com/ether/EtherPlotContentServiceImpl.java

    r371 r547  
    6060     * @return 
    6161     */ 
    62     @Nullable 
    63     public JPane createTimeSeriePlot( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight, final Locale locale ) 
     62    @NotNull 
     63    public JPane createTimeSeriePlot( @NotNull final VisualisationPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight, final Locale locale ) 
    6464            throws ServiceException 
    6565    { 
     
    181181 
    182182    @NotNull 
    183     public JPane create2DPlot( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight, @Nullable final Locale locale ) 
     183    public JPane create2DPlot( @NotNull final VisualisationPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight, @Nullable final Locale locale ) 
    184184            throws ServiceException 
    185185    { 
     
    228228        jPlotLayout.setEditClasses( false ); 
    229229        jPlotLayout.addData( simpleGrid, gridAttribute, legend ); 
     230        jPlotLayout.setTitles( "", "", "" ); 
     231        jPlotLayout.setSize( new Dimension( plotWidth, plotHeight ) ); 
     232 
     233        try 
     234        { 
     235//            jPlotLayout.setKeyLayerSizeP( new Dimension2D( 12.0, 24.0 ) ); 
     236//            jPlotLayout.setKeyBoundsP( new Rectangle2D.Double( 0.01, 1.01, 5.98, 1.0 ) ); 
     237            final Layer keyLayer = jPlotLayout.getKeyPane().getLayer( "Key Layer" ); 
     238            jPlotLayout.add( keyLayer ); 
     239        } 
     240        catch( LayerNotFoundException e ) 
     241        { 
     242            throw new ServiceException( ServiceException.ServiceCode.LEGEND_LAYER_NOT_FOUND, new Throwable( ServiceException.ServiceCode.LEGEND_LAYER_NOT_FOUND.toString() ) ); 
     243        } 
     244 
     245        // Copyright 
     246        displayCopyright( jPlotLayout, 1.0, 1.0, 1.15, 0.03 ); 
     247 
     248        // Period 
     249        displayPeriod( jPlotLayout, megapoliPlot.getBeginDate(), megapoliPlot.getEndDate() ); 
     250 
     251        return jPlotLayout; 
     252    } 
     253 
     254    @NotNull 
     255    public JPane createSimulationPlot( @NotNull final SimulationPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight, @Nullable final Locale locale ) 
     256            throws ServiceException 
     257    { 
     258        final ResourceBundle bundle = WebHelper.getBundle( locale ); 
     259 
     260//        final List<Double> parameterValues = (List<Double>) megapoliPlot.getData().getFirstArray(); 
     261//        final List<Double> latitudeValues = (List<Double>) megapoliPlot.getData().getSecondArray(); 
     262//        final List<Double> longitudeValues = (List<Double>) megapoliPlot.getData().getThirdArray(); 
     263//        final double[] parameterValuesArray = EtherHelper.convertListDoubleToDoubleArray( parameterValues ); 
     264//        final double[] latitudeValuesArray = EtherHelper.convertListDoubleToDoubleArray( latitudeValues ); 
     265//        final double[] longitudeValuesArray = EtherHelper.convertListDoubleToDoubleArray( longitudeValues ); 
     266 
     267        final double[] parameterValuesArray = _etherService.extractValuesByModelByVariableFromFile( megapoliPlot.getModelId(), megapoliPlot.getVariableName(), true ); 
     268        final double[] latitudeValuesArray = _etherService.extractValuesByModelByVariableFromFile( megapoliPlot.getModelId(), "lat", true ); 
     269        final double[] longitudeValuesArray = _etherService.extractValuesByModelByVariableFromFile( megapoliPlot.getModelId(), "lon", true ); 
     270 
     271        // Create the grid 
     272        final SGTMetaData xMeta = new SGTMetaData( bundle.getString( "plot.longitude" ), bundle.getString( "plot.degres" ) ); 
     273        final SGTMetaData yMeta = new SGTMetaData( bundle.getString( "plot.latitude" ), bundle.getString( "plot.degres" ) ); 
     274 
     275        final SimpleGrid simpleGrid = new SimpleGrid( parameterValuesArray, longitudeValuesArray, latitudeValuesArray, "Grid" ); 
     276        simpleGrid.setXMetaData( xMeta ); 
     277        simpleGrid.setYMetaData( yMeta ); 
     278        simpleGrid.setRealFullGrid( false ); 
     279 
     280        // Create the contour levels and color map 
     281        List<Double> parameterValues = EtherHelper.convertArrayDoubleToListDouble( parameterValuesArray ); 
     282        final Double min = Collections.min( parameterValues ); 
     283        final Double max = Collections.max( parameterValues ); 
     284        final Double delta = ( max - min ) / _numberOfColorsFor2D; 
     285        final Range2D datar = new Range2D( min, max, delta ); 
     286        final ContourLevels clevels = ContourLevels.getDefault( datar ); 
     287        final ColorMap cmap = createColorMap( datar ); 
     288 
     289        // Create a gridAttribute for contour data 
     290        final GridAttribute gridAttribute = new GridAttribute( clevels ); 
     291        gridAttribute.setColorMap( cmap ); 
     292        gridAttribute.setStyle( GridAttribute.RASTER ); 
     293 
     294        // Create the legend 
     295//        final Pair<Integer, Integer> pIdPId = megapoliPlot.getPfIdPIdList().get( 0 ); 
     296//        final Integer parameterId = pIdPId.getSecondValue(); 
     297 
     298//        final Parametre parametre = _etherService.getParameterById( parameterId ); 
     299//        if( null == parametre ) 
     300//            throw new ServiceException( ServiceException.ServiceCode.PARAMETER_IS_NULL, new Throwable( ServiceException.ServiceCode.PARAMETER_IS_NULL.toString() ) ); 
     301//        final String legend = parametre.getParametreNom() + " (" + parametre.getUnite().getUniteCode() + ")"; 
     302 
     303        // Create the plot 
     304        final JPlotLayout jPlotLayout = new JPlotLayout( true, false, false, "JPlotLayout Pane", null, true ); 
     305        jPlotLayout.setEditClasses( false ); 
     306//        jPlotLayout.addData( simpleGrid, gridAttribute, legend ); 
     307        jPlotLayout.addData( simpleGrid, gridAttribute, "legend" ); 
    230308        jPlotLayout.setTitles( "", "", "" ); 
    231309        jPlotLayout.setSize( new Dimension( plotWidth, plotHeight ) ); 
     
    269347     */ 
    270348    @NotNull 
    271     private CartesianGraph createGraphForFirstLine( @NotNull final MegapoliPlot megapoliPlot, @NotNull final JPane mainPane, final double xsize, final double ysize, final double ystart, final double yend, @NotNull final TimeAxis xTimeAxis, @NotNull final LinearTransform xt, @NotNull final SimpleLine firstLine, @NotNull final SoTRange ynRange, @NotNull final PlainAxis yAxis ) 
     349    private CartesianGraph createGraphForFirstLine( @NotNull final VisualisationPlot megapoliPlot, @NotNull final JPane mainPane, final double xsize, final double ysize, final double ystart, final double yend, @NotNull final TimeAxis xTimeAxis, @NotNull final LinearTransform xt, @NotNull final SimpleLine firstLine, @NotNull final SoTRange ynRange, @NotNull final PlainAxis yAxis ) 
    272350    { 
    273351        final Layer layer = new Layer( "Layer", new Dimension2D( xsize, ysize ) ); 
     
    411489     */ 
    412490    @NotNull 
    413     private LineKey createLineKey( final MegapoliPlot megapoliPlot, final double ysize, final Layer layer, final SimpleLine firstLine, final CartesianGraph graph ) 
     491    private LineKey createLineKey( final VisualisationPlot megapoliPlot, final double ysize, final Layer layer, final SimpleLine firstLine, final CartesianGraph graph ) 
    414492    { 
    415493        final LineKey lkey = new LineKey(); 
  • ether_megapoli/trunk/service/implementation/com/ether/EtherPlotServiceImpl.java

    r286 r547  
    6868        jPane.add( jPaneTop, BorderLayout.NORTH ); 
    6969 
    70         final Integer valuesNumber = ( null != megapoliPlot.getValuesNumber() ) ? megapoliPlot.getValuesNumber() : getEtherService().getNumberValuesByPlateformByParameterByPeriod( megapoliPlot.getPfIdPIdList(), megapoliPlot.getBeginDate(), megapoliPlot.getEndDate() ); 
    71  
    7270        // Bottom Pane 
    73         final JPane jPaneBottom = createBottomPane( valuesNumber, locale ); 
     71        final JPane jPaneBottom = createBottomPane( megapoliPlot.getValuesNumber(), locale ); 
    7472        jPane.add( jPaneBottom, BorderLayout.SOUTH ); 
    7573 
    7674        // Center Pane 
    7775        final Integer centerHeight = maxHeight - jPaneTop.getHeight() - jPaneBottom.getHeight(); 
    78         if( valuesNumber > 0 ) 
     76        if( null != megapoliPlot.getValuesNumber() && megapoliPlot.getValuesNumber() > 0 ) 
    7977        { 
    8078            final JPane jPaneCenter = createCenterPane( megapoliPlot, maxWidth, centerHeight, locale ); 
     
    254252     */ 
    255253    @Nullable 
    256     public JPane createCenterPane( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer maxWidth, @NotNull final Integer maxHeight, @Nullable final Locale locale ) 
     254    public <T extends MegapoliPlot> JPane createCenterPane( @NotNull final T megapoliPlot, @NotNull final Integer maxWidth, @NotNull final Integer maxHeight, @Nullable final Locale locale ) 
    257255            throws ServiceException 
    258256    { 
     
    260258        final Integer plotHeight = Math.min( maxHeight - MARGIN_LEFT_RIGHT, maxHeight ); 
    261259 
    262         if( megapoliPlot.isTimeSerie() ) 
    263             return createTimeSeriePlot( megapoliPlot, plotWidth, plotHeight, locale ); 
     260        if( megapoliPlot instanceof VisualisationPlot ) 
     261            if( ( (VisualisationPlot) megapoliPlot ).isTimeSerie() ) 
     262                return createTimeSeriePlot( (VisualisationPlot) megapoliPlot, plotWidth, plotHeight, locale ); 
     263            else 
     264                return create2DPlot( (VisualisationPlot) megapoliPlot, plotWidth, plotHeight, locale ); 
     265        else if( megapoliPlot instanceof SimulationPlot ) 
     266            return createSimulationPlot( (SimulationPlot) megapoliPlot, plotWidth, plotHeight, locale ); 
    264267        else 
    265             return create2DPlot( megapoliPlot, plotWidth, plotHeight, locale ); 
     268            return null; 
    266269    } 
    267270 
  • ether_megapoli/trunk/service/implementation/com/ether/EtherServiceImpl.java

    r545 r547  
    3939import javax.xml.bind.PropertyException; 
    4040import javax.xml.bind.Unmarshaller; 
     41import java.io.BufferedReader; 
    4142import java.io.File; 
     43import java.io.FileReader; 
    4244import java.io.IOException; 
     45import java.io.InputStreamReader; 
    4346import java.util.ArrayList; 
     47import java.util.Calendar; 
    4448import java.util.Date; 
    4549import java.util.HashSet; 
     
    732736    } 
    733737 
     738    /** 
     739     * This method extract data (parameters, latitudes, longitutes) from the file corresponding to the simulation for the megapoliPlot 
     740     * 
     741     * @param modelId 
     742     * @param variableName 
     743     * @param writeInTemporaryFiles : 
     744     *                              - if true, temporary files will be created in the directory filePath, and the values will be extract from this files. 
     745     *                              - if false, the values will be extract directory from the process 
     746     * @return 
     747     * @throws IOException 
     748     * @throws ServiceException 
     749     */ 
     750    @Nullable 
     751    @Transactional(readOnly = true) 
     752    public double[] extractValuesByModelByVariableFromFile( @NotNull final Integer modelId, @NotNull final String variableName, final boolean writeInTemporaryFiles ) 
     753            throws ServiceException 
     754    { 
     755        final String filePath = getLocationByModelId( modelId ); 
     756        final String resultFile = filePath + '_' + variableName; 
     757 
     758        try 
     759        { 
     760            Calendar cal = Calendar.getInstance(); 
     761            LOGGER.info( "extractValuesByModelByVariableFromFile _ START : " + cal.getTime().toString() ); 
     762 
     763            final Runtime runtime = Runtime.getRuntime(); 
     764            final String processString = writeInTemporaryFiles ? "/usr/bin/ncdump -v " + variableName + ' ' + filePath + " | sed -e '1,/data:/d' -e '1,/" + variableName + "/d' -e '$d' > " + resultFile : "/usr/bin/ncdump -v " + variableName + ' ' + filePath + " | sed -e '1,/data:/d' -e '1,/" + variableName + "/d' -e '$d'"; 
     765            final String[] argsNcdump = {"/bin/sh", "-c", processString}; 
     766            final Process exec = runtime.exec( argsNcdump ); 
     767            if( writeInTemporaryFiles ) 
     768                EtherHelper.waitForFileWithMax( new File( resultFile ), 5000 ); 
     769 
     770            // TODO : voir avec java 7 pour utiliser le Files.readAllLines() et obtenir directement une List<>, http://adiguba.developpez.com/tutoriels/java/7/ 
     771 
     772            final BufferedReader bufferedReader = writeInTemporaryFiles ? new BufferedReader( new FileReader( resultFile ) ) : new BufferedReader( new InputStreamReader( exec.getInputStream() ) ); 
     773            final StringBuffer stringBuffer = new StringBuffer(); 
     774            String line; 
     775            while( ( line = bufferedReader.readLine() ) != null ) 
     776                stringBuffer.append( line ); 
     777 
     778            final String bufferContent = stringBuffer.toString(); 
     779            final String[] valuesString = bufferContent.replaceAll( " ", "" ).replaceAll( ";", "" ).split( "," ); 
     780            final double[] values = new double[valuesString.length]; 
     781            int i = 0; 
     782            for( final String valueString : valuesString ) 
     783            { 
     784                if( null != valuesString ) 
     785                { 
     786                    values[i] = Double.valueOf( valueString ); 
     787                    i++; 
     788                } 
     789            } 
     790 
     791//            if( writeInTemporaryFiles && new File( resultFile ).exists() ) 
     792//                new File( resultFile ).delete(); 
     793 
     794            cal = Calendar.getInstance(); 
     795            LOGGER.info( "extractValuesByModelByVariableFromFile _ STOP : " + cal.getTime().toString() ); 
     796 
     797            return values; 
     798        } 
     799        catch( InterruptedException e ) 
     800        { 
     801            if( new File( resultFile ).exists() ) 
     802                new File( resultFile ).delete(); 
     803 
     804            throw new ServiceException( ServiceException.ServiceCode.ERROR_PROCESS_SIMULATION_NCDUMP_WAIT, e ); 
     805        } 
     806        catch( IOException e ) 
     807        { 
     808            if( new File( resultFile ).exists() ) 
     809                new File( resultFile ).delete(); 
     810 
     811            throw new ServiceException( ServiceException.ServiceCode.ERROR_PROCESS_SIMULATION_NCDUMP, e ); 
     812        } 
     813    } 
     814 
    734815    @Nullable 
    735816    @Transactional(readOnly = true) 
     
    890971        { 
    891972            throw new ServiceException( ServiceException.ServiceCode.VARIABLE_NOT_FOUND, e ); 
     973        } 
     974    } 
     975 
     976    @Nullable 
     977    @Transactional(readOnly = true) 
     978    public String getLocationByModelId( @NotNull final Integer modelId ) 
     979            throws ServiceException 
     980    { 
     981        try 
     982        { 
     983            return _simulationDAO.getLocationByModelId( modelId ); 
     984        } 
     985        catch( PersistenceException e ) 
     986        { 
     987            throw new ServiceException( ServiceException.ServiceCode.SIMULATION_NOT_FOUND, e ); 
    892988        } 
    893989    } 
  • ether_megapoli/trunk/service/implementation/com/ether/VisualisationPlot.java

    r423 r547  
    11package com.ether; 
    22 
    3 import com.medias.megapoli.utils.MegapoliInitialisation; 
    43import org.jetbrains.annotations.NotNull; 
    54import org.jetbrains.annotations.Nullable; 
    65 
    7 import java.util.Date; 
    86import java.util.List; 
    97 
     
    1210 * @date 31 may 2011 
    1311 */ 
    14 public class MegapoliPlot 
     12public class VisualisationPlot 
     13        extends MegapoliPlot 
    1514{ 
    16     @Nullable 
    17     public String getTitle() 
    18     { 
    19         return _title; 
    20     } 
    21  
    22     public void setTitle( @Nullable final String title ) 
    23     { 
    24         _title = title; 
    25     } 
    26  
    27     @NotNull 
    28     public String getLogoMegapoli() 
    29     { 
    30         return _logoMegapoli; 
    31     } 
    32  
    33     public void setLogoMegapoli( @NotNull final String logoMegapoli ) 
    34     { 
    35         _logoMegapoli = logoMegapoli; 
    36     } 
    37  
    38     @NotNull 
    39     public String getLogoEther() 
    40     { 
    41         return _logoEther; 
    42     } 
    43  
    44     public void setLogoEther( @NotNull final String logoEther ) 
    45     { 
    46         _logoEther = logoEther; 
    47     } 
    48  
    4915    @Nullable 
    5016    public Data getData() 
     
    7844    } 
    7945 
    80     @Nullable 
    81     public Integer getValuesNumber() 
    82     { 
    83         return _valuesNumber; 
    84     } 
    85  
    86     public void setValuesNumber( @Nullable final Integer valuesNumber ) 
    87     { 
    88         _valuesNumber = valuesNumber; 
    89     } 
    90  
    9146    @NotNull 
    9247    public String getAxeType() 
     
    11267 
    11368    @Nullable 
    114     public Date getBeginDate() 
    115     { 
    116         return _beginDate; 
    117     } 
    118  
    119     public void setBeginDate( @Nullable final Date beginDate ) 
    120     { 
    121         _beginDate = beginDate; 
    122     } 
    123  
    124     @Nullable 
    125     public Date getEndDate() 
    126     { 
    127         return _endDate; 
    128     } 
    129  
    130     public void setEndDate( @Nullable final Date endDate ) 
    131     { 
    132         _endDate = endDate; 
    133     } 
    134  
    135     @Nullable 
    136     private String _title; 
    137     @Nullable 
    13869    private Data _data; 
    139     @NotNull 
    140     private String _logoMegapoli = MegapoliInitialisation.pathImages + "/logo_Megapoli.png"; 
    141 //    private String _logoMegapoli = "/home_local/PROJETS/MEGAPOLI/megapoli/data/images/logo_Megapoli.png"; 
    142     @NotNull 
    143     private String _logoEther = MegapoliInitialisation.pathImages + "/logo_Ether.jpg"; 
    144 //    private String _logoEther = "/home_local/PROJETS/MEGAPOLI/megapoli/data/images/logo_Ether.jpg"; 
    14570 
    14671    private boolean _legendToHide = true; 
    14772    private boolean _isTimeSerie = true; 
    148     @Nullable 
    149     private Integer _valuesNumber; 
    15073    @NotNull 
    15174    private String _axeType; 
     
    15477    @Nullable 
    15578    private List<Pair<Integer, Integer>> _pfIdPIdList; 
    156     @Nullable 
    157     private Date _beginDate; 
    158     @Nullable 
    159     private Date _endDate; 
    16079} 
  • ether_megapoli/trunk/service/interface/com/ether/EtherPlotService.java

    r195 r547  
    3232 
    3333    @Nullable 
    34     public JPane createCenterPane( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer maxWidth, @NotNull final Integer maxHeight, @Nullable final Locale locale ) 
    35             throws ServiceException; 
    36  
    37     @Nullable 
    38     public JPane createTimeSeriePlot( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight, @Nullable final Locale locale ) 
     34    public <T extends MegapoliPlot> JPane createCenterPane( @NotNull final T megapoliPlot, @NotNull final Integer maxWidth, @NotNull final Integer maxHeight, @Nullable final Locale locale ) 
    3935            throws ServiceException; 
    4036 
    4137    @NotNull 
    42     public JPane create2DPlot( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight, @Nullable final Locale locale ) 
     38    public JPane createTimeSeriePlot( @NotNull final VisualisationPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight, @Nullable final Locale locale ) 
     39            throws ServiceException; 
     40 
     41    @NotNull 
     42    public JPane create2DPlot( @NotNull final VisualisationPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight, @Nullable final Locale locale ) 
     43            throws ServiceException; 
     44 
     45    @NotNull 
     46    public JPane createSimulationPlot( @NotNull final SimulationPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight, @Nullable final Locale locale ) 
    4347            throws ServiceException; 
    4448} 
  • ether_megapoli/trunk/service/interface/com/ether/EtherService.java

    r545 r547  
    181181 
    182182    @Nullable 
     183    double[] extractValuesByModelByVariableFromFile( @NotNull final Integer modelId, @NotNull final String variableName, final boolean writeInTemporaryFiles ) 
     184            throws ServiceException; 
     185 
     186    @Nullable 
    183187    Dimension getDimensionById( @NotNull final Integer dimensionId ) 
    184188            throws ServiceException; 
     
    219223    List<Variable> getVariablesByModelId( @NotNull final Integer modelId ) 
    220224            throws ServiceException; 
     225 
     226    @Nullable 
     227    String getLocationByModelId( @NotNull final Integer modelId ) 
     228            throws ServiceException; 
     229 
    221230} 
  • ether_megapoli/trunk/web/resources/css/visu_parameter_by_pf.css

    r546 r547  
    44} 
    55 
    6 #generalContainerModels, #containerOptionCalendar { 
     6#generalContainerModels, #generalContainerOptions { 
    77    min-height: 150px; 
    88} 
  • ether_megapoli/trunk/web/src/com/ether/ControllerPlot.java

    r216 r547  
    22 
    33import com.medias.Context; 
    4 import gov.noaa.pmel.util.SoTValue; 
    54import org.apache.commons.logging.Log; 
    65import org.apache.commons.logging.LogFactory; 
     
    9695 
    9796            // Create plot 
    98             final MegapoliPlot megapoliPlot = new MegapoliPlot(); 
     97            final VisualisationPlot megapoliPlot = new VisualisationPlot(); 
    9998            megapoliPlot.setTitle( title ); 
    10099            megapoliPlot.setAxeType( axeType ); 
     
    107106                megapoliPlot.setTimeSerie( true ); 
    108107                megapoliPlot.setLegendToHide( pIdPIdList.size() == 1 ); 
     108                final Integer valuesNumber = _etherService.getNumberValuesByPlateformByParameterByPeriod( megapoliPlot.getPfIdPIdList(), megapoliPlot.getBeginDate(), megapoliPlot.getEndDate() ); 
     109                megapoliPlot.setValuesNumber( valuesNumber ); 
    109110            } 
    110111            else 
  • ether_megapoli/trunk/web/src/com/ether/ControllerSimulationPlot.java

    r545 r547  
    6161            final Integer modelId = Integer.valueOf( request.getParameter( ParameterConstants.PARAMETER_MODEL_ID ) ); 
    6262            final Integer variableId = Integer.valueOf( request.getParameter( ParameterConstants.PARAMETER_VARIABLE_ID ) ); 
     63            final String variableName = request.getParameter( ParameterConstants.PARAMETER_VARIABLE_NAME ); 
    6364 
    6465            // Dates 
     
    8485 
    8586            // Create plot 
    86 //            final MegapoliPlot megapoliPlot = new MegapoliPlot(); 
    87 //            megapoliPlot.setTitle( title ); 
    88 //            megapoliPlot.setAxeType( axeType ); 
    89 //            megapoliPlot.setPfIdPIdList( pIdPIdList ); 
    90 //            megapoliPlot.setBeginDate( formatedDateBegin ); 
    91 //            megapoliPlot.setEndDate( formatedDateEnd ); 
    92 // 
    93 //            if( AxeTypeForFixedPlateform.TIME_LINE.name().equals( axeType ) || AxeTypeForFixedPlateform.TIME_POINTS.name().equals( axeType ) ) 
    94 //            { 
    95 //                megapoliPlot.setTimeSerie( true ); 
    96 //                megapoliPlot.setLegendToHide( pIdPIdList.size() == 1 ); 
    97 //            } 
    98 //            else 
    99 //            { 
    100 //                // 2D plot : only one parameter to display 
    101 //                final Integer plateformId = (Integer) pIdPIdList.get( 0 ).getFirstValue(); 
    102 //                final Integer parameterId = (Integer) pIdPIdList.get( 0 ).getSecondValue(); 
    103 //                final Data valuesLists = _etherService.getListsByPlateformByParameterByPeriodFor2D( plateformId, parameterId, formatedDateBegin, formatedDateEnd ); 
    104 ////                final Data<List, List, List> valuesLists = BouchonHelper.createValuesFor2D( 50 ); 
    105 //                megapoliPlot.setData( valuesLists ); 
    106 // 
    107 //                megapoliPlot.setTimeSerie( false ); 
    108 //                megapoliPlot.setLegendToHide( false ); 
    109 //                megapoliPlot.setValuesNumber( ( (ArrayList) valuesLists.getFirstArray() ).size() ); 
    110 //            } 
    111 // 
    112 //            final BufferedImage bufferedImage = _etherPlotService.createMainPane( megapoliPlot, Context.getLocale( request ) ); 
    113 //            ImageIO.write( bufferedImage, "png", response.getOutputStream() ); 
     87            final SimulationPlot megapoliPlot = new SimulationPlot(); 
     88            megapoliPlot.setTitle( title ); 
     89            megapoliPlot.setModelId( modelId ); 
     90            megapoliPlot.setVariableId( variableId ); 
     91            megapoliPlot.setVariableName( variableName ); 
     92            megapoliPlot.setBeginDate( formatedDateBegin ); 
     93            megapoliPlot.setEndDate( formatedDateEnd ); 
     94            // TODO : calculer le nombre de valeurs 
     95            megapoliPlot.setValuesNumber( 10 ); 
     96 
     97            final BufferedImage bufferedImage = _etherPlotService.createMainPane( megapoliPlot, Context.getLocale( request ) ); 
     98            ImageIO.write( bufferedImage, "png", response.getOutputStream() ); 
    11499        } 
    115100//        catch( ServiceException se ) 
  • ether_megapoli/trunk/web/visualization/visu_simulation-script.jsp

    r545 r547  
    131131    onSelectVariable: function( objVariable ) 
    132132    { 
    133         if( this.selectedVariable ) 
     133        if( this.selectedVariable && objVariable.getId() == this.selectedVariable.getId() ) 
    134134            return; 
    135135 
     
    177177    onClickVisualize: function() 
    178178    { 
    179         <%--if( this.selectedModel && this.selectedVariable )--%> 
    180         <%--{--%> 
    181             <%--var parameters = "dateBegin=" + this.beginDate--%> 
    182                     <%--+ "&dateEnd=" + this.endDate--%> 
    183                     <%--+ "&modelId =" + this.selectedModel.getId()--%> 
    184                     <%--+ "$variableId" + this.selectedVariable.getId();--%> 
    185  
    186             <%--var url = "simulation/simulationPlotEther?" + parameters;--%> 
    187             <%--var $dialog = $( '<div></div>' )--%> 
    188                     <%--.html( '<img src=' + url + ' />' )--%> 
    189                     <%--.dialog( {--%> 
    190                                  <%--autoOpen: false,--%> 
    191                                  <%--title: interfaceTexts["app.title"] + "-" + interfaceTexts["simulation.quicklook"],--%> 
    192                                  <%--minHeight: <%=EtherPlotServiceImpl.getMaxHeight()%>,--%> 
    193                                  <%--minWidth: <%=EtherPlotServiceImpl.getMaxWidth()%> + 28--%> 
    194                              <%--} );--%> 
    195         <%--}--%> 
    196         <%--else--%> 
    197         <%--{--%> 
    198             <%--var $dialog = $( '<div></div>' )--%> 
    199                     <%--.html( '<BR/><center>' + interfaceTexts["visualization.graph.noPlot"] + '</center>' )--%> 
    200                     <%--.dialog( {--%> 
    201                                  <%--autoOpen: false,--%> 
    202                                  <%--title: interfaceTexts["app.title"] + "-" + interfaceTexts["visualization.quicklook"],--%> 
    203                                  <%--height: 50,--%> 
    204                                  <%--width: 400--%> 
    205                              <%--} );--%> 
    206         <%--}--%> 
    207  
    208         <%--$dialog.dialog( 'open' );--%> 
     179        if( this.selectedModel && this.selectedVariable ) 
     180        { 
     181            var parameters = "dateBegin=" + this.beginDate 
     182                    + "&dateEnd=" + this.endDate 
     183                    + "&modelId=" + this.selectedModel.getId() 
     184                    + "&variableId=" + this.selectedVariable.getId() 
     185                    + "&variableName=" + this.selectedVariable.getName() 
     186                    + "&title=" + encodeURIComponent( $( "#textareaTitle" ).val() ); 
     187 
     188            var url = "simulation/simulationPlotEther?" + parameters; 
     189            var $dialog = $( '<div></div>' ) 
     190                    .html( '<img src=' + url + ' />' ) 
     191                    .dialog( { 
     192                                 autoOpen: false, 
     193                                 title: interfaceTexts["app.title"] + "-" + interfaceTexts["simulation.quicklook"], 
     194                                 minHeight: <%=EtherPlotServiceImpl.getMaxHeight()%>, 
     195                                 minWidth: <%=EtherPlotServiceImpl.getMaxWidth()%> + 28 
     196                             } ); 
     197        } 
     198        else 
     199        { 
     200            var $dialog = $( '<div></div>' ) 
     201                    .html( '<BR/><center>' + interfaceTexts["visualization.graph.noPlot"] + '</center>' ) 
     202                    .dialog( { 
     203                                 autoOpen: false, 
     204                                 title: interfaceTexts["app.title"] + "-" + interfaceTexts["visualization.quicklook"], 
     205                                 height: 50, 
     206                                 width: 400 
     207                             } ); 
     208        } 
     209 
     210        $dialog.dialog( 'open' ); 
    209211    }, 
    210212 
Note: See TracChangeset for help on using the changeset viewer.