1% BEGIN LICENSE BLOCK 2% Version: CMPL 1.1 3% 4% The contents of this file are subject to the Cisco-style Mozilla Public 5% License Version 1.1 (the "License"); you may not use this file except 6% in compliance with the License. You may obtain a copy of the License 7% at www.eclipse-clp.org/license. 8% 9% Software distributed under the License is distributed on an "AS IS" 10% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 11% the License for the specific language governing rights and limitations 12% under the License. 13% 14% The Original Code is The ECLiPSe Constraint Logic Programming System. 15% The Initial Developer of the Original Code is Cisco Systems, Inc. 16% Portions created by the Initial Developer are 17% Copyright (C) 2006 Cisco Systems, Inc. All Rights Reserved. 18% 19% Contributor(s): 20% 21% END LICENSE BLOCK 22 23\chapter{Visualisation clients} 24\label{sec:visu-clients} 25 26To visualise the \viewable{}s of an annotated program, the library 27\bipref{lib(java_vc)}{../bips/lib/java_vc/index.html} provides a Java 28based graphical visualisation client. 29 30A new Java visualisation client (Java VC) can be started from the 31tools menu of tkECLiPSe or using the predicate \startvcone{} in 32\bipref{lib(java_vc)}{../bips/lib/java_vc/index.html}. The single 33argument will return a unique name for the created client which can be 34used to close the client if required. While the Java VC is running, 35it will react automatically to the creation of \viewable{}s during 36ECLiPSe execution, but it cannot visualise \viewable{}s which were 37created before the Java VC was running. 38 39\begin{figure}[htsp] 40\centering 41\includegraphics[width=8cm]{vcstartup} 42\caption{The initial Java VC screen before any viewables have been created.} 43\label{fig:startup} 44\end{figure} 45 46 47\section{Control} 48 49When running a visualisation-annotated {\eclipse} program with a Java 50VC attached, control of the {\eclipse} process may pass between 51{\eclipse} and the VC throughout the program run. That is to say at 52certain key events in the program, {\eclipse} will pause in its 53running of the program and wait for user interaction with the VC 54before continuing. In such circumstances, the VC is said to 55\emph{hold} the control. 56 57Table \ref{tab:events} details the default behaviour for each of the 58visualisation events which may occur, and indicates whether or not 59this default behaviour can be altered. 60 61\begin{table}[htsp] 62\label{tab:events} 63\begin{tabular}{|l|p{7cm}|l|l|} 64\hline 65Event & Triggered by & Default hold & Alterable \\ 66\hline 67\hline 68viewable creation & 69\viewablecreatetwo{} \viewablecreatethree{} \viewablecreatefour{} & 70yes & 71no \\ 72\hline 73viewable expansion & 74\viewableexpandthree{} \viewableexpandfour{} & 75no & 76yes \\ 77\hline 78viewable contraction & 79Backtracked over a viewable expansion & 80no & 81yes \\ 82\hline 83viewable destruction & 84Backtracked over a viewable creation & 85yes & 86yes \\ 87\hline 88forward update & 89One or more elements in a viewable have been updated, ie. had their 90domain reduced or have been instantiated & 91no & 92yes \\ 93\hline 94backward update & 95A forward update has been backtracked over & 96no & 97yes \\ 98\hline 99\end{tabular} 100\caption{VC default behaviour for visualisation event.} 101\end{table} 102 103Should the VC hold, control can be passed back to {\eclipse} by 104pressing the \textbf{Resume} button at the bottom of the VC window, or 105by setting the \textbf{auto resume} timer. The \textbf{Resume} button 106and the \textbf{auto resume} timer are disabled when {\eclipse} has 107control, see Figure \ref{fig:autoresume}. 108 109\begin{figure}[htsp] 110\centering 111\includegraphics[width=8cm]{vcautoresume} 112\caption{The VC showing the auto resume menu option and timer slider.} 113\label{fig:autoresume} 114\end{figure} 115 116 117\section{Viewlets} 118 119The Java VC provides many ways of visualising any single element of a 120\viewable{}. 121 122\begin{enumerate} 123\item Textually, as though the element had been printed with 124\bipref{write/1}{../bips/kernel/ioterm/write-1.html}. This is 125suitable for all \viewable{} types. 126\item As a rectangular bar on a scale representing the current bounds 127of a \emph{numeric_bounds} type \viewable{} element. Bounds 128\viewlet{}s can be aligned either vertically or horizontally. 129\item As a node in a graph, similar to the simple textual 130representation but enclosed in a geometric shaped node. 131\item As an edge in a graph, with the textual representation attached 132as a label to the edge. 133\item With a colour which varies in shade and hue in response to 134events occurring on the variable. 135\end{enumerate} 136 137When rendered on the screen these representations are referred to as 138\viewlet{}s. Figure \ref{fig:viewlets} shows the same variable 139rendered using a number of \viewlet{} types. 140 141\begin{figure}[htsp] 142\centering 143\includegraphics[width=6cm]{vcviewlets} 144\caption{The FD variable with initial domain 0..10, reduced to 3..5 as 145rendered by text, bound, node and fade \viewlet{}s.} 146\label{fig:viewlets} 147\end{figure} 148 149 150\section{Viewers} 151 152The Java VC currently contains five different methods for rendering 153an entire \viewable{}. Each of these methods can be thought of as a 154window looking onto the \viewable{} and is referred to as a \viewer{}. 155 156Upon a \viewable{} being created, the user is presented with a dialog 157box asking which of the available \viewer{}s they wish to view the 158\viewable{} with. 159 160The currently available viewers are 161\begin{description} 162\item[TextTable] Renders any type of 1D and 2D \viewable{}s as a grid 163of textual descriptions of the elements. 164\item[BoundsTable] Renders numeric_bounds 1D and 2D \viewable{}s as a 165grid of rectangles representing the size of the numeric domains. 166\item[FadeTable] Renders 1D and 2D \viewable{}s as a grid of coloured 167rectangles whose colour changes represent domain changes in the 168\viewable{} elements. 169\item[Desktop] Allows the user to place all available representations 170of the \viewable{} elements anywhere on a desktop window. Also 171enables the loading of an arbitrary background image from file, and for 172placing images alongside \viewlet{}s. 173\item[Network] Renders \texttt{graph(fixed)} \viewable{}s graphically 174as connected nodes, where the textual representation of the 175\viewable{} elements is displayed at nodes and along edges. 176\item[Network (0/1)] Similar to the Network viewer except that if the 177edge annotation can be interpreted as the number 0, then the edge is 178not drawn. If it can be interpreted as the number 1, it is drawn in 179black. Any other value has the edge draw in gray. 180\item[Network (Capacity)] Similar to the Network viewer except that 181the edge labels are interpreted as fractions indicating the capacity 182of a link in a flow network. 0.0 indicating unused (thin black line) 183up to 1.0 indicating full usage (thick black line) and any number 184greater than one indicating over utilisation (very think red line). 185If the edge data cannot be interpreted as a number (eg. it is a 186variable) it is assumed to be 0. 187\item[Gantt] Interprets the first three rows of any 2D viewable with 188\texttt{numeric_bounds} elements (and at least 3 rows) as being the 189start times, durations and resource requirements of a scheduling 190problem. The resulting schedule/partial schedule is rendered as a 191gantt chart. 192\item[Bar chart] Renders any $n$-dimensional \texttt{numeric_bounds} 193viewable as a bar chart. Extra dimensions will be separated by gaps 194in the chart. 195\end{description} 196 197\begin{figure}[htsp] 198\centering 199\includegraphics[width=11cm]{vcallviewers} 200\caption{The VC showing some of the applicable viewers for the \texttt{SEND+MORE=MONEY} example.} 201\label{fig:allviewers} 202\end{figure} 203 204\begin{figure}[htsp] 205\centering 206\includegraphics[width=10cm]{vcnetworkviewer} 207\caption{The VC showing the network viewer displaying the graph example.} 208\label{fig:networkviewer} 209\end{figure} 210 211\begin{figure}[htsp] 212\centering 213\includegraphics[width=10cm]{vcchangeableexample} 214\caption{The VC showing various viewers for the changeable solver example.} 215\label{fig:changeableexample} 216\end{figure} 217 218Common to all viewers are the three menus \textbf{Options}, 219\textbf{Select} and \textbf{View}, the latter two also being 220accessible by pressing the right mouse button. 221 222\subsection{Options menu} 223The options menu contains controls for \viewer{}-wide properties. 224\begin{description} 225\item[Hold at expansions] Determines whether this \viewer{} will hold 226control when the \viewable{} is expanded. 227\item[Hold at contractions] Determines whether this \viewer{} will hold 228control when the \viewable{} is contracted. 229\item[Hold at destruction] Determines whether this \viewer{} will hold 230control when the \viewable{} is destroyed. This option is useful for 231examining the state of the \viewable{} immediately before the 232creation is backtracked over. 233\item[View propagation steps] Controls how frequently the visualisation client is informed of \emph{forward update} events. 234 235 \begin{description} 236 \item[fine] Events are sent as soon as they occur. 237 \item[coarse] Events are sent at priority 8 in the {\eclipse} 238 program. Typically this means that all the propagation that occurs 239 as a result of a single user level search step are sent together. 240 \item[timed] Events are collected and sent at regular timed 241 intervals. 242 \end{description} 243 244\item[Track updates] When set, the \viewer{} will attempt to ensure 245that all updates are visible within the window. This can be important 246when visualising large \viewable{}s which may not easily fit the 247window. 248\end{description} 249 250Figure \ref{fig:optionsmenu} shows the default settings for the 251\textbf{Options} menu. Note that the \textbf{View propagation steps} 252options are disabled because {\eclipse} has control and the update 253granularity can only be changed when the Java VC is holding control. 254 255\begin{figure}[htsp] 256\centering 257\includegraphics[width=4cm]{vcoptionsmenu} 258\caption{The options menu, common to all viewers.} 259\label{fig:optionsmenu} 260\end{figure} 261 262\subsection{Select menu} 263Contains convenience commands for dealing with the currently selected 264set of \viewlet{}s. 265 266Selecting individual \viewlet{}s can be done clicking on them with the left mouse button, whilst selecting ranges can be done by dragging the mouse across a range of \viewlet{}s. 267 268\begin{description} 269\item[Select all viewlets] Sets the selection to the entire \viewable{}. 270\item[Select updating viewlets(s)] Sets the selection to only those 271\viewlet{}s which have been marked as updating (either \emph{forward} 272or \emph{backward}). This option is only enabled when the Java VC has 273control, since it requires the state of the viewables to remain 274constant during the selection process. 275\item[Clear selection] Clears the selection. 276\end{description} 277 278 279\begin{figure}[htsp] 280\centering 281\includegraphics[width=3.5cm]{vcselectmenu} 282\caption{The select menu, common to all viewers.} 283\label{fig:selectmenu} 284\end{figure} 285 286\subsection{View menu} 287 288So as to facilitate visualisation of large \viewable{}s, all \viewer{}s 289have the ability to zoom in and out. All the options are self 290explanatory and will not be expanded further upon except to mention 291that the \textbf{Zoom to fit width} and \textbf{Zoom to fit height} 292options operate on the whole \viewer{} and not just the selected 293\viewlet{}s. 294 295\begin{figure}[htsp] 296\centering 297\includegraphics[width=3.5cm]{vcviewmenu} 298\caption{The view menu, common to all viewers.} 299\label{fig:viewmenu} 300\end{figure} 301 302Both the network and desktop viewers have an extra item on the view 303menu, \emph{Toggle high quality}. This toggles between quick 304rendering and high quality views, and may help to make the VC more 305reactive under high load. 306 307\subsection{Viewlet actions} 308 309Within a \viewer{}, as previously mentioned, any number of \viewlet{}s 310may be selected. These \viewlet{}s, once selected can have actions 311performed on them. The actions are selected by pressing the right 312mouse button in order to bring up the context sensitive actions menu. 313If the \viewlet{}s in the selection are of different types then all 314the available actions are displayed and once one has been selected, it 315will be applied to all applicable \viewlet{}s in the selection. This 316is a change from previous versions of the visualisation client, which 317would display only those actions common to all \viewlet{}s. 318 319\subsubsection{Hold on update} 320The most common action, which can be performed on any type of 321\viewlet{} is the \emph{Hold on updates} action, which, when set, 322indicates that the Java VC should hold control whenever any sort of 323update event is issued for the corresponding \viewable{} element. The 324\emph{Hold on updates} property of a \viewlet{} is indicated by a 325slight ``greying'' out of the \viewlet{}, or in the case of 326\viewlet{}s attached to edges in the network viewer, the edge is drawn 327``dotted'' instead of solid. 328 329Figure \ref{fig:viewlethold} shows the graphical effect of setting the 330\emph{Hold on update} property of a text \viewlet. 331 332\begin{figure}[htsp] 333\centering 334\includegraphics[width=4cm]{vcviewlethold} 335\caption{The sequence of actions required to select \textbf{Hold on update} for a \viewlet{}} 336\label{fig:viewlethold} 337\end{figure} 338 339Table \ref{tab:viewletactions} lists the available \viewlet{} actions 340and indicates for which type the actions are valid. 341 342\begin{table}[htsp] 343\centering 344\begin{tabular}{|l|p{7cm}|l|} 345\hline 346Name & Description & Applicable \\ 347\hline 348\hline 349Hold on updates & Causes the VC to hold control on forward or backward 350update events for the selected \viewlet{}s. & all \\ 351 352% \hline 353% Fit to text & Resizes the selected \viewlet{}s to exactly fit the 354% width of the widest textual representation. In order to resize 355% \viewlet{}s in a \textbf{TextTableLight} you should simply resize the 356% column by clicking on the edge of the column header and dragging, then 357% the whole column will resize. & 1+ & 0 \\ 358 359\hline 360Fade update history & Toggles using the background color of the 361viewlet to indicate recent update history. This has the effect of 362fading from green to white in the event of a forward update and from 363red to white for backward updates. & text, node, fade, edge \\ 364 365\hline 366View bounds in detail & Pops up a window detailing the original bounds and the current bounds for the single selected \viewlet{}. & bound \\ 367 368\hline 369Align bounds & Causes the selected \viewlet{}s to use the same underlying scale when displaying the bounds. This allows variables whose initial bounds were different to be visually compared. & bound \\ 370 371\hline 372Toggle horizontal/vertical range bar & Toggles the rotation of the bar for all bounds \viewlet{}s & bound \\ 373\hline 374\end{tabular} 375\caption{The available \viewlet{} actions and associated types.} 376\label{tab:viewletactions} 377\end{table} 378 379\subsection{Desktop/Network viewers} 380 381All the \textbf{table} viewers have essentially the same functionality 382-- they do not allow flexible placement of viewables and both deal 383only with 1 or 2 dimensional \viewable{}s. A more flexible \viewer{} 384is provided in the \textbf{Desktop viewer}. 385 386This \viewer{} aims to implement the common \emph{desktop} metaphor by 387providing the user with a rectangular region of the screen upon which 388\viewlet{}s can be dropped, stacked and moved around as though they 389were pieces of paper on a desk. 390 391\subsubsection{Adding viewlets} 392Typically, \viewlet{}s will be added to a desktop immediately after the 393\viewer{} has been created. To minimise the overhead of having to 394layout the \viewlet{}s each time the user's program is run (a 395potentially time consuming task), the Java VC provides an automatic 396\emph{recording and repeat} mechanism which is triggered every time a 397\viewer{} is created. Section \ref{sec:scenarios} explains this 398feature in more detail. 399 400Adding \viewlet{}s to a Desktop \viewer{} is done by selecting the 401required \viewlet{} type from the \textbf{Insert} menu. This menu 402will contain only those \viewlet{} types which are appropriate for the 403type of the \viewable{}. 404 405Once an appropriate \viewlet{} type has been selected, the range 406selection dialog will pop up, from which any combination of dimension 407ranges may be selected. 408 409Figure \ref{fig:rangeselect} shows the range select dialog for the on 410going \texttt{SEND+MORE=MONEY} example. 411 412\begin{figure}[htsp] 413\centering 414\includegraphics[width=4cm]{vcrangeselect} 415\caption{The range selection dialog for the \texttt{SEND+MORE=MONEY} example} 416\label{fig:rangeselect} 417\end{figure} 418 419At least one selection must be made from each of the dimensions, 420though it is possible to select multiple values in each dimension. 421 422Figures \ref{fig:rangeselect1d} and \ref{fig:rangeselect2d} illustrate 423the default layout of \viewlet{}s when 1 and 2 dimensional ranges are 424selected. The desktop will automatically resize to ensure that all 425\viewlet{}s fit. Attempts to move a viewlet \emph{off} the desktop 426will cause it to grow. 427 428\begin{figure}[htsp] 429\centering 430\includegraphics[width=10cm]{vcrangeselect1d} 431\caption{The result of selecting a 1D range} 432\label{fig:rangeselect1d} 433\end{figure} 434 435\begin{figure}[htsp] 436\centering 437\includegraphics[width=10cm]{vcrangeselect2d} 438\caption{The result of selecting a 2D range} 439\label{fig:rangeselect2d} 440\end{figure} 441 442Higher dimension range selections result in a stacked 2D grid, with 443progressive dimensions appearing underneath the initially visible grid. 444 445\subsection{Adding images} 446 447As well as \viewlet{}s, the \textbf{Desktop viewer} can show icons 448loaded from disk by selecting the \textbf{Image} option from the 449\textbf{Insert} menu. This brings up a file selection dialog from 450which the user may select an image file to load. The loaded image 451will be added to the \viewer{} as a small icon which is selectable and 452movable like other items on the desktop. Currently there is no way to 453increase the size of the loaded image. 454 455\subsubsection{Background images} 456In keeping with the computer GUI \emph{desktop} metaphor, the user may 457set the \emph{background} image for the desktop \viewer{}. Aside from 458making the \viewer{} look pretty this feature is intended to allow 459graphical context to be associated with the visualisation of a program. 460For example the background image could be a diagram representing the 461network topology and the values being visualised could be the flows 462through various parts of the network. By placing the \viewlet{}s near 463the appropriate nodes on the background image the user could more 464easily visualise the network flow problem. 465 466Background images are loaded by selecting the \textbf{Import 467background image} option from the \textbf{Background} menu and are 468removed by selecting the \textbf{Clear background} option. Currently 469only \textbf{GIF}, \textbf{PNG} and \textbf{JPEG} format images can be 470loaded. 471 472In keeping with our \texttt{SEND+MORE=MONEY} example, figure 473\ref{fig:sendmoremoney} shows the problem visualised on a desktop 474viewer, placed over a background image\footnote{Background image 475\copyright 1999-2003 \texttt{www.barrysclipart.com}}. 476 477 478\begin{figure}[htsp] 479\centering 480\includegraphics[width=10cm]{vcsendmoremoney} 481\caption{The \texttt{SEND+MORE=MONEY} example displayed on a Desktop 482\viewer{} with a background image} 483\label{fig:sendmoremoney} 484\end{figure} 485 486\subsection{Layout} 487 488Items on the desktop may be manually positioned by selecting (single 489click) and dragging (click-and-move) them. New items may be added to 490the current selection by holding down the \textbf{Ctrl} key whilst 491clicking with the left mouse button. Ranges of items are selected by 492clicking on the background of the desktop and dragging a selection 493rectangle around the desired items. When dragging a selection all 494items move, except lines on the \textbf{Network viewer}. 495 496It is also possible to use one of the automatic layout options 497available from the \textbf{Graph} menu. These options make use of the 498external graph layout tools \texttt{dot}, \texttt{neato} and 499\texttt{twopi} from the AT\&T Labs Research project 500\emph{Graphviz}\footnote{\texttt{http://www.research.att.com/sw/tools/graphviz/}}. 501These tools should be automatically installed as part of the 502{\eclipse} installation procedure. 503 504\subsection{Gantt charts} 505 506The Gantt chart viewer has many of the same options as the Network 507viewer previously mentioned but in addition, the \textbf{Gantt} menu 508provides access to options that control how transparent the individual 509gantt task bars are drawn. By selecting the \textbf{transparent} 510option, regions where tasks overlap will be rendered in a darker 511colour. The darker the colour, the more tasks overlap there. 512 513When either the start time or the duration of a task is a variable, 514then the task will be draw as two connected bars indicating the 515earliest \& shortest possible occurrence of the task and the latest \& 516longest possible occurrence. 517 518Above the gantt chart is a numeric scale indicating time. By clicking 519and dragging this scale can be expanded or shrunk so as to fit the 520gantt chart into the window. This feature works independently of the 521zoom. 522\begin{figure}[htsp] 523\centering 524\includegraphics[width=10cm]{vcbridgeexample} 525\caption{The VC showing the Gantt viewer for a scheduling 526example. Note the highlighted task showing the earliest start/shortest 527and latest/longest times of the task.} 528\label{fig:bridgeexample} 529\end{figure} 530 531 532\subsection{Printing} 533 534To print the current state of almost all viewers, right-click on the 535background and select the \textbf{Print} option from the popup menu. 536This will bring up the print dialog as shown in 537figure~\ref{fig:printdialog}. 538 539\begin{figure}[htsp] 540\centering 541\includegraphics[width=6cm]{vcprintdialog} 542\caption{The print options dialog box.} 543\label{fig:printdialog} 544\end{figure} 545 546 547\section{Scenarios} 548\label{sec:scenarios} 549 550To make the process of setting up the visualisation environment and 551the laying out of \viewer{}s and \viewlet{}s quicker, the Java VC 552provides a \emph{record and playback} feature where all user visible 553changes and actions that are performed following the creation of a 554\viewable{} are recorded in a visualisation \textbf{scenario}. This 555action sequence can then be optionally re-played the next time a 556\viewable{} of the same name is created. 557 558The common use case is as follows. 559\begin{enumerate} 560\item Start Java VC. 561\item Run program which creates \viewable{} ``foo'' for the first 562time. 563\item Select \viewer{}s for ``foo''. 564\item Arrange \viewer{} windows on screen, resize and scale to taste. 565Optionally insert and layout \viewlet{}s on a Desktop viewer. 566\item Press \textbf{Resume} button to continue running program. 567\item Watch visualisation of program run until \viewable{} is 568destroyed (ie. is backtracked over). 569\item Re-run program, after having made some changes. 570\item Answer \textbf{yes} to the prompt to \emph{reinstate 571visualisation preferences for viewable ``foo''}. 572\item Watch as things magically re-arrange themselves into the configuration you previously had. 573\item (optional) Make some more layout changes. 574\item Press \textbf{Resume} again. 575\item Repeat. 576\end{enumerate} 577 578To make long running visualisation projects easier and also to assist 579in running demonstrations, these visualisation preferences can be 580saved to disk and loaded back into memory at any time. The loading 581and saving of scenarios is achieved by using the \textbf{Load} and 582\textbf{Save} options of the \textbf{File} menu. The most common 583point at which a \textbf{scenario} is saved is just after laying out 584all the \viewer{}s and just before passing control back to {\eclipse}. 585It should be noted that the scenarios (settings) for many different 586viewables can be saved into/loaded from a single file, this is to aid 587visualisation of large programs. 588