Skip to content

Commit

Permalink
Replaced HtmlExample with real jcp.html page
Browse files Browse the repository at this point in the history
  • Loading branch information
annulen committed Apr 28, 2010
1 parent 016875e commit 8d812c6
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 44 deletions.
1 change: 1 addition & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@
<fileset dir="libutil" >
<include name="html.jar"/>
</fileset>
<fileset dir="${cdk.dist}/jar"/>
<pathelement location="${dist-classes}"/>
<pathelement location="${dist}"/>
</classpath>
Expand Down
99 changes: 55 additions & 44 deletions src/util/HtmlExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.io.PrintStream;
import java.io.IOException;

import org.openscience.jchempaint.GT;

class HtmlExample {

public static FileOutputStream Output;
Expand All @@ -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("&nbsp;&nbsp;&nbsp;");
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)
Expand All @@ -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);
}
}

0 comments on commit 8d812c6

Please sign in to comment.