Writing result printers/Aggregatable printers

Aggregatable printers
Result printer that supports the distribution parameter, and related parameters. It allows the user to choose between regular behaviour or getting a distribution of values.

For example, this result set: "foo bar baz foo bar bar ohi" will be turned into
 * bar (3)
 * foo (2)
 * baz (1)
 * ohi (1)

getFormatOutput
Such formats inherit from the class SMWAggregatablePrinter, which in turn derives from SMWResultPrinter. In most cases they should not implement getResultText, which is handled by SMWAggregatablePrinter. Instead they should implement the getFormatOutput method. It has a similar function as getResultText, since it is also responsible for constructing the formats output and returning it. However, it does not get handled a query result object, but rather an array with already processed data depending on the values of the distribution-related parameters. This data is an associative array where each array key is a label, and their corresponding value is a number.

addResources
The SMWAggregatablePrinter also has a addResources method which gets called case there are actual results, and so provides a convenient way to add resources such as JavaScript and CSS. This method is a stub in the SMWAggregatablePrinter class which can be overridden, but this is of course not required.