Search in sources :

Example 56 with AbstractRecordLayer

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

the class FieldCalculator method validateExpression.

private void validateExpression() {
    boolean valid = true;
    final String scriptText = this.expressionField.getText();
    if (scriptText.isEmpty()) {
        valid = false;
    } else {
        try {
            this.script = this.scriptEngineCompiler.compile(scriptText);
            final Bindings bindings = newBindings();
            final AbstractRecordLayer layer = getLayer();
            final RecordDefinition recordDefinition = layer.getRecordDefinition();
            final Record record = new ArrayRecord(recordDefinition);
            for (final FieldDefinition field : layer.getFieldDefinitions()) {
                bindings.put(field.getName(), null);
            }
            bindings.put("record", record);
            this.script.eval(bindings);
            this.errorsField.setText(null);
        } catch (final Throwable e) {
            String errorMessage = e.getMessage();
            if (!Property.hasValue(errorMessage)) {
                errorMessage = "null pointer";
            }
            this.errorsField.setText(errorMessage);
            this.errorsField.setCaretPosition(0);
            valid = false;
            this.script = null;
        }
    }
    setFormValid(valid);
}
Also used : ArrayRecord(com.revolsys.record.ArrayRecord) FieldDefinition(com.revolsys.record.schema.FieldDefinition) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) Record(com.revolsys.record.Record) ArrayRecord(com.revolsys.record.ArrayRecord) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) Bindings(javax.script.Bindings) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 57 with AbstractRecordLayer

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

the class AbstractMultipleRenderer method convertToScaleStyle.

public ScaleMultipleRenderer convertToScaleStyle() {
    final AbstractRecordLayer layer = getLayer();
    final List<AbstractRecordLayerRenderer> renderers = getRenderers();
    final AbstractMultipleRenderer parent = (AbstractMultipleRenderer) getParent();
    final Map<String, Object> style = toMap();
    style.remove("styles");
    final ScaleMultipleRenderer newRenderer = new ScaleMultipleRenderer(layer, parent);
    newRenderer.setProperties(style);
    newRenderer.setRenderers(JavaBeanUtil.clone(renderers));
    final String name = getName();
    if (name.equals("Filter Style")) {
        newRenderer.setName("Scale Style");
    } else if (name.equals("Multiple Style")) {
        newRenderer.setName("Scale Style");
    }
    replace(layer, parent, newRenderer);
    return newRenderer;
}
Also used : AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer)

Example 58 with AbstractRecordLayer

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

the class AbstractMultipleRenderer method convertToMultipleStyle.

public MultipleRecordRenderer convertToMultipleStyle() {
    final AbstractRecordLayer layer = getLayer();
    final List<AbstractRecordLayerRenderer> renderers = getRenderers();
    final AbstractMultipleRenderer parent = (AbstractMultipleRenderer) getParent();
    final Map<String, Object> style = toMap();
    style.remove("styles");
    final MultipleRecordRenderer newRenderer = new MultipleRecordRenderer(layer, parent);
    newRenderer.setProperties(style);
    newRenderer.setRenderers(JavaBeanUtil.clone(renderers));
    final String name = getName();
    if (name.equals("Filter Style")) {
        newRenderer.setName("Multiple Style");
    } else if (name.equals("Scale Style")) {
        newRenderer.setName("Multiple Style");
    }
    replace(layer, parent, newRenderer);
    return newRenderer;
}
Also used : AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer)

Example 59 with AbstractRecordLayer

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

the class ModeAbstractCached method forEachRecord.

@Override
public void forEachRecord(final Query query, final Consumer<? super LayerRecord> action) {
    final Condition filter = query.getWhereCondition();
    final Map<? extends CharSequence, Boolean> orderBy = query.getOrderBy();
    final AbstractRecordLayer layer = getLayer();
    final Iterable<LayerRecord> records = new ListByIndexIterator<>(this.records);
    layer.forEachRecord(records, filter, orderBy, action);
}
Also used : Condition(com.revolsys.record.query.Condition) ListByIndexIterator(com.revolsys.collection.list.ListByIndexIterator) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 60 with AbstractRecordLayer

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

the class ModeAllPaged method forEachRecord.

@Override
public void forEachRecord(final Query query, final Consumer<? super LayerRecord> action) {
    final AbstractRecordLayer layer = getLayer();
    layer.forEachRecord(query, action);
}
Also used : AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer)

Aggregations

AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)71 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)35 Geometry (com.revolsys.geometry.model.Geometry)9 ArrayList (java.util.ArrayList)8 AbstractLayer (com.revolsys.swing.map.layer.AbstractLayer)7 Layer (com.revolsys.swing.map.layer.Layer)7 List (java.util.List)7 Record (com.revolsys.record.Record)6 Condition (com.revolsys.record.query.Condition)6 LayerGroup (com.revolsys.swing.map.layer.LayerGroup)6 CloseLocation (com.revolsys.swing.map.overlay.CloseLocation)4 Color (java.awt.Color)4 BoundingBox (com.revolsys.geometry.model.BoundingBox)3 Point (com.revolsys.geometry.model.Point)3 Field (com.revolsys.swing.field.Field)3 LayerRecordMenu (com.revolsys.swing.map.layer.record.LayerRecordMenu)3 WebColors (com.revolsys.awt.WebColors)2 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)2 Identifier (com.revolsys.identifier.Identifier)2 FieldDefinition (com.revolsys.record.schema.FieldDefinition)2