Search in sources :

Example 1 with FilterMultipleRenderer

use of com.revolsys.swing.map.layer.record.renderer.FilterMultipleRenderer in project com.revolsys.open by revolsys.

the class ArcGisRestServerRecordLayer method initRenderer.

private void initRenderer() {
    final List<AbstractRecordLayerRenderer> renderers = new ArrayList<>();
    final MapEx drawingInfo = this.layerDescription.getProperty("drawingInfo");
    if (drawingInfo != null) {
        final MapEx rendererProperties = drawingInfo.getValue("renderer");
        if (rendererProperties != null) {
            final String rendererType = rendererProperties.getString("type");
            if ("simple".equals(rendererType)) {
                final AbstractRecordLayerRenderer renderer = newSymbolRenderer(rendererProperties, "symbol");
                if (renderer != null) {
                    renderers.add(renderer);
                }
            } else if ("uniqueValue".equals(rendererType)) {
                final FilterMultipleRenderer filterRenderer = newUniqueValueRenderer(rendererProperties);
                renderers.add(filterRenderer);
            } else {
                Logs.error(this, "Unsupported renderer=" + rendererType + "\n" + rendererProperties);
            }
        }
        final List<MapEx> labellingInfo = drawingInfo.getValue("labelingInfo");
        if (labellingInfo != null) {
            final MultipleRecordRenderer labelRenderer = new MultipleRecordRenderer(this);
            labelRenderer.setName("labels");
            for (final MapEx labelProperties : labellingInfo) {
                addTextRenderer(labelRenderer, labelProperties);
            }
            if (!labelRenderer.isEmpty()) {
                renderers.add(labelRenderer);
            }
        }
    }
    if (renderers.isEmpty()) {
    } else if (renderers.size() == 1) {
        setRenderer(renderers.get(0));
    } else {
        setRenderer(new MultipleRecordRenderer(this, renderers));
    }
}
Also used : AbstractRecordLayerRenderer(com.revolsys.swing.map.layer.record.renderer.AbstractRecordLayerRenderer) MapEx(com.revolsys.collection.map.MapEx) MultipleRecordRenderer(com.revolsys.swing.map.layer.record.renderer.MultipleRecordRenderer) ArrayList(java.util.ArrayList) FilterMultipleRenderer(com.revolsys.swing.map.layer.record.renderer.FilterMultipleRenderer)

Example 2 with FilterMultipleRenderer

use of com.revolsys.swing.map.layer.record.renderer.FilterMultipleRenderer in project com.revolsys.open by revolsys.

the class ArcGisRestServerRecordLayer method newUniqueValueRenderer.

@SuppressWarnings("unchecked")
private FilterMultipleRenderer newUniqueValueRenderer(final MapEx rendererProperties) {
    final FilterMultipleRenderer filterRenderer = new FilterMultipleRenderer(this);
    final String fieldName = rendererProperties.getString("field1");
    filterRenderer.setName(fieldName);
    for (final MapEx valueProperties : (List<MapEx>) rendererProperties.getValue("uniqueValueInfos")) {
        final AbstractRecordLayerRenderer valueRenderer = newSymbolRenderer(valueProperties, "symbol");
        if (valueRenderer != null) {
            final String valueLabel = valueProperties.getString("label");
            if (valueLabel != null) {
                valueRenderer.setName(valueLabel);
            }
            final String value = valueProperties.getString("value");
            if (value != null) {
                final FieldDefinition fieldDefinition = getFieldDefinition(fieldName);
                if (fieldDefinition.getDataType().isRequiresQuotes()) {
                    valueRenderer.setQueryFilter(fieldName + "='" + value + '\'');
                } else {
                    valueRenderer.setQueryFilter(fieldName + " = " + value);
                }
            }
            filterRenderer.addRenderer(valueRenderer);
        }
    }
    final AbstractRecordLayerRenderer defaultRenderer = newSymbolRenderer(rendererProperties, "defaultSymbol");
    if (defaultRenderer != null) {
        final String defaultLabel = rendererProperties.getString("defaultLabel", "Default");
        defaultRenderer.setName(defaultLabel);
        filterRenderer.addRenderer(defaultRenderer);
    }
    return filterRenderer;
}
Also used : AbstractRecordLayerRenderer(com.revolsys.swing.map.layer.record.renderer.AbstractRecordLayerRenderer) MapEx(com.revolsys.collection.map.MapEx) FieldDefinition(com.revolsys.record.schema.FieldDefinition) ArrayList(java.util.ArrayList) List(java.util.List) FilterMultipleRenderer(com.revolsys.swing.map.layer.record.renderer.FilterMultipleRenderer)

Aggregations

MapEx (com.revolsys.collection.map.MapEx)2 AbstractRecordLayerRenderer (com.revolsys.swing.map.layer.record.renderer.AbstractRecordLayerRenderer)2 FilterMultipleRenderer (com.revolsys.swing.map.layer.record.renderer.FilterMultipleRenderer)2 ArrayList (java.util.ArrayList)2 FieldDefinition (com.revolsys.record.schema.FieldDefinition)1 MultipleRecordRenderer (com.revolsys.swing.map.layer.record.renderer.MultipleRecordRenderer)1 List (java.util.List)1