Each model, either an existing model or a custom one, contains a set of properties describing the data of the model. Some of those properties are of no added value for an end user, such as a database identifier for a model element. Some models even store their geometry as a property. This geometry is necessary to correctly visualize the elements of the model, but the exact coordinates of the points defining an underlying polyline, for instance, do not bring any added value in a properties table.

Therefore, it is possible to annotate certain properties with the TLcdHiddenDataPropertyAnnotation.java. When you use this annotation, the property and its value are automatically removed from the properties window in the LuciadLightspeed samples. The property and its value are also removed from the Lucy UI, with an immediate effect on:

  • The table view (Ctrl+T) does not show a column for hidden properties

  • The filter on the table view

  • The object properties window

  • The label filtering tool

In this short how-to, you will learn how to annotate properties so that they are hidden in your end user application

Hiding properties

Hiding properties of existing models

This section shows you how to hide properties of existing models based on their name.

This is not a unique identifier, so if multiple properties have the same name, they will all get the hidden annotation.

Code snippet

Program: How to hide properties in existing models.
static void annotatePropertiesAsHidden(ILcdModel aModel, List<String> aPropertyNames) {
  ILcdModelDescriptor aModelDescriptor = aModel.getModelDescriptor();
  if (aModelDescriptor instanceof ILcdDataModelDescriptor) {
    TLcdDataModel dataModel = ((ILcdDataModelDescriptor) aModelDescriptor).getDataModel();
    annotatePropertiesAsHidden(dataModel, aPropertyNames);
  }
}

static void annotatePropertiesAsHidden(TLcdDataModel aDataModel, List<String> propertyNames) {
  boolean annotated = false;
  for (TLcdDataType aDataType : aDataModel.getDeclaredTypes()) {
    for (String aPropertyName : propertyNames) {
      TLcdDataProperty property = aDataType.getProperty(aPropertyName);
      if (property != null) {
        property.addAnnotation(new TLcdHiddenDataPropertyAnnotation());
        annotated = true;
      }
    }
  }
  if (!annotated) {
    throw new IllegalArgumentException(
        "This datamodel " + aDataModel.getName() +
        " has no DataTypes containing properties with the given names: " +
        propertyNames.toString());
  }
}

Hiding properties of custom models

This snippet shows you how to hide properties for a custom model, while building its dataModel:

Code snippet

Program: How to hide properties in custom models.
static TLcdDataType annotateCustomModelProperties() {
  TLcdDataModelBuilder builder = new TLcdDataModelBuilder(
      "http://www.mydomain.com/datamodel/MyNavaidModel");

  builder.typeBuilder("LonLatPointType")
         .superType(TLcdShapeDataTypes.SHAPE_TYPE)
         .primitive(true)
         .instanceClass(ILcdPoint.class);

  // Define the types and their properties
  // We choose to annotate the id as hidden, since it brings no useful information to the end-user
  // We choose to annotate the lonlat point as hidden, since this holds the geometry
  TLcdDataTypeBuilder myNavaidBuilder = builder.typeBuilder("NavaidType");
  myNavaidBuilder.addProperty("name", TLcdCoreDataTypes.STRING_TYPE);
  myNavaidBuilder.addProperty("id", TLcdCoreDataTypes.STRING_TYPE)
                 .annotate(new TLcdHiddenDataPropertyAnnotation());
  myNavaidBuilder.addProperty("type", TLcdCoreDataTypes.STRING_TYPE);
  myNavaidBuilder.addProperty("lonlatpoint", TLcdCoreDataTypes.OBJECT_TYPE)
                 .annotate(new TLcdHiddenDataPropertyAnnotation());

  // Finalize the creation
  TLcdDataModel dataModel = builder.createDataModel();

  TLcdDataType type = dataModel.getDeclaredType("NavaidType");
  // make sure LuciadLightspeed finds the geometry
  type.addAnnotation(new TLcdHasGeometryAnnotation(type.getProperty("lonlatpoint")));

  return type;
}

Getting all non-hidden properties

Program: How to get all not-annotated-as-hidden properties.

static Stream<TLcdDataProperty> getVisibleDataProperties(TLcdDataType aDataType) {
  return aDataType.getProperties()
                  .stream()
                  .filter(p -> !p.isAnnotationPresent(TLcdHiddenDataPropertyAnnotation.class));
}