JDisplay Listing Colouriser  JDisplay Listing Colouriser

go to home page Applets full screen, hide local find menu Google search web for more information on this topic jump to foot of page translate this page with Babelfish ©1996-2009 Roedy Green, Canadian Mind Products

Introduction

JDisplay stands for Java Display. It started out as a way to display Java source code listings in a variety of colours, fonts, sizes, and weights to help make them more presentable and readable on a website. Then I expanded it to handle HTML, bat, btm, SQL, ini, csv, and *.properties files.

Why would you use it? For the same sorts of reasons you use colours and fonts in an IDE like IntelliJ or Eclipse. They make your code much easier to understand for visitors to your website. The techniques used are more much more efficient of bandwidth than displaying images.

There is no server-side code used. Java utilities parse the code snippets into compact binary tokens, assigning colours, fonts, sizes and weights to each token. Then the tokens can be rendered three ways:

  1. using a Java Applet. This is usually best for very large listings.
  2. as piece of CSS style-decorated HTML code you include in your html as an iframe. This is usually best for intermediate listings.
  3. inline in your HTML. This is usually best for short listings. The problem, in the process of editing the html it is fairly easy to damage the generated listings. They must be regenerated before every upload.
I have been using the JDisplay suite of utilities for many years. I did not write it for public use. I offer it on an as-is basis. The code itself in well documented, but there is no step-by-step documentation on getting it to work.

I presume the user is familiar with bat and ant files and Java building.

I have not included the enormous HTML static macros package which I use for deciding the sizes and display rendering method for each snippet, though I did include the code to make those decisions hooked into your own framework. At some point in the near future I will make the htmlmacros package available for download separately.

The parsers are rough and ready. They need to work on code snippets and erroneous code, not perfect code the way a standard parser does. If improve the parsers, or add new ones, please pass them along for the public distribution.

JDisplay is enormously more complicated than it appears on the surface. You can spelunk and discover all manner of interesting code you can cannibalise. There are finite state machines, clipregion sensitive Canvas rendering, HTML generators, ObjectStreams…

Advantages

Disadvantages

Packages

com.mindprod.compactor compacts html to remove excess white space.
com.mindprod.entities interconvert && etc.
com.mindprod.filter set of FilenameFilters
com.mindprod.htmlmacros jdisplay.java part of a large static macros package to expand macros embedded in HTML before the files are uploaded to the server.
com.mindprod.hunkio does IO in big hunks.
com.mindprod.jdisplayaux static macro to decide which of three ways to render a given snippet and inserts the appropriate HTML to do that into your HTML.
com.mindprod.jdisplayorphans detects orphans not referenced by any of your HTML.
com.mindprod.jprep parses the snippets of code, producing binary *.ser files.
com.mindprod.jtokens Tokens and parsers for various languages rendered.
mindprod.css style sheet that controls the fonts/tokens/sizes

