[jsword-devel] display methods
DM Smith
jsword-devel@crosswire.org
Thu, 18 Mar 2004 04:35:29 -0500
>From: Joe
>
>DM Smith wrote:
>
>>What JavaScript features would be desirable?
>
>I would like to be able to have regions of the page hidden until the user
>takes some action. Generally speaking you just want to read, and strongs
>numbers/references/etc get in the way. It would be good to be able to hide
>them until needed.
>I don't have a specific design in mind, but I have a hunch that this could
>be useful. I wrote a JavaDoc navigator that uses this principle:
>http://www.getahead.ltd.uk/doctree/
I really like your JavaDoc navigator!!!
The two basic uses of JavaScript that I have seen are seamless page
rewriting
and graphic wiz-bangs (e.g. rollovers). There may be others.
I have used XSLT to do page rewriting. Imagine if there is a check box for
toggling Strongs. When it is toggled the stylesheet is invalidated so that
it is
recompiled. The value of the check box is parmed into the stylesheet to
show/hide
strongs numbering. The trick would be to remember where the page is scrolled
and to re-establish that location.
>>>JEditorPane in JDK1.4:
>>> does not do JavaScript or CSS level anything
>>
>>I have notice in JSword that when Strong's numbering is rendered the words
>>all run together because the space between words (In this case, it would
>>be between <A href="">word</A> tags) is missing. I have not looked into
>>where the hypertext is created yet.
>>
>>What are the other shortcomings (other than CSS or JavaScript)?
>
>The lack of CSS is a biggy because it limits you to the available tags. I
>seem to remember giving up on tables that were anything other than very
>simple too. Div is obviously out.
>
I found that jdk1.4 does have limited CSS and I was able to get it to work
two
different ways:
1) Use the link tag inside of the <head>...</head> of the HTML document:
I tried this in the simple.xsl:
<xsl:param name="css"
select="'file:/e:/eclipse/jsword/resource/xsl/cswing/simple.css'"/>
...
<link ref="stylesheet" url="{$css}" title="simple css" />
I tried the <style> tag, but it did not work.
The value of the parameter is not important as long as it is parmed in, just
like font.
It would probably be best to leave the 'select' off of it, just like the
font param.
The only trick is that the value of the param cannot be relative, since the
doc being
created by the xsl is in core. Or the code would need to be changed to
provide a location
for the Source object (via its second parameter).
Interestingly, the xsl function system-property(name) will return the values
of Java system properties. So that would be another way to pass in
parameters into Xalan.
2) The other way is to do it inside of Java. By grabbing the document from
JTextPane
and getting its default StyleSheet, a new stylesheet imported or linked:
// I hacked this into InnerDisplayPanel
try {
StyleSheet defaultStyleSheet = ((HTMLDocument)
txtView.getDocument()).getStyleSheet();
defaultStyleSheet.importStyleSheet(ResourceUtil.getResource("xsl/cswing/simple.css"));
} catch (MalformedURLException e) {
}
... or ...
try {
StyleSheet defaultStyleSheet = ((HTMLDocument)
txtView.getDocument()).getStyleSheet();
StyleSheet myStyleSheet = new StyleSheet();
myStyleSheet.importStyleSheet(ResourceUtil.getResource("xsl/cswing/simple.css"));
defaultStyleSheet.addStyleSheet(myStyleSheet);
} catch (MalformedURLException e) {
}
With this second mechanism, you can add and remove linked CSS stylesheets.
This would allow for changing styles on the fly.
_________________________________________________________________
Check out MSN PC Safety & Security to help ensure your PC is protected and
safe. http://specials.msn.com/msn/security.asp