Java Site MenuProgramming SectionsMiscellaneous StuffConsultancy ServicesDownloadsFeedback Form

siteViewer.class [Previous] [Home]


This is another of my applets. It can be used to display a Web site in a hierarchical format similar to a disk drive layout, with the ability to open and close layers of the site in a fashion synonymous to folders. The hierarchy information is contained within a data file whose location is passed to the applet via the FILE_NAME parameter.

The data file can be broken into 3 parts.

  1. header text
  2. image number to suffix mapping
  3. site hierarchy listed in sequential display order
The header text is a single line that is displayed as the top level of the resulting hierarchy, and can be any text you like.

In order to display different images against different types of item I decided to use suffix to image mapping rather than to specify an image for each item in the file. The second section of the file carries this mapping information and is simply a block of lines, immediately after the header text line, that each start with a number and end with a suffix. The number is the index of the image to display, the images coming from the IMAGE_FILE. This file is in transparent GIF format, and contains all the images that can be displayed against an item. Each image is 16 pixels square, the IMAGE_FILE essentially containing a table of images, with each row of the table being 16 images wide. You can supply your own IMAGE_FILE as long as it conforms to this 16 pixels square image, 16 images wide, n images deep format. Here is the file that I have used in the above example.

As you can see there are over 130 images that I can chose from by just loading this single file.

The last section of the file is where the hierarchy, URLs and display text is defined. The viewer is constructed sequentially so each level of the site hierarchy must appear one entry after the other in the file, IE all items for level A followed by all items for level B followed by level C and so on, no intermixing of levels is supported.

The format for the lines is simple. There are 2 types of line, one describing a level of hierarchy (a folder if you like), and the other an item within the current level.

Level line
The first field on this line is the hierarchy level specifier, all the text that follows this is displayed against the image. The image cannot be changed (currently) and is either image 12 (closed folder) or image 50 (open folder). The level specifier can be any text you choose as long as it does not start with a digit and does not contain spaces as these are used to separate the fields on the lines. Each level within the specifier must be separated by a / character and the last character must be a / aswell. For instance a level specifier might be:
level1/ OR
info/links/html/
Item line
The format of the item lines is similar to the level lines. The first field on the line specifies the type of the item and confirms its position within the hierarchy. This specifier starts with the same text as the current hierarchy level specifier, complete with / characters, and ends with the desired suffix, fixing the image to be displayed. The next field is the actual URL for the item and follows normal URL rules, except that it cannot contain spaces (currently) as these are the field delimeter characters. All the text that follows the URL field is displayed against the image.

The file that I used to generate the applet above can be found here. If you look at it I hope that you I hope you agree that the format for the file is quite simple and can be generated pretty quickly with a half decent text editor.


[Fiendish Home]


Content of this page Copyright © Robert Quince 1996 - 2005.
Site Comments