Gravy Pressure Gauge

After seeing A Close Shave, I decided that my web pages needed an oscillating gravy pressure gauge like the one on the huge pot pie maker, so I built one up in Java. The reading on the dial doesn't mean anything; the needle just makes a random walk (although it would be fairly straightforward to tie it to some value....). It's just a random bit of surreality to add to a web page.

This is surreality version 2, check near the bottom for non-square gauges.

Stupid JavaTM Trick

The one I finally settled on is much more parameterizable than it really needs to be, but this just makes a little easier to tailor to other pages. Parameters are specified as <param> tags in the <applet> tag. The parameters are:

Background
An integer that gives the background color. This is a 3 byte red, green, blue color value, best expressed in hex, e.g., ffffff is white, ff0000 is red
PointerColor
The color to use for the pointer as an integer
LabelColor
The color to use for the labels (text) as an integer
DialColor
The color to use for the dial markings as an integer
WarningColor
The color to use for the warning area as an integer
Ticks
Number of tick marks on the dial
WarningTicks
Number of tick marks in the warning area
NumLabels
Number of lines on the dial. Each line is given by a Labeln parameter.
FontName
Java font name for the text.
FontSize
Java font size for the text (an integer).
UpdateFreq
How often to update the dial (in ms)
TickZero
Value of the lowest tick mark
TickWidth
Value added for each tick

For example, a gauge labelled Vacuum Pressure with a blue warning area woule be set up like this:

Stupid JavaTM Trick
    <object codebase="/~faber/java/gravy" classid="java:Gravy.class"
    archive="gravy.jar" height="200" width="200">
    <param name="Background" value="ffffff"/>
    <param name="WarningColor" value="0000ff"/>
    <param name="NumLabels" value="2"/>
    <param name="Label1" value="Vacuum"/>
    <param name="Label2" value="Pressure"/>
    Stupid Java<sup><small>TM</small></sup> Trick</object>
    

An example of changing the ticks is:

Stupid JavaTM Trick
    <object codebase="/~faber/java/gravy" classid="java:Gravy.class"
    archive="gravy.jar" height="200" width="200">
    <param name="Background" value="ffffff"/>
    <param name="PointerColor" value="ff0000"/>
    <param name="Ticks" value="5"/>
    <param name="TickZero" value="-2"/>
    <param name="TickWidth" value="1"/>
    Stupid Java<sup><small>TM</small></sup> Trick</object>
    

The old version didn't respond well if the allocated sizes weren't square. I've updated the code, and non-square gauges should work fine. Be advised, this is done by using the java.awt.geom affine transform features pretty extensively, and one side effect is that font size changes should be largely redundant. In any case, changing font sizes may have odd effects. Here's a non-square gauge.

Stupid JavaTM Trick
    <object codebase="/~faber/java/gravy" 
       classid="java:Gravy.class" archive="gravy.jar"
       height="500" width="200">
    <param name="Background" value="ffffff"/>
    <param name="NumLabels" value="2"/>
    <param name="Label1" value="Tall"/>
    <param name="Label2" value="Gauge"/>
    Stupid Java<sup><small>TM</small></sup> Trick</object>
    

Feel free to play with them. The source and a jar file are available. Don't sell them in whole or in part without asking me. If you use them on your web pages, a link back here would be nice. And I always enjoy hearing that someone's using them.

This page written and maintained by Ted Faber.
Please mail me any problems with, or comments about this page.
Lunabase logo designed by and licensed from Roger Strunk
PGP Public Keys