Search in sources :

Example 16 with Facet

use of au.org.ala.legend.Facet in project spatial-portal by AtlasOfLivingAustralia.

the class LayerLegendScatterplotController method registerScatterPlotSelection.

private void registerScatterPlotSelection() {
    try {
        if (data.getLayer1() != null && data.getLayer1().length() > 0 && data.getLayer2() != null && data.getLayer2().length() > 0) {
            Facet f = getFacetIn();
            int count = 0;
            if (f != null) {
                Query q = data.getQuery().newFacet(f, false);
                count = q.getOccurrenceCount();
            }
            updateCount(String.valueOf(count));
        }
    } catch (Exception e) {
        LOGGER.error("error updating scatterplot selection", e);
        clearSelection();
        getMapComposer().applyChange(mapLayer);
    }
}
Also used : Query(au.org.ala.spatial.util.Query) Facet(au.org.ala.legend.Facet)

Example 17 with Facet

use of au.org.ala.legend.Facet in project spatial-portal by AtlasOfLivingAustralia.

the class AddFacetController method onClick$btnOk.

public void onClick$btnOk(Event event) {
    if (btnOk.isDisabled()) {
        return;
    }
    try {
        if (!hasCustomArea && (isAreaCustom() || isAreaHighlightCustom())) {
            this.doOverlapped();
            this.setTop("-9999px");
            this.setLeft("-9999px");
            Map<String, Object> winProps = new HashMap<String, Object>();
            winProps.put(StringConstants.PARENT, this);
            winProps.put(StringConstants.PARENTNAME, "Tool");
            winProps.put(StringConstants.SELECTEDMETHOD, selectedMethod);
            List<MapLayer> layers = getMapComposer().getPolygonLayers();
            if (layers != null && !layers.isEmpty()) {
                prevTopArea = layers.get(0);
            } else {
                prevTopArea = null;
            }
            Window window = (Window) Executions.createComponents("WEB-INF/zul/add/AddArea.zul", this, winProps);
            window.setAttribute("winProps", winProps, true);
            window.setParent(this);
            window.doModal();
            return;
        }
        Div currentDiv = (Div) getFellowIfAny(StringConstants.ATSTEP + currentStep);
        Div nextDiv = (Div) getFellowIfAny(StringConstants.ATSTEP + (currentStep + 1));
        if (!currentDiv.getZclass().contains(StringConstants.LAST)) {
            currentDiv.setVisible(false);
            nextDiv.setVisible(true);
            Html previousStepCompletedImg = (Html) getFellowIfAny(StringConstants.IMG_COMPLETED_STEP + (currentStep));
            previousStepCompletedImg.setVisible(true);
            Label previousStepLabel = (Label) getFellowIfAny(StringConstants.LBLSTEP + (currentStep));
            previousStepLabel.setStyle(StringConstants.FONT_WEIGHT_NORMAL);
            Label currentStepLabel = (Label) getFellowIfAny(StringConstants.LBLSTEP + (currentStep + 1));
            currentStepLabel.setStyle(StringConstants.FONT_WEIGHT_BOLD);
            currentStep++;
            updateWindowTitle();
            fixFocus();
            sa = getSelectedArea();
            query = QueryUtil.queryFromSelectedArea(query, sa, false, getGeospatialKosher());
            if (query != null) {
                List<QueryField> fields = query.getFacetFieldList();
                Collections.sort(fields, new QueryField.QueryFieldComparator());
                String lastGroup = null;
                for (QueryField field : fields) {
                    String newGroup = field.getGroup().getName();
                    if (!newGroup.equals(lastGroup)) {
                        Comboitem sep = new Comboitem(StringConstants.SEPERATOR);
                        sep.setLabel("---------------" + StringUtils.center(newGroup, 19) + "---------------");
                        sep.setParent(cbColour);
                        sep.setDisabled(true);
                        lastGroup = newGroup;
                    }
                    Comboitem ci = new Comboitem(field.getDisplayName());
                    ci.setValue(field.getName());
                    ci.setParent(cbColour);
                }
            }
            btnBack.setDisabled(false);
            btnOk.setDisabled(true);
        } else {
            if (selectedList.size() == 0) {
                btnOk.setDisabled(true);
            }
            Facet f = Facet.parseFacet(getSelectionFacet());
            Query querynew = query.newFacet(f, true);
            if (querynew.getOccurrenceCount() <= 0) {
                getMapComposer().showMessage(CommonData.lang(StringConstants.NO_OCCURRENCES_SELECTED));
            } else {
                getMapComposer().mapSpecies(querynew, StringConstants.MY_FACET, StringConstants.SPECIES, -1, LayerUtilitiesImpl.SPECIES, null, 0, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), false);
                this.detach();
            }
        }
    } catch (Exception ex) {
        LOGGER.error("error adding facet", ex);
    }
    fixFocus();
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) SuspendNotAllowedException(org.zkoss.zk.ui.SuspendNotAllowedException) QueryField(au.org.ala.legend.QueryField) LegendObject(au.org.ala.legend.LegendObject) Facet(au.org.ala.legend.Facet)

