use of org.activityinfo.shared.report.content.BubbleMapMarker in project activityinfo by bedatadriven.
the class ItextReportRendererTest method htmlImages.
@Test
public void htmlImages() throws IOException {
DummyPivotTableData data = new DummyPivotTableData();
PivotChartContent chartContent = new PivotChartContent();
chartContent.setData(data.table);
chartContent.setYMin(0);
chartContent.setYStep(100);
chartContent.setFilterDescriptions(Collections.EMPTY_LIST);
PivotChartReportElement chart = new PivotChartReportElement(Type.Pie);
chart.setTitle("My Pie Chart");
chart.setCategoryDimensions(data.colDims);
chart.setSeriesDimensions(data.rowDims);
chart.setContent(chartContent);
PivotContent tableContent = new PivotContent();
tableContent.setFilterDescriptions(Collections.EMPTY_LIST);
tableContent.setData(data.table);
PivotTableReportElement table = new PivotTableReportElement();
table.setColumnDimensions(data.colDims);
table.setRowDimensions(data.rowDims);
table.setTitle("My Table");
table.setContent(tableContent);
BubbleMapMarker marker1 = new BubbleMapMarker();
marker1.setLat(-2.45);
marker1.setLng(28.8);
marker1.setX(100);
marker1.setY(100);
marker1.setRadius(25);
TileBaseMap baseMap = new TileBaseMap();
baseMap.setTileUrlPattern("http://mt{s}.aimaps.net/nordkivu.cd/v1/z{z}/{x}x{y}.png");
MapContent mapContent = new MapContent();
mapContent.setFilterDescriptions(Collections.EMPTY_LIST);
mapContent.setBaseMap(baseMap);
mapContent.setZoomLevel(8);
mapContent.setCenter(new Extents(-2.2, -2.1, 28.85, 28.9).center());
mapContent.setMarkers(Arrays.asList((MapMarker) marker1));
MapReportElement map = new MapReportElement();
map.setTitle("My Map");
map.setContent(mapContent);
ReportContent content = new ReportContent();
content.setFilterDescriptions(Collections.EMPTY_LIST);
Report report = new Report();
report.setContent(content);
report.addElement(chart);
report.addElement(table);
report.addElement(new TextReportElement("Testing 1..2.3.. français"));
report.addElement(map);
renderToPdf(report, "piechart.pdf");
renderToHtml(report, "piechart.html");
// renderToHtmlUsingWriter(report, "piechart2.html");
renderToRtf(report, "piechart.rtf");
}
use of org.activityinfo.shared.report.content.BubbleMapMarker in project activityinfo by bedatadriven.
the class ItextReportRendererTest method googleMapsBaseMap.
@Test
public void googleMapsBaseMap() throws IOException {
ReportContent content = new ReportContent();
content.setFilterDescriptions(Collections.EMPTY_LIST);
Report report = new Report();
report.setContent(content);
TileBaseMap referenceBaseMap = new TileBaseMap();
referenceBaseMap.setTileUrlPattern("http://www.activityinfo.org/resources/tile/admin.cd/{z}/{x}/{y}.png");
referenceBaseMap.setName("Administrative Map");
BaseMap[] baseMaps = new BaseMap[] { referenceBaseMap, GoogleBaseMap.HYBRID, GoogleBaseMap.ROADMAP, GoogleBaseMap.SATELLITE, GoogleBaseMap.TERRAIN };
for (BaseMap baseMap : baseMaps) {
BubbleMapMarker marker1 = new BubbleMapMarker();
marker1.setLat(-2.45);
marker1.setLng(28.8);
marker1.setX(100);
marker1.setY(100);
marker1.setRadius(25);
MapContent mapContent = new MapContent();
mapContent.setFilterDescriptions(Collections.EMPTY_LIST);
mapContent.setBaseMap(baseMap);
mapContent.setZoomLevel(8);
mapContent.setCenter(new Extents(-2.2, -2.1, 28.85, 28.9).center());
mapContent.setMarkers(Arrays.asList((MapMarker) marker1));
MapReportElement satelliteMap = new MapReportElement();
satelliteMap.setTitle(baseMap.toString());
satelliteMap.setContent(mapContent);
report.addElement(satelliteMap);
}
// renderToPdf(report, "google map.pdf");
// renderToHtml(report, "google map.html");
renderToRtf(report, "google map.rtf");
}
use of org.activityinfo.shared.report.content.BubbleMapMarker in project activityinfo by bedatadriven.
the class ExcelMapDataExporter method render.
@Override
public void render(ReportElement element, OutputStream stm) throws IOException {
if (!(element instanceof MapReportElement)) {
throw new RuntimeException("ExcelMapDataExporter accepts only MapElements");
}
MapContent content = ((MapReportElement) element).getContent();
Workbook book = new HSSFWorkbook();
Sheet sheet = book.createSheet();
Helper helper = new Helper(book);
Row headerRow = sheet.createRow(0);
helper.addCell(headerRow, 0, "Latitude");
helper.addCell(headerRow, 1, "Longitude");
helper.addCell(headerRow, 2, "Value");
helper.addCell(headerRow, 3, "Color");
helper.addCell(headerRow, 4, "Icon");
int rowIndex = 1;
for (MapMarker marker : content.getMarkers()) {
Row dataRow = sheet.createRow(rowIndex++);
helper.addCell(dataRow, 0, marker.getLat());
helper.addCell(dataRow, 1, marker.getLng());
if (marker instanceof BubbleMapMarker) {
BubbleMapMarker bmarker = (BubbleMapMarker) marker;
helper.addCell(dataRow, 2, bmarker.getValue());
helper.addCell(dataRow, 3, bmarker.getColor());
}
if (marker instanceof IconMapMarker) {
IconMapMarker imarker = (IconMapMarker) marker;
if (imarker.getIcon() != null) {
helper.addCell(dataRow, 4, imarker.getIcon().getName());
}
}
}
book.write(stm);
}
use of org.activityinfo.shared.report.content.BubbleMapMarker in project activityinfo by bedatadriven.
the class BubbleLayerGenerator method generate.
@Override
public void generate(TiledMap map, MapContent content) {
// define our symbol scaling
RadiiCalculator radiiCalculator;
if (layer.getScaling() == ScalingType.None || layer.getMinRadius() == layer.getMaxRadius()) {
radiiCalculator = new FixedRadiiCalculator(layer.getMinRadius());
} else if (layer.getScaling() == ScalingType.Graduated) {
radiiCalculator = new GsLogCalculator(layer.getMinRadius(), layer.getMaxRadius());
} else {
radiiCalculator = new FixedRadiiCalculator(layer.getMinRadius());
}
BubbleIntersectionCalculator intersectionCalculator = new BubbleIntersectionCalculator(layer.getMaxRadius());
Clusterer clusterer = ClustererFactory.fromClustering(layer.getClustering(), radiiCalculator, intersectionCalculator);
// create the list of input point values
List<PointValue> points = new ArrayList<PointValue>();
List<PointValue> unmapped = new ArrayList<PointValue>();
generatePoints(sites, map, layer, clusterer, points, unmapped);
// Cluster points by the clustering algorithm set in the layer
List<Cluster> clusters = clusterer.cluster(map, points);
// add unmapped sites
for (PointValue pv : unmapped) {
content.getUnmappedSites().add(pv.getSite().getId());
}
BubbleLayerLegend legend = new BubbleLayerLegend();
legend.setDefinition(layer);
// create the markers
List<BubbleMapMarker> markers = new ArrayList<BubbleMapMarker>();
for (Cluster cluster : clusters) {
Point px = cluster.getPoint();
AiLatLng latlng = map.fromPixelToLatLng(px);
BubbleMapMarker marker = new BubbleMapMarker();
for (PointValue pv : cluster.getPointValues()) {
marker.getSiteIds().add(pv.getSite().getId());
}
marker.setX(px.getX());
marker.setY(px.getY());
marker.setValue(cluster.sumValues());
marker.setRadius((int) cluster.getRadius());
marker.setLat(latlng.getLat());
marker.setLng(latlng.getLng());
marker.setAlpha(layer.getAlpha());
marker.setTitle(formatTitle(cluster));
marker.setIndicatorIds(new HashSet<Integer>(layer.getIndicatorIds()));
marker.setClusterAmount(cluster.getPointValues().size());
marker.setClustering(layer.getClustering());
marker.setColor(layer.getBubbleColor());
if (marker.getValue() < legend.getMinValue()) {
legend.setMinValue(marker.getValue());
}
if (marker.getValue() > legend.getMaxValue()) {
legend.setMaxValue(marker.getValue());
}
markers.add(marker);
}
// sort order by symbol radius descending
// (this assures that smaller symbols are drawn on
// top of larger ones)
Collections.sort(markers, new Comparator<MapMarker>() {
@Override
public int compare(MapMarker o1, MapMarker o2) {
if (o1.getSize() > o2.getSize()) {
return -1;
} else if (o1.getSize() < o2.getSize()) {
return 1;
}
return 0;
}
});
// number markers if applicable
if (layer.getLabelSequence() != null) {
numberMarkers(markers);
}
content.addLegend(legend);
content.getMarkers().addAll(markers);
}
use of org.activityinfo.shared.report.content.BubbleMapMarker in project activityinfo by bedatadriven.
the class PPTMapRenderer method render.
public void render(MapReportElement element, SlideShow ppt) throws IOException {
// add first slide
Slide slide = ppt.createSlide();
// calculate map offset
Dimension pageSize = ppt.getPageSize();
int offsetX = ((int) pageSize.getWidth() - element.getWidth()) / 2;
int offsetY = ((int) pageSize.getHeight() - element.getHeight()) / 2;
// add the map background image
drawBasemap(element, new PPTTileHandler(ppt, slide));
// keep a list of map icons
Map<String, Integer> iconPictureIndex = new HashMap<String, Integer>();
// Add the indicator markers to the slide as shapes
for (MapMarker marker : element.getContent().getMarkers()) {
if (inView(element, marker)) {
if (marker instanceof IconMapMarker) {
addIconMarker(ppt, slide, offsetX, offsetY, iconPictureIndex, (IconMapMarker) marker);
} else if (marker instanceof BubbleMapMarker) {
addBubble(slide, offsetX, offsetY, (BubbleMapMarker) marker);
}
}
}
}
Aggregations