Changeset 132


Ignore:
Timestamp:
08/23/11 16:52:29 (13 years ago)
Author:
vmipsl
Message:

[Visualization] latitude/longitude axeType

Location:
ether_megapoli/trunk
Files:
13 edited
1 copied
1 moved

Legend:

Unmodified
Added
Removed
  • ether_megapoli/trunk/domain/interface/com/ether/AxeTypeForFixedPlateform.java

    r130 r132  
    11package com.ether; 
    22 
    3 public enum AxeType 
     3public enum AxeTypeForFixedPlateform 
    44{ 
    55    TIME, 
    6     LATITUDE, 
     6    FIXE, 
    77} 
  • ether_megapoli/trunk/domain/interface/com/ether/AxeTypeForMobilePlateform.java

    r130 r132  
    11package com.ether; 
    22 
    3 public enum AxeType 
     3public enum AxeTypeForMobilePlateform 
    44{ 
    5     TIME, 
    65    LATITUDE, 
     6    MOBILE, 
    77} 
  • ether_megapoli/trunk/persistence/implementation/com/medias/objects/Parametre.hbm.xml

    r89 r132  
    1212            </generator> 
    1313        </id> 
    14         <many-to-one name="unite" class="com.medias.database.objects.Unite" fetch="select"> 
     14        <many-to-one name="unite" class="com.medias.database.objects.Unite" fetch="select" lazy="false"> 
    1515            <column name="unite_id" not-null="true"> 
    1616                <comment>lien vers la table unite</comment> 
  • ether_megapoli/trunk/persistence/implementation/com/medias/objects/Plateforme.hbm.xml

    r89 r132  
    1717            </column> 
    1818        </many-to-one> 
    19         <many-to-one name="typePlateforme" class="com.medias.database.objects.TypePlateforme" fetch="select"> 
     19        <many-to-one name="typePlateforme" class="com.medias.database.objects.TypePlateforme" fetch="select" lazy="false"> 
    2020            <column name="type_plateforme_id" not-null="true"> 
    2121                <comment>lien vers la table type_plateforme</comment> 
  • ether_megapoli/trunk/service/implementation/com/ether/EtherPlotServiceImpl.java

    r130 r132  
    22 
    33import gov.noaa.pmel.sgt.JPane; 
    4 import gov.noaa.pmel.sgt.dm.SGTData; 
    54import gov.noaa.pmel.sgt.swing.JPlotLayout; 
    65import org.apache.commons.logging.Log; 
     
    2423        implements EtherPlotService 
    2524{ 
     25    public static Integer getMaxWidth() 
     26    { 
     27        final Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); 
     28        return Math.min( Double.valueOf( screenSize.getWidth() ).intValue(), MAX_WIDTH ); 
     29    } 
     30 
     31    public static Integer getMaxHeight() 
     32    { 
     33        final Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); 
     34        return Math.min( Double.valueOf( screenSize.getHeight() ).intValue(), MAX_HEIGHT ); 
     35    } 
     36 
    2637    /** 
    2738     * Create the main JPane with the 3 jPanes 
     
    3445    public BufferedImage createMainPane( @NotNull final MegapoliPlot megapoliPlot, @Nullable final Locale locale ) 
    3546    { 
    36 //        JPane jPane = new JPane( "Main jPane", new Dimension( MAIN_WIDTH, MAIN_HEIGHT ) ); 
    37         JPane jPane = new JPane( "Main jPane", new Dimension( MAIN_WIDTH, 700 ) ); 
    38         if( null != megapoliPlot.getWidth() && null != megapoliPlot.getHeight() ) 
    39             jPane = new JPane( "Main jPane", new Dimension( megapoliPlot.getWidth(), megapoliPlot.getHeight() ) ); 
    40  
     47        final Integer maxWidth = getMaxWidth(); 
     48        final Integer maxHeight = getMaxHeight(); 
     49 
     50        final JPane jPane = new JPane( "Main jPane", new Dimension( maxWidth, maxHeight ) ); 
    4151        jPane.setLayout( new BorderLayout() ); 
    4252        jPane.setBackground( Color.white ); 
    43         jPane.setBorder( BorderFactory.createLineBorder( Color.black, 2 ) ); 
    4453        jPane.setOpaque( true ); 
    4554 
    4655        // Top Pane 
    47 //        final JPane jPaneTop = createTopPane( megapoliPlot ); 
    48 //        jPane.add( jPaneTop, BorderLayout.NORTH ); 
     56        final JPane jPaneTop = createTopPane( megapoliPlot ); 
     57        jPane.add( jPaneTop, BorderLayout.NORTH ); 
     58 
     59        final Integer valuesNumber = megapoliPlot.getData().getYArray().length; 
     60 
     61        // Bottom Pane 
     62        final JPane jPaneBottom = createBottomPane( valuesNumber, locale ); 
     63        jPane.add( jPaneBottom, BorderLayout.SOUTH ); 
    4964 
    5065        // Center Pane 
    51         final Integer valuesNumber = megapoliPlot.getData().getYArray().length; 
     66        final Integer centerHeight = maxHeight - jPaneTop.getHeight() - jPaneBottom.getHeight(); 
    5267        final JPane jPaneCenter; 
    5368        if( valuesNumber > 0 ) 
    54             jPaneCenter = createCenterPane( megapoliPlot.getData() ); 
     69            jPaneCenter = createCenterPane( megapoliPlot, maxWidth, centerHeight ); 
    5570        else 
    5671            jPaneCenter = createEmptyCenterPane( locale ); 
    5772        jPane.add( jPaneCenter, BorderLayout.CENTER ); 
    5873 
    59         // Bottom Pane 
    60 //        final JPane jPaneBottom = createBottomPane( valuesNumber, locale ); 
    61 //        jPane.add( jPaneBottom, BorderLayout.SOUTH ); 
    6274 
    6375        final JPanelToImageManager jPanelToImageManager = new JPanelToImageManager( jPane ); 
     
    105117     * Create the center JPane with the graph 
    106118     * 
    107      * @param data 
    108      * @return 
    109      */ 
    110     @NotNull 
    111     public JPane createCenterPane( @NotNull final SGTData data ) 
    112     { 
    113 //        final JPane jPaneCenter = new JPane( "Center jPane", new Dimension( 0, 1000 ) ); 
     119     * @param megapoliPlot 
     120     * @param maxWidth 
     121     * @param maxHeight 
     122     * @return 
     123     */ 
     124    @NotNull 
     125    public JPane createCenterPane( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer maxWidth, @NotNull final Integer maxHeight ) 
     126    { 
     127        final Integer plotWidth = Math.min( maxWidth - MARGIN_LEFT_RIGHT, maxWidth ); 
     128        final Integer plotHeight = Math.min( maxHeight - MARGIN_LEFT_RIGHT, maxHeight ); 
    114129 
    115130        // Graph 
    116         final JPlotLayout jPlotLayout = new JPlotLayout( false, true, false, "Trajectory data", null, false ); 
     131        final JPlotLayout jPlotLayout = new JPlotLayout( false, true, false, "Trajectory data", null, megapoliPlot.isLegendToHide() ); 
    117132        jPlotLayout.setTitles( "", "", "" ); 
    118         jPlotLayout.addData( data, data.getTitle() ); 
    119 //        jPlotLayout.setSize( 800, 1 ); 
     133        // Add data and legend 
     134        jPlotLayout.addData( megapoliPlot.getData(), megapoliPlot.getData().getTitle() ); 
     135        jPlotLayout.setSize( plotWidth, plotHeight ); 
    120136        jPlotLayout.setVisible( true ); 
    121137 
    122138        jPlotLayout.addNotify(); 
    123139        jPlotLayout.validate(); 
     140        jPlotLayout.setOpaque( true ); 
    124141 
    125142        // TODO : remove this change to bufferedImage to insert directly the jPlotLayout !!!! 
    126 //        final BufferedImage bufferedImage = new BufferedImage( jPlotLayout.getWidth(), jPlotLayout.getHeight(), BufferedImage.TYPE_INT_RGB ); 
    127143        final BufferedImage bufferedImage = new BufferedImage( jPlotLayout.getWidth(), jPlotLayout.getHeight(), BufferedImage.TYPE_INT_RGB ); 
    128144        final Graphics2D graphics2D = bufferedImage.createGraphics(); 
     
    130146 
    131147        final ImageIcon imageIcon = new ImageIcon( bufferedImage ); 
    132         final JLabel jLabel = new JLabel( imageIcon, JLabel.CENTER ); 
    133         jLabel.setBorder( BorderFactory.createLineBorder( Color.blue, 2 ) ); 
    134  
    135 //        final JPane jPaneCenter = new JPane( "Center jPane", new Dimension( jPlotLayout.getWidth(), jPlotLayout.getHeight() ) ); 
    136         final JPane jPaneCenter = new JPane(); 
    137         jPaneCenter.setLayout( new BorderLayout() ); 
    138         jPaneCenter.add( jLabel, BorderLayout.CENTER ); 
     148        final JLabel jLabelPlot = new JLabel( imageIcon, JLabel.CENTER ); 
     149        jLabelPlot.setBorder( BorderFactory.createLineBorder( Color.black, 1 ) ); 
     150 
     151        final JPane jPaneCenter = new JPane( "Center jPane", new Dimension( jPlotLayout.getWidth(), jPlotLayout.getHeight() ) ); 
     152        jPaneCenter.setLayout( new GridBagLayout() ); 
     153        jPaneCenter.add( jLabelPlot, 
     154                new GridBagConstraints( 0, 0, 1, 1, 0, 0, 
     155                        GridBagConstraints.CENTER, 
     156                        GridBagConstraints.CENTER, 
     157                        new Insets( 0, 0, 0, 0 ), 0, 0 ) ); 
    139158 
    140159        return jPaneCenter; 
     
    206225     */ 
    207226    @NotNull 
    208     public BufferedImage createErrorPane( @NotNull final String mainError, @NotNull final String errorText, @Nullable final Locale locale ) 
     227    public BufferedImage createErrorPane( @NotNull final String mainError, @Nullable final String errorText, @Nullable final Locale locale ) 
    209228    { 
    210229        // Image 
     
    215234        final ResourceBundle bundle = WebHelper.getBundle( locale ); 
    216235        final String mainMessage = bundle.getString( "plot.errorMessage" ); 
    217         final JLabel jLabelError = new JLabel( "<html>" + mainMessage + "<br><br>" + mainError + "<br>" + errorText + "</html>", JLabel.CENTER ); 
     236 
     237        final JLabel jLabelError; 
     238        if( null != errorText ) 
     239            jLabelError = new JLabel( "<html>" + mainMessage + "<br><br>" + mainError + "<br>" + errorText + "</html>", JLabel.CENTER ); 
     240        else 
     241            jLabelError = new JLabel( "<html>" + mainMessage + "<br><br>" + mainError + "</html>", JLabel.CENTER ); 
     242 
    218243        final Font police = new Font( "Arial", Font.BOLD, ERROR_FONT_SIZE ); 
    219244        jLabelError.setFont( police ); 
    220245 
    221246        // jPane 
    222         final JPane jPane = new JPane( "jPane", new Dimension( MAIN_WIDTH, errorImage.getIconHeight() ) ); 
     247        final JPane jPane = new JPane( "jPane", new Dimension( MAX_WIDTH, errorImage.getIconHeight() ) ); 
    223248        jPane.setLayout( new BorderLayout() ); 
    224249        jPane.setBackground( Color.white ); 
     
    243268    } 
    244269 
    245     public static final int TOP_HEIGHT = 110; 
    246     public static final int CENTER_HEIGHT = 400; 
    247     public static final int BOTTOM_HEIGHT = 50; 
    248  
    249270    private static final Log LOGGER = LogFactory.getLog( EtherPlotServiceImpl.class ); 
    250271 
    251272    // Dimensions of the jPanes 
    252     private static final int MAIN_WIDTH = 800; 
    253     private static final int MAIN_HEIGHT = 800; 
     273    private static final int MAX_WIDTH = 800; 
     274    private static final int MAX_HEIGHT = 700; 
     275    private static final int MARGIN_LEFT_RIGHT = 50; 
    254276 
    255277    private static final int TITLE_FONT_SIZE = 20; 
  • ether_megapoli/trunk/service/implementation/com/ether/MegapoliPlot.java

    r130 r132  
    11package com.ether; 
    22 
    3 import gov.noaa.pmel.sgt.LineAttribute; 
    4 import gov.noaa.pmel.sgt.beans.DataModel; 
    5 import gov.noaa.pmel.sgt.beans.Page; 
    6 import gov.noaa.pmel.sgt.beans.PanelModel; 
    73import gov.noaa.pmel.sgt.dm.SimpleLine; 
    84import org.jetbrains.annotations.NotNull; 
     
    106import org.medias.megapoli.utils.MegapoliInitialisation; 
    117 
    12 import javax.swing.*; 
    13 import java.awt.*; 
    14  
    158/** 
    169 * @author vmipsl 
    1710 * @date 31 may 2011 
    1811 */ 
    19 // TODO : range this class !!!! 
    2012public class MegapoliPlot 
    2113{ 
    22     public MegapoliPlot() 
    23     { 
    24     } 
    25  
    26     public MegapoliPlot( @Nullable final Integer width, @Nullable final Integer height ) 
    27     { 
    28         _width = width; 
    29         _height = height; 
    30     } 
    31  
    3214    @Nullable 
    3315    public String getTitle() 
     
    7456    } 
    7557 
    76     @NotNull 
    77     public LineAttribute getLineAttribute() 
     58    public boolean isLegendToHide() 
    7859    { 
    79         return _lineAttribute; 
     60        return _legendToHide; 
    8061    } 
    8162 
    82     public void setLineAttribute( @NotNull final LineAttribute lineAttribute ) 
     63    public void setLegendToHide( final boolean legendToHide ) 
    8364    { 
    84         _lineAttribute = lineAttribute; 
     65        _legendToHide = legendToHide; 
    8566    } 
    86  
    87     @NotNull 
    88     public Page getPage() 
    89     { 
    90         return _page; 
    91     } 
    92  
    93     public void setPage( @NotNull final Page page ) 
    94     { 
    95         _page = page; 
    96     } 
    97  
    98     @NotNull 
    99     public PanelModel getPanelModel() 
    100     { 
    101         return _panelModel; 
    102     } 
    103  
    104     public void setPanelModel( @NotNull final PanelModel panelModel ) 
    105     { 
    106         _panelModel = panelModel; 
    107     } 
    108  
    109     @NotNull 
    110     public DataModel getDataModel() 
    111     { 
    112         return _dataModel; 
    113     } 
    114  
    115     public void setDataModel( @NotNull final DataModel dataModel ) 
    116     { 
    117         _dataModel = dataModel; 
    118     } 
    119  
    120     @NotNull 
    121     public JPanel getjPanel() 
    122     { 
    123         return _jPanel; 
    124     } 
    125  
    126     public void setjPanel( @NotNull final JPanel jPanel ) 
    127     { 
    128         _jPanel = jPanel; 
    129     } 
    130  
    131     @Nullable 
    132     public Integer getWidth() 
    133     { 
    134         return _width; 
    135     } 
    136  
    137     public void setWidth( @Nullable final Integer width ) 
    138     { 
    139         _width = width; 
    140     } 
    141  
    142     @Nullable 
    143     public Integer getHeight() 
    144     { 
    145         return _height; 
    146     } 
    147  
    148     public void setHeight( @Nullable final Integer height ) 
    149     { 
    150         _height = height; 
    151     } 
    152  
    153 /** 
    154  * Instantiate the three primary SGT Bean objects. 
    155  * Page -       Main SGT JavaBean used with PanelModel and DataModel to 
    156  * create a graphic. 
    157  * <p/> 
    158  * PanelModel - A model that supports the Panel structure of a plot. 
    159  * DataModel -  A model that supplies the relationship between SGTData objects, 
    160  * its Attribute and the Panel and DataGroup in which it is 
    161  * displayed and the Legend. 
    162  * JPanel   - The JPanel that will be used to contain the graphic. 
    163  */ 
    164  
    165     /** 
    166      * PanelModel corresponds to the file "megapoli.xml" 
    167      * PanelHolder corresponds to one of the Panels from "panelList" described in the PanelModel 
    168      * contains positions of labels, legends, title, etc.. 
    169      */ 
    170  
    171     @NotNull 
    172     private Page _page = new Page(); 
    173     @NotNull 
    174     private PanelModel _panelModel = new PanelModel(); 
    175     @NotNull 
    176     private DataModel _dataModel = new DataModel(); 
    177     @NotNull 
    178     private JPanel _jPanel = new JPanel( new BorderLayout() ); 
    17967 
    18068    @Nullable 
     
    18371    private SimpleLine _data; 
    18472    @NotNull 
    185     private LineAttribute _lineAttribute = new LineAttribute( LineAttribute.SOLID, Color.red ); 
    186     @Nullable 
    187     private Integer _width; 
    188     @Nullable 
    189     private Integer _height; 
    190     @NotNull 
    19173    private String _logoMegapoli  = MegapoliInitialisation.pathImages + "/logo_Megapoli.png"; 
    19274    @NotNull 
    19375    private String _logoEther = MegapoliInitialisation.pathImages + "/logo_Ether.jpg"; 
    194  
    195  
    196     // Labels used in the megapoli.xml 
    197     public static final String FILE_NAME = "megapoli.xml"; 
    198     public static final String PANEL_GRAPH = "Panel_graph"; 
    199     public static final String PANEL_IMAGE = "Panel_image"; 
    200     public static final String DATA_GROUP = "DataGroup"; 
    201     public static final String LABEL_TITLE = "Label_title"; 
    202     public static final String LABEL_LOGO_MEGAPOLI = "Label_logoMegapoli"; 
    203     public static final String LABEL_LOGO_ETHER = "Label_logoEther"; 
    204     public static final String LEGEND = "Legend"; 
     76    private boolean _legendToHide = true; 
    20577} 
  • ether_megapoli/trunk/service/interface/com/ether/EtherPlotService.java

    r130 r132  
    2323 
    2424    @NotNull 
    25     public JPane createCenterPane( @NotNull final SGTData data ); 
     25    public JPane createCenterPane( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer maxWidth, @NotNull final Integer maxHeight ); 
    2626 
    2727    @NotNull 
     
    2929 
    3030    @NotNull 
    31     public BufferedImage createErrorPane( @NotNull final String mainError, @NotNull final String errorText, @Nullable final Locale locale ); 
     31    public BufferedImage createErrorPane( @NotNull final String mainError, @Nullable final String errorText, @Nullable final Locale locale ); 
    3232} 
  • ether_megapoli/trunk/web/src/ApplicationResources.properties

    r130 r132  
    438438plot.errorMessage=Erreur de cr\u00E9ation du quicklook. <BR>Veuillez essayer de corriger les erreurs suivantes ou contacter l'administrateur en indiquant les erreurs rencontr\u00E9es. 
    439439plot.noData=Aucune donn\u00E9e extraite 
     440plot.latitude=Latitude 
     441plot.longitude=Longitude 
     442plot.degres=Degr\u00E9s 
  • ether_megapoli/trunk/web/src/ApplicationResources_en.properties

    r130 r132  
    425425plot.errorMessage=Error creating the quicklook. <BR>Please try to correct the following errors or contact the administrator with the detected errors. 
    426426plot.noData=No extracted data 
     427plot.latitude=Latitude 
     428plot.longitude=Longitude 
     429plot.degres=Degrees 
  • ether_megapoli/trunk/web/src/com/ether/Controller.java

    r130 r132  
    66import com.medias.database.objects.Parametre; 
    77import com.medias.database.objects.Plateforme; 
     8import com.medias.database.objects.TypePlateforme; 
    89import net.sf.json.JSONObject; 
    910import org.apache.commons.logging.Log; 
     
    5051            throws ServiceException 
    5152    { 
    52         final List<Plateforme> plateforms = _etherService.getAllPlateforms(); 
    53 //        final List<Plateforme> plateforms = new ArrayList<Plateforme>(); 
    54 //        final Plateforme pf = new Plateforme(); 
    55 //        pf.setPlateformeId( 1 ); 
    56 //        pf.setPlateformeNom( "LHVP" ); 
    57 //        plateforms.add( pf ); 
    58 //        final Plateforme pf2 = new Plateforme(); 
    59 //        pf2.setPlateformeId( 2 ); 
    60 //        pf2.setPlateformeNom( "SIRTA" ); 
    61 //        plateforms.add( pf2 ); 
     53//        final List<Plateforme> plateforms = _etherService.getAllPlateforms(); 
     54        final List<Plateforme> plateforms = new ArrayList<Plateforme>(); 
     55        final Plateforme pf = new Plateforme(); 
     56        pf.setPlateformeId( 1 ); 
     57        pf.setPlateformeNom( "LHVP" ); 
     58        final TypePlateforme type = new TypePlateforme(  ); 
     59        type.setTypePlateformeNom( "MOBILE" ); 
     60        pf.setTypePlateforme( type ); 
     61        plateforms.add( pf ); 
     62 
     63        final Plateforme pf2 = new Plateforme(); 
     64        pf2.setPlateformeId( 2 ); 
     65        pf2.setPlateformeNom( "SIRTA" ); 
     66        final TypePlateforme type2 = new TypePlateforme(  ); 
     67        type2.setTypePlateformeNom( "FIXED" ); 
     68        pf2.setTypePlateforme( type2 ); 
     69        plateforms.add( pf2 ); 
    6270 
    6371        final Map<String, Object> model = new HashMap<String, Object>(); 
    6472        model.put( "plateforms", getJsonHelper().toJSON( plateforms ) ); 
    65         model.put( "axeTypes", getJSONAxeTypes() ); 
     73        model.put( "axeTypesForFixedPlateforms", getJSONAxeTypesForFixedPlateforms() ); 
     74        model.put( "axeTypesForMobilePlateforms", getJSONAxeTypesForMobilePlateforms() ); 
    6675        return model; 
    6776    } 
     
    7786    { 
    7887        final List<Parametre> parametersByPlateform = _etherService.getParametersByPlateformId( plateformId ); 
    79 //        final List<Parametre> parametersByPlateform = new ArrayList<Parametre>( 2 ); 
    80 //        final Parametre p1 = new Parametre(); 
    81 //        p1.setParametreId( 1 ); 
    82 //        p1.setParametreNom( "JNO2" ); 
    83 //        parametersByPlateform.add( p1 ); 
    84 //        final Parametre p2 = new Parametre(); 
    85 //        p2.setParametreId( 2 ); 
    86 //        p2.setParametreNom( "CO2" ); 
    87 //        parametersByPlateform.add( p2 ); 
    8888 
    8989        final JSONObject result = new JSONObject(); 
     
    9292    } 
    9393 
    94     @ControllerMethod(jsonResult = true) 
    95     private List<JSONObject> getJSONAxeTypes() 
     94    private List<JSONObject> getJSONAxeTypesForFixedPlateforms() 
    9695    { 
    97         final AxeType[] axeTypes = AxeType.values(); 
     96        final AxeTypeForFixedPlateform[] axeTypes = AxeTypeForFixedPlateform.values(); 
    9897 
    9998        final List<JSONObject> jsonAxeTypes = new ArrayList<JSONObject>( axeTypes.length ); 
    10099 
    101         for( final AxeType axeType : axeTypes ) 
     100        for( final AxeTypeForFixedPlateform axeType : axeTypes ) 
     101        { 
     102            final JSONObject jsonAxeType = new JSONObject(); 
     103            jsonAxeType.put( "text", axeType.name() ); 
     104            jsonAxeType.put( "value", axeType.name() ); 
     105            jsonAxeTypes.add( jsonAxeType ); 
     106        } 
     107        return jsonAxeTypes; 
     108    } 
     109 
     110    private List<JSONObject> getJSONAxeTypesForMobilePlateforms() 
     111    { 
     112        final AxeTypeForMobilePlateform[] axeTypes = AxeTypeForMobilePlateform.values(); 
     113 
     114        final List<JSONObject> jsonAxeTypes = new ArrayList<JSONObject>( axeTypes.length ); 
     115 
     116        for( final AxeTypeForMobilePlateform axeType : axeTypes ) 
    102117        { 
    103118            final JSONObject jsonAxeType = new JSONObject(); 
  • ether_megapoli/trunk/web/src/com/ether/ControllerPlot.java

    r130 r132  
    22 
    33import com.medias.Context; 
     4import com.medias.database.objects.Parametre; 
     5import com.medias.database.objects.Unite; 
    46import gov.noaa.pmel.sgt.dm.SGTMetaData; 
    57import gov.noaa.pmel.sgt.dm.SimpleLine; 
     
    2426import java.util.Date; 
    2527import java.util.List; 
     28import java.util.Locale; 
     29import java.util.ResourceBundle; 
    2630 
    2731/** 
     
    109113            //** ******************************************************************** **// 
    110114 
    111  
    112             final SimpleLine data = new SimpleLine( dateArray, dataArray, "legend" ); 
    113             SGTMetaData meta = new SGTMetaData( "Longitude", "degrees East", false, false ); 
    114             data.setXMetaData( meta ); 
    115  
    116             meta = new SGTMetaData( "parameterName", "parameterUnit", false, false ); 
    117             data.setYMetaData( meta ); 
     115            final Parametre parametre = _etherService.getParameterById( parameterId ); 
     116 
     117//            final Parametre parametre = new Parametre(); 
     118//            parametre.setParametreNom( "Ozone" ); 
     119//            final Unite unit = new Unite(); 
     120//            unit.setUniteCode( "ppb" ); 
     121//            parametre.setUnite( unit ); 
     122            if( null == parametre ) 
     123            { 
     124                createErrorPane( response, request, WebException.WebCode.PARAMETER_IS_NULL.toString(), null ); 
     125                flagException = true; 
     126                throw new ServletException( WebException.WebCode.PARAMETER_IS_NULL.toString(), null ); 
     127            } 
     128 
     129 
     130            final SimpleLine data; 
     131            if( AxeTypeForFixedPlateform.TIME.name().equals( axeType ) ) 
     132                data = createTimeSerie( dateArray, dataArray, parametre.getParametreNom(), parametre.getUnite() ); 
     133            else 
     134                data = createLatitudeSerie( dataArray, dataArray, parametre.getParametreNom(), Context.getLocale( request ) ); 
    118135 
    119136            final MegapoliPlot megapoliPlot = new MegapoliPlot(); 
    120137            megapoliPlot.setTitle( title ); 
    121138            megapoliPlot.setData( data ); 
     139            megapoliPlot.setLegendToHide( null == data.getTitle() ); 
    122140 
    123141            final BufferedImage bufferedImage = _etherPlotService.createMainPane( megapoliPlot, Context.getLocale( request ) ); 
     
    138156    } 
    139157 
    140     private void createErrorPane( final HttpServletResponse response, final HttpServletRequest request, @NotNull final String mainError, @NotNull final Exception e ) 
     158    private SimpleLine createTimeSerie( @NotNull final GeoDateArray dateArray, @NotNull final double[] dataArray, @Nullable final String parameterName, @Nullable final Unite unit ) 
     159    { 
     160        final SimpleLine data = new SimpleLine( dateArray, dataArray, null ); 
     161        SGTMetaData meta = new SGTMetaData( null, null, false, false ); 
     162        data.setXMetaData( meta ); 
     163 
     164        meta = new SGTMetaData( parameterName, unit.getUniteCode(), false, false ); 
     165        data.setYMetaData( meta ); 
     166        return data; 
     167    } 
     168 
     169    private SimpleLine createLatitudeSerie( @NotNull final double[] dateArray, @NotNull final double[] dataArray, @Nullable final String legend, @Nullable final Locale locale ) 
     170    { 
     171        final ResourceBundle bundle = WebHelper.getBundle( locale ); 
     172 
     173        final SimpleLine data = new SimpleLine( dateArray, dataArray, legend ); 
     174        SGTMetaData meta = new SGTMetaData( bundle.getString( "plot.longitude" ), bundle.getString( "plot.degres" ), false, true ); 
     175        // TODO : vérifier modulo = 360 
     176//        meta.setModuloValue( 360 ); 
     177        data.setXMetaData( meta ); 
     178 
     179        meta = new SGTMetaData( bundle.getString( "plot.latitude" ), bundle.getString( "plot.degres" ), false, true ); 
     180        // TODO : vérifier modulo = 360 
     181//        meta.setModuloValue( 360 ); 
     182        data.setYMetaData( meta ); 
     183        return data; 
     184    } 
     185 
     186    private void createErrorPane( final HttpServletResponse response, final HttpServletRequest request, @NotNull final String mainError, @Nullable final Exception e ) 
    141187            throws IOException 
    142188    { 
    143         final BufferedImage errorImage = _etherPlotService.createErrorPane( mainError, e.toString(), Context.getLocale( request ) ); 
     189        final BufferedImage errorImage; 
     190        if( null != e ) 
     191            errorImage = _etherPlotService.createErrorPane( mainError, e.toString(), Context.getLocale( request ) ); 
     192        else 
     193            errorImage = _etherPlotService.createErrorPane( mainError, null, Context.getLocale( request ) ); 
     194 
    144195        ImageIO.write( errorImage, "png", response.getOutputStream() ); 
    145196    } 
  • ether_megapoli/trunk/web/src/com/ether/WebException.java

    r130 r132  
    3434                ERROR_NUMBER_OF_PARAM_TYPES_NOT_EQUAL_TO_PARAM_ANNOTATIONS, 
    3535        INVALID_DATE, 
     36        PARAMETER_IS_NULL, 
    3637    } 
    3738} 
  • ether_megapoli/trunk/web/src/json/serializers/PlateformJsonSerializer.java

    r89 r132  
    55import net.sf.json.JsonConfig; 
    66 
    7 public class PlateformJsonSerializer extends AbstractJsonSerializer<Plateforme> 
     7public class PlateformJsonSerializer 
     8        extends AbstractJsonSerializer<Plateforme> 
    89{ 
    910    public JSONObject process( final Plateforme plateform, final JsonConfig jsonConfig ) 
     
    1314        serialize( result, "id", plateform.getPlateformeId(), jsonConfig ); 
    1415        serialize( result, "name", plateform.getPlateformeNom(), jsonConfig ); 
     16        serialize( result, "type", plateform.getTypePlateforme().getTypePlateformeNom(), jsonConfig ); 
    1517 
    1618        return result; 
  • ether_megapoli/trunk/web/visualization/visu_parameter_by_pf-script.jsp

    r130 r132  
     1<%@ page import="com.ether.EtherPlotServiceImpl" %> 
    12<script type="text/javascript"> 
    23var InterfaceVisualization = Class.create( { 
    34 
    4     initialize: function( jsonPlateforms, axeTypes ) 
     5    initialize: function( jsonPlateforms, axeTypesForFixedPlateforms, axeTypesForMobilePlateforms ) 
    56    { 
    67        // Values 
     
    1112        this.generalContainerOptions = $( "generalContainerOptions" ); 
    1213        this.jsonPlateforms = jsonPlateforms || null; 
    13         this.jsonAxeTypes = axeTypes || null; 
     14        this.jsonAxeTypesForFixedPlateforms = axeTypesForFixedPlateforms || null; 
     15        this.jsonAxeTypesForMobilePlateforms = axeTypesForMobilePlateforms || null; 
    1416        this.selectedPlateform = false; 
    1517        this.selectedParameter = false; 
     
    8991        paramSelect.parent = $( "containerOptionAxe" ); 
    9092        this.selectAxes = new Select( paramSelect ); 
    91  
    92         this.jsonAxeTypes.each( function ( axeType ) 
    93         { 
    94             this.selectAxes.add( axeType.value, interfaceTexts[axeType.text] ); 
    95         }.bind( this ) ); 
    96  
    97         this.selectAxes.selectFirst( false ); 
    9893    }, 
    9994 
     
    160155        if( this.selectedParameter ) 
    161156            this.selectedParameter = false; 
     157 
     158        // Change plateformType's select 
     159        this.updateListAxes(); 
    162160 
    163161        $( "textareaTitle" ).value = this.selectedPlateform.getName(); 
     
    219217//                + "&axeType=" + this.selectAxes.getValue(); 
    220218 
    221         var url = "visualization/plotEther?plateformId=33" 
    222                 + "&parameterId=10" 
     219        var url = "visualization/plotEther?plateformId=14" 
     220                + "&parameterId=125" 
    223221                + "&dateBegin=" + this.beginDate 
    224222                + "&dateEnd=" + this.endDate 
     
    227225 
    228226        this.plotWindow.getContent().innerHTML = '<img src=' + url + ' />'; 
    229 //        this.plotWindow.setSize( this.plotWindow.getContent().firstChild.width, this.plotWindow.getContent().firstChild.height, true ); 
    230         this.plotWindow.setSize( 800, 700 ); 
     227        this.plotWindow.setSize( <%=EtherPlotServiceImpl.getMaxWidth()%>, <%=EtherPlotServiceImpl.getMaxHeight()%> ); 
    231228        this.plotWindow.show(); 
    232 //        this.plotWindow.height = this.plotWindow.getContent().firstChild.height; 
    233 //        this.plotWindow.width = this.plotWindow.getContent().firstChild.width; 
    234229    }, 
    235230 
     
    281276        this.visualizeButton.enable(); 
    282277        this.downloadButton.enable(); 
     278    }, 
     279 
     280    updateListAxes: function() 
     281    { 
     282        this.selectAxes.clear(); 
     283        var jsonAxeTypes; 
     284 
     285        if( "MOBILE" == this.selectedPlateform.jsonElement.type ) 
     286            jsonAxeTypes = this.jsonAxeTypesForMobilePlateforms; 
     287        else 
     288            jsonAxeTypes = this.jsonAxeTypesForFixedPlateforms; 
     289 
     290        jsonAxeTypes.each( function ( axeType ) 
     291        { 
     292            this.selectAxes.add( axeType.value, interfaceTexts[axeType.text] ); 
     293        }.bind( this ) ); 
     294 
     295        this.selectAxes.selectFirst( false ); 
    283296    } 
    284297 
  • ether_megapoli/trunk/web/visualization/visu_parameter_by_pf.jsp

    r130 r132  
    11<!-- /*** ****************** VISU ******************** **/ --> 
    22<%@ page import="com.medias.Context" %> 
    3 <%@ page import="com.ether.AxeType" %> 
     3<%@ page import="com.ether.AxeTypeForFixedPlateform" %> 
     4<%@ page import="com.ether.AxeTypeForMobilePlateform" %> 
    45 
    56<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> 
     
    2526        <ether:htmlCss cssFile="windows_js_1.3/themes/mac_os_x"/> 
    2627 
    27         <%-- Select --%> 
    28         <%--ether:htmlCss cssFile="customedSelect/css/customSelect" /--%> 
    2928    </tiles:put> 
    3029 
     
    4645        <ether:htmlJs jsFile="windows_js_1.3/javascripts/window_ext"/> 
    4746 
    48         <%-- Select --%> 
    49         <%--ether:htmlJs jsFile="customedSelect/js/customSelect"/--%> 
    5047    </tiles:put> 
    5148 
     
    6158    <tiles:put name="body" type="string"> 
    6259 
    63         <div class="span-24"> 
     60        <div class="span-25"> 
    6461            <div id="generalContainerPlateforms" class="span-7 colborder"> 
    6562                <div id="messages"><bean:message key="data.visualization.selectPf"/></div> 
     
    7471            </div> 
    7572 
    76             <div id="generalContainerOptions" class="span-9 last"> 
    77                 <div id="containerOptionCalendar" class="span-9"> 
     73            <div id="generalContainerOptions" class="span-10 last"> 
     74                <div id="containerOptionCalendar" class="span-10"> 
    7875                    <div id="messages" class="messagesHeight"><bean:message key="data.visualization.selectPeriod"/></div> 
    7976                    <input type="text" id="beginDate" size="15"/> 
     
    119116            interfaceTexts["data.visualization.selectMinute"] = "<bean:message key="data.visualization.selectMinute"/>"; 
    120117 
    121             interfaceTexts["<%=AxeType.TIME%>"] = "<bean:message key="data.visualization.axeType.Time"/>"; 
    122             interfaceTexts["<%=AxeType.LATITUDE%>"] = "<bean:message key="data.visualization.axeType.Latitude"/>"; 
     118            interfaceTexts["<%=AxeTypeForFixedPlateform.TIME%>"] = "<bean:message key="data.visualization.axeType.Time"/>"; 
     119            interfaceTexts["<%=AxeTypeForMobilePlateform.LATITUDE%>"] = "<bean:message key="data.visualization.axeType.Latitude"/>"; 
    123120 
    124             var interfaceVisualization = new InterfaceVisualization( ${plateforms}, ${axeTypes} ); 
     121            var interfaceVisualization = new InterfaceVisualization( ${plateforms}, ${axeTypesForFixedPlateforms}, ${axeTypesForMobilePlateforms} ); 
    125122        </script> 
    126123 
Note: See TracChangeset for help on using the changeset viewer.