The Horizon package considers the parameters needed to describe a coordinate system, such as the number of axes, the width of a voxel along each axis, etc., to be metadata of the system. Different kinds of coordinate systems will need different sets of metadata to define the system. In some cases, a large number of parameters will be needed to define the system. Thus, the Metadata class provides a clean way to gather up all the necessary parameters and pass them to the constructor of a CoordinateSystem.
To illustrate this procedure, we can look at a trivial example using
the basic
[4] CoordinateSystem class which by itself does
not apply any conversion between data positions and coordinate
positions-that is, when one calls the getCoordPos method for a
particular data position, that position is returned unchanged (though
in a different form). A plain CoordinateSystem is used when no
special coordinate system is defined for the dataset, such as GIF or
JPEG images. When this kind of data is displayed with a viewer that
tracks coordinate positions (like the PosTrackerViewer, see
§4.1), only the dataset positions are displayed. The
only metadatum needed to describe this system is the number of axes.
Thus, we can construct the CoordinateSystem object in the following
way:
Metadata cmdata = new Metadata();
cmdata.put("naxes", new Integer(2));
CoordinateSystem csys = new CoordinateSystem(cmdata);
Although this example is illustrative, it is a bit more lengthy than it needs to be; plus, it is error-prone (what if we had saved ``naxes'' as a Double?). As an aid for collecting metadata specifically associated with coordinate systems, the Horizon package provides the CoordMetadata class. With this class, one can accomplish the same as above with:
CoordinateSystem csys = new CoordinateSystem(new CoordMetadata(2));This is the preferred way to construct a simple CoordinateSystem; not only is it more concise and safer, it actually sets some other default metadata as described in the next section.