Example 18 with Facet

use of au.org.ala.legend.Facet in project spatial-portal by AtlasOfLivingAustralia.

the class AddFacetController method onClick$dbutton.

public void onClick$dbutton(Event event) {
    uncheckAll();
    minValue = dmin.getValue();
    maxValue = dmax.getValue();
    //get count and display
    Facet f = Facet.parseFacet(getSelectionFacet());
    Query querynew = query.newFacet(f, true);
    lblOccurrencesSelected.setValue(querynew.getOccurrenceCount() + " occurrences selected");
}
Also used : Facet(au.org.ala.legend.Facet)

Example 19 with Facet

use of au.org.ala.legend.Facet in project spatial-portal by AtlasOfLivingAustralia.

the class AreaEnvironmentalEnvelope method getFacets.

List<Facet> getFacets() {
    List<Facet> facets = new ArrayList<Facet>();
    for (int i = 0; i < selectedLayers.size(); i++) {
        SPLFilter splf = selectedSPLFilterLayers.get(selectedLayers.get(i).get(StringConstants.ID));
        Facet f = new Facet(CommonData.getLayerFacetName(splf.getLayername()), splf.getMinimumValue(), splf.getMaximumValue(), true);
        facets.add(f);
    }
    return facets;
}
Also used : ArrayList(java.util.ArrayList) Facet(au.org.ala.legend.Facet)

Example 20 with Facet

use of au.org.ala.legend.Facet in project spatial-portal by AtlasOfLivingAustralia.

the class ClassificationLegend method updateD.

void updateD() {
    if (!dmin.isDisabled()) {
        double range = gMaxValue - gMinValue;
        if (range > 0) {
            dmin.setValue(minValue);
            dmax.setValue(maxValue);
            mapLayer.setHighlight(getSelectionFacet());
            Facet f = Facet.parseFacet(getSelectionFacet());
            int occurrencesCount = query.getOccurrenceCount();
            if (f != null) {
                occurrencesCount = query.newFacet(f, false).getOccurrenceCount();
            }
            String minText = minValue == (int) minValue ? String.valueOf((int) minValue) : String.format("%f", minValue);
            String maxText = maxValue == (int) maxValue ? String.valueOf((int) maxValue) : String.format("%f", maxValue);
            String unknownText = dunknown.isChecked() ? " +Unknown" : " ";
            String selectedText;
            if (occurrencesCount == query.getOccurrenceCount()) {
                selectedText = String.format(" (all of %d records selected)", occurrencesCount);
            } else {
                selectedText = String.format(" (%d of %d records selected)", occurrencesCount, query.getOccurrenceCount());
            }
            createInGroup.setVisible(!disableselection && occurrencesCount != 0 && occurrencesCount != query.getOccurrenceCount());
            if (createOutGroup != null)
                createOutGroup.setVisible(!disableselection && occurrencesCount != 0 && occurrencesCount != query.getOccurrenceCount());
            clearSelection.setVisible(!disableselection && occurrencesCount != 0 && occurrencesCount != query.getOccurrenceCount());
            dlabel.setValue(minText + " to " + maxText + unknownText + selectedText);
            getMapComposer().applyChange(mapLayer);
        }
    } else {
        dlabel.setValue("list selection underway, range selection disabled");
    }
}
Also used : Facet(au.org.ala.legend.Facet)

Aggregations

Facet (au.org.ala.legend.Facet)35 MapLayer (au.org.emii.portal.menu.MapLayer)12 SelectedArea (au.org.emii.portal.menu.SelectedArea)12 JSONObject (org.json.simple.JSONObject)8 ArrayList (java.util.ArrayList)7 JSONParser (org.json.simple.parser.JSONParser)6 ParseException (org.json.simple.parser.ParseException)6 Query (au.org.ala.spatial.util.Query)5 LegendObject (au.org.ala.legend.LegendObject)3 MapLayerMetadata (au.org.emii.portal.menu.MapLayerMetadata)3 Geometry (com.vividsolutions.jts.geom.Geometry)3 IOException (java.io.IOException)3 StringReader (java.io.StringReader)3 HttpClient (org.apache.commons.httpclient.HttpClient)3 PostMethod (org.apache.commons.httpclient.methods.PostMethod)3 JSONArray (org.json.simple.JSONArray)3 CSVReader (au.com.bytecode.opencsv.CSVReader)2 ScatterplotDataDTO (au.org.ala.spatial.dto.ScatterplotDataDTO)2 BiocacheQuery (au.org.ala.spatial.util.BiocacheQuery)2 XmlArrayList (com.thoughtworks.xstream.persistence.XmlArrayList)2