jakarta-ecs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sn...@apache.org
Subject cvs commit: jakarta-ecs/build build-ecs.xml
Date Thu, 27 Sep 2001 15:55:42 GMT
snagy       01/09/27 08:55:42

  Modified:    build    build-ecs.xml
  Added:       src/java/org/apache/ecs/examples WebColors.java
  Log:
  Add an example for using ecs, edited build-ecs.xml so that the example isn't compiled
  by default since we don't distribute the servlet.jar.
  Submitted by:	horombo@gmx.de
  Reviewed by:	snagy@apache.org
  
  Revision  Changes    Path
  1.1                  jakarta-ecs/src/java/org/apache/ecs/examples/WebColors.java
  
  Index: WebColors.java
  ===================================================================
  package org.apache.ecs.examples;
  
  import java.io.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import org.apache.ecs.html.*;
  
  /**
   * This simple servlet displays the 216 safe web colors that can be
   * rendered by any browser on any platform.
   *
   * @author <a href="mailto:horombo@gmx.de">Christian Brensing</a>
   * @version 1.0, 04.07.2001
   */
  public class WebColors extends HttpServlet {
  
    /** Valid rgb components */
    private String[] hex = { "00","33","66","99","CC","FF" };
  
    /**
     * Processes a GET request.
     */
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
  
      // Set response type to html
      response.setContentType("text/html");
  
      // Get PrintWriter
      PrintWriter out = response.getWriter();
  
      // New <html>
      Html html = new Html();
  
      // New <head>
      Head head = new Head();
      Title title = new Title("The 216 safe web colors");
      head.addElement(title);
  
      // Add <head> to <html>
      html.addElement(head);
  
      // New <body>
      Body body = new Body();
      body.setStyle("background: none white;");
  
      // New <table>
      Table table = new Table();
      table.setCellSpacing(0).setAlign("center");
      table.setStyle("border: none; width: 600px; "
      .concat("font: normal 10pt Times,serif;"));
  
      // Modulate green
      for (int g = 0; g < hex.length; g++) {
  
        // Get current green component
        String green = hex[g];
  
        // Modulate red
        for (int r = 0; r < hex.length; r++) {
  
          // Get current red component
          String red = hex[r];
  
          // New <tr>
          TR tr = new TR();
          tr.setStyle("color: white;");
  
          // Change fontcolor if cell background is to bright
          if (g > 3) { tr.setStyle("color: black;"); }
  
          // Modulate blue
          for (int b = 0; b < hex.length; b++) {
  
            // Get current blue component
            String blue = hex[b];
  
            // Generate new rgb with modulated green, red and blue
            StringBuffer rgb = new StringBuffer("#");
            rgb.append(red).append(green).append(blue);
  
            // New <td> for each color
            TD td = new TD(rgb.toString()).setAlign("center");
  
            // Generate background style for each color
            StringBuffer bg = new StringBuffer("background: ");
            bg.append("none ").append(rgb.toString()).append(";");
  
            // Set background for this <td>-tag
            td.setStyle(bg.toString());
  
            // Add <td> to <tr>
            tr.addElement(td);
  
          } // next b
  
          // Add this <tr> to <table>
          table.addElement(tr);
  
        } // next r
  
      } // next g
  
      // Add <table> to <body>
      body.addElement(table);
  
      // Add <body> to <html>
      html.addElement(body);
  
      // Return <html>
      out.println(html.toString());
  
    } // doGet
  
  } // WebColors
  
  
  1.20      +1 -0      jakarta-ecs/build/build-ecs.xml
  
  Index: build-ecs.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ecs/build/build-ecs.xml,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- build-ecs.xml	2001/07/25 23:06:58	1.19
  +++ build-ecs.xml	2001/09/27 15:55:42	1.20
  @@ -63,6 +63,7 @@
   
           <copy todir="${build.src}/org" filtering="yes">
               <fileset dir="${src.java.dir}/org">
  +				<exclude name="**/WebColors.java"/>
                   <include name="**/*.java"/>
                   <include name="**/*.properties"/>
                   <include name="**/package.html"/>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ecs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ecs-dev-help@jakarta.apache.org


Mime
View raw message