Java Reference
In-Depth Information
As we did in previous chapters, we choose XML to structure the informa-
tion that will be made persistent in a file. Every subclass of MapEntity has the
responsibility to serialize the content of its data structure. Similarly, classes
MapEntitySet , MapLayer and CartographicMap make their data persistent
using XML. When the user creates a cartographic map, he or she is requested
to choose the name of a file that will then be saved on the local file system.
The following tags are used to structure the file as shown in Figure 15.4.
POINT indicates the coordinates of a 2D point belonging to the boundary
of a geometric figure.
ENTITY delimits a list of point tags describing the geometric figure of a
map entity.
SET groups entities of the same type.
LAYER groups several set sections.
GISMAP records the name of the cartographic map and the location of the
image file.
15.4.3
Implementation
The implementation of the object model is quite simple. Class MapEntity
defines three abstract methods that are implemented in every subclass in
order to handle the construction of the entity's geometric figure (method
<GISMAP MAPNAME # "Imperial Rome" FILENAME # "C:\GIS\images\Rome.jpg"/>
<LAYER NAME # "Settlements" COLOR # "Blue">
<SET TYPE # "SITE" >
<ENTITY>
<POINT X # "119" Y # "89"/>
</ENTITY>
</SET>
<SET TYPE # "LINK">
<ENTITY>
<POINT X # "286" Y # "236"/>
<POINT X # "269" Y # "252"/>
<POINT X # "263" Y # "260"/>
</ENTITY>
</SET>
<SET TYPE # "AREA">
<ENTITY>
<POINT X # "327" Y # "265"/>
<POINT X # "355" Y # "266"/>
<POINT X # "350" Y # "274"/>
</ENTITY>
</SET>
</LAYER>
</GISMAP>
Figure 15.4 An XML file that records the geometric description of a cartographic
map
 
 
Search WWH ::




Custom Search