Search in sources :

Example 1 with AbstractRecordLayerRenderer

use of com.revolsys.swing.map.layer.record.renderer.AbstractRecordLayerRenderer 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 AbstractRecordLayerRenderer

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

the class SelectRecordsOverlay method refreshImageRenderer.

private void refreshImageRenderer(final ImageViewport viewport, final LayerGroup layerGroup) {
    for (final Layer layer : layerGroup.getLayers()) {
        if (layer instanceof LayerGroup) {
            final LayerGroup childGroup = (LayerGroup) layer;
            refreshImageRenderer(viewport, childGroup);
        } else if (layer instanceof AbstractRecordLayer) {
            final AbstractRecordLayer recordLayer = (AbstractRecordLayer) layer;
            final AbstractRecordLayerRenderer layerRenderer = layer.getRenderer();
            if (recordLayer.isSelectable()) {
                final List<LayerRecord> selectedRecords = recordLayer.getSelectedRecords();
                for (final LayerRecord record : selectedRecords) {
                    if (record != null && recordLayer.isVisible(record)) {
                        if (!recordLayer.isDeleted(record)) {
                            layerRenderer.renderSelectedRecord(viewport, recordLayer, record);
                        }
                    }
                }
            }
        }
    }
}
Also used : AbstractRecordLayerRenderer(com.revolsys.swing.map.layer.record.renderer.AbstractRecordLayerRenderer) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) List(java.util.List) ArrayList(java.util.ArrayList) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) Layer(com.revolsys.swing.map.layer.Layer) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer)

Example 3 with AbstractRecordLayerRenderer

use of com.revolsys.swing.map.layer.record.renderer.AbstractRecordLayerRenderer 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)

Example 4 with AbstractRecordLayerRenderer

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

the class AbstractRecordLayer method setStyle.

@SuppressWarnings("unchecked")
public void setStyle(Object style) {
    if (style instanceof Map) {
        final Map<String, Object> map = (Map<String, Object>) style;
        style = MapObjectFactory.toObject(map);
    }
    if (style instanceof AbstractRecordLayerRenderer) {
        final AbstractRecordLayerRenderer renderer = (AbstractRecordLayerRenderer) style;
        setRenderer(renderer);
    } else {
        Logs.error(this, "Cannot create renderer for: " + style);
    }
}
Also used : AbstractRecordLayerRenderer(com.revolsys.swing.map.layer.record.renderer.AbstractRecordLayerRenderer) LineString(com.revolsys.geometry.model.LineString) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap)

Example 5 with AbstractRecordLayerRenderer

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

the class AbstractRecordLayer method addRenderer.

@Override
public int addRenderer(final LayerRenderer<?> child, final int index) {
    final AbstractRecordLayerRenderer oldRenderer = getRenderer();
    AbstractMultipleRenderer rendererGroup;
    if (oldRenderer instanceof AbstractMultipleRenderer) {
        rendererGroup = (AbstractMultipleRenderer) oldRenderer;
    } else {
        final AbstractRecordLayer layer = oldRenderer.getLayer();
        rendererGroup = new MultipleRecordRenderer(layer);
        rendererGroup.addRenderer(oldRenderer);
        setRenderer(rendererGroup);
    }
    if (index == 0) {
        rendererGroup.addRenderer(0, (AbstractRecordLayerRenderer) child);
        return 0;
    } else {
        rendererGroup.addRenderer((AbstractRecordLayerRenderer) child);
        return rendererGroup.getRenderers().size() - 1;
    }
}
Also used : AbstractRecordLayerRenderer(com.revolsys.swing.map.layer.record.renderer.AbstractRecordLayerRenderer) AbstractMultipleRenderer(com.revolsys.swing.map.layer.record.renderer.AbstractMultipleRenderer) MultipleRecordRenderer(com.revolsys.swing.map.layer.record.renderer.MultipleRecordRenderer)

Aggregations

AbstractRecordLayerRenderer (com.revolsys.swing.map.layer.record.renderer.AbstractRecordLayerRenderer)5 ArrayList (java.util.ArrayList)3 MapEx (com.revolsys.collection.map.MapEx)2 FilterMultipleRenderer (com.revolsys.swing.map.layer.record.renderer.FilterMultipleRenderer)2 MultipleRecordRenderer (com.revolsys.swing.map.layer.record.renderer.MultipleRecordRenderer)2 List (java.util.List)2 LineString (com.revolsys.geometry.model.LineString)1 FieldDefinition (com.revolsys.record.schema.FieldDefinition)1 AbstractLayer (com.revolsys.swing.map.layer.AbstractLayer)1 Layer (com.revolsys.swing.map.layer.Layer)1 LayerGroup (com.revolsys.swing.map.layer.LayerGroup)1 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)1 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)1 AbstractMultipleRenderer (com.revolsys.swing.map.layer.record.renderer.AbstractMultipleRenderer)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1