Search in sources :

Example 1 with NoClustering

use of org.activityinfo.legacy.shared.reports.model.clustering.NoClustering in project activityinfo by bedatadriven.

the class LayersWidget method addLayer.

public void addLayer(MapLayer layer) {
    if (layer instanceof PointMapLayer) {
        ((PointMapLayer) layer).setClustering(new NoClustering());
    }
    mapElement.getLayers().add(layer);
    reportEventBus.fireChange();
    updateStore();
}
Also used : NoClustering(org.activityinfo.legacy.shared.reports.model.clustering.NoClustering) PointMapLayer(org.activityinfo.legacy.shared.reports.model.layers.PointMapLayer)

Example 2 with NoClustering

use of org.activityinfo.legacy.shared.reports.model.clustering.NoClustering in project activityinfo by bedatadriven.

the class ClusteringOptionsWidget method buildForm.

private void buildForm(Collection<AdminLevelDTO> adminLevels) {
    radios = Lists.newArrayList();
    radios.add(new ClusteringRadio(I18N.CONSTANTS.none(), new NoClustering()));
    radios.add(new ClusteringRadio(I18N.CONSTANTS.automatic(), new AutomaticClustering()));
    for (AdminLevelDTO level : adminLevels) {
        AdministrativeLevelClustering clustering = new AdministrativeLevelClustering();
        clustering.getAdminLevels().add(level.getId());
        radios.add(new ClusteringRadio(level.getName(), clustering));
    }
    radioGroup = new RadioGroup();
    radioGroup.setOrientation(Orientation.VERTICAL);
    radioGroup.setStyleAttribute("padding", "5px");
    for (ClusteringRadio radio : radios) {
        radioGroup.add(radio);
        if (radio.getClustering().equals(value)) {
            radioGroup.setValue(radio);
        }
    }
    add(radioGroup);
    radioGroup.addListener(Events.Change, new Listener<FieldEvent>() {

        @Override
        public void handleEvent(FieldEvent be) {
            ClusteringRadio radio = (ClusteringRadio) radioGroup.getValue();
            setValue(radio.getClustering(), true);
        }
    });
    layout();
// unmask();
}
Also used : AdministrativeLevelClustering(org.activityinfo.legacy.shared.reports.model.clustering.AdministrativeLevelClustering) RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup) AdminLevelDTO(org.activityinfo.legacy.shared.model.AdminLevelDTO) FieldEvent(com.extjs.gxt.ui.client.event.FieldEvent) NoClustering(org.activityinfo.legacy.shared.reports.model.clustering.NoClustering) AutomaticClustering(org.activityinfo.legacy.shared.reports.model.clustering.AutomaticClustering)

Example 3 with NoClustering

use of org.activityinfo.legacy.shared.reports.model.clustering.NoClustering in project activityinfo by bedatadriven.

the class PiechartMapLayerGeneratorTest method testSomething.

@Test
public void testSomething() {
    SiteDTO siteData = new SiteDTO();
    siteData.setId(42);
    siteData.setX(15.0);
    siteData.setY(0.0);
    siteData.setIndicatorValue(1, 50.0);
    siteData.setIndicatorValue(2, 10.0);
    siteData.setIndicatorValue(3, 20.0);
    siteData.setIndicatorValue(4, 40.0);
    PiechartMapLayer pcml = new PiechartMapLayer();
    pcml.setMinRadius(10);
    pcml.setMaxRadius(50);
    pcml.addIndicatorId(1);
    pcml.addIndicatorId(2);
    pcml.addIndicatorId(3);
    pcml.addIndicatorId(4);
    pcml.setClustering(new NoClustering());
    TiledMap map = new TiledMap(500, 600, new AiLatLng(15.0, 0.0), 6);
    Map<Integer, Indicator> indicators = Maps.newHashMap();
    indicators.put(1, new Indicator());
    indicators.put(2, new Indicator());
    indicators.put(3, new Indicator());
    indicators.put(4, new Indicator());
    PiechartLayerGenerator gen = new PiechartLayerGenerator(pcml, indicators);
    gen.setSites(Arrays.asList(siteData));
    MapContent mc = new MapContent();
    gen.generate(map, mc);
    assertThat(mc.getMarkers().size(), equalTo(1));
    assertThat(((PieMapMarker) mc.getMarkers().get(0)).getSlices().size(), equalTo(4));
}
Also used : MapContent(org.activityinfo.legacy.shared.reports.content.MapContent) NoClustering(org.activityinfo.legacy.shared.reports.model.clustering.NoClustering) PieMapMarker(org.activityinfo.legacy.shared.reports.content.PieMapMarker) AiLatLng(org.activityinfo.model.type.geo.AiLatLng) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) PiechartMapLayer(org.activityinfo.legacy.shared.reports.model.layers.PiechartMapLayer) Indicator(org.activityinfo.server.database.hibernate.entity.Indicator) Test(org.junit.Test)

Aggregations

NoClustering (org.activityinfo.legacy.shared.reports.model.clustering.NoClustering)3 FieldEvent (com.extjs.gxt.ui.client.event.FieldEvent)1 RadioGroup (com.extjs.gxt.ui.client.widget.form.RadioGroup)1 AdminLevelDTO (org.activityinfo.legacy.shared.model.AdminLevelDTO)1 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)1 MapContent (org.activityinfo.legacy.shared.reports.content.MapContent)1 PieMapMarker (org.activityinfo.legacy.shared.reports.content.PieMapMarker)1 AdministrativeLevelClustering (org.activityinfo.legacy.shared.reports.model.clustering.AdministrativeLevelClustering)1 AutomaticClustering (org.activityinfo.legacy.shared.reports.model.clustering.AutomaticClustering)1 PiechartMapLayer (org.activityinfo.legacy.shared.reports.model.layers.PiechartMapLayer)1 PointMapLayer (org.activityinfo.legacy.shared.reports.model.layers.PointMapLayer)1 AiLatLng (org.activityinfo.model.type.geo.AiLatLng)1 Indicator (org.activityinfo.server.database.hibernate.entity.Indicator)1 Test (org.junit.Test)1