The Object Hierarchy

Now that we have created our first ZoomMapZoomMap, let us examine how it relates to other kinds of ObjectObject before investigating what we can do with it.

We have so far indicated that a ZoomMap is a kind of Object and have also mentioned that it is a kind of MappingMapping as well. These statements can be represented very simply using the following hierarchy:


\begin{terminalv}
Object
Mapping
ZoomMap
\end{terminalv}

which is a way of stating that a ZoomMap is a special class of Mapping, while a Mapping, in turn, is a special class of Object. This is exactly like saying that an Oak is a special form of Tree, while a Tree, in turn, is a special form of Plant. This may seem almost trivial, but before you turn to read something less dull, be assured that it is a very important idea to keep in mind in what follows.

If we look at some of the other Objects used by the AST library, we can see how these are all related in a similar way (don't worry about what they do at this stage):


\begin{terminalv}
Object
Mapping
Frame
FrameSet
Plot
UnitMap
ZoomMap
Channel
FitsChan
XmlChan
\end{terminalv}

Notice that there are several different types of Mapping available (i.e. there are classes of Object indented beneath the “Mapping” heading) and, in addition, other types of Object which are not Mappings—Channels for instance (which are at the same hierarchical level as Mappings).

The most specialised Object we have shown here is the PlotPlot (which we will not discuss in detail until ยง21). As you can see, a Plot is a FrameSetFrameSet... and a FrameFrame... and a Mapping... and, like everything else, ultimately an Object.

What this means is that you can use a Plot not only for its own specialised behaviour, but also whenever any of these other less-specialised classes of Object is called for. The general rule is that an Object of a particular class may substitute for any of the classes appearing above it in this hierarchy. The Object is then said to inherit the behaviour of these higher classes. We can therefore use our ZoomMap whenever a ZoomMap, a Mapping or an Object is called for.

Sometimes, this can lead to some spectacular short-cuts by avoiding the need to break large Objects down in order to access their components. With some practice and a little lateral thinking you should soon be able to spot opportunities for this.

You can find the full class hierarchy, as this is called, for the AST library in Appendix A and you may need to refer to it occasionally until you are familiar with the classes you need to use.