FOray Users
Module Users

FOray Modules: FOray Graphic



FOray Graphic is an implementation of the aXSL Graphic interfaces, which should be consulted for details on the general API, sample code, etc. Although it is possible to use the FOray Graphic package directly, there is probably no good reason to do so. If the aXSL Graphic interface is not sufficient for your needs, we recommend that you suggest changes to it instead of using the FOray Graphic package directly. This allows your application to use any aXSL-compliant graphic system without making substantial changes to your code.

Bootstrapping FOray Graphic

The FOray-specific tasks that are needed to bootstrap the use of FOray Graphic are as follows:

  1. Obtain a GraphicServer4a instance. GraphicServer4a is an aXSL GraphicServer implementation, and can be instantiated using its constructor. It is safe to create multiple instances, but this should be necessary only in extremely sophisticated environments. The server can cache graphics for efficiency, so client applications may wish to reuse the GraphicServer for multiple documents.
  2. Register any custom graphic types using GraphicServer4a.registerFactory(final GraphicFactory factory). Factories are automatically loaded during server construction for the standard graphic types. Register additional factories to support additional graphic types or to replace a standard factory.
  3. Register any custom output types using GraphicServer4a.registerGraphicOutputFactory(GraphicOutputFactory4a). Output factories are automatically loaded during server construction for the standard output types (currently PDF and PostScript). Register additional output factories to support additional output types or to replace a standard output factory.

Once these tasks are accomplished, all downstream processing is documented in the aXSL Graphic API. In general, this consists of using passing a URL to the GraphicServer.makeGraphic() method and getting a Graphic instance back, which can then be used by your client application.

Here is some sample bootstrap code:

// Instantiate the server
Log logger = org.foray.common.Logging.makeDefaultLogger();
GraphicServer server = new GraphicServer4a(logger);

Known Limitations

  • The axslGraphic Graphic interface exposes two methods for obtaining the actual sample content for raster image files. The first, getContent(), returns the sample content in a standard format, that is, the content is probably filtered by FOray to get it into that standard format. The second, getRawSamples(), returns the sample content in the native file format. The FOray implementation currently supports only getRawSamples() for JPEG and TIFF, and supports only getContent() for BMP, GIF, and PNG. Use of the unsupported methods will result in an exception. The exception can be avoided by testing the image type before using the method.

    For PostScript and PDF output, these limitations should not be a problem, because output from these methods is suitable for those formats, the only difference being that JPEG and TIFF need to be treated as already filtered (compressed), while the other formats may need compression filters applied to them as they are embedded in the output. However, other output formats or uses may need support for the other methods, which we hope to add in the future. Post a message on the developer mailing list if this limitation affects you.