Search in sources :

Example 1 with ListEntryDTO

use of au.org.ala.spatial.dto.ListEntryDTO in project spatial-portal by AtlasOfLivingAustralia.

the class EnvironmentalList method setupListEntries.

void setupListEntries() {
    listEntries = new ArrayList<ListEntryDTO>();
    JSONArray ja = CommonData.getLayerListJSONArray();
    for (int i = 0; i < ja.size(); i++) {
        JSONObject field = (JSONObject) ja.get(i);
        JSONObject layer = (JSONObject) field.get("layer");
        listEntries.add(new ListEntryDTO(field.get(StringConstants.ID).toString(), field.containsKey(StringConstants.NAME) ? field.get(StringConstants.NAME).toString() : field.get(StringConstants.ID).toString(), layer.containsKey(StringConstants.CLASSIFICATION1) ? layer.get(StringConstants.CLASSIFICATION1).toString() : "", layer.containsKey(StringConstants.CLASSIFICATION2) ? layer.get(StringConstants.CLASSIFICATION2).toString() : "", layer.containsKey(StringConstants.TYPE) ? layer.get(StringConstants.TYPE).toString() : "", layer.containsKey(StringConstants.DOMAIN) ? layer.get(StringConstants.DOMAIN).toString() : "", layer));
    }
    if (includeAnalysisLayers) {
        for (MapLayer ml : mapComposer.getAnalysisLayers()) {
            ListEntryDTO le = null;
            if (ml.getSubType() == LayerUtilitiesImpl.ALOC) {
                le = new ListEntryDTO(ml.getName(), ml.getDisplayName(), StringConstants.ANALYSIS, StringConstants.CLASSIFICATION, "Contextual", null, null);
            } else if (ml.getSubType() == LayerUtilitiesImpl.MAXENT) {
                le = new ListEntryDTO(ml.getName(), ml.getDisplayName(), StringConstants.ANALYSIS, StringConstants.PREDICTION, StringConstants.ENVIRONMENTAL, null, null);
            } else if (ml.getSubType() == LayerUtilitiesImpl.GDM) {
                le = new ListEntryDTO(ml.getName(), ml.getDisplayName(), StringConstants.ANALYSIS, StringConstants.GDM, StringConstants.ENVIRONMENTAL, null, null);
            } else if (ml.getSubType() == LayerUtilitiesImpl.ODENSITY) {
                le = new ListEntryDTO(ml.getName(), ml.getDisplayName(), StringConstants.ANALYSIS, StringConstants.OCCURRENCE_DENSITY, StringConstants.ENVIRONMENTAL, null, null);
            } else if (ml.getSubType() == LayerUtilitiesImpl.SRICHNESS) {
                le = new ListEntryDTO(ml.getName(), ml.getDisplayName(), StringConstants.ANALYSIS, StringConstants.SPECIES_RICHNESS, StringConstants.ENVIRONMENTAL, null, null);
            }
            if (le != null) {
                listEntries.add(le);
            }
        }
    }
    java.util.Collections.sort(listEntries, new Comparator<ListEntryDTO>() {

        @Override
        public int compare(ListEntryDTO e1, ListEntryDTO e2) {
            return (e1.getCatagory1() + " " + e1.getCatagory2() + " " + e1.getDisplayName()).compareTo(e2.getCatagory1() + " " + e2.getCatagory2() + " " + e2.getDisplayName());
        }
    });
}
Also used : ListEntryDTO(au.org.ala.spatial.dto.ListEntryDTO) JSONObject(org.json.simple.JSONObject) MapLayer(au.org.emii.portal.menu.MapLayer) JSONArray(org.json.simple.JSONArray)

Example 2 with ListEntryDTO

use of au.org.ala.spatial.dto.ListEntryDTO in project spatial-portal by AtlasOfLivingAustralia.

the class EnvironmentalList method updateDistances.

