Search in sources :

Example 11 with IndicatorDTO

use of org.activityinfo.legacy.shared.model.IndicatorDTO in project activityinfo by bedatadriven.

the class MapGenerator method toDTOs.

private Set<IndicatorDTO> toDTOs(Collection<Indicator> indicators) {
    Set<IndicatorDTO> indicatorDTOs = new HashSet<IndicatorDTO>();
    for (Indicator indicator : indicators) {
        IndicatorDTO indicatorDTO = new IndicatorDTO();
        indicatorDTO.setId(indicator.getId());
        indicatorDTO.setName(indicator.getName());
        indicatorDTO.setType(FormFieldType.valueOf(indicator.getType()));
        indicatorDTO.setExpression(indicator.getExpression());
        indicatorDTO.setRelevanceExpression(indicator.getRelevanceExpression());
        indicatorDTOs.add(indicatorDTO);
    }
    return indicatorDTOs;
}
Also used : IndicatorDTO(org.activityinfo.legacy.shared.model.IndicatorDTO) Indicator(org.activityinfo.server.database.hibernate.entity.Indicator)

Example 12 with IndicatorDTO

use of org.activityinfo.legacy.shared.model.IndicatorDTO 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);
    try (FileOutputStream fos = TestOutput.open(getClass(), "polygon-hole.pdf")) {
        PdfReportRenderer renderer = new PdfReportRenderer(TestGeometry.get(), MAP_ICON_PATH);
        renderer.render(map, fos);
    }
}
Also used : PolygonMapLayer(org.activityinfo.legacy.shared.reports.model.layers.PolygonMapLayer) PdfReportRenderer(org.activityinfo.server.report.renderer.itext.PdfReportRenderer) MapReportElement(org.activityinfo.legacy.shared.reports.model.MapReportElement) IndicatorDTO(org.activityinfo.legacy.shared.model.IndicatorDTO) FileOutputStream(java.io.FileOutputStream) AiLatLng(org.activityinfo.model.type.geo.AiLatLng) Test(org.junit.Test)

Example 13 with IndicatorDTO

use of org.activityinfo.legacy.shared.model.IndicatorDTO in project activityinfo by bedatadriven.

the class ItextReportRendererTest method legendTest.

@Test
public void legendTest() throws IOException {
    BubbleMapMarker marker1 = new BubbleMapMarker();
    marker1.setLat(-2.45);
    marker1.setLng(28.8);
    marker1.setX(100);
    marker1.setY(100);
    marker1.setRadius(25);
    marker1.setValue(300);
    TileBaseMap baseMap = new TileBaseMap();
    baseMap.setTileUrlPattern("//www.activityinfo.org/resources/tile/nordkivu.cd/{z}/{x}/{y}.png");
    BubbleMapLayer layer1 = new BubbleMapLayer();
    layer1.addIndicatorId(101);
    layer1.setMinRadius(10);
    layer1.setMaxRadius(10);
    BubbleLayerLegend legend1 = new BubbleLayerLegend();
    legend1.setDefinition(layer1);
    legend1.setMinValue(1000);
    legend1.setMaxValue(3000);
    BubbleMapLayer layer2 = new BubbleMapLayer();
    layer2.addIndicatorId(102);
    layer2.addIndicatorId(103);
    layer2.setMinRadius(10);
    layer2.setMaxRadius(25);
    BubbleLayerLegend legend2 = new BubbleLayerLegend();
    legend2.setDefinition(layer2);
    legend2.setMinValue(600);
    legend2.setMaxValue(999);
    IconMapLayer layer3 = new IconMapLayer();
    layer3.setIcon(MapIcon.Icon.Default.name());
    layer3.getIndicatorIds().add(101);
    IconLayerLegend legend3 = new IconLayerLegend();
    legend3.setDefinition(layer3);
    List<PieChartLegend> pieChartLegends = Lists.newArrayList();
    List<PiechartMapLayer> pieChartLayers = Lists.newArrayList();
    int[] indicatorIds = new int[] { 101, 102, 103 };
    for (int sliceCount = 1; sliceCount < 10; ++sliceCount) {
        PiechartMapLayer pieChartLayer = new PiechartMapLayer();
        for (int i = 0; i != sliceCount; ++i) {
            pieChartLayer.addIndicatorId(indicatorIds[i % indicatorIds.length]);
        }
        pieChartLayer.setMinRadius(25);
        pieChartLayer.setMaxRadius(25);
        PieChartLegend pieChartLegend = new PieChartLegend();
        pieChartLegend.setDefinition(pieChartLayer);
        pieChartLayers.add(pieChartLayer);
        pieChartLegends.add(pieChartLegend);
    }
    IndicatorDTO indicator101 = new IndicatorDTO();
    indicator101.setId(101);
    indicator101.setName("Nombre de salles de classe fonctionnelles (construites, rehabilitees, equipees) " + "pour l'education formelle et non formelle.");
    IndicatorDTO indicator102 = new IndicatorDTO();
    indicator102.setId(102);
    indicator102.setName("Nombre d'enfants ayant beneficie de kits scolaires, recreatifs et didactiques");
    IndicatorDTO indicator103 = new IndicatorDTO();
    indicator103.setId(103);
    indicator103.setName("Pourcentage des ménages qui utilsent la moustiquaire rationnellement");
    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));
    mapContent.getIndicators().addAll(Arrays.asList(indicator101, indicator102, indicator103));
    mapContent.addLegend(legend1);
    mapContent.addLegend(legend2);
    mapContent.addLegend(legend3);
    mapContent.getLegends().addAll(pieChartLegends);
    MapReportElement map = new MapReportElement();
    map.setTitle("My Map");
    map.setContent(mapContent);
    map.addLayer(layer1);
    map.addLayer(layer2);
    map.addLayer(layer3);
    map.getLayers().addAll(pieChartLayers);
    ReportContent content = new ReportContent();
    content.setFilterDescriptions(Collections.EMPTY_LIST);
    Report report = new Report();
    report.setContent(content);
    report.addElement(map);
    renderToPdf(report, "legend.pdf");
    renderToHtml(report, "legend.html");
    renderToRtf(report, "legend.rtf");
}
Also used : IconMapLayer(org.activityinfo.legacy.shared.reports.model.layers.IconMapLayer) BubbleMapLayer(org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer) Extents(org.activityinfo.model.type.geo.Extents) IndicatorDTO(org.activityinfo.legacy.shared.model.IndicatorDTO) TileBaseMap(org.activityinfo.legacy.shared.model.TileBaseMap) PiechartMapLayer(org.activityinfo.legacy.shared.reports.model.layers.PiechartMapLayer) Test(org.junit.Test)

