Printing – part 1

One of the major gripes about V1 was the somewhat inflexible and limited printing mechanism. No-one was satisfied (including me). You could never get your plan objects and or observations printed the way you wanted them. More annoyingly, you had to waste paper to see what you were going to get.

Added to problem was the really nasty printing code within AstroPlanner. Making changes to it was a nightmare, and required five cups of coffee (and sometimes a few shots of the hard stuff) to render me brave enough to open up the code.

V2 changes all that. The scripting mechanism is now called to do the printing. This has many benefits:

  • Making changes means that only a script needs to be changed (in general). Script-savvy users can change the printing code for themselves. A new release of the application isn’t required.
  • User-contributed printing scripts will open up the app to all sorts of new and improved printing concepts. See below.
  • All printing now comes with a built-in “preview” so you can see the entire document before committing it to dead trees.

Let’s see what it entails. Firstly there’s a new print dialog that appears when you use File->Print…

print1a.jpg

The first thing you’ll notice (well, apart from the fact that it’s completely different) is the Printing script and Task popups at the top. There will be default scripts built into AstroPlanner, but any other printing scripts you might have developed or downloaded will appear in the popup. Each script can handle one or more printing tasks (in this case, printing Objects, Observations, Forms, etc.).

The other parameters are all defined by the script itself. More below.

Once you’ve set up your parameters to your liking (yes – they’ll be remembered), you click the Preview… button to see the result, in the full resolution of your printer.

print1b.jpg

You can scroll through the pages, and when you’re ready, click the Print… button to dump to dead trees.

So, what juicy new ideas can you come up with? Here’s some that come to mind:

  • Michael Portuesi’s Print Finder Charts script can be quite easily (sic) converted into a printing script. Then you’ll have finder charts “built-in” rather than as a separate script with a separate interface.
  • Specialty reports for double star observers, that can combine all the observations of a particular star together, compute statistics, and even print reports formatted to looks like (for example, BAA or Web Society standards).

…and many other weird and wonderful ideas.

How is this all done?

Magic? In the words of Arthur C. Clark (1917-2008. R.I.P): “Any sufficiently advanced technology is indistinguishable from magic.”

Well, perhaps not magic. Just code. The going gets nerdy from here out, so feel free to abandon this posting if you aren’t a script kiddie.

I made mention in a previous posting that there are now “special” scripts for printing. These are largely identical to normal scripts, except that:

a. They contain a description of the user interface elements.

b. They make use of the PrinterCanvas object rather than a plain Canvas object.

The user interface is defined using XML, which is added to the script as a specially formatted set of comments.

print1c.jpg

The printing mechanism extracts this definition from the script and uses it to set up the dialog interface. It’s then up to the program part of the script to use those settings and options to figure out what to print.

By using the PrinterCanvas (a subclass of Canvas) you can access all the options and settings. A lot of the common stuff is handled for you (such as printing headers and footers). The rest is up to you.

Sure getting the scripting going to the extent that it’s equivalent to (or better than) the existing V1 mechanism requires a fairly complex script. However, your script will probably be a lot simpler.

Yes, I will make the default script code available for you to look at, modify, etc.

I’m still working on printing the observation database, so there might well be a Part 2 of this posting later.

…and, as usual: Any or all of this might change between now and the final release.