
This is an Entrance chart on an iPhone. It was generated by a Groovy script using the Entrance Java API to plot data from a RAWS weather station.
The script takes advantage of certain Apple iPhone CSS extensions and Joe Hewitt’s iUI framework to make the page behave a lot like like a native iPhone application. If you have an iPhone, you can see the result here here
Groovy and the Entrance API
Groovy is a scripting language for the Java platform. To use the Entrance Java API from Groovy scripts drop two jars, ‘entrance.jar’ and ‘cotta.jar’, into the Groovy ‘lib’ directory. If you are running Groovy from the command line, put them in:
(your home dir)/.groovy/lib
To use the Entrance API with the Groovy servlet, put them in:
(your webapps)/groovy/WEB-INF/lib
Scripts you write using the Entrance desktop application can also be run from the Entrance API using EntrancePlot. These two methods take the path to an Entrance script file as an argument:
public static String generatePNG( Connection con,
String pngFile, String scriptFile,
boolean deleteIfExists)
public static String generateTempPNG(Connection con,
String scriptFile)
and this method takes the script itself as a String argument:
public static String generatePNG(Connection con,
String pngFile,
String script);
Here’s the usual pattern for drawing Entrance charts with Groovy:
import com.dbentrance.entrance.EntrancePlot
import groovy.sql.Sql
sql = Sql.newInstance(
"jdbc:mysql://localhost/test", (user),
(password), "com.mysql.jdbc.Driver")
script = """
... a PLOT script ...
"""
EntrancePlot.generatePNG(sql.getConnection(),
"/usr/local/tomcat/webapps/groovy/bndc1_files/wind.png",
script);
... then refer to the PNG file in HTML output ...
Note that this technique will work for any database with a JDBC driver. The complete groovy script for the example above is here.
Sizing the charts
Use PAGE and FRAME in an Entrance script to size charts for mobile devices like the iPhone:
PAGE 0 0 (width) (height)
FRAME (x0) (y0) (x1) (y1)
Both take pixel coordinates. In pixel coordinates the upper left hand corner of the display is (0,0),. Coordinates increase going down and to the right.
Use PAGE to set the width and height of the output bitmap, and use FRAME to locate the chart on the page.
The first two coordinates of FRAME specify the upper left hand corner of the chart. The last two specify its lower right hand corner.
Once you have a PAGE and FRAME combination you like, you can copy and paste it into other scripts. These sizes worked well to for fitting two charts at a time in iUI on an iPhone screen:
PAGE 0 0 275 150
FRAME 46 5 245 125
To completely fill the iPhone display in landscape mode without iUI, you could use:
PAGE 0 0 320 356
Fonts
Generally, the default font sizes should work for both the screen and iPhone output. If you find you need to tune font sizes, use FONT and TITLEFONT::
FONT (font family) (style) (size)
TITLEFONT (font family) (style) (size)
Both take a font family, which can be one of the platform-independent names: Serif, SansSerif, Monospaced, Dialog, and DialogInput, or another font family names supported by your platform. ‘Style’ can be PLAIN, BOLD, or ITALIC and the font ’size’ is set using point sizes. Generally speaking a font size that is legible on the display screen will also be legible on the iPhone.
Black Backgrounds
Use BACKGROUND, FOREGROUND and GRIDLINES to change colors:
BACKGROUND BLACK
FOREGROUND GRAY
GRIDLINES GRAY
A Note About the iPad
You can also use Entrance API to generate charts for the iPad. The iPad display is 1024 x 768 and 132 pixels per inch. I haven’t tested it, but I think you will want to double Entrance font sizes that look good on the desktop display when sending them to iPad. More to come on the iPad.
The latest version of Entrance can be downloaded from the main page.