Return-Path: Delivered-To: apmail-jakarta-ecs-dev-archive@apache.org Received: (qmail 91073 invoked from network); 10 Jan 2002 22:34:34 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 10 Jan 2002 22:34:34 -0000 Received: (qmail 17414 invoked by uid 97); 10 Jan 2002 22:34:40 -0000 Delivered-To: qmlist-jakarta-archive-ecs-dev@jakarta.apache.org Received: (qmail 17398 invoked by uid 97); 10 Jan 2002 22:34:39 -0000 Mailing-List: contact ecs-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "ECS Developers List" Reply-To: "ECS Developers List" Delivered-To: mailing list ecs-dev@jakarta.apache.org Received: (qmail 17387 invoked by uid 97); 10 Jan 2002 22:34:39 -0000 Date: 10 Jan 2002 22:34:31 -0000 Message-ID: <20020110223431.30493.qmail@icarus.apache.org> From: rdonkin@apache.org To: jakarta-ecs-cvs@apache.org Subject: cvs commit: jakarta-ecs/src/java/org/apache/ecs/examples WebColors.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N rdonkin 02/01/10 14:34:31 Modified: src/java/org/apache/ecs/examples WebColors.java Log: Christian Brensing submitted an improved version of his ecs example Revision Changes Path 1.3 +102 -110 jakarta-ecs/src/java/org/apache/ecs/examples/WebColors.java Index: WebColors.java =================================================================== RCS file: /home/cvs/jakarta-ecs/src/java/org/apache/ecs/examples/WebColors.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- WebColors.java 6 Nov 2001 23:06:44 -0000 1.2 +++ WebColors.java 10 Jan 2002 22:34:31 -0000 1.3 @@ -15,23 +15,23 @@ * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: - * "This product includes software developed by the Java Apache + * "This product includes software developed by the Java Apache * Project. " * - * 4. The names "Java Apache Element Construction Set", "Java Apache ECS" and - * "Java Apache Project" must not be used to endorse or promote products + * 4. The names "Java Apache Element Construction Set", "Java Apache ECS" and + * "Java Apache Project" must not be used to endorse or promote products * derived from this software without prior written permission. * - * 5. Products derived from this software may not be called - * "Java Apache Element Construction Set" nor "Java Apache ECS" appear - * in their names without prior written permission of the + * 5. Products derived from this software may not be called + * "Java Apache Element Construction Set" nor "Java Apache ECS" appear + * in their names without prior written permission of the * Java Apache Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: - * "This product includes software developed by the Java Apache + * "This product includes software developed by the Java Apache * Project. " - * + * * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -62,107 +62,99 @@ * This simple servlet displays the 216 safe web colors that can be * rendered by any browser on any platform. * + * @version 1.1, 2001/12/30, removed all CSS code and switched back + * to full HTML 3.2 compatibility + * @version 1.0, 2001/07/04, initial release * @author Christian Brensing - * @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 = new Html(); - - // New - Head head = new Head(); - Title title = new Title("The 216 safe web colors"); - head.addElement(title); - - // Add to - html.addElement(head); - - // New - Body body = new Body(); - body.setStyle("background: none white;"); - - // New - 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 = 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 - tr.addElement(td); - - } // next b - - // Add this to
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 -tag - td.setStyle(bg.toString()); - - // Add to
- table.addElement(tr); - - } // next r - - } // next g - - // Add
to - body.addElement(table); - - // Add to - html.addElement(body); - - // Return - out.println(html.toString()); - - } // doGet - -} // WebColors \ No newline at end of file +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 = new Html(); + + // New with + Head head = new Head(new Title + ("The 216 safe web colors")); + + // Add <head> to <html> + html.addElement(head); + + // New <body> with white background-color + Body body = new Body().setBgColor("#FFFFFF"); + + // New <table> with no border + Table table = new Table(0).setWidth(600); + table.setCellSpacing(0).setAlign("center"); + + // 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(); + + // Modulate blue + for (int b = 0; b < hex.length; b++) + { + // Get current blue component + String blue = hex[b]; + + // New RGB with modulated green, red and blue + String rgb = "#" + red + green + blue; + + // New <font> with white foreground-color + Font font = new Font().setColor("#FFFFFF"); + + // Change font-color if cell background is to bright + if (g > 3) { font.setColor("#000000"); } + + // New <td> for each color + TD td = new TD(font.addElement(rgb)); + + // Set background for this <td>-tag + td.setBgColor(rgb).setAlign("center"); + + // Add <td> to <tr> + tr.addElement(td); + } + + // Add this <tr> to <table> + table.addElement(tr); + } + } + + // Add <table> to <body> + body.addElement(table); + + // Add <body> to <html> + html.addElement(body); + + // Return <html> + out.println(html.toString()); + } +} \ No newline at end of file -- To unsubscribe, e-mail: <mailto:ecs-dev-unsubscribe@jakarta.apache.org> For additional commands, e-mail: <mailto:ecs-dev-help@jakarta.apache.org>