Changeset 196


Ignore:
Timestamp:
09/14/11 16:58:17 (13 years ago)
Author:
vmipsl
Message:

Servlet _ 2D ok

Location:
ether_megapoli/trunk/service
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ether_megapoli/trunk/service/implementation/com/ether/EtherPlotContentServiceImpl.java

    r195 r196  
    227227        try 
    228228        { 
    229             jPlotLayout.setKeyLayerSizeP( new Dimension2D( 6.0, 1.02 ) ); 
    230             jPlotLayout.setKeyBoundsP( new Rectangle2D.Double( 0.01, 1.01, 5.98, 1.0 ) ); 
     229//            jPlotLayout.setKeyLayerSizeP( new Dimension2D( 12.0, 24.0 ) ); 
     230//            jPlotLayout.setKeyBoundsP( new Rectangle2D.Double( 0.01, 1.01, 5.98, 1.0 ) ); 
    231231            final Layer keyLayer = jPlotLayout.getKeyPane().getLayer( "Key Layer" ); 
    232232            jPlotLayout.add( keyLayer ); 
    233  
    234233        } 
    235234        catch( LayerNotFoundException e ) 
    236235        { 
    237             e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates. 
     236            throw new ServiceException( ServiceException.ServiceCode.LEGEND_LAYER_NOT_FOUND, new Throwable( ServiceException.ServiceCode.LEGEND_LAYER_NOT_FOUND.toString() ) ); 
    238237        } 
    239238 
  • ether_megapoli/trunk/service/implementation/com/ether/EtherPlotServiceImpl.java

    r195 r196  
    8787            else 
    8888            { 
    89                 if( megapoliPlot.isTimeSerie() ) 
    90                 { 
    91                     final JLabel jLabelPlot = transformJPaneToJLabel( jPaneCenter, true ); 
    92  
    93                     final JPane jPaneCenterToImage = new JPane( "Center jPane", new Dimension( jLabelPlot.getWidth(), jLabelPlot.getHeight() ) ); 
    94                     jPaneCenterToImage.setLayout( new GridBagLayout() ); 
    95                     jPaneCenterToImage.add( jLabelPlot, 
    96                             new GridBagConstraints( 0, 0, 1, 1, 0, 0, 
    97                                     GridBagConstraints.CENTER, 
    98                                     GridBagConstraints.CENTER, 
    99                                     new Insets( 0, 0, 0, 0 ), 0, 0 ) ); 
    100  
    101                     jPane.add( jPaneCenterToImage, BorderLayout.CENTER ); 
    102                 } 
    103                 else 
    104                 { 
    105                     final JLabel jLabelPlot2D = transformJPaneToJLabel( jPaneCenter, true ); 
    106 //                    final JPane keyPane = ( (JPlotLayout) jPaneCenter ).getKeyPane(); 
    107 //                    final JLabel jLabelPlotLegend = transformJPaneToJLabel( keyPane, false ); 
    108 //                    final JPane jPane2D = new JPane( "2D jPane", new Dimension( jPaneCenter.getWidth(), jPaneCenter.getHeight() + keyPane.getHeight() ) ); 
    109 //                    jPane2D.setLayout( new BorderLayout() ); 
    110 //                    jPane2D.setBackground( Color.white ); 
    111 //                    jPane2D.add( jLabelPlot2D, BorderLayout.SOUTH ); 
    112 //                    jPane2D.add( jLabelPlotLegend, BorderLayout.NORTH ); 
    113 //                    jPane2D.setVisible( true ); 
    114 //                    jPane2D.setOpaque( true ); 
    115 //                    jPane2D.validate(); 
    116  
    117 //                    final JPanelToImageManager jPanelToImageManager = new JPanelToImageManager( jPane2D ); 
    118 //                    final BufferedImage bufferedImage = jPanelToImageManager.saveAsImage(); 
    119 // 
    120 //                    final ImageIcon imageIcon = new ImageIcon( bufferedImage ); 
    121 //                    final JLabel jLabelPlot = new JLabel( imageIcon, JLabel.CENTER ); 
    122 //                    jLabelPlot.setBorder( BorderFactory.createLineBorder( Color.black, 1 ) ); 
    123 // 
    124                     final JPane jPaneCenterToImage = new JPane( "Center jPane", new Dimension( jLabelPlot2D.getWidth(), jLabelPlot2D.getHeight() ) ); 
    125                     jPaneCenterToImage.setLayout( new GridBagLayout() ); 
    126                     jPaneCenterToImage.add( jLabelPlot2D, 
    127                             new GridBagConstraints( 0, 0, 1, 1, 0, 0, 
    128                                     GridBagConstraints.CENTER, 
    129                                     GridBagConstraints.CENTER, 
    130                                     new Insets( 0, 0, 0, 0 ), 0, 0 ) ); 
    131  
    132                     jPane.add( jPaneCenterToImage, BorderLayout.CENTER ); 
    133                 } 
     89                final JLabel jLabelPlot = transformJPaneToJLabel( jPaneCenter ); 
     90 
     91                final JPane jPaneCenterToImage = new JPane(); 
     92                jPaneCenterToImage.setLayout( new GridBagLayout() ); 
     93                jPaneCenterToImage.add( jLabelPlot, 
     94                        new GridBagConstraints( 0, 0, 1, 1, 0, 0, 
     95                                GridBagConstraints.CENTER, 
     96                                GridBagConstraints.CENTER, 
     97                                new Insets( 0, 0, 0, 0 ), 0, 0 ) ); 
     98 
     99                jPane.add( jPaneCenterToImage, BorderLayout.CENTER ); 
    134100            } 
    135101        } 
     
    144110    } 
    145111 
    146     private JLabel transformJPaneToJLabel( final JPane jPane, final boolean needeBorder ) 
    147     { 
    148         final BufferedImage jPaneBufferedImage = new BufferedImage( jPane.getWidth(), jPane.getHeight(), BufferedImage.TYPE_INT_ARGB ); 
    149         final Graphics2D graphics2D = jPaneBufferedImage.createGraphics(); 
    150         jPane.addNotify(); 
    151         jPane.validate(); 
    152         jPane.draw( graphics2D ); 
    153  
    154         final ImageIcon imageIcon = new ImageIcon( jPaneBufferedImage ); 
    155         final JLabel jLabelPlot = new JLabel( imageIcon, JLabel.CENTER ); 
    156         if( needeBorder ) 
    157             jLabelPlot.setBorder( BorderFactory.createLineBorder( Color.black, 1 ) ); 
    158         return jLabelPlot; 
    159     } 
    160  
    161112    /** 
    162113     * Create the top JPane with the logos and title 
     
    314265    } 
    315266 
     267    /** 
     268     * This method transform a jPane to a jLabel with a BufferedImage inside and a black border 
     269     * 
     270     * @param jPane 
     271     * @return 
     272     */ 
     273    @NotNull 
     274    private JLabel transformJPaneToJLabel( @NotNull final JPane jPane ) 
     275    { 
     276        final BufferedImage jPaneBufferedImage = new BufferedImage( jPane.getWidth(), jPane.getHeight(), BufferedImage.TYPE_INT_ARGB ); 
     277        final Graphics2D graphics2D = jPaneBufferedImage.createGraphics(); 
     278        jPane.addNotify(); 
     279        jPane.validate(); 
     280        jPane.draw( graphics2D ); 
     281 
     282        final ImageIcon imageIcon = new ImageIcon( jPaneBufferedImage ); 
     283        final JLabel jLabelPlot = new JLabel( imageIcon, JLabel.CENTER ); 
     284        jLabelPlot.setBorder( BorderFactory.createLineBorder( Color.black, 1 ) ); 
     285        return jLabelPlot; 
     286    } 
     287 
    316288    @NotNull 
    317289    private String formatTitle( @Nullable final String title ) 
  • ether_megapoli/trunk/service/interface/com/ether/ServiceException.java

    r185 r196  
    2828        PARAMETER_IS_NULL, 
    2929        VALUE_NOT_FOUND, 
    30         PANEL_MODEL_NOT_FOUND; 
     30        PANEL_MODEL_NOT_FOUND, 
     31        LEGEND_LAYER_NOT_FOUND; 
    3132    } 
    3233} 
Note: See TracChangeset for help on using the changeset viewer.