use of org.activityinfo.shared.report.content.AdminMarker in project activityinfo by bedatadriven.
the class AdminChloroplethFeatures method style.
@Override
public JSObject style(JSObject feature) {
int adminEntityId = feature.getPropertyAsInt("id");
AdminMarker polygon = overlay.getPolygon(adminEntityId);
JSObject style = JSObject.createJSObject();
style.setProperty("fillColor", LeafletUtil.color(polygon.getColor()));
style.setProperty("fillOpacity", 0.5);
style.setProperty("stroke", true);
style.setProperty("weight", 2);
style.setProperty("color", LeafletUtil.color(overlay.getOutlineColor()));
return style;
}
use of org.activityinfo.shared.report.content.AdminMarker in project activityinfo by bedatadriven.
the class PolygonLayerGenerator method queryBuckets.
private void queryBuckets(DispatcherSync dispatcher, Filter layerFilter) {
PivotSites query = new PivotSites();
query.setFilter(layerFilter);
AdminDimension adminDimension = new AdminDimension(layer.getAdminLevelId());
query.setDimensions(adminDimension);
MagnitudeScaleBuilder scaleBuilder = new MagnitudeScaleBuilder(layer);
this.pivotResult = dispatcher.execute(query);
for (Bucket bucket : pivotResult.getBuckets()) {
EntityCategory category = (EntityCategory) bucket.getCategory(adminDimension);
if (category != null) {
int adminEntityId = category.getId();
AdminMarker polygon = overlay.getPolygon(adminEntityId);
if (polygon != null) {
polygon.setValue(bucket.doubleValue());
scaleBuilder.addValue(bucket.doubleValue());
}
}
}
colorScale = scaleBuilder.build();
}
use of org.activityinfo.shared.report.content.AdminMarker in project activityinfo by bedatadriven.
the class ImageMapRenderer method drawAdminOverlay.
@LogSlow(threshold = 50)
protected void drawAdminOverlay(TiledMap map, Graphics2D g2d, AdminOverlay overlay) {
List<AdminGeo> geometry = geometryProvider.getGeometries(overlay.getAdminLevelId());
Color strokeColor = ColorUtil.colorFromString(overlay.getOutlineColor());
g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
for (AdminGeo adminGeo : geometry) {
AdminMarker polygon = overlay.getPolygon(adminGeo.getId());
if (polygon != null) {
GeneralPath path = PathUtils.toPath(map, adminGeo.getGeometry());
g2d.setColor(bubbleFillColor(ColorUtil.colorFromString(polygon.getColor())));
g2d.fill(path);
g2d.setColor(strokeColor);
g2d.draw(path);
}
}
}
use of org.activityinfo.shared.report.content.AdminMarker in project activityinfo by bedatadriven.
the class PolygonLayerGenerator method queryBounds.
private void queryBounds(DispatcherSync dispatcher, Filter layerFilter) {
GetAdminEntities query = new GetAdminEntities();
query.setLevelId(layer.getAdminLevelId());
AdminEntityResult entities = dispatcher.execute(query);
for (AdminEntityDTO entity : entities.getData()) {
if (entity.hasBounds()) {
AdminMarker marker = new AdminMarker(entity);
overlay.addPolygon(marker);
}
}
}
use of org.activityinfo.shared.report.content.AdminMarker in project activityinfo by bedatadriven.
the class PolygonGeneratorTest method polygonWithHole.
@Test
public void polygonWithHole() throws IOException {
AdminMarker marker = new AdminMarker();
marker.setAdminEntityId(1930);
marker.setColor("#FFBBBB");
AdminOverlay overlay = new AdminOverlay(1383);
overlay.setOutlineColor("#FF0000");
overlay.addPolygon(marker);
PolygonMapLayer layer = new PolygonMapLayer();
layer.addIndicatorId(1);
layer.setAdminLevelId(1383);
MapContent content = new MapContent();
content.setZoomLevel(8);
content.setBaseMap(GoogleBaseMap.ROADMAP);
content.setCenter(new AiLatLng(12.60500192642215, -7.98924994468689));
content.getAdminOverlays().add(overlay);
content.setFilterDescriptions(new ArrayList<FilterDescription>());
PolygonLegend.ColorClass clazz1 = new PolygonLegend.ColorClass(1, 53.6, "0000FF");
PolygonLegend.ColorClass clazz2 = new PolygonLegend.ColorClass(600, 600, "FF0000");
PolygonLegend legend = new PolygonLegend(layer, Lists.newArrayList(clazz1, clazz2));
content.getLegends().add(legend);
IndicatorDTO indicator = new IndicatorDTO();
indicator.setId(1);
indicator.setName("Indicator Test");
content.getIndicators().add(indicator);
MapReportElement map = new MapReportElement();
map.addLayer(layer);
map.setContent(content);
FileOutputStream fos = new FileOutputStream("target/report-tests/polygon-hole.pdf");
PdfReportRenderer pdfr = new PdfReportRenderer(TestGeometry.get(), "");
pdfr.render(map, fos);
fos.close();
}
Aggregations