home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 March / CMCD0305.ISO / Software / Shareware / Grafica / 3dpie / Documentation / ServerTemplateScripts / PieConfigServlet.java < prev    next >
Text File  |  2004-07-05  |  6KB  |  121 lines

  1. import java.sql.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import javax.servlet.*;
  5. import javax.servlet.http.*;
  6.  
  7. public class PieConfigServlet extends HttpServlet {
  8. //
  9. // This simple servlet is designed to demonstrate how a servlet can be used
  10. // to return configuration information to either the graphing applet or servlet.
  11. // As you will see the main routine ( doGet() ) uses the method
  12. // GraphData() to construct the return data.
  13. // Although in this example the GraphData() rountine simply builds the return
  14. // data from 'hard coded' values, in practice this rountine would be expanded
  15. // to first gather data from any number of datasources.
  16. // eg. databases, files other server processes.
  17. //
  18. // For further information visit,
  19. // http://www.jpowered.com/pie_chart/
  20. //
  21. //-----------------------------------------------------------------------------
  22.  
  23.     public void doGet(HttpServletRequest req, HttpServletResponse res)
  24.            throws ServletException, IOException {
  25.  
  26.         res.setContentType("text/html");
  27.         ServletOutputStream out = res.getOutputStream();
  28.  
  29.         // Return the Data
  30.         out.println(ConfigData());
  31.  
  32.                            } // End doGet
  33. //-----------------------------------------------------------------------------
  34.     public void doPost(HttpServletRequest request,HttpServletResponse response)
  35.                 throws ServletException, IOException {doGet(request, response);}
  36. //-----------------------------------------------------------------------------
  37.  
  38.     public static String ConfigData() {
  39.  
  40.         String rsltStr =
  41.          "<!-- Chart Switches -->         \n"+
  42.          "3D:                  true       \n"+
  43.          "Slabels:             true       \n"+
  44.          "legend:              true       \n"+
  45.          "displayPercentages:  true       \n"+
  46.          "<!-- Chart Characteristics -->  \n"+
  47.          "width:       550                \n"+
  48.          "height:      450                \n"+
  49.          "nPies:       3                  \n"+
  50.          "depth3D:     15                 \n"+
  51.          "ndecplaces:  0                  \n"+
  52.          "3Dangle:     50                 \n"+
  53.          "<!-- Link Cursor -->                                                       \n"+
  54.          "<!--  valid values are - crosshair, default, hand, move, text or wait -->  \n"+
  55.          "linkCursor:       hand                                                     \n"+
  56.          "<!-- Popup segment Value Pre & Post Symbols\n"+
  57.          "valuepresym:   $ \n"+
  58.          "valuepostsym:    \n"+
  59.          "<!-- thousand seperater -->\n"+
  60.          "thousandseparator: ,       \n"+
  61.          "<!-- Additional font information -->     \n"+
  62.          "popupfont:       Arial,B,12              \n"+
  63.          "slabelfont:      Arial,N,10              \n"+
  64.          "<!-- Additional color information -->    \n"+
  65.          "bgcolor:       white                     \n"+
  66.          "labelcolor:    50,50,50                  \n"+
  67.          "popupbgcolor:  175,175,200               \n"+
  68.          "<!-- Legend Information -->         \n"+
  69.          "legendfont:        Arial,N,10       \n"+
  70.          "legendposition:    400,250          \n"+
  71.          "legendtitle:       Sales Regions    \n"+
  72.          "LegendBackground:  255,255,255      \n"+
  73.          "LegendBorder:      125,125,125      \n"+
  74.          "LegendtextColor:   0,0,0            \n"+
  75.          "<!-- Title -->                                            \n"+
  76.          "<!-- title   text|xpos,ypos|Font|Color Defintion -->      \n"+
  77.          "title:       Sales by Region|200,15|Arial,BI,16|grey      \n"+
  78.          "<!-- Free Form Text -->                                   \n"+
  79.          "<!--  textN  text|xpos,ypos|Font|Color Defintion -->      \n"+
  80.          "text1:       Product X|100,45|Arial,B,12|50,50,150        \n"+
  81.          "text2:       Product Y|350,100|Arial,B,12|50,150,50       \n"+
  82.          "text3:       Product Z|140,275|Arial,B,12|200,50,50       \n"+
  83.          "<!-- Pie Data -->                                         \n"+
  84.          "<!--  PieN   x,y,size,number of segments, seperation -->  \n"+
  85.          "Pie1:       80,55,115,6,0                                 \n"+
  86.          "Pie2:       310,125,140,6,10                              \n"+
  87.          "Pie3:       80,300,175,6,10                               \n"+
  88.          "<!-- Pie Segement Labels -->    \n"+
  89.          "pie1label1:       N.America     \n"+
  90.          "pie1label2:       Europe        \n"+
  91.          "pie1label3:       Asia          \n"+
  92.          "pie1label4:       Africa        \n"+
  93.          "pie1label5:       Australia     \n"+
  94.          "pie1label6:       S.America     \n"+
  95.          "pie2label1:       N.America     \n"+
  96.          "pie2label2:       Europe        \n"+
  97.          "pie2label3:       Asia          \n"+
  98.          "pie2label4:       Africa        \n"+
  99.          "pie2label5:       Australia     \n"+
  100.          "pie2label6:       S.America     \n"+
  101.          "pie3label1:       N.America     \n"+
  102.          "pie3label2:       Europe        \n"+
  103.          "pie3label3:       Asia          \n"+
  104.          "pie3label4:       Africa        \n"+
  105.          "pie3label5:       Australia     \n"+
  106.          "pie3label6:       S.America     \n"+
  107.          "<!-- Segment Data -->                                                       \n"+
  108.          "<!-- segmentN       series color|legend label|URL|Target -->                \n"+
  109.          "segment1:       115,152,164|North America|http://www.jpowered.com|_self     \n"+
  110.          "segment2:       99,99,156|Europe|http://www.jpowered.com|_self              \n"+
  111.          "segment3:       185,53,8|Asia|http://www.jpowered.com|_self                 \n"+
  112.          "segment4:       239,214,115|Africa|http://www.jpowered.com|_self            \n"+
  113.          "segment5:       0,63,68|Australia|http://www.jpowered.com|_self             \n"+
  114.          "segment6:       17,97,158|South America|http://www.jpowered.com|_self       \n";
  115.  
  116.  
  117.  
  118.          return(rsltStr);
  119.     }
  120. //-----------------------------------------------------------------------------
  121. } // End class