Search in sources :

Example 11 with MapReportElement

use of org.activityinfo.shared.report.model.MapReportElement in project activityinfo by bedatadriven.

the class MapTemplate method createElement.

@Override
public void createElement(final AsyncCallback<ReportElement> callback) {
    final NewLayerWizard wizard = new NewLayerWizard(dispatcher);
    WizardDialog dialog = new WizardDialog(wizard);
    dialog.setHeading(I18N.CONSTANTS.newMap());
    dialog.show(new WizardCallback() {

        @Override
        public void onFinished() {
            MapReportElement map = new MapReportElement();
            map.addLayer(wizard.createLayer());
            callback.onSuccess(map);
        }
    });
// dialog.addValueChangeHandler(new ValueChangeHandler<MapLayer>() {
// 
// @Override
// public void onValueChange(ValueChangeEvent<MapLayer> event) {
// createMap(callback, event.getValue());
// }
// });
}
Also used : NewLayerWizard(org.activityinfo.client.report.editor.map.NewLayerWizard) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) WizardCallback(org.activityinfo.client.widget.wizard.WizardCallback) WizardDialog(org.activityinfo.client.widget.wizard.WizardDialog)

Example 12 with MapReportElement

use of org.activityinfo.shared.report.model.MapReportElement in project activityinfo by bedatadriven.

the class ReportJsonFactory method decodeMapReportElement.

public MapReportElement decodeMapReportElement(JsonObject element) {
    MapReportElement mapElement = new MapReportElement();
    JsonElement title = element.get("title");
    if (title != null) {
        mapElement.setTitle(title.getAsString());
    }
    JsonElement sheetTitle = element.get("sheetTitle");
    if (sheetTitle != null) {
        mapElement.setSheetTitle(sheetTitle.getAsString());
    }
    JsonElement baseMapId = element.get("baseMapId");
    if (baseMapId != null) {
        mapElement.setBaseMapId(baseMapId.getAsString());
    }
    JsonElement width = element.get("width");
    if (width != null) {
        mapElement.setWidth(width.getAsInt());
    }
    JsonElement height = element.get("height");
    if (height != null) {
        mapElement.setHeight(height.getAsInt());
    }
    JsonElement zoomLevel = element.get("zoomLevel");
    if (zoomLevel != null) {
        mapElement.setBaseMapId(zoomLevel.getAsString());
    }
    JsonElement center = element.get("center");
    if (center != null) {
        mapElement.setBaseMapId(center.getAsString());
    }
    JsonArray layers = element.get("layers").getAsJsonArray();
    if (layers.size() > 0) {
        mapElement.setLayers(decodeLayers(layers));
    }
    JsonObject filter = element.get("filter").getAsJsonObject();
    mapElement.setFilter(decodeFilter(filter));
    return mapElement;
}
Also used : JsonArray(com.google.gson.JsonArray) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject)

Example 13 with MapReportElement

use of org.activityinfo.shared.report.model.MapReportElement in project activityinfo by bedatadriven.

the class PPTRenderer method render.

@Override
public void render(ReportElement element, OutputStream os) throws IOException {
    if (element instanceof Report) {
        SlideShow ppt = new SlideShow();
        Report report = (Report) element;
        for (ReportElement child : report.getElements()) {
            if (child instanceof MapReportElement) {
                mapRenderer.render((MapReportElement) child, ppt);
            } else if (child instanceof PivotChartReportElement) {
                chartRenderer.render((PivotChartReportElement) child, ppt);
            }
        }
        ppt.write(os);
    } else if (element instanceof MapReportElement) {
        mapRenderer.render((MapReportElement) element, os);
    } else if (element instanceof PivotChartReportElement) {
        chartRenderer.render((PivotChartReportElement) element, os);
    }
}
Also used : MapReportElement(org.activityinfo.shared.report.model.MapReportElement) Report(org.activityinfo.shared.report.model.Report) SlideShow(org.apache.poi.hslf.usermodel.SlideShow) ReportElement(org.activityinfo.shared.report.model.ReportElement) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement)

Example 14 with MapReportElement

use of org.activityinfo.shared.report.model.MapReportElement in project activityinfo by bedatadriven.

the class JaxbParseTest method testElements.

