NVG 2.0 data can contain domain objects with a time range. The NVG model offers support for easily filtering domain objects based on a time value.
Usually the end users of an application decide which particular elements they are interested in, by making a selection in
the graphical interface.
In such a case, the users configure the filter through a GUI selection widget.
The NVG sample includes a filter UI called FilterManagerUI
for this purpose.
The panel retrieves the set of points in time from the TLcdNVG20FilteredModel
.
You can see how this is done in Program: Retrieving the timing information of an NVG model for a filter GUI..
samples/common/dimensionalfilter/model/FilterProvider
)
ILcdMultiDimensionalModel filteredModel = (ILcdMultiDimensionalModel) model;
List<? extends ILcdDimension<?>> dimensions = filteredModel.getDimensions();
if (dimensions != null) {
for (ILcdDimension dimension : dimensions) {
if (shouldHandleDimensionAxis(dimension)) {
DimensionalFilter dimensionalFilter = createFilter(aLayered, aLayer, dimension);
dimensionalFilters.add(dimensionalFilter);
}
}
}
Program: Interactively filtering an NVG model with time information. shows how to change the filtering based on a specific date.
samples/common/dimensionalfilter/model/FilterProvider
)
ILcdMultiDimensionalModel model = (ILcdMultiDimensionalModel) getLayer().getModel();
try (TLcdLockUtil.Lock ignored = TLcdLockUtil.writeLock(model)) {
TLcdDimensionInterval<?> newValue = TLcdDimensionInterval.createSingleValue(
type,
aValue
);
TLcdDimensionFilter filter = TLcdDimensionFilter.newBuilder().filterDimension(fDimension.getAxis(), newValue).build();
TLcdDimensionFilter snappingFilter = filter.createSnappingFilter(model, TLcdDimensionFilter.SnapMode.NEAREST);
List<TLcdDimensionInterval> values = getDimension().getValues();
if (!values.get(0).isSingleValue()) {
//get the missing dimension values from snapping filter
for (TLcdDimensionAxis axis : snappingFilter.getAxes()) {
if (!axis.equals(getDimension().getAxis())) {
filter = filter.asBuilder().filterDimension(axis, snappingFilter.getInterval(axis)).build();
}
}
} else {
filter = snappingFilter;
}
model.applyDimensionFilter(filter, ILcdModel.FIRE_LATER);
} finally {
getLayer().getModel().fireCollectedModelChanges();
}