% javahelp.4ht (2014-05-24-11:52), generated from tex4ht-javahelp.tex
% Copyright (C) 2009-2010 TeX Users Group
% Copyright (C) 2003-2009 Eitan M. Gurari
<.TeX4ht copywrite.> -_-_-
Prepare a LATEX file and compile it for HTML 3.2. For instance, with the command
htlatex jobname "html,3.2,3,javahelp".
\def\Write:File#1#2{%
\special{t4ht>#1}%
\special{t4ht=#2}%
\special{t4ht*>#1}%
\special{t4ht*>}%
}
-_-_-
\NewConfigure{jhxml}[1]{\concat:config\a:jhxml{#1}}
\let\a:jhxml\relax
-_-_-
% javahelp-a.4ht (2014-05-24-11:52), generated from tex4ht-javahelp.tex
% Copyright (C) 2009-2010 TeX Users Group
% Copyright (C) 2003-2009 Eitan M. Gurari
<.TeX4ht copywrite.>
\NextFile{\jobname.tmp}
\HPage{}
\bgroup
\catcode‘\:=11
\catcode‘\@=11
\catcode‘\"=12
\Configure{PROLOG}{}
\Configure{HtmlPar}{}{}{}{}
\Configure{tableofcontents}{}{}{}{}{}
\Configure{htf}{0}{+}{}{}{}{}{}{}{}
\ScriptEnv{dito}{\IgnorePar}{}
\a:jhxml
<.jh util.>
<.jh root.>
<.jh toc.>
<.jh index.>
<.jh at end.>
\egroup
\EndHPage{} -_-_-
The HPage above is to ensure the all the references in the javahelp files will be
to locations at other files, and so they will explicitly include the names of
the files being referenced. The page is empty and not referenced by other
pages.
\immediate\write-1{--------------- JavaHelp -----------------}
\immediate\write-1{The entry (HelpSet) file for the java program
is at ‘\jobname.hs’}
\immediate\write-1{Generate a search database
with, for instance, the command}
\immediate\write-1{ java -jar
...../jh1.1.3/javahelp/bin/jhindexer.jar
-db \jobname-jhs \jobname*.html}
\immediate\write-1{Compile the java program with a command similar to}
\immediate\write-1{ javac -classpath
...../jh1.1.3/javahelp/lib/jh.jar program.java}
\immediate\write-1{Run the java program with a command similar to}
\immediate\write-1{ java -classpath
...../jh1.1.3/javahelp/lib/jh.jar;. program}
\immediate\write-1{JavaHelp might require a compilation for HTML 3.2,
for instance,}
\immediate\write-1{ htlatex \jobname\space "html,javahelp,3.2,3"}
\immediate\write-1{------------------------------------------}
-_-_-
\def\jhNote{%
Created for JavaHelp
(http://java.sun.com/products/javahelp/)\Hnewline
by TeX4ht (http://www.cse.ohio-state.edu/\string
~gurari/TeX4ht/)\Hnewline from \jobname.tex at \:today \space
}
-_-_-
We can’t keep the comment boundaries in the macro because the adjacent
hyphens in some cases merge into a n-dash under font encoding T1. For
instance,
\documentclass{report}
\usepackage[T1]{fontenc}
\begin{document}
\ScriptEnv{dito}{}{}
\begin{dito}
--[]-[]
\end{dito}
\end{document}
\Configure{crosslinks}{}{}{}{}{}{}{}{}{}
-_-_-
This file introduces the files in the help distribution.
The etension name must be ‘hs’!
\def\dTdLaNg{\expandafter
\ifx \csname a:dtd-lang\endcsname\relax EN\else
\csname a:dtd-lang\endcsname
\fi }
-_-_-
\edef\tocLabel{\ifx\contentsname\:UnDef Table Of Contents\else
\ifx\contentsname\empty Table Of Contents\else
\contentsname\fi\fi}
\edef\indexLabel{\ifx\indexname\:UnDef Index\else
\ifx\indexname\empty Index\else \indexname\fi\fi}
\ifTag{TITLE+}
{\edef\titleLabel{\LikeRef{TITLE+}}}
{\def\titleLabel{\jobname}}
-_-_-
Use a command similar to ‘java -jar ...../jh2.0/javahelp/bin/jhindexer.jar
-db tex4ht-javahelp-jhs tex4ht-javahelp*.html’ to create a search directory
JavaHelpSearch for JavaHelp from the HTML pages of the documentation.
The homeId tag provides the default entry to present when a HelpSet is first
shown.
The default entry point can be overwritten in:
Assigns keys to locations within the HTML document.
<?xml version="1.0" encoding="ISO-8859-1" ?>\Hnewline
<.map DTD.>
\Hnewline <!-- <.tex4ht note.> -->\Hnewline
<map version="\dotVersion">\Hnewline
<mapID target="<.entry point.>" url="\jobname.html"/>\Hnewline -_-_-
\gHAdvance\mapEntry by 1
\Write:File
{<.url of jh keys file.>}%
{<mapID target="indexentry-\mapEntry"
url="\RefFileNumber\FileNumber
\#\title:chs {dx\last:haddr}{\cur:th\:currentlabel}%
" />\Hnewline}% -_-_-
\AtBeginDocument{%
\let\jh:toc=\auto:toc
\expandafter\append:defI\csname tableofcontents*\endcsname{%
\global\let\jh:toc=\auto:toc }%
}
-_-_-
\expandafter\ifx \csname jh:toc\endcsname\relax
\tableofcontents
\else
\expandafter\expandafter\expandafter\tableofcontents
\expandafter\expandafter\expandafter[\csname
jh:toc\endcsname]%
\fi
-_-_-
\Configure{Link}{mapID}{target="\a:mapIdTarget" url=}{}{}
\Configure{TocLink}{\Link{#2}{}\EndLink}
\let\jh:doTocEntry\:doTocEntry
\def\:doTocEntry#1#2#3{%
\edef\sectioningKey{\expandafter\gob:IV\string#1}%
\edef\:temp{\noexpand\ConfigureToc{\sectioningKey}
{}{\relax}{}{}}\:temp
<.config toc target entry.>%
\jh:doTocEntry#1{#2}{#3}}
\def\gob:IV#1#2#3#4{}
\def\sectioningKey{NoToc} -_-_-
\EndNoFonts
\catcode‘\:=11 \catcode‘\@=11
\end:jhhook
\begin{dito}
</tocitem>
</toc>
\end{dito}
\special{t4ht<<.url of jh toc file.>} -_-_-
\Configure{TocLink}
{\HCode{<tocitem target="\a:mapIdTarget"\Hnewline
text="}\hbox{#4}\HCode{<.uni sp.>">\Hnewline}}
\let\jh:doTocEntry\:doTocEntry
\def\:doTocEntry#1#2#3{%
\edef\sectioningKey{\expandafter\gob:IV\string#1}%
\edef\:temp{\noexpand\ConfigureToc{\sectioningKey}
{}{\noexpand\set:endtocitem{\sectioningKey}}{}{}}\:temp
<.config toc target entry.>%
\jh:doTocEntry#1{#2}{#3}}
\def\gob:IV#1#2#3#4{}
\def\sectioningKey{NoToc} -_-_-
\csname jh:#1\endcsname
\expandafter\gdef\csname jh:#1\endcsname{%
\expandafter\global\expandafter\let\csname jh:#1\endcsname=\empty
\HCode{</tocitem><!--/#1-->}}%
-_-_-
\expandafter\ifx \csname catchAt:##1\endcsname \relax
\expandafter\gdef\csname
catchAt:##1\endcsname{\csname jh:#1\endcsname}%
\else
\expandafter\pend:def\csname
catchAt:##1\endcsname{\csname jh:#1\endcsname}%
\expandafter\global\expandafter\let\csname
catchAt:##1\expandafter\endcsname\csname catchAt:##1\endcsname
\fi
-_-_-
\append:def\end:jhhook{%
\csname jh:#1\endcsname
\expandafter\global\expandafter
\let\csname jh:#1\endcsname\:UnDef}%
\global\let\end:jhhook\end:jhhook
-_-_-
\let\indexname\empty
\def\gobbleLnk#1, \LNK#2#3#4#5{#1\HCode{" target="indexentry-#5"}}
\Configure{theindex}
{}{}
{\hbox\bgroup\HCode{<\string !--index-item--><indexitem
text="}\gobbleLnk}
{\HCode{/>}\egroup\hfill\break}
{\hbox\bgroup\HCode{<\string !--subex-item--><indexitem
text="}\gobbleLnk}
{\HCode{/>}\egroup\hfill\break}
{\hbox\bgroup\HCode{<\string !--subsubitem--><indexitem
text="}\gobbleLnk}
{\HCode{/>}\egroup\hfill\break}
{}
\immediate\openin15=\jobname.ind
\ifeof15
\immediate\closein15
\else
\immediate\closein15
\input \jobname.ind
\fi
-_-_-
\def\beforeindex#1|LNK#2#3{#1}%
\def\indexentry#1#2{\HCode{<indexitem target="indexentry-#2"
text="}\beforeindex#1\HCode{<.uni sp.>" />\Hnewline}}%
\immediate\openin15=\jobname.4dx
\ifeof15
\immediate\closein15
\else
\immediate\closein15
\input \jobname.4dx
\fi -_-_-
JavaHelp has problems with unicode values at the end of text fields in
the toc of within the jht file: it refuses ‘text="Menü"’ (but accepts
‘text="Menü "’). The following adds spaces at the end of the text attribute
values.
A similar problem occurs when two unicode character codes follow each other. In
this case, the second one is not properly rendered.
\expandafter\target:info#3//%
\b:mapIdTarget
-_-_-
\def\target:info#1#2#3#4#5#6//{%
\let\sectionType=\sectioningKey
\let\sectionId\TocCount
\Advance:\sectionId 1
\def\sectionName{#5}%
}
\NewConfigure{mapIdTarget}{2}
\Configure{mapIdTarget}
{\sectionType-\sectionId}
{}
-_-_-
\begin{dito}-\
<!DOCTYPE helpset PUBLIC
"-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version \dotVersion//<.dtd lang.>"
"http://java.sun.com/products/javahelp/helpset_\subVersion.dtd">
\end{dito} -_-_-
\begin{dito}-\
<!DOCTYPE toc PUBLIC
"-//Sun Microsystems Inc.//DTD JavaHelp TOC Version \dotVersion//<.dtd lang.>"
"http://java.sun.com/products/javahelp/toc_\subVersion.dtd">
\end{dito} -_-_-
\begin{dito}-\
<!DOCTYPE index PUBLIC
"-//Sun Microsystems Inc.//DTD JavaHelp Index Version \dotVersion//<.dtd lang.>"
"http://java.sun.com/products/javahelp/index_\subVersion.dtd">
\end{dito} -_-_-
<!DOCTYPE index PUBLIC
"-//Sun Microsystems Inc.//DTD JavaHelp Index Version \dotVersion//<.dtd lang.>"
"http://java.sun.com/products/javahelp/index_\subVersion.dtd"> -_-_-
<!DOCTYPE map PUBLIC\Hnewline
"-//Sun Microsystems Inc.//DTD
JavaHelp Map Version \dotVersion//<.dtd lang.>"\Hnewline
"http://java.sun.com/products/javahelp/map_\subVersion.dtd"> -_-_-
\:CheckOption{jh1.0} \if:Option
\def\dotVersion{1.0}
\def\subVersion{1\string_0}
\else
\def\dotVersion{2.0}
\def\subVersion{2\string_0}
\fi
-_-_-
Url of JavaHelp root file (jobname.hs)
http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/javahelp/javahelp.html
import java.net.URL;
import javax.help.*;
import javax.swing.*;
public class program {
//^^^^^^^
public static void main(String args[]) {
JHelp helpViewer=null;
try {
ClassLoader cl = program.class.getClassLoader();
//^^^^^^^
URL url = HelpSet.findHelpSet(cl,
"<.jobname.hs: url of jh root file.>");
HelpSet hs = new HelpSet(cl, url);
helpViewer = new JHelp( hs );
/*
helpViewer.setCurrentID("<.entry point.>");
*/
} catch (Exception e) {
System.out.println("error"); System.exit(0);
}
JFrame frame = new JFrame();
frame.getContentPane().add(helpViewer);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setSize(500,500);
frame.setVisible(true);
}
} -_-_-
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javahelp/
import java.net.*;
import javax.help.*;
import javax.swing.*;
import java.awt.event.*;
public class HelpMenu {
JFrame f;
JMenuItem topics;
public HelpMenu() {
f = new JFrame("Menu Example");
JMenuBar mbar = new JMenuBar();
// a file menu
JMenu file = new JMenu("File");
JMenu help = new JMenu("Help");
// add an item to the help menu
help.add(topics = new JMenuItem("Help Topics"));
// add the menu items to the menu bar
mbar.add(file);
mbar.add(help);
// 1. create HelpSet and HelpBroker objects
HelpSet hs = getHelpSet(<.jobname.hs: url of jh root file.>);
HelpBroker hb = hs.createHelpBroker();
// 2. assign help to components
/*
CSH.setCurrentID("<.entry point.>");
*/
// 3. handle events
topics.addActionListener(new CSH.DisplayHelpFromSource(hb));
// attach menubar to frame, set its size, and make it visible
f.setJMenuBar(mbar);
f.setSize(500, 300);
f.setVisible(true);
}
/**
* find the helpset file and create a HelpSet object
*/
public HelpSet getHelpSet(String helpsetfile) {
HelpSet hs = null;
ClassLoader cl = this.getClass().getClassLoader();
try {
URL hsURL = HelpSet.findHelpSet(cl, helpsetfile);
hs = new HelpSet(null, hsURL);
} catch(Exception ee) {
System.out.println("HelpSet: "+ee.getMessage());
System.out.println("HelpSet: "+ helpsetfile + " not found");
}
return hs;
}
public static void main(String argv[]) {
new HelpMenu();
}
} -_-_-
Add JavaHelp to your program, say ‘program.java’, and compile the program with
the command ‘javac -classpath ...../jh2.0/javahelp/lib/jh.jar
program.java’.
Use the a command similar to ‘java -classpath ...../jh2.0/javahelp/lib/jh.jar;.
program’.
javac -classpath c:\jh1.1.3\javahelp\lib\jhall.jar
-d c:\temp
JavaHelpTest.java
jar cvfm JavaHelpTest.jar manifest JavaHelpTest.class
java -jar jh1.3.1/demos/bin/UserGuide.jar
Download JavaHelp from http://java.sun.com/products/javahelp/download_binary.html
and unzip it into some directory (say ...../).