@Test
public void testElements() throws JAXBException {
    Report report = parseXml("report-elements.xml");
    dumpXml(report);
    Assert.assertEquals("element count", 7, report.getElements().size());
    Assert.assertTrue("pivotTable", report.getElements().get(0) instanceof PivotTableReportElement);
    Assert.assertTrue("pivotChart", report.getElements().get(1) instanceof PivotChartReportElement);
    Assert.assertTrue("table", report.getElements().get(2) instanceof TableElement);
    Assert.assertTrue("map", report.getElements().get(3) instanceof MapReportElement);
    Assert.assertTrue("static", report.getElements().get(4) instanceof TextReportElement);
    Assert.assertTrue("static", report.getElements().get(5) instanceof TextReportElement);
    Assert.assertTrue("static", report.getElements().get(6) instanceof ImageReportElement);
}
Also used : MapReportElement(org.activityinfo.shared.report.model.MapReportElement) ImageReportElement(org.activityinfo.shared.report.model.ImageReportElement) Report(org.activityinfo.shared.report.model.Report) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) TableElement(org.activityinfo.shared.report.model.TableElement) TextReportElement(org.activityinfo.shared.report.model.TextReportElement) Test(org.junit.Test)

Example 15 with MapReportElement

use of org.activityinfo.shared.report.model.MapReportElement in project activityinfo by bedatadriven.

the class ReadWriteReportTest method readWriteReportTest.

@Test
public void readWriteReportTest() throws Throwable {
    Report report = new Report();
    MapReportElement map = new MapReportElement();
    map.getLayers().add(new BubbleMapLayer());
    PiechartMapLayer pielayer = new PiechartMapLayer();
    Slice slice1 = new Slice();
    slice1.setColor("FF00AA");
    slice1.setIndicatorId(1);
    Slice slice2 = new Slice();
    slice2.setColor("00FFAA");
    slice2.setIndicatorId(2);
    pielayer.getSlices().add(slice1);
    pielayer.getSlices().add(slice2);
    map.getLayers().add(pielayer);
    report.getElements().add(map);
    Report.class.getPackage();
    JAXBContext jc = JAXBContext.newInstance(Report.class.getPackage().getName());
    Marshaller marshaller = jc.createMarshaller();
    marshaller.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    FileOutputStream fo = new FileOutputStream("SomeXmlTest.xml");
    marshaller.marshal(report, fo);
}
Also used : MapReportElement(org.activityinfo.shared.report.model.MapReportElement) Marshaller(javax.xml.bind.Marshaller) Report(org.activityinfo.shared.report.model.Report) Slice(org.activityinfo.shared.report.model.layers.PiechartMapLayer.Slice) FileOutputStream(java.io.FileOutputStream) BubbleMapLayer(org.activityinfo.shared.report.model.layers.BubbleMapLayer) JAXBContext(javax.xml.bind.JAXBContext) PiechartMapLayer(org.activityinfo.shared.report.model.layers.PiechartMapLayer) Test(org.junit.Test)

Aggregations

MapReportElement (org.activityinfo.shared.report.model.MapReportElement)23 Test (org.junit.Test)17 MapContent (org.activityinfo.shared.report.content.MapContent)12 Report (org.activityinfo.shared.report.model.Report)8 BubbleMapMarker (org.activityinfo.shared.report.content.BubbleMapMarker)6 IconMapMarker (org.activityinfo.shared.report.content.IconMapMarker)6 TileBaseMap (org.activityinfo.shared.map.TileBaseMap)5 MapMarker (org.activityinfo.shared.report.content.MapMarker)5 BubbleMapLayer (org.activityinfo.shared.report.model.layers.BubbleMapLayer)5 FileOutputStream (java.io.FileOutputStream)4 PivotChartReportElement (org.activityinfo.shared.report.model.PivotChartReportElement)4 AiLatLng (org.activityinfo.shared.report.content.AiLatLng)3 ReportContent (org.activityinfo.shared.report.content.ReportContent)3 TableElement (org.activityinfo.shared.report.model.TableElement)3 PiechartMapLayer (org.activityinfo.shared.report.model.layers.PiechartMapLayer)3 Extents (org.activityinfo.shared.util.mapping.Extents)3 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 PdfReportRenderer (org.activityinfo.server.report.renderer.itext.PdfReportRenderer)2 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)2