use of org.activityinfo.shared.report.model.layers.PiechartMapLayer.Slice in project activityinfo by bedatadriven.
the class ReportJsonFactory method encodeSlicesList.
private JsonArray encodeSlicesList(List<Slice> slices) {
JsonArray jsonSlices = new JsonArray();
for (int i = 0; i < slices.size(); i++) {
Slice slice = slices.get(i);
JsonObject jsonSlice = new JsonObject();
if (slice.getColor() != null) {
jsonSlice.addProperty("color", slice.getColor());
}
jsonSlice.addProperty("indicatorId", slice.getIndicatorId());
jsonSlices.add(jsonSlice);
}
return jsonSlices;
}
use of org.activityinfo.shared.report.model.layers.PiechartMapLayer.Slice in project activityinfo by bedatadriven.
the class PiechartLayerOptions method populateColorPickerWidget.
private void populateColorPickerWidget() {
indicatorsStore.removeAll();
if (piechartMapLayer != null && piechartMapLayer.getIndicatorIds() != null && piechartMapLayer.getIndicatorIds().size() > 0) {
for (Slice slice : piechartMapLayer.getSlices()) {
String name = schema.getIndicatorById(slice.getIndicatorId()).getName();
indicatorsStore.add(new NamedSlice(slice.getColor(), slice.getIndicatorId(), name, slice));
}
}
layout(true);
}
use of org.activityinfo.shared.report.model.layers.PiechartMapLayer.Slice in project activityinfo by bedatadriven.
the class PiechartLayerGenerator method calulateSlices.
private void calulateSlices(PointValue pv, SiteDTO site) {
pv.setSlices(new ArrayList<PieMapMarker.SliceValue>());
for (Slice slice : layer.getSlices()) {
EntityCategory indicatorCategory = new EntityCategory(slice.getIndicatorId());
Double value = site.getIndicatorValue(slice.getIndicatorId());
if (value != null && value != 0) {
PieMapMarker.SliceValue sliceValue = new PieMapMarker.SliceValue();
sliceValue.setValue(value);
sliceValue.setCategory(indicatorCategory);
sliceValue.setColor(slice.getColor());
sliceValue.setIndicatorId(slice.getIndicatorId());
pv.getSlices().add(sliceValue);
}
}
}
use of org.activityinfo.shared.report.model.layers.PiechartMapLayer.Slice in project activityinfo by bedatadriven.
the class ItextMapRenderer method addPieChartDescription.
private void addPieChartDescription(MapReportElement element, Cell descriptionCell, PiechartMapLayer layer) throws BadElementException, IOException {
for (Slice slice : layer.getSlices()) {
IndicatorDTO indicator = element.getContent().getIndicatorById(slice.getIndicatorId());
Color color = ColorUtil.colorFromString(slice.getColor());
ItextGraphic sliceImage = renderSlice(imageCreator, color, 10);
Chunk box = new Chunk(sliceImage.toItextImage(), 0, 0);
Chunk description = new Chunk(indicator.getName());
Phrase phrase = new Phrase();
phrase.add(box);
phrase.add(description);
Paragraph paragraph = new Paragraph(phrase);
descriptionCell.add(paragraph);
}
}
use of org.activityinfo.shared.report.model.layers.PiechartMapLayer.Slice 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