A selection of reports comes with the GenealogyJ distribution and can be found in the report-directory inside the GenJ installation directory.
There are multiple ways of intergrating a report with GenJ. Generally every report found in the report-directory (or one of its sub-directories) will be loaded and displayed in ReportView. There the user can read about the report's author and operation description, set report-options and run them individually.
A report can also be run by opening the context-menu for a Gedcom element in the UI. Depending on the selected element (for example an entity, a property or a Gedcom-file itself) reports that can accept this context as input are presented. The simplest way for a report to declare that it can run on a given Gedcom object is by declaring any of these methods:
start(genj.gedcom.Gedcom aGedcomInput) start(genj.gedcom.Property aPropertyInput) start(genj.gedcom.Property[] propertiesInput) start(genj.gedcom.Entity[] entitiesInput) start(genj.gedcom.Entity anEntityInput)
If the user selects the right input those reports are automatically matched for selection to be run.
Another more advanced way to declare applicability to be run is to override:
String accepts(Object context)
The report is expected to return a text that describes the report's action on given context or null if the input is not compatible. The report still has to declare one of the start-methods above or override this basic method (should normally not be necessary):
String accepts(Object context)
Reports have several ways of interacting with the user. As a basic and very easy to use method they can generate output by simply dumping text to a stream that is displayed in ReportView (see println()).
Alternatively the start method can return an instance of one of the following types which is then presented to the user:
Type | Result |
java.net.URL | Platform's browser is opened to show the URL |
genj.chart.Chart | Chart is shown in report view |
javax.swing.JComponent | Component is shown in report view |
genj.fo.Document | User is asked for document formatting and the result is shown |
java.io.File | Platform's default viewer for file is opened |
genj.view.ViewContext.ContextList | List of Gedcom objects is shown to user in report view |
Reports can also ask for input:
All of these methods are defined in the super-class Report that every custom Report needs to extend.
Since Reports are written in Java they have to be compiled before they can be used through GenJ. This can be achieved by running the Recompile Reports reports from within the UI and then clicking on the reload button in the Run-dialog of Report View.