This guide describes how you can convert an existing GXY view-based application to a Lightspeed application. Refer to Benefits of Lightspeed views for more information on the benefits of using Lightspeed rendering.

Converting a GXY view to a Lightspeed view and Converting a GXY layer to a Lightspeed layer highlight the most important similarities and differences you must keep in mind when moving your view and your layers.

Converting a GXY view to a Lightspeed view

In many aspects, a Lightspeed view is similar to a GXY view: it also has a specific world reference and separates its content into layers that are added, removed, moved and retrieved, just as in an GXY view. TLspViewBuilder provides a convenient way to set up a Lightspeed view, as demonstrated in Creating the map.

The default Lightspeed view (TLspAWTView), unlike its GXY counterpart (for example, TLcdMapJPanel), is in itself not a Java Component. This means that existing instanceof checks and cast operations in your code may fail. Instead, you can retrieve the view’s host component by calling the getHostComponent method. As an added convenience, the view also exposes an overlay panel to insert Java Component instances on top of the view (see the getOverlayComponent method).

A Lightspeed view comes by default with a controller for panning, zooming, selecting and editing, but you can create your own controller or chain of controllers. For more information, see Introduction to controllers. In addition, TLspViewNavigationUtil offers functionality to fit and center on layers.

Setting the number of cached background layers is no longer necessary in a Lightspeed view: a Lightspeed layer can indicate whether it is a background layer or not. See the getLayerType method in ILspLayer for more information.

An ILspView picks up elevation data automatically if the data is visualized in a TLspRasterLayer and one of the following conditions is fulfilled:

  • The data is part of an ILcdEarthTileSet with a CoverageType.ELEVATION type.

  • The data is part of an ILcd(Multilevel)Raster. The model descriptor is a TLcd(Multilevel)RasterModelDescriptor, and its isElevation() method returns true.

The combined elevation data of a view can be accessed from ILspView.getServices().getTerrainSupport(). If layers with elevation data overlap, the elevation of the top-most layer will be selected.

Converting a GXY layer to a Lightspeed layer

The Lightspeed equivalent of a ILcdGXYLayer is an ILspInteractivePaintableLayer. ILspInteractivePaintableLayer paints and styles the objects of its model using stylers, and optionally uses one or more ILspEditor instances to edit these objects. The default ILspInteractivePaintableLayer implementation is TLspLayer.

Raster and vector layers

A raster layer is particularly easy to convert. A special layer builder, TLspRasterLayerBuilder, allows you to visualize any model with an ILcdRaster, ILcdMultilevelRaster, or ILcdEarthTileSet, without any configuration. Simply create an ILspLayer using the builder, add it to your view, and you are ready to go.

Similarly, you can use TLspShapeLayerBuilder for vector layers. This builder creates layers that can paint all LuciadLightspeed shapes. Hence, there is no need for a specific circle, point list, or icon painter.

Paint representations

LuciadLightspeed allows you to visualize many different representations of the same object. All these visualizations use the same painter interface: ILspPainter.

As opposed to the requirements of a GXY layer, there is no need for a special label painter interface in a Lightspeed layer. Instead, you can configure different painters for different paint representations, including labels.

See Introduction to labeling vector data for more information.

Styling

LuciadLightspeed has an elaborate API for styling, from line types and fill colors to icons and label content. The styling API can be used to replace most, if not all, of your custom GXY layer implementations.

A major difference with GXY view styling is that Lightspeed view styling can be configured per object. To achieve this, Lightspeed painters map styles onto objects using an ILspStyler. A TLspStyler returns the same style(s) for every object, and is particularly useful when you are replacing GXY painters. This is illustrated in Introduction to styling vector data.

While styling is usually performed by the painter, most of the Lightspeed layer implementations implement ILspStyledLayer, allowing you to directly configure styling by calling setStyler.

To see other examples of layer and painter styles, have a look at the many Lightspeed samples on labels, icons, and styling. Note that no explicit layer invalidation is necessary when you change a styler.