Java Reference
In-Depth Information
public class
CartographicMap
extends
JPanel {
private
ArrayList layerList
#
new
ArrayList();
private
MapLayer currentLayer
#
null
; // selected layer
private
Image mapImage
#
null
;
private
String fileName
#
null
;
private
String mapName
#
null
;
private boolean
sitesVisible
#
true
; // true for entities
private boolean
linksVisible
#
true
; // to be displayed
private boolean
areasVisible
#
true
; // on the map image
public void
createMap(String fileName, String mapName) { }
private void
showMap() { }
public void
saveMap(String mapName) { }
public void
openMap(InputStream inStream) { }
public void
addLayer(String layerName, String colorName) {
currentLayer
#
new
MapLayer(layerName, colorName);
layerList.add(currentLayer);
}
public
String[] getLayerList() { }
public void
setCurrentLayer(String layerName) { . . . }
public
MapLayer getCurrentLayer() {
return
currentLayer; }
public void
setLayerVisibility(String name,
boolean
v) { }
public void
setEntityVisibility(
boolean
sites,
boolean
links,
boolean
areas) { }
}
Class
Editor
is the main class of the graphical editor. It builds on the
graphical components of the
java.awt.
*
and
javax.swing.
*
packages that
implement the menu and the mouse handlers used to create and edit a
cartographic map and to select its entities. We do not show the code, since
it is quite standard and could be created using any commercial CASE tool.
15.4.4
Test
The test cases should verify the correct behaviour of the graphical interface
and the correspondence between data inserted by the user through the
interface, the data displayed on the screen, and the data saved on the XML
file. In particular it is necessary to verify that:
The creation of new maps, new layers and new entities is handled
properly.
■
Layer visibility and entity visibility are handled properly through the
menus of the graphical interface.
■
Only one layer and one type of entity are active at a time during the
editing process.
■
The vertices of the entities' shapes correspond to the selected mouse
positions.
■
For each map the user can save the list of layers and entities on an XML
file.
■