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());
// }
// });
}
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;
}
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);
}
}
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);
}
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);
}
Aggregations