RK061008 chapter 26.4 about the minibrowser added
authorrkoenig
Sun, 08 Oct 2006 22:34:06 +0200
changeset 3669a1936b3ab460
parent 3668 3bcc599e739a
child 3670 0743eaa1d84c
RK061008 chapter 26.4 about the minibrowser added
doc/sdd-content.tex
     1.1 --- a/doc/sdd-content.tex	Sun Oct 08 22:33:18 2006 +0200
     1.2 +++ b/doc/sdd-content.tex	Sun Oct 08 22:34:06 2006 +0200
     1.3 @@ -990,6 +990,115 @@
     1.4  %WN040815---MH->isac-SDD6-----------------END---please don't remove this line
     1.5  %WN040815---MH->isac-SDD6-----------------END---please don't remove this line
     1.6  
     1.7 +%--------------------------------------------------------------------------------------------------------
     1.8 +%--------------------------------------------------------------------------------------------------------
     1.9 +%--------------------------------------------------------------------------------------------------------
    1.10 +%--------------------------------------------------------------------------------------------------------
    1.11 +%--------------------------------------------------------------------------------------------------------
    1.12 +%FIXXME RK Oct 2006 NEW:
    1.13 +\section{Minibrowser}
    1.14 +\label{sec.RK-hmtl-in-java}
    1.15 +Displaying HTML content in a Java GUI is in no big problem since most of the
    1.16 +\verb'javax.swing.*' components, which are used to display plain text, are also able
    1.17 +to display HTML content. The task of displaying HTML content is done by the
    1.18 +\verb'Minibrowser' as shown in figure \ref{fig.RK-browsers}. The \verb'Minibrowser' is an extension of the
    1.19 +\verb'javax.swing.JEditorPane'. The \verb'JEditorPane' is per default able to deal with the
    1.20 +following content:
    1.21 +\begin{itemize}
    1.22 +\item text/plain
    1.23 +\item text/html
    1.24 +\item text/rtf
    1.25 +\end{itemize}
    1.26 +The type of content can be selected with the \verb'setContetType()' method. There are 
    1.27 +two methods for displaying HTML content:
    1.28 +\begin{itemize}
    1.29 +\item {\bf setText(String html)}: shows the passed HTML string directly. The disadvantage
    1.30 +of this method is, that the HTML content has to be loaded into a string manually.
    1.31 +According to SR.\ref{SR.RK-html-local-web}, urls pointing to the local file system must 
    1.32 +work as well as urls pointing to
    1.33 +documents available over the World Wide Web via http. Thus, an extra loading-class would
    1.34 +be necessary to get the HTML content independent from the location. 
    1.35 +Additionally, the whole user interaction should not block while the file is loaded, so
    1.36 +the loading-class would have to run in an extra thread, as required in SR.\ref{SR.RK-browser-load-asynch}. All the problems of thread-synchronization
    1.37 +would have to be solved. However, the big advantage would be,
    1.38 +that the HTML string could be manipulated directly. The content of HTML tags could be
    1.39 +replaced or modified by dynamically generated HTML parts with a single \verb'String.replace()' command.
    1.40 +\item {\bf setPage(String url)} loads the content of the passed url. This works from
    1.41 +the World Wide Web as well as from the local file system. The page can be loaded synchronously or
    1.42 +asynchronously. Dynamic changes in the static HTML document are not that easy, but they
    1.43 +are possible by use of a so called \verb'EditorKit'. This is explained in section \ref{sec.RK-context_replace} in detail.
    1.44 +\end{itemize}
    1.45 +The use of the \verb'setPage()' method clearly results in less work to be done, so it
    1.46 +was declared to be the weapon of choice for the \verb'MiniBrowser'.
    1.47 +
    1.48 +\subsection{The Processing of Links}
    1.49 +Links are handled with so called \verb'HyperLinkListeners'.
    1.50 +Whenever a link in the \verb'JEditorPane' is selected, the registered \verb'HyperLinkListener' is called. In our
    1.51 +case, the \verb'BrowserFrame' implements the \verb'HyperlinkListener' interface. It is added
    1.52 +as the one and only \verb'HyperlinkListener' of the \verb'Minibrowser'. If a link is selected,
    1.53 +the \verb'hyperlinkUpdate()' method is called. The BrowserFrame creates and sends an \verb'UserActionOnLink'.
    1.54 +If a new page has to be displayed, and \verb'UIActionOnLink' containing the
    1.55 +link target gets to the \verb'Minibrowser'. It is loaded by use of the \verb'setPage()' 
    1.56 +method of the \verb'JEditorPane' class.
    1.57 +
    1.58 +\subsection{Dynamic Modification of the Static HTML Content}
    1.59 +\label{sec.RK-context_replace}
    1.60 +According to SR.\ref{SR.RK-add-context-2-html}, the content displayed in the knowledge browsers can be enriched with context dependent information.
    1.61 +A context refers to the active formula. The reader may have a look at figure \ref{all-modules}
    1.62 +while reading the following explanation.
    1.63 +
    1.64 +The worksheetdialog is the module which knows the active formula. It queries the math engine
    1.65 +over the bridge for a specific context (a context to theories, problems or methods) for this formula.
    1.66 +The math engine responses on this query with the XML representation of the desired context.
    1.67 +The context is parsed, which leads to a \verb'Context' object (either \verb'ContextTheory', \verb'ContextProblem' or \verb'ContextMethod')
    1.68 +carrying the information in attributes. This Context object is passed to the corresponding browserdialog.
    1.69 +The browserdialog remembers the context as current context and forwards it to the browser.
    1.70 +
    1.71 +
    1.72 +\begin{figure}[htb]
    1.73 +\centerline{\includegraphics[height=\textwidth, keepaspectratio=true,angle=270]{fig/poseidon/RK-htmltagrendering}}
    1.74 +\caption{The Use of an EditorKit to Manipulate the Representation}
    1.75 +\label{fig.RK-editor-kit}
    1.76 +\end{figure}
    1.77 +
    1.78 +
    1.79 +As mentioned in section \ref{sec.RK-hmtl-in-java}, the HTML content itself is never available in a string to
    1.80 +be modified directly. The \verb'JEditorPane' uses an \verb'HTMLEditorKit' for displaying HTML content.
    1.81 +The only possibility for manipulating the representation is, to use an \verb'EditorKit'.
    1.82 +The solution is shown in figure \ref{fig.RK-editor-kit}.
    1.83 +
    1.84 +An \verb'HTMLFactory' is used to create components to be displayed out of HTML elements.
    1.85 +Instead of the standard \verb'EditorKit', a self made \verb'EditorKit' can be used. 
    1.86 +A \verb'MinibroserEditorKit' is derived from the \verb'HTMLEditorKit'.
    1.87 +The meth\-od \verb'getViewFactory()' is overridden by a method which returns a self written view factory called \verb'MiniBrowserViewFactory'.
    1.88 +The \verb'create()'-method is called with all HTML elements of an HTML document. The returned \verb'View' is
    1.89 +displayed. This \verb'MiniBrowserViewFactory' contains a map between HTML tag strings and \verb'IHTMLElementRenderer' interfaces.
    1.90 +If an HTML tag is not in the map, the \verb'create()' method returns the standard \verb'View'. If the tag
    1.91 +is in the map, the \verb'renderElement()' method of the corresponding interface is called to get the \verb'View'. 
    1.92 +The class
    1.93 +behind the interface can create an own object, which is derived from the \verb'ComponentView'. 
    1.94 +The \verb'createComponent()' methode can now implement the representation of the HTML element just as desired.
    1.95 +
    1.96 +This design can be used very flexible. Whenever an HTML tag has to be displayed in an special
    1.97 +manner, a new \verb'ContextRenderer' which implements the \verb'IHTMLRenderer' interface and a \verb'View' which
    1.98 +creates the \verb'Component' has to be programmed. The tag to be processed and the according
    1.99 +\verb'Renderer' has to be inserted into the map by use of the \verb'addElementPresenter()' method of
   1.100 +the \verb'MiniBrowserViewFactory'.
   1.101 +
   1.102 +In the current state of the \isac-software, this feature is only used to replace everything
   1.103 +which is inside a \verb'<class="context">'\verb'</class>' tag with the context information from the
   1.104 +math engine. The string \verb,'context', is inserted together with a \verb'ContextRenderer' into the
   1.105 +map of the \verb'ViewFactory'. This class creates a \verb'ContextView'. The \verb'createComponent()' method of
   1.106 +this class returns a \verb'Component' displaying the HTML representation of the (dynamic) context
   1.107 +instead of the static content between the \verb'<class="context">' \verb'</class>' tags.
   1.108 +The \verb'toHtml()' method is called on the \verb'current_context_'. This method returns an HTML string
   1.109 +presenting the attributes of the context object.
   1.110 +
   1.111 +%--------------------------------------------------------------------------------------------------------
   1.112 +%--------------------------------------------------------------------------------------------------------
   1.113 +%--------------------------------------------------------------------------------------------------------
   1.114 +%--------------------------------------------------------------------------------------------------------
   1.115 +%--------------------------------------------------------------------------------------------------------
   1.116  
   1.117  \chapter{Bridge Java -- SML}
   1.118  %WN040815---RG->isac-SDD1-----------------BEGIN---please don't remove this line