org.crosswire.bibledesktop.display.textpane
Class TextPaneBookDataDisplay

java.lang.Object
  extended by org.crosswire.bibledesktop.display.textpane.TextPaneBookDataDisplay
All Implemented Interfaces:
EventListener, HyperlinkListener, BookDataDisplay

public class TextPaneBookDataDisplay
extends Object
implements BookDataDisplay, HyperlinkListener

A JDK JTextPane implementation of an OSIS displayer.

Author:
Joe Walker [joe at eireneh dot com], DM Smith [dmsmith555 at yahoo dot com]
See Also:
for license details. The copyright to this program is held by it's authors.

Field Summary
private  Book book
          The current book
private  Converter converter
          To convert OSIS to HTML
private static String DOUBLE_SLASH
           
private static String HYPERLINK_STYLE
           
private  Key key
          The current key
private  int lastLength
          length of last enter event
private  int lastStart
          location of last enter event
private  EventListenerList listenerList
          The listeners for handling urls
protected static Logger log
          The log stream
private static String RELATIVE_URL_PROTOCOL
           
private static String SCROLL_TO_URL
           
private  Style style
          A sytle used to underline a hyperlink
private  StyledDocument styledDoc
          The styled document of the JTextPane.
private  JTextPane txtView
          The display component
 
Constructor Summary
TextPaneBookDataDisplay()
          Simple ctor
 
Method Summary
 void addMouseListener(MouseListener li)
          Forward the mouse listener to our child components
 void addURLEventListener(URLEventListener listener)
          Adds a hyperlink listener for notification of any changes, for example when a link is selected and entered.
 void copy()
          Copy the selection to the clipboard
 void fireActivateURL(URLEvent e)
          Notify the listeners that the hyperlink (URL) has been activated.
 void fireEnterURL(URLEvent e)
          Notify the listeners that the hyperlink (URL) has been entered.
 void fireLeaveURL(URLEvent e)
          Notify the listeners that the hyperlink (URL) has been left.
 Book getBook()
          Accessor for the Book used in the current display, or null if we are not displaying anything.
 Component getComponent()
          Accessor for the Swing component
 Key getKey()
          The Book Key that we are displaying, or null if we are not displaying anything
private  String[] getParts(String reference)
           
 void hyperlinkUpdate(HyperlinkEvent ev)
           
 void refresh()
          Cause the BookData to be re-displayed.
 void removeMouseListener(MouseListener li)
          Forward the mouse listener to our child components
 void removeURLEventListener(URLEventListener listener)
          Removes a hyperlink listener.
 void setBookData(Book book, Key key)
          Set the BookData to be displayed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HYPERLINK_STYLE

private static final String HYPERLINK_STYLE
See Also:
Constant Field Values

DOUBLE_SLASH

private static final String DOUBLE_SLASH
See Also:
Constant Field Values

SCROLL_TO_URL

private static final String SCROLL_TO_URL
See Also:
Constant Field Values

RELATIVE_URL_PROTOCOL

private static final String RELATIVE_URL_PROTOCOL
See Also:
Constant Field Values

log

protected static final Logger log
The log stream


book

private Book book
The current book


key

private Key key
The current key


converter

private Converter converter
To convert OSIS to HTML


txtView

private JTextPane txtView
The display component


style

private Style style
A sytle used to underline a hyperlink


lastStart

private int lastStart
location of last enter event


lastLength

private int lastLength
length of last enter event


styledDoc

private StyledDocument styledDoc
The styled document of the JTextPane.


listenerList

private EventListenerList listenerList
The listeners for handling urls

Constructor Detail

TextPaneBookDataDisplay

public TextPaneBookDataDisplay()
Simple ctor

Method Detail

setBookData

public void setBookData(Book book,
                        Key key)
Description copied from interface: BookDataDisplay
Set the BookData to be displayed. The data to be displayed is specified as a book and key rather than the more obvious BookData (the result of reading a book using a key) since some displays may wish so split up the display and only look up smaller sections at a time.

Specified by:
setBookData in interface BookDataDisplay
Parameters:
book - The Book to read data from
key - The key to read from the given book

refresh

public void refresh()
Description copied from interface: BookDataDisplay
Cause the BookData to be re-displayed.

Specified by:
refresh in interface BookDataDisplay

hyperlinkUpdate

public void hyperlinkUpdate(HyperlinkEvent ev)
Specified by:
hyperlinkUpdate in interface HyperlinkListener

getParts

private String[] getParts(String reference)
                   throws MalformedURLException
Throws:
MalformedURLException

getComponent

public Component getComponent()
Accessor for the Swing component

Specified by:
getComponent in interface BookDataDisplay

copy

public void copy()
Description copied from interface: BookDataDisplay
Copy the selection to the clipboard

Specified by:
copy in interface BookDataDisplay

addURLEventListener

public void addURLEventListener(URLEventListener listener)
Adds a hyperlink listener for notification of any changes, for example when a link is selected and entered.

Specified by:
addURLEventListener in interface BookDataDisplay
Parameters:
listener - the listener

removeURLEventListener

public void removeURLEventListener(URLEventListener listener)
Removes a hyperlink listener.

Specified by:
removeURLEventListener in interface BookDataDisplay
Parameters:
listener - the listener

fireActivateURL

public void fireActivateURL(URLEvent e)
Notify the listeners that the hyperlink (URL) has been activated.

Parameters:
e - the event
See Also:
EventListenerList

fireEnterURL

public void fireEnterURL(URLEvent e)
Notify the listeners that the hyperlink (URL) has been entered.

Parameters:
e - the event
See Also:
EventListenerList

fireLeaveURL

public void fireLeaveURL(URLEvent e)
Notify the listeners that the hyperlink (URL) has been left.

Parameters:
e - the event
See Also:
EventListenerList

removeMouseListener

public void removeMouseListener(MouseListener li)
Forward the mouse listener to our child components


addMouseListener

public void addMouseListener(MouseListener li)
Forward the mouse listener to our child components


getKey

public Key getKey()
Description copied from interface: BookDataDisplay
The Book Key that we are displaying, or null if we are not displaying anything

Specified by:
getKey in interface BookDataDisplay
Returns:
The current key

getBook

public Book getBook()
Description copied from interface: BookDataDisplay
Accessor for the Book used in the current display, or null if we are not displaying anything.

Specified by:
getBook in interface BookDataDisplay
Returns:
The current book

Copyright ? 2003-2006