001    /*
002     * This file is part of the Echo Point Project.  This project is a
003     * collection of Components that have extended the Echo Web Application
004     * Framework Version 3.
005     *
006     * Version: MPL 1.1
007     *
008     * The contents of this file are subject to the Mozilla Public License Version
009     * 1.1 (the "License"); you may not use this file except in compliance with
010     * the License. You may obtain a copy of the License at
011     * http://www.mozilla.org/MPL/
012     *
013     * Software distributed under the License is distributed on an "AS IS" basis,
014     * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015     * for the specific language governing rights and limitations under the
016     * License.
017     */
018    
019    package echopoint.google.chart;
020    
021    import echopoint.google.chart.internal.AdvancedChartPeer;
022    import nextapp.echo.app.Component;
023    import nextapp.echo.app.util.Context;
024    import nextapp.echo.webcontainer.ServerMessage;
025    import nextapp.echo.webcontainer.Service;
026    import nextapp.echo.webcontainer.WebContainerServlet;
027    import nextapp.echo.webcontainer.service.JavaScriptService;
028    
029    /**
030     * Rendering peer for the {@link echopoint.google.chart.ScatterPlot} component.
031     *
032     * @author Rakesh 2008-08-23
033     * @version $Id: ScatterPlotPeer.java 86 2008-11-09 14:44:29Z sptrakesh $
034     */
035    public class ScatterPlotPeer extends AdvancedChartPeer
036    {
037      /** The component name for which this class is a peer. */
038      private static final String COMPONENT_NAME = ScatterPlot.class.getName();
039    
040      /** The service for the client side peer for this component. */
041      private static final Service COMPONENT_SERVICE =
042          JavaScriptService.forResource( ScatterPlotPeer.COMPONENT_NAME,
043              "resource/js/google/chart/Sync.ScatterPlot.js" );
044    
045      /** Register the services */
046      static
047      {
048        WebContainerServlet.getServiceRegistry().add( COMPONENT_SERVICE );
049      }
050    
051      /**
052       * {@inheritDoc}
053       */
054      @Override
055      public void init( final Context context, final Component component )
056      {
057        super.init( context, component );
058        final ServerMessage serverMessage =
059            (ServerMessage) context.get( ServerMessage.class );
060        serverMessage.addLibrary( COMPONENT_NAME );
061      }
062    
063      /**
064       * {@inheritDoc}
065       */
066      @Override
067      public Class getComponentClass()
068      {
069        return ScatterPlot.class;
070      }
071    
072      /**
073       * {@inheritDoc}
074       */
075      @Override
076      public String getClientComponentType( final boolean shortType )
077      {
078        return COMPONENT_NAME;
079      }
080    }