• For a Lightspeed 2D view, the background color is determined by the background property of the ILspView

  • For a Lightspeed 3D view, this background color is only visible when there is no atmosphere with stars visible.

You can adjust the background color and disable the atmosphere in the TLcyLspMapComponentFactory. This ensures that all your maps have a custom background color.

public class CustomLspMapComponentFactory extends TLcyLspMapComponentFactory {

  public CustomLspMapComponentFactory(ILcyLucyEnv aLucyEnv) {
    super(aLucyEnv);
  }

  @Override
  protected TLspViewBuilder createViewBuilder(ALcyProperties aProperties) {
    //Ask the super method to create the builder
    TLspViewBuilder viewBuilder = super.createViewBuilder(aProperties);
    //Configure the background color on it
    viewBuilder.background(Color.RED);
    return viewBuilder;
  }

  @Override
  public ALspGraphicsEffect createGraphicsEffect(int aID, ALcyProperties aProperties) {
    //Disable the atmosphere
    //Only needed if you want to replace the star field with the background color in 3D
    if (aID == ATMOSPHERE_GRAPHICS_EFFECT) {
      return null;
    }
    return super.createGraphicsEffect(aID, aProperties);
  }
}

The How to modify a map component through the API ? explains how to install and use a custom map component factory.

An alternative is to adjust the background color after the map has been created, by using a listener:

ILcyGenericMapManagerListener<ILcdView, ILcdLayer> listener =
    ILcyGenericMapManagerListener.onMapAdded(ILspView.class, mapComponent -> mapComponent.getMainView().setBackground(Color.RED));
aLucyEnv.getCombinedMapManager().addMapManagerListener(listener);

When you use the listener, the background color will only be visible for 2D maps. In 3D, the atmosphere with stars will still be visible.