use of org.hisp.dhis.mapping.MapView in project dhis2-core by dhis2.
the class BaseAnalyticalObjectTest method testAddDataDimensionItem.
@Test
public void testAddDataDimensionItem() {
DataElement deA = new DataElement();
deA.setAutoFields();
MapView mv = new MapView(MapView.LAYER_THEMATIC1);
mv.addDataDimensionItem(deA);
assertEquals(1, mv.getDataDimensionItems().size());
}
use of org.hisp.dhis.mapping.MapView in project dhis2-core by dhis2.
the class GeoToolsMapGenerationService method generateMapImageForUser.
@Override
public BufferedImage generateMapImageForUser(Map map, Date date, OrganisationUnit unit, Integer width, Integer height, User user) {
Assert.isTrue(map != null, "Map cannot be null");
if (width == null && height == null) {
width = MapUtils.DEFAULT_MAP_WIDTH;
}
InternalMap internalMap = new InternalMap();
List<MapView> mapViews = new ArrayList<>(map.getMapViews());
Collections.reverse(mapViews);
for (MapView mapView : mapViews) {
InternalMapLayer mapLayer = getSingleInternalMapLayer(mapView, user, date);
if (mapLayer != null) {
internalMap.getLayers().add(mapLayer);
}
}
if (internalMap.getLayers().isEmpty()) {
return null;
}
InternalMapLayer dataLayer = internalMap.getFirstDataLayer();
BufferedImage mapImage = MapUtils.render(internalMap, width, height);
if (dataLayer == null) {
mapViews.forEach(BaseAnalyticalObject::clearTransientState);
return mapImage;
} else {
LegendSet legendSet = new LegendSet(dataLayer);
BufferedImage legendImage = legendSet.render(i18nManager.getI18nFormat());
BufferedImage titleImage = MapUtils.renderTitle(map.getName(), getImageWidth(legendImage, mapImage));
mapViews.forEach(BaseAnalyticalObject::clearTransientState);
return combineLegendAndMapImages(titleImage, legendImage, mapImage);
}
}
Aggregations