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));
}
}
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);
}
}
}
}
}
}
}
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;
}
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);
}
}
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;
}
}
Aggregations