public void updateDistances() {
    this.setMultiple(true);
    if (listEntries == null) {
        return;
    }
    String fieldId;
    for (ListEntryDTO le : listEntries) {
        //set to 2 for contextual and 'no association distance'
        if (StringConstants.CONTEXTUAL.equalsIgnoreCase(le.getType()) || le.getLayerObject() == null || !le.getLayerObject().containsKey(StringConstants.FIELDS) || (fieldId = getFieldId(le.getLayerObject())) == null || CommonData.getDistancesMap().get(fieldId) == null) {
            le.setValue(2);
        } else {
            le.setValue(1);
        }
    }
    for (Object o : getSelectedItems()) {
        ListEntryDTO l = listEntries.get(((Listitem) o).getIndex());
        l.setValue(0);
        String[] domain;
        if (StringConstants.ENVIRONMENTAL.equalsIgnoreCase(l.getType()) && l.getLayerObject() != null && CommonData.getDistancesMap().get(l.getName()) != null && (domain = Util.getDomain(l.getLayerObject())).length > 0) {
            for (ListEntryDTO le : listEntries) {
                if (le.getLayerObject() != null && (!singleDomain || Util.isSameDomain(Util.getDomain(le.getLayerObject()), domain))) {
                    Double d = CommonData.getDistancesMap().get(l.getName()).get(le.getName());
                    if (d != null) {
                        le.setValue((float) Math.min(le.getValue(), d));
                    }
                }
            }
        }
    }
    for (int i = 0; i < listEntries.size(); i++) {
        float value = listEntries.get(i).getValue();
        String type = listEntries.get(i).getType();
        Listcell lc = (Listcell) (getItemAtIndex(i).getLastChild());
        if (StringConstants.ENVIRONMENTAL.equalsIgnoreCase(type)) {
            if (threasholds[0] > value) {
                lc.setSclass(StringConstants.LCRED);
            } else if (threasholds[1] > value) {
                lc.setSclass(StringConstants.LCYELLOW);
            } else if (1 >= value) {
                lc.setSclass(StringConstants.LCGREEN);
            } else {
                lc.setSclass(StringConstants.LCWHITE);
            }
        }
    }
    forceDomain();
}
Also used : ListEntryDTO(au.org.ala.spatial.dto.ListEntryDTO) JSONObject(org.json.simple.JSONObject)

Example 3 with ListEntryDTO

use of au.org.ala.spatial.dto.ListEntryDTO in project spatial-portal by AtlasOfLivingAustralia.

the class EnvironmentalList method forceDomain.

void forceDomain() {
    String[] firstDomain = getFirstDomain();
    String[] thisDomain;
    if (!singleDomain || firstDomain.length == 0) {
        for (int i = 0; i < listEntries.size(); i++) {
            boolean defaultDisable = disableContextualLayers && StringConstants.CONTEXTUAL.equalsIgnoreCase(listEntries.get(i).getType());
            getItemAtIndex(i).setDisabled(defaultDisable);
        }
        return;
    }
    for (int i = 0; i < listEntries.size(); i++) {
        ListEntryDTO l = listEntries.get(i);
        if (l.getLayerObject() != null) {
            thisDomain = Util.getDomain(l.getLayerObject());
            if (thisDomain.length > 0) {
                boolean defaultDisable = disableContextualLayers && StringConstants.CONTEXTUAL.equalsIgnoreCase(listEntries.get(i).getType());
                boolean match = false;
                for (String d1 : firstDomain) {
                    for (String d2 : thisDomain) {
                        if (d1.equalsIgnoreCase(d2)) {
                            match = true;
                        }
                    }
                }
                getItemAtIndex(i).setDisabled(defaultDisable || !match);
                if (!match && getItemAtIndex(i).isSelected()) {
                    toggleItemSelection(getItemAtIndex(i));
                }
            }
        }
    }
}
Also used : ListEntryDTO(au.org.ala.spatial.dto.ListEntryDTO)

Aggregations

ListEntryDTO (au.org.ala.spatial.dto.ListEntryDTO)3 JSONObject (org.json.simple.JSONObject)2 MapLayer (au.org.emii.portal.menu.MapLayer)1 JSONArray (org.json.simple.JSONArray)1