Program Flow

  1. Run jprep to parse snippets to binary *.ser files and iframe/*.html files.
  2. Manually decide which of three methods to use, and insert the appropriate HTML. (or rig up some code to do this automatically using code in JDisplayAux). To see what the embedded HTML looks like see Java Presenter Student Project which describes how JDisplay works inside. This HTML was generated with static macros. You might do the same, or compose the embedded HTML directly.
  3. Upload to website.
  4. View code inline, as iframe, or via invocation of JDisplay Applet.

Examples

  1. Listing expanded inline as HTML with classes for each token. Style sheet mindprod.css controls the colour, font, size and weight. HTML looks like this
    The display looks like this:
    ...
    
    Border b1 = BorderFactory.createLineBorder( Color.black );
    Border b2 = BorderFactory.createEtchedBorder( EtchedBorder.LOWERED );
    Border b3 = new BevelBorder ( BevelBorder.LOWERED, Color.red );
    
    JPanel panel = new JPanel();
    panel.setBorder( b2 );
  2. Listing using a separate iframe in HTML with classes for each token. Style sheet mindprod.css controls the colour, font, size and weight. The HTML to include an iframe JDisplay looks like this:
    The display itself looks like this:
  3. Listing using the JDisplay Applet to render a *.ser binary token file. The HTML to invoke an Applet to display the JDisplay binary token *.ser file looks like this:
    The display itself looks like this: view

Prerequisites

If, jdisplay, the above Program Listing Display Java Applet does not work…

  1. This Java Applet needs Java 1.5 or later, best version 1.5.0_22 or later, version 1.6.0_17 recommended and a recent browser.
  2. You should see the Applet above looking much like the screenshot. If you don’t, the following should help you get it working:
  3. If you are using Microsoft Internet Explorer, try another browser. Seriously. Microsoft has taken great pains, over and over, to screw up Java and every other multi-platform standardisation.
  4. If you are using Internet Explorer 7 or 8, you must allow blocked content permission for Active X to run. This also gives permission to Java to run. Click the Information bar, and then click Allow blocked content. Unfortunately, this also allows dangerous ActiveX code to run. However, you must do this in order to get access to perfectly-safe Java Applets running in a sandbox. This is part of Microsoft’s war on Java. Don’t put up with it! Use a different browser.
  5. Especially if this Applet has worked before, try clearing the browser cache and rebooting.
  6. To ensure your Java is up to date, check with Wassup. First, download it and run it as an application independent of your browser, then run it online as an Applet to add the complication of your browser.
  7. If the above Applet does not work, check the Java console for error messages.
  8. If the above Applet does not work, you might have better luck with the downloadable version.
  9. If you are using Mac OS X and would like an improved Look and Feel, download the QuaQua look & feel from randelshofer.ch/quaqua. UnZip the contained quaqua.jar and install it in ~/Library/Java/Extensions or one of the other ext dirs.
  10. If you still can’t get the program working click HELP for more detail.
  11. If you can’t get the above Applet working after trying the advice above and from the HELP button below, have bugs to report or ideas to improve the program or its documentation, please send me an email atemail Roedy Green.
Java powered   Get New Java  Get New Browser   Help
PackageVersionReleasedLicenceLanguageNotes 
jdisplay
JDisplay
4.2 2009-09-30 free Java
summaryfactsscreenshotbrowse source repository for the current version of JDisplay. Displays Java, HTML, bat, SQL, ini, csv, properties... source.
download JDisplay Java source and compiled class files to run on your own machine as an Applet.

First install the most recent Java.

To install, extract the zip download with WinZip, (or similar unzip utility) into any directory you please, often J:\ — ticking off the “user folder names” option.

To check out the corresponding source from the Subversion repository, use the TortoiseSVN repo-browser to
access jdisplay source in repository with [Tortoise] Subversion client on wush.net/svn/mindprod/com/mindprod/jdisplay/.

download ASP PAD XML program description for the current version of JDisplay.

JDisplay is free. Full source included. You may even include the source code, modified or unmodified in commercial programs that you write and distribute. Non-military use only.
   
 

Directory Structure

Let’s say your html lives in:

E:\mindprod\jgloss

Then the corresponding program listing snippets will live in:

E:\mindprod\jgloss\snippet

the generated *.ser files live in

E:\mindprod\jgloss\snippet\ser

and the generated iframe *.html files will live in

E:\mindprod\jgloss\snippet\iframe

All off this must be uploaded to your website.

Resolving Problems

All code should be included with the exception of the htmlmacros package. If you find something missing you can probably download it. In any case, please let me know, so I can include it.

If you have questions, please feel free to ask atemail feedback to Roedy Green or Canadian Mind Products. It will help me put together some minimalist documentation. If you are interested in using JDisplay in other contexts (e.g. without htmlmacros), I will be willing to help and write interfacing code at no charge. One PhD student from Germany has used JDisplay to automatically colourise source code listings embedded in JavaDoc. He has not yet publicly released the code. I wrote JDisplay originally primarily to demonstrate my vision of the future of what program listings should look like in advanced editors that I call SCIDs. I would love to see JDisplay-like logic in an IDE editor.

colouriser
downloading JDisplay
Java Presenter Student Project
JDisplay Download
JDisplay Overwiew
other downloads
troubleshooting JDisplay


CMP homejump to top You can get the freshest copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/applet/jdisplay.html J:\mindprod\applet\jdisplay.html
CMP logofeedback Please email your feedback for publication, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email
mindprod.com IP:[65.110.21.43]
view BlogYour face IP:[38.107.191.104]
You are visitor number 11.