Ignore:
Timestamp:
08/18/11 12:39:22 (13 years ago)
Author:
vmipsl
Message:

[Visualization] interface quite finish

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ether_megapoli/trunk/web/src/com/ether/ControllerPlot.java

    r129 r130  
    88import org.apache.commons.logging.LogFactory; 
    99import org.jetbrains.annotations.NotNull; 
     10import org.jetbrains.annotations.Nullable; 
    1011import org.springframework.context.ApplicationContext; 
    1112import org.springframework.web.context.support.WebApplicationContextUtils; 
     
    1920import java.awt.image.BufferedImage; 
    2021import java.io.IOException; 
    21 import java.text.ParseException; 
     22import java.util.ArrayList; 
     23import java.util.Calendar; 
    2224import java.util.Date; 
    2325import java.util.List; 
     
    5759            throws ServletException 
    5860    { 
     61        boolean flagException = false; 
     62 
    5963        try 
    6064        { 
     65            //Parameters 
    6166            final Integer plateformId = Integer.valueOf( request.getParameter( "plateformId" ) ); 
    6267            final Integer parameterId = Integer.valueOf( request.getParameter( "parameterId" ) ); 
     68            final String title = request.getParameter( "title" ); 
     69            final String axeType = request.getParameter( "axeType" ); 
     70 
    6371            final String dateBegin = request.getParameter( "dateBegin" ); 
    6472            final String dateEnd = request.getParameter( "dateEnd" ); 
    65             final String pofBegin = "2009-07-13 13:00"; 
    66             final String pofEnd = "2009-07-14 14:00"; 
    67             final Date formatedDateBegin = DateHelper.parseDate( pofBegin, DateHelper.ENGLISH_DATE_PATTERN ); 
    68             final Date formatedDateEnd = DateHelper.parseDate( pofEnd, DateHelper.ENGLISH_DATE_PATTERN ); 
     73            final Calendar calendar = Calendar.getInstance(); 
     74            final Date formatedDateBegin; 
     75            final Date formatedDateEnd; 
     76            try 
     77            { 
     78                calendar.setTimeInMillis( Long.valueOf( dateBegin ) ); 
     79                formatedDateBegin = calendar.getTime(); 
     80                calendar.setTimeInMillis( Long.valueOf( dateEnd ) ); 
     81                formatedDateEnd = calendar.getTime(); 
     82            } 
     83            catch( Exception e ) 
     84            { 
     85                createErrorPane( response, request, WebException.WebCode.INVALID_DATE.toString(), e ); 
     86                flagException = true; 
     87                throw new ServletException( WebException.WebCode.INVALID_DATE.toString(), e ); 
     88            } 
    6989 
     90            // Create plot 
    7091            //** ******************************************************************** **// 
    7192            // TODO : replace List<Data> by List<value> and List<double> 
    7293            //** ******************************************************************** **// 
    73             final List<Pair<Double, Date>> values = _etherService.getValuesByPlateformByParameterByPeriod( plateformId, parameterId, formatedDateBegin, formatedDateEnd ); 
     94//            final List<Pair<Double, Date>> values = _etherService.getValuesByPlateformByParameterByPeriod( plateformId, parameterId, formatedDateBegin, formatedDateEnd ); 
     95            final List<Pair<Double, Date>> values = new ArrayList<Pair<Double, Date>>(); 
     96            final Pair<Double, Date> p1 = new Pair<Double, Date>( Double.valueOf( 23 ), new Date() ); 
     97            final Pair<Double, Date> p2 = new Pair<Double, Date>( Double.valueOf( 24 ), new Date() ); 
     98            final Pair<Double, Date> p3 = new Pair<Double, Date>( Double.valueOf( 25 ), new Date() ); 
     99            final Pair<Double, Date> p4 = new Pair<Double, Date>( Double.valueOf( 26 ), new Date() ); 
     100            values.add( p1 ); 
     101            values.add( p2 ); 
     102            values.add( p3 ); 
     103            values.add( p4 ); 
    74104            final double[] dataArray = extractDoubles( values ); 
    75105            final Date[] dateValues = extractDates( values ); 
     
    88118 
    89119            final MegapoliPlot megapoliPlot = new MegapoliPlot(); 
    90             megapoliPlot.setTitle( "Mobilis LIDAR" ); 
     120            megapoliPlot.setTitle( title ); 
    91121            megapoliPlot.setData( data ); 
    92122 
    93             final BufferedImage bufferedImage = _etherPlotService.createJPane( megapoliPlot, Context.getLocale( request ) ); 
    94  
     123            final BufferedImage bufferedImage = _etherPlotService.createMainPane( megapoliPlot, Context.getLocale( request ) ); 
    95124            ImageIO.write( bufferedImage, "png", response.getOutputStream() ); 
    96125        } 
    97         catch( IOException e ) 
     126        catch( Exception e1 ) 
    98127        { 
    99             throw new ServletException( "Error : no possibity to write image in response", e ); 
     128            try 
     129            { 
     130                if( !flagException ) 
     131                    createErrorPane( response, request, "", e1 ); 
     132            } 
     133            catch( Exception e2 ) 
     134            { 
     135                throw new ServletException( "Error : no possibity to write image in response", e2 ); 
     136            } 
    100137        } 
    101         catch( ServiceException e ) 
    102         { 
    103             throw new ServletException( "Error : no possibility to extract data from base", e ); 
    104         } 
    105         catch( ParseException e ) 
    106         { 
    107             throw new ServletException( "Error : invalid dates, no parsing available", e ); 
    108         } 
     138    } 
     139 
     140    private void createErrorPane( final HttpServletResponse response, final HttpServletRequest request, @NotNull final String mainError, @NotNull final Exception e ) 
     141            throws IOException 
     142    { 
     143        final BufferedImage errorImage = _etherPlotService.createErrorPane( mainError, e.toString(), Context.getLocale( request ) ); 
     144        ImageIO.write( errorImage, "png", response.getOutputStream() ); 
    109145    } 
    110146 
     
    137173    private static final Log LOGGER = LogFactory.getLog( ControllerPlot.class ); 
    138174 
    139     // Dimensions of the jPanes 
    140     private static final int MAIN_WIDTH = 1000; 
    141     private static final int MAIN_HEIGHT = 1000; 
    142  
    143175    private EtherService _etherService; 
    144176    private EtherPlotService _etherPlotService; 
Note: See TracChangeset for help on using the changeset viewer.