The Model-View-Controller architecture
The LuciadLightspeed API is based on the Model-View-Controller (MVC) architecture. The underlying concept of the MVC architecture is to separate the data (model), representation of the data (view), and the user interaction (controller) from each other. This separation results in a simpler design of the application and a higher flexibility and re-usability of code.
The MVC parts of the LuciadLightspeed API are defined as follows:
A LuciadLightspeed model stores and describes geographical data regardless of how to visualize and interact with the data. For example: a model contains the location of a number of hospitals together with additional information such as capacity.
A LuciadLightspeed view contains all information for the representation of data contained in LuciadLightspeed models. A view does not contain data itself. For example: in case of the hospitals, a view represents the location of a hospital with a red cross.
A LuciadLightspeed controller interprets user interaction and performs the required action on LuciadLightspeed models and views regardless of the type of model and view. For example: in the case of the hospitals, right-clicking on a red cross pops up information such as location and capacity.
Separating the different parts of the application allows you to re-use objects for different purposes and redefine objects without changing other objects. You can, for example, change a view without making changes to the models represented in the view. Or you can redefine user interaction on a view without changing the view. Object reuse shortens the time for writing an application. In addition, it enhances a consistent functionality and design of all your applications.
Using the MVC architecture allows you to focus on the definition of the objects instead of solving design issues.
Figure 1, “The MVC parts of the LuciadLightspeed API” depicts the MVC architecture of the LuciadLightspeed API. LuciadLightspeed and its MVC architecture describes the MVC parts of the LuciadLightspeed API in more detail.
LuciadLightspeed and its MVC architecture
The LuciadLightspeed API is based on the MVC architecture and separates the functionality for the model, view, and controller parts as shown in Figure 1, “The MVC parts of the LuciadLightspeed API”. The LuciadLightspeed API strictly separates the functionality for:
Modeling data (model)
Visualizing data (view)
Interacting with the view or with the data (controller)
The sections below provide detailed descriptions of LuciadLightspeed models, views, and controllers, as well as instructions on how to build these components.
A LuciadLightspeed model (
ILcdModel) is a container for a set of geographical data of the same type, for example cities, roads, elevation data, flight plans,
and so on. There are two types of geographical data:
Vector data that consists of geometries such as points, lines, circles, and polygons. Examples of vector data are streets, buildings, airports, radars, and so on.
Raster data that consists of a grid of cells. Examples of raster data are aerial photographs, satellite images, weather data, elevation data, and so on.
To define the model data, or domain objects, in a uniform way, each
ILcdModel is associated with:
A model reference(
ILcdModelReference) that specifies the coordinate reference system that is used for locating the model data on earth. All LuciadLightspeed models need to be associated with a reference system. Otherwise, it is not possible to determine the location of the data. LuciadLightspeed coordinate reference systems provides more information on the type of reference systems that are used as model reference.
A model descriptor (
ILcdModelDescriptor) that provides additional information, or metadata, about the model data. The metadata usually specifies the source of the data, the data type, and a name to refer to the data in the view (the display name). Depending on the type of data, the model descriptor may include information about the content and/or the structure of the data or make metadata accessible that is stored with the data.
A model metadata (
TLcdModelMetadata) object that provides advanced metadata information about the model data. This object supports ISO metadata, and can be obtained without decoding the model itself.
Figure 2, “A LuciadLightspeed model” illustrates a LuciadLightspeed model and its associated components.
The model data can be used in the application as:
Background data: the data is used as reference for the data that you want to interact with (business data). Background data, such as terrain or elevation data, is typically loaded from an external source.
Business data: the data that you want to interact with. Business data is usually visualized together with background data and can be loaded from an external source or created by the application itself.
A LuciadLightspeed view allows you to visualize the data of one or more LuciadLightspeed models in a graphical form. LuciadLightspeed offers two types of views:
- GXY views
are views that display graphics in 2D, also known as classical 2D view. The abbreviation GXY refers to the graphical 2D screen coordinates. A GXY view is represented by
- Lightspeed views
are views that can display in 2D as well as in 3D, and use the OpenGL API to perform their rendering. A Lightspeed view is represented by
Both view types are subtypes of the interface
Associated with a view are:
A world reference: To represent geographical data in a view, all data is transformed on the fly into a common coordinate system. This reference system is called a world reference. For 2D views, it is typically defined by a map projection to map the curved surface of the earth to the flat surface of the view. For 3D views, it is typically a geocentric coordinate system. Coordinate systems provides more information about the types of reference systems that are used as world references.
One or more layers: To properly visualize the model data in a LuciadLightspeed view, each model is placed in a LuciadLightspeed layer. These layers are associated with painters and editors:
A painter takes care of displaying the model data in a view. The type of painter depends on the type of model data. LuciadLightspeed provides painters and layers for the most commonly used vector and raster data.
An editor that takes care of editing the data in a view.
A set of properties that indicate, for example, whether the layer data is visible, selectable, and editable in a view.
Figure 3, “A LuciadLightspeed view” illustrates a LuciadLightspeed view and its associated components.
Your choice of view type determines the layer type you need to use. To create layers in a GXY view, you need to use GXY layers. To create layers in a Lightspeed view, you need to use Lightspeed layers. However, adapters are available that allow you to combine GXY and Lightspeed technology.
For more information about the differences between GXY and Lightspeed views, see this article.
LuciadLightspeed provides implementations based on the Java Abstract Windows (AWT), the Swing and the JavaFX toolkit, as well as implementations to perform off-screen rendering.
A LuciadLightspeed controller defines the action that a user can perform on a view or on data visualized in the view. Multiple controllers can be defined in a LuciadLightspeed application but only one controller can be active in a view. To perform a controller action, a user typically uses the mouse, clicks on a button, or selects a menu item. LuciadLightspeed provides a number of commonly used controllers, for example, for selecting and editing objects visualized in a view and zooming in or out on a view.