From 8d812c6945f56e0523891d2945d19a266f834700 Mon Sep 17 00:00:00 2001 From: annulen Date: Wed, 28 Apr 2010 16:21:57 +0000 Subject: [PATCH] Replaced HtmlExample with real jcp.html page --- build.xml | 1 + src/util/HtmlExample.java | 99 ++++++++++++++++++++++----------------- 2 files changed, 56 insertions(+), 44 deletions(-) diff --git a/build.xml b/build.xml index e9e8b9d..e790aaa 100755 --- a/build.xml +++ b/build.xml @@ -809,6 +809,7 @@ + diff --git a/src/util/HtmlExample.java b/src/util/HtmlExample.java index 42dafd5..6ad78d7 100644 --- a/src/util/HtmlExample.java +++ b/src/util/HtmlExample.java @@ -4,6 +4,8 @@ import java.io.PrintStream; import java.io.IOException; +import org.openscience.jchempaint.GT; + class HtmlExample { public static FileOutputStream Output; @@ -16,60 +18,54 @@ public static void main(String argv[]) { // a simple header Tag head = new Tag("head"); Tag title = new Tag("title"); - title.add("HTML generator example"); + title.add("JChemPaint User's Guide"); + head.add(new Tag("link", "rel=stylesheet type=text/css href=jcp.css title=Style")); head.add(title); body.add(head); - - // add h1 title + Tag h1 = new Tag("h1"); - h1.add("HTML Generator demo"); + h1.add("JChemPaint User's Guide"); body.add(h1); - - // creat a table - Tag table = - new Tag("table", "border=1 cellpadding=0 cellspacing=0"); - body.add(table); // table is not finished yet! - - // create two rows with five columns each - Tag row1 = new Tag("tr"); - Tag row2 = new Tag("tr"); - - for (int j = 0; j < 5; j++) { - // create new cell tag - Tag cell = new Tag("td"); - // fill in content - cell.add(Integer.toString(j)); - // add cell (same object) to row1 and row2 - row1.add(cell); - row2.add(cell); - } - - // rows can be added later - table.add(row1); - table.add(row2); + body.add(new Tag("img", "src=../../large-bin/jcplogo.gif width=150 height=150")); + Tag p_1 = new Tag("p"); + p_1.add("This user's guide contains the following sections:"); + body.add(p_1); - // now replace cell 4 in row 2 - // first, create new cell with its content - Tag cell = new Tag("td"); - cell.add("*"); - // overwrite old content - row2.set(3, cell); // we can use any method from java.util.List + //GT.setLanguage("ru"); + contentsEntry(body, /*GT._*/("About JChemPaint"), "contain/aboutJCP.html", + /*GT._*/("General information about the JChemPaint program and the JChemPaint project.")); + contentsEntry(body, /*GT._*/("Basic Tutorial"), "contain/tutorial.html", + /*GT._*/("This section explains on a few basic examples the use of JChemPaint and more in detail how new compounds and reactions can be drawn.")); + contentsEntry(body, /*GT._*/("Rgroup Query Tutorial"), "contain/", + /*GT._*/("An introduction to R-groups and how to draw them with JChemPaint.")); + contentsEntry(body, /*GT._*/("Reference Guide"), "contain/referenceGuide.html", + /*GT._*/("A general overview on JChemPaint. Describes the use of JChemPaint and how it can be customized. It also tried to describe as best as possible which algorithms are used, and in which CDK classes those can be found.")); + contentsEntry(body, /*GT._*/("Miscellaneous topics"), "contain/misc.html", + /*GT._*/("Some miscellaneous remarks on JChemPaint.")); + contentsEntry(body, /*GT._*/("Feedback"), "contain/feedback.html", + /*GT._*/("How to give feedback on JChemPaint.")); - // add line break (no closing tag) after table - body.add(new Tag("br", false)); - - // simple string - body.add("End of Example"); - - // add title again at bottom - re-use h1 object - body.add(h1); - - html.add(body); // no header here + Tag h2 = new Tag("h2"); + h2.add("Keeping in Touch"); + body.add(h2); + + Tag p_2 = new Tag("p"); + p_2.add("Comments and questions about how the JChemPaint software works are welcome. If you have further questions, please review the FAQ at our home page:"); + body.add(p_2); + + Tag p_3 = new Tag("p"); + p_3.add("   "); + Tag a = new Tag("a", "href=http://jchempaint.sourceforge.net"); + a.add("href=http://jchempaint.sourceforge.net"); + p_3.add(a); + body.add(p_3); + + html.add(body); // Write to file try { - Output = new FileOutputStream("example.html"); + Output = new FileOutputStream("dist/classes/org/openscience/jchempaint/resources/userhelp_jcp/en_US/example.html"); file = new PrintStream(Output); } catch(Exception e) @@ -78,4 +74,19 @@ public static void main(String argv[]) { } file.println(html); } + + public static void contentsEntry(Tag body, String name, + String ref, String description) + { + Tag p_1 = new Tag("p"); + Tag b = new Tag("b"); + b.add(name); + Tag a = new Tag("a", "href="+ref); + a.add(b); + p_1.add(a); + body.add(p_1); + Tag p_2 = new Tag("p"); + p_2.add(description); + body.add(p_2); + } }