Sunday, 21 June 2009

Painting Pictures

As part of the grand scheme of releasing new versions of all my products in advance of getting down to completing my new reporting tools, this week I've turned my attention to mvScan. This is a set of analytical tools for scanning a UniVerse system and determining all the impacts: programs accessing files, subroutine calls (including external function calls), routines called from dictionaries, PROCs accessing files, tools called from menus - all the bits and pieces that make up a live UniVerse application.

The analytical part derived from some tools I've been using in a consulting mode, and so when I came to take a new look at them last month, they were capable but not particularly user-friendly. And whilst they generate a goldmine of information, navigating that takes some work. So I needed a new way to present the results.

Part of that job was already done: the tools produce technical documentation in the form of HTML pages - handy since anyone can view them and they can drill up and down through the relationships. But I wanted something more graphical to present these links as a chart or diagram.

UniVerse and Graphics



Now whilst UniVerse has plenty of APIs for working with data and for interacting with remote systems, graphics has never been part of the mix. Normally I would tackle this by adding an external library, something along the lines of mvPDF that runs as a service backed by calls made from UniVerse Basic. Using this technique I could simply harness existing Windows graphics libraries to generate images. But it seemed a little cumbersome for what I was looking for, and in any case there is an additional complication in the fact that I want these to include the same links. Clicking a subroutine in a diagram should take you to the map for that subroutine, and so forth. This would mean not only creating an image, but an image map to overlay, which seemed to be the wrong choice.

So I decided that I needed a way to generate web images directly from UniVerse Basic. That means using a format that can be easily assembled by a language that is predominently string based and lacks the sort of feedback required for image placement.

Which leads to two real possibilities: markup languages like XAML or a dedicated image language like SVG.

Vector Graphics



I had not really appreciated SVG (Scalable Vector Graphics) before this exercise. This is an XML based definition of - well, scalable vector graphics. And it has the great benefit of being extremely simple.

SVG is presented as an XML document. Despite being a W3C recommendation, it is noticeably absent in Internet Explorer, but can be viewed using a free plugin from Adobe. The syntax consists of graphics primitives: lines, rectangles, ellipses, polygons, polylines, paths and text. Graphics elements can be combined into reusable definitions - perfect for a diagram holding a limited pallate of symbols. And the rendering of those elements: fill, stroke, colours etc. all follows regular CSS. Even better, you can include regular HTML style anchor tags to provide hot-spotting.

So I'm now working towards my goal of generating diagrams directly from UniVerse Basic. When the new evaluation version of mvScan is released, you can see how I got on.

0 comments: