Changeset 189


Ignore:
Timestamp:
09/09/11 12:09:09 (13 years ago)
Author:
vmipsl
Message:

Servlet _ TimeSerie? :

  • 1 paramètre ok
  • même paramètre sur différentes plateformes ok
  • plusieurs paramètres sur même ou différentes plateformes ok
Location:
ether_megapoli/trunk
Files:
1 added
4 edited

Legend:

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

    r185 r189  
    9292 
    9393        // Actions Panel 
    94         final JPanel jPanelControl = _etherPlotService.createControlPanel(); 
     94//        final JPanel jPanelControl = _etherPlotService.createControlPanel(); 
    9595//        add( jPanelControl, BorderLayout.SOUTH ); 
    9696 
  • ether_megapoli/trunk/applets/src/com/ether/AppletTimeSerie.java

    r185 r189  
    7979 
    8080        // Actions Panel 
    81         final JPanel jPanelControl = _etherPlotService.createControlPanel(); 
     81//        final JPanel jPanelControl = _etherPlotService.createControlPanel(); 
    8282//        add( jPanelControl, BorderLayout.SOUTH ); 
    8383 
  • ether_megapoli/trunk/service/implementation/com/ether/EtherPlotContentServiceImpl.java

    r188 r189  
    55import gov.noaa.pmel.sgt.Axis; 
    66import gov.noaa.pmel.sgt.CartesianGraph; 
    7 import gov.noaa.pmel.sgt.ColorMap; 
    8 import gov.noaa.pmel.sgt.ContourLevels; 
    97import gov.noaa.pmel.sgt.Graph; 
    10 import gov.noaa.pmel.sgt.GridAttribute; 
    11 import gov.noaa.pmel.sgt.IndexedColorMap; 
    128import gov.noaa.pmel.sgt.JPane; 
    139import gov.noaa.pmel.sgt.Layer; 
     
    2016import gov.noaa.pmel.sgt.StackedLayout; 
    2117import gov.noaa.pmel.sgt.TimeAxis; 
    22 import gov.noaa.pmel.sgt.demo.TestData; 
    23 import gov.noaa.pmel.sgt.dm.SGTData; 
    2418import gov.noaa.pmel.sgt.dm.SGTMetaData; 
    25 import gov.noaa.pmel.sgt.dm.SimpleGrid; 
    2619import gov.noaa.pmel.sgt.dm.SimpleLine; 
    27 import gov.noaa.pmel.sgt.swing.JPlotLayout; 
    2820import gov.noaa.pmel.util.Dimension2D; 
    29 import gov.noaa.pmel.util.GeoDate; 
    3021import gov.noaa.pmel.util.GeoDateArray; 
    3122import gov.noaa.pmel.util.Point2D; 
     
    3728import org.springframework.beans.factory.annotation.Required; 
    3829 
    39 import javax.swing.*; 
    40 import javax.swing.border.EtchedBorder; 
    4130import java.awt.*; 
    4231import java.util.ArrayList; 
     
    4736import java.util.ResourceBundle; 
    4837 
     38/** 
     39 * @author vmipsl 
     40 * @date 05 sept. 2011 
     41 */ 
    4942public class EtherPlotContentServiceImpl 
    5043{ 
     
    8174        mainPane.add( layer ); 
    8275 
    83         final CartesianGraph graph = new CartesianGraph( "First Graph" ); 
    84         layer.setGraph( graph ); 
    85  
    8676        final Pair<List, List> listPairOfPIdPIdForTwoAxes = extractListPairForAxes( megapoliPlot.getpIdPIdList() ); 
    8777        final List<Pair> pIdPIdListForFirstAxis = listPairOfPIdPIdForTwoAxes.getFirstValue(); 
     
    9282        final SimpleLine firstLine = lines.get( 0 ); 
    9383 
    94         /** *********** RANGES ************ **/ 
     84        /** ********** AXIS RANGES ********* **/ 
    9585        final SoTRange xnRange = firstLine.getXRange(); 
    9686        final SoTRange yRange = firstLine.getYRange(); 
     
    10494            xnRange.add( line.getXRange() ); 
    10595 
    106         // TODO : automatiser le nb d'intervalles en fonction des valeurs de y 
    10796        final SoTRange ynRange = Graph.computeRange( yRange, _intervalsNumber ); 
    10897 
     
    111100 
    112101 
    113         /** ************ X-AXIS ********** **/ 
     102        /** ************ AXIS ********** **/ 
    114103        // Time axis is the same for the two y-axis 
    115         final TimeAxis xbot = new TimeAxis( "X-Axis", TimeAxis.AUTO ); 
    116         xbot.setRangeU( xnRange ); 
    117         xbot.setLocationU( originPoint ); 
    118         xbot.setLabelFont( _axisFont ); 
    119         xbot.setLabelHeightP( _heightAxisFont ); 
    120         xbot.setMajorLabelFormat( "yyyy-MM-dd HH:mm:ss" ); 
    121  
    122         // Create the vertical axis, set its range in user units and its origin. Create the axis title. 
    123         final PlainAxis yleft = createYAxis( firstLine, ynRange, originPoint, null ); 
     104        final TimeAxis xTimeAxis = createXTimeAxis( xnRange, originPoint ); 
     105        final PlainAxis yLeftAxis = createYAxis( firstLine, ynRange, originPoint, null ); 
    124106 
    125107        /** ************ GRAPH ********** **/ 
    126         // Create first CartesianGraph and transforms 
    127 //        final CartesianGraph graph = new CartesianGraph( "First Graph" ); 
     108        final CartesianGraph graph = new CartesianGraph( "First Graph" ); 
     109        layer.setGraph( graph ); 
     110 
    128111        final LinearTransform xt = new LinearTransform( new Range2D( xstart, xend ), xnRange ); 
    129112        graph.setXTransform( xt ); 
     
    131114        graph.setYTransform( yt ); 
    132115 
    133         graph.addXAxis( xbot ); 
    134         graph.addYAxis( yleft ); 
    135  
    136         SimpleLine firstLineForSecondAxis = null; 
    137  
    138         LinearTransform ytForSecondAxis = null; 
     116        graph.addXAxis( xTimeAxis ); 
     117        graph.addYAxis( yLeftAxis ); 
     118 
     119        final LineAttribute lineAttribute = createRandomLineAttribute( megapoliPlot.getAxeType() ); 
     120        graph.setData( firstLine, lineAttribute ); 
     121 
     122        /** *********** LEGEND ********* **/ 
     123        final LineKey lkey = createLineKey( megapoliPlot, ysize, layer, firstLine, graph ); 
     124 
     125        /** *********** OTHER LAYERS ********* **/ 
     126        // First axis 
     127        addOtherLinesForOneAxis( megapoliPlot.getAxeType(), mainPane, xsize, ysize, lines, xt, yt, lkey, 1 ); 
     128 
     129        // Second axis 
    139130        if( !pIdPIdListForSecondAxis.isEmpty() ) 
    140131        { 
    141             firstLineForSecondAxis = linesForSecondAxis.get( 0 ); 
     132            final SimpleLine firstLineForSecondAxis = linesForSecondAxis.get( 0 ); 
    142133 
    143134            final SoTRange yRangeForSecondAxis = firstLineForSecondAxis.getYRange(); 
     
    148139            final SoTPoint endPointForSecondAxis = new SoTPoint( ynRangeForSecondAxis.getStart(), xnRange.getEnd() ); 
    149140 
    150             final PlainAxis yleftForSecondAxis = createYAxis( firstLineForSecondAxis, ynRangeForSecondAxis, endPointForSecondAxis, Axis.POSITIVE_SIDE ); 
    151  
    152             ytForSecondAxis = new LinearTransform( new Range2D( ystart, yend ), ynRangeForSecondAxis ); 
     141            final PlainAxis yRightAxis = createYAxis( firstLineForSecondAxis, ynRangeForSecondAxis, endPointForSecondAxis, Axis.POSITIVE_SIDE ); 
     142 
     143            final LinearTransform ytForSecondAxis = new LinearTransform( new Range2D( ystart, yend ), ynRangeForSecondAxis ); 
     144 
     145            // It transforms the graph with the maximum yAxis 
    153146            if( ytForSecondAxis.getRangeU().end > yt.getRangeU().end ) 
    154147                graph.setYTransform( ytForSecondAxis ); 
    155             graph.addYAxis( yleftForSecondAxis ); 
    156         } 
    157  
    158 //        layer.setGraph( graph ); 
    159  
    160         final LineAttribute lineAttribute = createRandomLineAttrbute( megapoliPlot.getAxeType() ); 
    161         graph.setData( firstLine, lineAttribute ); 
    162  
    163         /** *********** LEGEND ********* **/ 
     148            graph.addYAxis( yRightAxis ); 
     149 
     150            addOtherLinesForOneAxis( megapoliPlot.getAxeType(), mainPane, xsize, ysize, linesForSecondAxis, xt, ytForSecondAxis, lkey, 0 ); 
     151        } 
     152 
     153        return mainPane; 
     154    } 
     155 
     156    @NotNull 
     157    public JPane create2DPlot( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight, @Nullable final Locale locale ) 
     158    { 
     159        final JPane mainPane = new JPane( "2D Pane", new Dimension( plotWidth, plotHeight ) ); 
     160 
     161        final ResourceBundle bundle = WebHelper.getBundle( locale ); 
     162 
     163        final Data realValuesFor2D = BouchonHelper.createRealValuesFor2D(); 
     164//        final double[] parameterValues = (double[]) megapoliPlot.getData().getFirstArray(); 
     165//        final double[] latitudeValues = (double[]) megapoliPlot.getData().getSecondArray(); 
     166//        final double[] longitudeValues = (double[]) megapoliPlot.getData().getThirdArray(); 
     167 
     168        final double[] parameterValues = (double[]) realValuesFor2D.getFirstArray(); 
     169        final double[] latitudeValues = (double[]) realValuesFor2D.getSecondArray(); 
     170        final double[] longitudeValues = (double[]) realValuesFor2D.getThirdArray(); 
     171 
     172        return mainPane; 
     173    } 
     174 
     175    @NotNull 
     176    protected String formatTitle( @Nullable final String title ) 
     177    { 
     178        if( null == title ) 
     179            return ""; 
     180        else 
     181        { 
     182            final String formatTitle = title.replaceAll( "\\n", "<br>" ); 
     183            return "<html>" + formatTitle + "</html>"; 
     184        } 
     185    } 
     186 
     187    /** 
     188     * This method creates a legend 
     189     * 
     190     * @param megapoliPlot 
     191     * @param ysize 
     192     * @param layer 
     193     * @param firstLine 
     194     * @param graph 
     195     * @return 
     196     */ 
     197    @NotNull 
     198    private LineKey createLineKey( final MegapoliPlot megapoliPlot, final double ysize, final Layer layer, final SimpleLine firstLine, final CartesianGraph graph ) 
     199    { 
    164200        final LineKey lkey = new LineKey(); 
    165201        if( !megapoliPlot.isLegendToHide() ) 
     
    173209            lkey.addLineGraph( (LineCartesianRenderer) graph.getRenderer(), firstLine.getKeyTitle() ); 
    174210        } 
    175  
    176         /** *********** OTHER LAYERS ********* **/ 
    177         addOtherLinesForOneAxis( megapoliPlot.getAxeType(), mainPane, xsize, ysize, lines, xt, yt, lkey, 1 ); 
    178  
    179         if( !pIdPIdListForSecondAxis.isEmpty() ) 
    180             addOtherLinesForOneAxis( megapoliPlot.getAxeType(), mainPane, xsize, ysize, linesForSecondAxis, xt, ytForSecondAxis, lkey, 0 ); 
    181  
    182         return mainPane; 
     211        return lkey; 
     212    } 
     213 
     214    /** 
     215     * This method creates a x-axis for time serie 
     216     * 
     217     * @param xnRange 
     218     * @param originPoint 
     219     * @return 
     220     */ 
     221    @NotNull 
     222    private TimeAxis createXTimeAxis( final SoTRange xnRange, final SoTPoint originPoint ) 
     223    { 
     224        final TimeAxis xbot = new TimeAxis( "X-Axis", TimeAxis.AUTO ); 
     225        xbot.setRangeU( xnRange ); 
     226        xbot.setLocationU( originPoint ); 
     227        xbot.setLabelFont( _axisFont ); 
     228        xbot.setLabelHeightP( _heightAxisFont ); 
     229        xbot.setMajorLabelFormat( "yyyy-MM-dd HH:mm:ss" ); 
     230        return xbot; 
    183231    } 
    184232 
     
    205253            otherLayer.setGraph( otherGraph ); 
    206254 
    207             final LineAttribute otherLineAttribute = createRandomLineAttrbute( axeType ); 
     255            final LineAttribute otherLineAttribute = createRandomLineAttribute( axeType ); 
    208256            otherGraph.setData( line, otherLineAttribute ); 
    209257            lkey.addLineGraph( (LineCartesianRenderer) otherGraph.getRenderer(), line.getKeyTitle() ); 
    210 //            lkey.setColumns( lkey.getColumns() + 1 ); 
    211         } 
    212     } 
    213  
     258        } 
     259    } 
     260 
     261    /** 
     262     * This method creates a vertical axis, set its range in user units and its origin and creates the axis title 
     263     * 
     264     * @param line 
     265     * @param ynRange 
     266     * @param originPoint 
     267     * @param labelPosition 
     268     * @return 
     269     */ 
    214270    @NotNull 
    215271    private PlainAxis createYAxis( final SimpleLine line, final SoTRange ynRange, final SoTPoint originPoint, @Nullable final Integer labelPosition ) 
    216272    { 
    217         final PlainAxis yleft = new PlainAxis( "Y-Axis" ); 
    218         yleft.setRangeU( ynRange ); 
    219         yleft.setLocationU( originPoint ); 
    220         yleft.setLabelFont( _axisFont ); 
     273        final PlainAxis yAxis = new PlainAxis( "Y-Axis" ); 
     274        yAxis.setRangeU( ynRange ); 
     275        yAxis.setLocationU( originPoint ); 
     276        yAxis.setLabelFont( _axisFont ); 
    221277        if( null != labelPosition ) 
    222             yleft.setLabelPosition( labelPosition ); 
     278            yAxis.setLabelPosition( labelPosition ); 
    223279 
    224280        final String yLabel = line.getYMetaData().getName() + " (" + line.getYMetaData().getUnits() + ")"; 
     
    226282        ytitle.setFont( _axisFont ); 
    227283        ytitle.setHeightP( _heightAxisFont ); 
    228         yleft.setTitle( ytitle ); 
    229         return yleft; 
    230     } 
    231  
     284        yAxis.setTitle( ytitle ); 
     285        return yAxis; 
     286    } 
    232287 
    233288    /** 
     
    238293     */ 
    239294    @NotNull 
    240     private LineAttribute createRandomLineAttrbute( @NotNull final String axeType ) 
     295    private LineAttribute createRandomLineAttribute( @NotNull final String axeType ) 
    241296    { 
    242297        final LineAttribute attr; 
     
    253308    } 
    254309 
     310    /** 
     311     * This method extracts from a list of <plateformId, parameterId> two lists of <plateformId, parameterId> corresponding for the 2 axes needed for the graph 
     312     * The second list can be empty, in this case, only one axis is needed 
     313     * 
     314     * @param pIdPIdList 
     315     * @return 
     316     */ 
     317    @NotNull 
    255318    private Pair<List, List> extractListPairForAxes( @NotNull final List<Pair> pIdPIdList ) 
    256319    { 
    257         final List<Pair> pIdPIdListForFirstAxis = new ArrayList<Pair>(); 
    258         final List<Pair> pIdPIdListForSecondAxis = new ArrayList<Pair>(); 
     320        final List<Pair<Integer, Integer>> pIdPIdListForFirstAxis = new ArrayList<Pair<Integer, Integer>>(); 
     321        final List<Pair<Integer, Integer>> pIdPIdListForSecondAxis = new ArrayList<Pair<Integer, Integer>>(); 
    259322 
    260323        for( final Pair pIdPId : pIdPIdList ) 
    261324        { 
    262             final List<Integer> secondValuesForFirstAxis = getSecondValues( pIdPIdListForFirstAxis ); 
     325            final List<Integer> secondValuesForFirstAxis = EtherHelper.getSecondValues( pIdPIdListForFirstAxis ); 
    263326            final Integer parameterId = (Integer) pIdPId.getSecondValue(); 
    264327 
     
    270333 
    271334        return new Pair( pIdPIdListForFirstAxis, pIdPIdListForSecondAxis ); 
    272     } 
    273  
    274     private List getSecondValues( @NotNull final List<Pair> pairList ) 
    275     { 
    276         final List secondValues = new ArrayList<Integer>( pairList.size() ); 
    277         for( final Pair pair : pairList ) 
    278             secondValues.add( pair.getSecondValue() ); 
    279         return secondValues; 
    280335    } 
    281336 
     
    336391    } 
    337392 
    338     @NotNull 
    339     public JPane create2DPlot( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight, @Nullable final Locale locale ) 
    340     { 
    341         SGTData newData; 
    342         TestData td; 
    343  
    344         final ResourceBundle bundle = WebHelper.getBundle( locale ); 
    345  
    346         final Data realValuesFor2D = BouchonHelper.createRealValuesFor2D(); 
    347 //        final double[] parameterValues = (double[]) megapoliPlot.getData().getFirstArray(); 
    348 //        final double[] latitudeValues = (double[]) megapoliPlot.getData().getSecondArray(); 
    349 //        final double[] longitudeValues = (double[]) megapoliPlot.getData().getThirdArray(); 
    350  
    351         final double[] parameterValues = (double[]) realValuesFor2D.getFirstArray(); 
    352         final double[] latitudeValues = (double[]) realValuesFor2D.getSecondArray(); 
    353         final double[] longitudeValues = (double[]) realValuesFor2D.getThirdArray(); 
    354  
    355 //        final SimpleLine data = new SimpleLine( longitudeValues, latitudeArray, "legend" ); 
    356 //        final SimpleGrid data = new SimpleGrid( parameterArray, longitudeValues, latitudeArray, "Test Series" ); 
    357 //        SGTMetaData meta = new SGTMetaData( bundle.getString( "plot.longitude" ), bundle.getString( "plot.degres" ), false, true ); 
    358         // TODO : vérifier modulo = 360 
    359 //        meta.setModuloValue( 360 ); 
    360 //        data.setXMetaData( meta ); 
    361  
    362 //        meta = new SGTMetaData( bundle.getString( "plot.latitude" ), bundle.getString( "plot.degres" ), false, true ); 
    363         // TODO : vérifier modulo = 360 
    364 //        meta.setModuloValue( 360 ); 
    365 //        data.setYMetaData( meta ); 
    366         /* 
    367        * Create a test grid with sinasoidal-ramp data. 
    368         */ 
    369 //        Range2D xr = new Range2D( 190.0f, 250.0f, 1.0f ); 
    370 //        Range2D yr = new Range2D( 0.0f, 45.0f, 1.0f ); 
    371         Range2D xr = new Range2D( 190.0f, 250.0f, 1.0f ); 
    372         Range2D yr = new Range2D( 0.0f, 45.0f, 1.0f ); 
    373 //        newData = testDataa( xr, yr, TestData.SINE_RAMP, 12.0f, 30.f, 5.0f, parameterArray, latitudeArray, longitudeValues ); 
    374  
    375  
    376 //            public SGTData testDataa( Range2D range1, Range2D range2, int type, float amp, float off, float per, final double[] parameterArray, final double[] latitudeArray, final double[] longitudeValues ) 
    377         final SimpleGrid simpleGrid; 
    378         final SGTMetaData xMeta; 
    379         final SGTMetaData yMeta; 
    380         final SGTMetaData zMeta; 
    381  
    382         final int num1 = (int) ( ( xr.end - xr.start ) / xr.delta ) + 1; 
    383         final double[] axis1 = new double[num1]; 
    384         final int num2 = (int) ( ( yr.end - yr.start ) / yr.delta ) + 1; 
    385         final double[] axis2 = new double[num2]; 
    386  
    387         for( int count = 0; count < num1; count++ ) 
    388             axis1[count] = xr.start + count * xr.delta; 
    389  
    390         for( int count = 0; count < num2; count++ ) 
    391             axis2[count] = yr.start + count * yr.delta; 
    392  
    393         final double[] valuesOrig = getValues( axis1, num1, axis2, num2, TestData.SINE_RAMP, 12.0f, 30.f, 5.0f ); 
    394         final double[] values = getValues( longitudeValues, longitudeValues.length, latitudeValues, latitudeValues.length, TestData.SINE_RAMP, 12.0f, 30.f, 5.0f ); 
    395  
    396         SGLabel keyLabel = new SGLabel( "Key Label", "", new Point2D.Double( 0.0, 0.0 ) ); 
    397         keyLabel.setHeightP( 0.16 ); 
    398         // 
    399         // create SimpleGrid 
    400         // 
    401         zMeta = new SGTMetaData( "ts", "m s-1" ); 
    402         keyLabel.setText( "XY test grid" ); 
    403         xMeta = new SGTMetaData( "lon", "degE" ); 
    404         yMeta = new SGTMetaData( "lat", "deg" ); 
    405         final SimpleGrid sg = new SimpleGrid( valuesOrig, axis1, axis2, "Test Series" ); 
    406         simpleGrid = new SimpleGrid( parameterValues, longitudeValues, latitudeValues, "Test Series" ); 
    407 //        simpleGrid = new SimpleGrid( values, longitudeValues, latitudeValues, "Test Series" ); 
    408 //        simpleGrid = new SimpleGrid( valuesOrig, axis1, axis2, "Test Series" ); 
    409  
    410         simpleGrid.setXMetaData( xMeta ); 
    411         simpleGrid.setYMetaData( yMeta ); 
    412         simpleGrid.setZMetaData( zMeta ); 
    413         simpleGrid.setKeyTitle( keyLabel ); 
    414  
    415  
    416         // Create the contour levels and color map 
    417 //        final Range2D datar = new Range2D( -20.0f, 50.0f, 5.0f ); 
    418         final Range2D datar = new Range2D( 5f, 10.0f, 1f ); 
    419         final ContourLevels clevels = ContourLevels.getDefault( datar ); 
    420         final ColorMap cmap = createColorMap( datar ); 
    421  
    422         // Create a grid for contour data 
    423         final GridAttribute gridAttribute = new GridAttribute( clevels ); 
    424         gridAttribute.setColorMap( cmap ); 
    425         gridAttribute.setStyle( GridAttribute.RASTER_CONTOUR ); 
    426  
    427         // Create the plot 
    428         final JPlotLayout jPlotLayout = new JPlotLayout( true, false, false, "JPlotLayout Pane", null, true ); 
    429         jPlotLayout.setEditClasses( false ); 
    430         jPlotLayout.addData( simpleGrid, gridAttribute, "First Data" ); 
    431         jPlotLayout.setTitles( "", "", "" ); 
    432         jPlotLayout.setSize( new Dimension( plotWidth, plotHeight ) ); 
    433  
    434         /* 
    435        * Resize the key Pane, both the device size and the physical 
    436        * size. Set the size of the key in physical units and place 
    437        * the key pane at the "South" of the frame. 
    438         */ 
    439 //    rpl.setKeyLayerSizeP(new Dimension2D(6.0, 1.02)); 
    440 //    rpl.setKeyBoundsP(new Rectangle2D.Double(0.01, 1.01, 5.98, 1.0)); 
    441  
    442         return jPlotLayout; 
    443     } 
    444  
    445     @NotNull 
    446     public JPanel createControlPanel() 
    447     { 
    448         final JPanel controlPanel = new JPanel(); 
    449         final ButtonGroup gridtype = new ButtonGroup(); 
    450         final JCheckBox stacked = new JCheckBox(); 
    451         final JCheckBox grid = new JCheckBox(); 
    452  
    453         controlPanel.setLayout( new GridBagLayout() ); 
    454 //    controlPanel.setBackground(new java.awt.Color(200,200,200)); 
    455         controlPanel.setBounds( 0, 679, 426, 33 ); 
    456         controlPanel.setBorder( new EtchedBorder() ); 
    457         gridtype.add( stacked ); 
    458         stacked.setSelected( true ); 
    459         stacked.setText( "Overlayed" ); 
    460  
    461         GridBagConstraints gbc = new GridBagConstraints(); 
    462         gbc.gridx = 0; 
    463         gbc.gridy = 0; 
    464         gbc.gridwidth = 1; 
    465         gbc.gridheight = 1; 
    466         gbc.weightx = 0.0; 
    467         gbc.weighty = 1.0; 
    468         gbc.anchor = GridBagConstraints.EAST; 
    469         gbc.fill = GridBagConstraints.BOTH; 
    470         gbc.insets = new Insets( 5, 15, 5, 5 ); 
    471         gbc.ipadx = 0; 
    472         gbc.ipady = 0; 
    473         controlPanel.add( stacked, gbc ); 
    474         stacked.setBounds( 15, 5, 84, 23 ); 
    475         gridtype.add( grid ); 
    476         grid.setText( "Grid" ); 
    477  
    478         gbc.gridx = 1; 
    479         gbc.gridy = 0; 
    480         gbc.gridwidth = 1; 
    481         gbc.gridheight = 1; 
    482         gbc.weightx = 0.5; 
    483         gbc.weighty = 1.0; 
    484         gbc.anchor = GridBagConstraints.WEST; 
    485         gbc.fill = GridBagConstraints.VERTICAL; 
    486         gbc.insets = new Insets( 5, 5, 5, 0 ); 
    487         gbc.ipadx = 0; 
    488         gbc.ipady = 0; 
    489         controlPanel.add( grid, gbc ); 
    490         grid.setBounds( 109, 5, 53, 23 ); 
    491         final JButton showTree = new JButton(); 
    492         showTree.setText( "Show Class Tree" ); 
    493  
    494         gbc.gridx = 2; 
    495         gbc.gridy = 0; 
    496         gbc.gridwidth = 1; 
    497         gbc.gridheight = 1; 
    498         gbc.weightx = 1.0; 
    499         gbc.weighty = 1.0; 
    500         gbc.anchor = GridBagConstraints.EAST; 
    501         gbc.fill = GridBagConstraints.VERTICAL; 
    502         gbc.insets = new Insets( 5, 5, 5, 15 ); 
    503         gbc.ipadx = 0; 
    504         gbc.ipady = 0; 
    505         controlPanel.add( showTree, gbc ); 
    506         showTree.setBackground( Color.yellow.brighter() ); 
    507         showTree.setBounds( 302, 5, 109, 23 ); 
    508  
    509         final SymItem lSymItem = new SymItem( stacked, grid ); 
    510         stacked.addItemListener( lSymItem ); 
    511         grid.addItemListener( lSymItem ); 
    512 //        SymAction lSymAction = new SymAction(); 
    513 //        showTree.addActionListener( lSymAction ); 
    514  
    515         return controlPanel; 
    516     } 
    517  
    518     /** 
    519      * Change the Pane layout to StackedLayout. 
    520      * 
    521      * @param event 
    522      */ 
    523  
    524     void stacked_itemStateChanged( java.awt.event.ItemEvent event ) 
    525     { 
    526         /* 
    527         * Get the component list for mainPane_ and change 
    528         * the layout to StackedLayout. 
    529         */ 
    530 //        Component[] comps = mainPane_.getComponents(); 
    531 //        mainPane_.setBatch( true ); 
    532 //        mainPane_.setLayout( new StackedLayout() ); 
    533 //        /* 
    534 //        * Remove any axes that have been associated with 
    535 //        * the second graph.  With the layers overlayed it 
    536 //        * is not necessary to have duplicate axes. 
    537 //        */ 
    538 //        Graph gr2 = ( (Layer) comps[1] ).getGraph(); 
    539 //        ( (CartesianGraph) gr2 ).removeAllXAxes(); 
    540 //        ( (CartesianGraph) gr2 ).removeAllYAxes(); 
    541 //        /* 
    542 //        * Tell the Applet that the mainPane_ needs to 
    543 //        * be layed out and re-draw the mainPane_. 
    544 //        */ 
    545 //        if( isApplet_ ) 
    546 //        { 
    547 //            validate(); 
    548 //        } 
    549 //        else 
    550 //        { 
    551 //            frame.validate(); 
    552 //        } 
    553 //        mainPane_.setBatch( false ); 
    554 //        if( tree_ != null ) 
    555 //        { 
    556 //            if( tree_.isVisible() ) 
    557 //            { 
    558 //                tree_.setJPane( mainPane_ ); 
    559 //                tree_.expandTree(); 
    560 //            } 
    561 //        } 
    562     } 
    563  
    564     /** 
    565      * Change the Pane layout to GridLayout. 
    566      * 
    567      * @param event 
    568      */ 
    569  
    570     void grid_itemStateChanged( java.awt.event.ItemEvent event ) 
    571     { 
    572         /* 
    573         * Get the component list for mainPane_ and change 
    574         * the layout to GridLayout. 
    575         */ 
    576 //        Component[] comps = mainPane_.getComponents(); 
    577 //        mainPane_.setBatch( true ); 
    578 //        mainPane_.setLayout( new GridLayout( 2, 0 ) ); 
    579 //        /* 
    580 //        * Get the first and second graphs from the first 
    581 //        * and second layers, respectively. 
    582 //        */ 
    583 //        Graph gr = ( (Layer) comps[0] ).getGraph(); 
    584 //        Graph gr2 = ( (Layer) comps[1] ).getGraph(); 
    585 //        /* 
    586 //        * Create copies of all X-Axes associated with the first 
    587 //        * graph for the second graph. If the axes are not copied then 
    588 //        * the second graph will have the second line plotted, but without 
    589 //        * any axes. 
    590 //        */ 
    591 //        for( Enumeration xa = ( (CartesianGraph) gr ).xAxisElements(); xa.hasMoreElements(); ) 
    592 //        { 
    593 //            ( (CartesianGraph) gr2 ).addXAxis( ( (Axis) xa.nextElement() ).copy() ); 
    594 //        } 
    595 //        /* 
    596 //        * Create copies of all Y-Axes associated with the first 
    597 //        * graph for the second graph. 
    598 //        */ 
    599 //        for( Enumeration ya = ( (CartesianGraph) gr ).yAxisElements(); ya.hasMoreElements(); ) 
    600 //        { 
    601 //            ( (CartesianGraph) gr2 ).addYAxis( ( (Axis) ya.nextElement() ).copy() ); 
    602 //        } 
    603 //        /* 
    604 //        * Tell the Applet that the mainPane_ needs to 
    605 //        * be layed out and re-draw the mainPane_. 
    606 //        */ 
    607 //        if( isApplet_ ) 
    608 //        { 
    609 //            validate(); 
    610 //        } 
    611 //        else 
    612 //        { 
    613 //            frame.validate(); 
    614 //        } 
    615 //        //    mainPane_.draw(); 
    616 //        mainPane_.setBatch( false ); 
    617 //        if( tree_ != null ) 
    618 //        { 
    619 //            if( tree_.isVisible() ) 
    620 //            { 
    621 //                tree_.setJPane( mainPane_ ); 
    622 //                tree_.expandTree(); 
    623 //            } 
    624 //        } 
    625     } 
    626  
    627     void showTree_ActionPerformed( java.awt.event.ActionEvent event ) 
    628     { 
    629 //        /* 
    630 //        * Create the ClassTree dialog to display the classes used 
    631 //        * in the mainPane_ and allow editing. 
    632 //        */ 
    633 //        if( tree_ == null ) 
    634 //        { 
    635 //            tree_ = new JClassTree( "Classes for LayoutDemo" ); 
    636 //        } 
    637 //        tree_.setJPane( mainPane_ ); 
    638 //        tree_.show(); 
    639     } 
    640  
    641 //    @NotNull 
    642 //    private JPlotLayout createJPlotLayoutFor2DOrig( final MegapoliPlot megapoliPlot, final Integer plotWidth, final Integer plotHeight, @Nullable final Locale locale ) 
    643 //    { 
    644 //        final ResourceBundle bundle = WebHelper.getBundle( locale ); 
    645 // 
    646 //        final double[] parameterArray = (double[]) megapoliPlot.getData().getFirstArray(); 
    647 //        final double[] latitudeArray = (double[]) megapoliPlot.getData().getSecondArray(); 
    648 //        final double[] longitudeValues = (double[]) megapoliPlot.getData().getThirdArray(); 
    649 // 
    650 ////        final SimpleLine data = new SimpleLine( longitudeValues, latitudeArray, "legend" ); 
    651 //        final SimpleGrid data = new SimpleGrid( parameterArray, longitudeValues, latitudeArray, "Test Series" ); 
    652 //        SGTMetaData meta = new SGTMetaData( bundle.getString( "plot.longitude" ), bundle.getString( "plot.degres" ), false, true ); 
    653 //        // TODO : vérifier modulo = 360 
    654 ////        meta.setModuloValue( 360 ); 
    655 //        data.setXMetaData( meta ); 
    656 // 
    657 //        meta = new SGTMetaData( bundle.getString( "plot.latitude" ), bundle.getString( "plot.degres" ), false, true ); 
    658 //        // TODO : vérifier modulo = 360 
    659 ////        meta.setModuloValue( 360 ); 
    660 //        data.setYMetaData( meta ); 
    661 // 
    662 //        // Graph 
    663 //        final JPlotLayout jPlotLayout = new JPlotLayout( true, false, false, "JGridDemo Pane", null, true ); 
    664 //        jPlotLayout.setEditClasses( false ); 
    665 //        /* 
    666 //       * Create a GridAttribute for CONTOUR style. 
    667 //        */ 
    668 //        final Range2D datar = new Range2D( -20.0f, 45.0f, 5.0f ); 
    669 //        final ContourLevels clevels = ContourLevels.getDefault( datar ); 
    670 //        final GridAttribute gridAttr = new GridAttribute( clevels ); 
    671 //        /* 
    672 //       * Create a ColorMap and change the style to RASTER_CONTOUR. 
    673 //        */ 
    674 //        final ColorMap cmap = createColorMap( datar ); 
    675 //        gridAttr.setColorMap( cmap ); 
    676 //        gridAttr.setStyle( GridAttribute.RASTER_CONTOUR ); 
    677 //        /* 
    678 //       * Add the grid to the layout and give a label for 
    679 //       * the ColorKey. 
    680 //        */ 
    681 //        jPlotLayout.addData( data, gridAttr, "First Data" ); 
    682 // 
    683 ////        final JPlotLayoutEther jPlotLayout = new JPlotLayoutEther( false, megapoliPlot.isXTime(), false, "Trajectory data", null, megapoliPlot.isLegendToHide() ); 
    684 ////        jPlotLayout.setTitles( "", "", "" ); 
    685 // 
    686 //        // Replace legend 
    687 ////        final String legend = megapoliPlot.getData().getTitle(); 
    688 ////        final Dimension2D layerSizeP = jPlotLayout.getLayerSizeP(); 
    689 ////        final double factorForPlotWidthInPhysicalUnits = layerSizeP.getWidth() / Double.valueOf( plotWidth ); 
    690 ////        final double legendSizeInPhysicalUnits = legend.length() * factorForPlotWidthInPhysicalUnits * 7; 
    691 ////        jPlotLayout.setKeyLocationP( new Point2D.Double( layerSizeP.getWidth() - legendSizeInPhysicalUnits, layerSizeP.getHeight() - 0.1 ) ); 
    692 // 
    693 //        // Add data and legend 
    694 ////        jPlotLayout.addData( megapoliPlot.getData(), legend ); 
    695 //        jPlotLayout.setSize( plotWidth, plotHeight ); 
    696 //        jPlotLayout.setVisible( true ); 
    697 // 
    698 //        jPlotLayout.addNotify(); 
    699 //        jPlotLayout.validate(); 
    700 //        jPlotLayout.setOpaque( true ); 
    701 //        return jPlotLayout; 
    702 //    } 
    703  
    704     @NotNull 
    705     protected String formatTitle( @Nullable final String title ) 
    706     { 
    707         if( null == title ) 
    708             return ""; 
    709         else 
    710         { 
    711             final String formatTitle = title.replaceAll( "\\n", "<br>" ); 
    712             return "<html>" + formatTitle + "</html>"; 
    713         } 
    714     } 
    715  
    716     @NotNull 
    717     private ColorMap createColorMap( final Range2D datar ) 
    718     { 
    719         final int[] red = 
    720                 {0, 0, 0, 0, 0, 0, 0, 0, 
    721                         0, 0, 0, 0, 0, 0, 0, 0, 
    722                         0, 0, 0, 0, 0, 0, 0, 0, 
    723                         0, 7, 23, 39, 55, 71, 87, 103, 
    724                         119, 135, 151, 167, 183, 199, 215, 231, 
    725                         247, 255, 255, 255, 255, 255, 255, 255, 
    726                         255, 255, 255, 255, 255, 255, 255, 255, 
    727                         255, 246, 228, 211, 193, 175, 158, 140}; 
    728         final int[] green = 
    729                 {0, 0, 0, 0, 0, 0, 0, 0, 
    730                         0, 11, 27, 43, 59, 75, 91, 107, 
    731                         123, 139, 155, 171, 187, 203, 219, 235, 
    732                         251, 255, 255, 255, 255, 255, 255, 255, 
    733                         255, 255, 255, 255, 255, 255, 255, 255, 
    734                         255, 247, 231, 215, 199, 183, 167, 151, 
    735                         135, 119, 103, 87, 71, 55, 39, 23, 
    736                         7, 0, 0, 0, 0, 0, 0, 0}; 
    737         final int[] blue = 
    738                 {0, 143, 159, 175, 191, 207, 223, 239, 
    739                         255, 255, 255, 255, 255, 255, 255, 255, 
    740                         255, 255, 255, 255, 255, 255, 255, 255, 
    741                         255, 247, 231, 215, 199, 183, 167, 151, 
    742                         135, 119, 103, 87, 71, 55, 39, 23, 
    743                         7, 0, 0, 0, 0, 0, 0, 0, 
    744                         0, 0, 0, 0, 0, 0, 0, 0, 
    745                         0, 0, 0, 0, 0, 0, 0, 0}; 
    746  
    747         final IndexedColorMap cmap = new IndexedColorMap( red, green, blue ); 
    748         cmap.setTransform( new LinearTransform( 0.0, (double) red.length, datar.start, datar.end ) ); 
    749         return cmap; 
    750     } 
    751  
    752     public SGTData testDataa( Range2D range1, Range2D range2, int type, float amp, float off, float per, final double[] parameterArray, final double[] latitudeArray, final double[] longitudeValues ) 
    753     { 
    754         SimpleGrid sg; 
    755         SGTMetaData xMeta; 
    756         SGTMetaData yMeta; 
    757         SGTMetaData zMeta; 
    758  
    759         double[] axis1, axis2; 
    760         double[] values; 
    761         double[] zero; 
    762         GeoDate tzero[] = new GeoDate[1]; 
    763         int count; 
    764  
    765         zero = new double[1]; 
    766         tzero[0] = new GeoDate(); 
    767         zero[0] = 0; 
    768         tzero[0].now(); 
    769         int num1 = (int) ( ( range1.end - range1.start ) / range1.delta ) + 1; 
    770         axis1 = new double[num1]; 
    771         int num2 = (int) ( ( range2.end - range2.start ) / range2.delta ) + 1; 
    772         axis2 = new double[num2]; 
    773  
    774         for( count = 0; count < num1; count++ ) 
    775         { 
    776             axis1[count] = range1.start + count * range1.delta; 
    777         } 
    778         for( count = 0; count < num2; count++ ) 
    779         { 
    780             axis2[count] = range2.start + count * range2.delta; 
    781         } 
    782  
    783         values = getValues( axis1, num1, axis2, num2, type, amp, off, per ); 
    784  
    785         SGLabel keyLabel = new SGLabel( "Key Label", "", new Point2D.Double( 0.0, 0.0 ) ); 
    786         keyLabel.setHeightP( 0.16 ); 
    787         // 
    788         // create SimpleGrid 
    789         // 
    790         zMeta = new SGTMetaData( "ts", "m s-1" ); 
    791         keyLabel.setText( "XY test grid" ); 
    792         xMeta = new SGTMetaData( "lon", "degE" ); 
    793         yMeta = new SGTMetaData( "lat", "deg" ); 
    794 //        sg = new SimpleGrid( values, axis1, axis2, "Test Series" ); 
    795         sg = new SimpleGrid( values, axis1, latitudeArray, "Test Series" ); 
    796  
    797         sg.setXMetaData( xMeta ); 
    798         sg.setYMetaData( yMeta ); 
    799         sg.setZMetaData( zMeta ); 
    800         sg.setKeyTitle( keyLabel ); 
    801         return sg; 
    802     } 
    803  
    804     private double[] getValues( double[] axis1, int num1, double[] axis2, int num2, 
    805                                 int type, float amp, float off, float per ) 
    806     { 
    807         double[] values; 
    808         int count1, count2, count; 
    809         values = new double[num1 * num2]; 
    810         switch( type ) 
    811         { 
    812             default: 
    813             case TestData.RANDOM: 
    814                 for( count = 0; count < num1 * num2; count++ ) 
    815                 { 
    816                     values[count] = amp * Math.random() + off; 
    817                 } 
    818                 break; 
    819             case TestData.SINE: 
    820                 count = 0; 
    821                 for( count1 = 0; count1 < num1; count1++ ) 
    822                 { 
    823                     for( count2 = 0; count2 < num2; count2++ ) 
    824                     { 
    825                         values[count] = amp * Math.sin( axis1[count1] / per ) * 
    826                                 Math.sin( axis2[count2] / per ) + off; 
    827                         count++; 
    828                     } 
    829                 } 
    830                 break; 
    831             case TestData.SINE_RAMP: 
    832                 count = 0; 
    833                 double ax1factr = 0.08 * Math.abs( axis1[0] - axis1[num1 - 1] ) / 
    834                         Math.max( Math.abs( axis1[0] ), Math.abs( axis1[num1 - 1] ) ); 
    835                 double ax2factr = 0.08 * Math.abs( axis2[0] - axis2[num2 - 1] ) / 
    836                         Math.max( Math.abs( axis2[0] ), Math.abs( axis2[num2 - 1] ) ); 
    837                 for( count1 = 0; count1 < num1; count1++ ) 
    838                 { 
    839                     for( count2 = 0; count2 < num2; count2++ ) 
    840                     { 
    841                         values[count] = amp * Math.sin( axis1[count1] / per ) * 
    842                                 Math.sin( axis2[count2] / per ) + off + 
    843                                 amp * ( ax1factr * count1 - ax2factr * count2 ); 
    844                         count++; 
    845                     } 
    846                 } 
    847  
    848         } 
    849         return values; 
     393 
     394    public EtherService getEtherService() 
     395    { 
     396        return _etherService; 
    850397    } 
    851398 
     
    854401    { 
    855402        _etherService = etherService; 
    856     } 
    857  
    858     public EtherService getEtherService() 
    859     { 
    860         return _etherService; 
    861403    } 
    862404 
  • ether_megapoli/trunk/service/interface/com/ether/EtherPlotService.java

    r184 r189  
    4242    @NotNull 
    4343    public JPane create2DPlot( @NotNull final MegapoliPlot megapoliPlot, @NotNull final Integer plotWidth, @NotNull final Integer plotHeight, @Nullable final Locale locale ); 
    44  
    45     @NotNull 
    46     public JPanel createControlPanel(); 
    4744} 
Note: See TracChangeset for help on using the changeset viewer.