Example 14 with IndicatorDTO

use of org.activityinfo.legacy.shared.model.IndicatorDTO in project activityinfo by bedatadriven.

the class IndicatorLinkPage method onIndicatorSelectionChanged.

protected void onIndicatorSelectionChanged() {
    IndicatorDTO source = sourceIndicatorGrid.getSelectedItem();
    IndicatorDTO dest = destIndicatorGrid.getSelectedItem();
    if (source == null || dest == null) {
        linkButton.disable();
    } else if (source.getId() == dest.getId()) {
        // indicators should not be linked to themselves.
        linkButton.setVisible(true);
        linkButton.disable();
        ToolTipConfig config = linkTip(I18N.CONSTANTS.indicatorCannotBeLinkedToItself());
        linkButtonTip.update(config);
        linkButtonTip.show();
    } else {
        sourceIndicatorGrid.getRowY(source);
        destIndicatorGrid.getRowY(dest);
        sourceIndicatorGrid.el().getRight(false);
        boolean linked = linkGraph.linked(source, dest);
        linkButton.enable();
        linkButton.toggle(linked);
        linkButtonTip.update(linkTip(linked ? I18N.CONSTANTS.clickToUnlink() : I18N.CONSTANTS.clickToLink()));
        linkButtonTip.initTarget(linkButton);
        linkButtonTip.show();
    }
}
Also used : IndicatorDTO(org.activityinfo.legacy.shared.model.IndicatorDTO) ToolTipConfig(com.extjs.gxt.ui.client.widget.tips.ToolTipConfig)

Aggregations

IndicatorDTO (org.activityinfo.legacy.shared.model.IndicatorDTO)14 Test (org.junit.Test)3 LayoutContainer (com.extjs.gxt.ui.client.widget.LayoutContainer)2 Text (com.extjs.gxt.ui.client.widget.Text)2 TextField (com.extjs.gxt.ui.client.widget.form.TextField)2 MessageBoxEvent (com.extjs.gxt.ui.client.event.MessageBoxEvent)1 Field (com.extjs.gxt.ui.client.widget.form.Field)1 NumberField (com.extjs.gxt.ui.client.widget.form.NumberField)1 HBoxLayout (com.extjs.gxt.ui.client.widget.layout.HBoxLayout)1 TableData (com.extjs.gxt.ui.client.widget.layout.TableData)1 TableLayout (com.extjs.gxt.ui.client.widget.layout.TableLayout)1 ToolTipConfig (com.extjs.gxt.ui.client.widget.tips.ToolTipConfig)1 Color (com.google.code.appengine.awt.Color)1 com.lowagie.text (com.lowagie.text)1 FileOutputStream (java.io.FileOutputStream)1 List (java.util.List)1 LinkIndicators (org.activityinfo.legacy.shared.command.LinkIndicators)1 VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)1 ActivityFormDTO (org.activityinfo.legacy.shared.model.ActivityFormDTO)1 ReportVisibilityDTO (org.activityinfo.legacy.shared.model.ReportVisibilityDTO)1