Search in sources :

Example 21 with AbstractRecordLayer

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

the class EditRecordGeometryOverlay method mouseClicked.

@Override
public void mouseClicked(final MouseEvent event) {
    if (modeAddGeometryClick(event)) {
    } else if (SwingUtil.isLeftButtonAndNoModifiers(event) && event.getClickCount() == 2) {
        final List<LayerRecord> records = new ArrayList<>();
        final BoundingBox boundingBox = getHotspotBoundingBox();
        final Geometry boundary = boundingBox.toPolygon().prepare();
        addRecords(records, getProject(), boundary);
        final int size = records.size();
        if (size == 0) {
        } else if (size < 10) {
            for (final LayerRecord record : records) {
                final AbstractRecordLayer layer = record.getLayer();
                layer.showForm(record);
            }
            event.consume();
        } else {
            JOptionPane.showMessageDialog(this, "There are too many " + size + " selected to view. Maximum 10. Select fewer records or move mouse to middle of geometry.", "Too Many Selected Records", JOptionPane.ERROR_MESSAGE);
            event.consume();
        }
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) BoundingBox(com.revolsys.geometry.model.BoundingBox) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) List(java.util.List) ArrayList(java.util.ArrayList) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 22 with AbstractRecordLayer

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

the class EditRecordGeometryOverlay method getSnapLayers.

@Override
protected List<AbstractRecordLayer> getSnapLayers() {
    final Project project = getProject();
    final double scale = project.getMapPanel().getScale();
    final Set<AbstractRecordLayer> layers = new LinkedHashSet<>();
    boolean snapAll = false;
    if (isOverlayAction(ACTION_ADD_GEOMETRY)) {
        snapAll = addSnapLayers(layers, project, this.addLayer, scale);
    } else {
        for (final CloseLocation location : getMouseOverLocations()) {
            final AbstractRecordLayer layer = location.getLayer();
            snapAll |= addSnapLayers(layers, project, layer, scale);
        }
    }
    if (snapAll) {
        final List<AbstractRecordLayer> visibleDescendants = project.getVisibleDescendants(AbstractRecordLayer.class, scale);
        return visibleDescendants;
    }
    return new ArrayList<>(layers);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CloseLocation(com.revolsys.swing.map.overlay.CloseLocation) Project(com.revolsys.swing.map.layer.Project) ArrayList(java.util.ArrayList) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer)

Example 23 with AbstractRecordLayer

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

the class EditRecordGeometryOverlay method splitLineKeyPress.

// K key to split a record
protected boolean splitLineKeyPress(final KeyEvent e) {
    final int keyCode = e.getKeyCode();
    if (keyCode == KeyEvent.VK_K) {
        if (!isOverlayAction(ACTION_ADD_GEOMETRY) && hasMouseOverLocation()) {
            for (final CloseLocation mouseLocation : getMouseOverLocations()) {
                final LayerRecord record = mouseLocation.getRecord();
                final AbstractRecordLayer layer = record.getLayer();
                layer.splitRecord(record, mouseLocation);
            }
            e.consume();
            return true;
        }
    }
    return false;
}
Also used : CloseLocation(com.revolsys.swing.map.overlay.CloseLocation) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) Point(com.revolsys.geometry.model.Point)

Example 24 with AbstractRecordLayer

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

the class EditRecordGeometryOverlay method addSnapLayers.

protected boolean addSnapLayers(final Set<AbstractRecordLayer> layers, final Project project, final AbstractRecordLayer layer, final double scale) {
    if (layer != null) {
        if (layer.isSnapToAllLayers()) {
            return true;
        } else {
            layers.add(layer);
            final Collection<String> layerPaths = layer.getSnapLayerPaths();
            if (layerPaths != null) {
                for (final String layerPath : layerPaths) {
                    final Layer snapLayer = project.getLayer(layerPath);
                    if (snapLayer instanceof AbstractRecordLayer) {
                        if (snapLayer.isVisible(scale)) {
                            layers.add((AbstractRecordLayer) snapLayer);
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LineString(com.revolsys.geometry.model.LineString) ElevationModelLayer(com.revolsys.swing.map.layer.elevation.ElevationModelLayer) Layer(com.revolsys.swing.map.layer.Layer) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer)

Example 25 with AbstractRecordLayer

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

the class FieldCalculator method initFieldPanel.

@Override
protected JPanel initFieldPanel() {
    final FieldDefinition fieldDefinition = this.getFieldDefinition();
    final String fieldName = fieldDefinition.getName();
    final JPanel fieldPanel = new JPanel(new VerticalLayout());
    final ToolBar toolBar = new ToolBar();
    fieldPanel.add(toolBar);
    this.expressionField = new TextArea("script", 8, 1);
    fieldPanel.add(new JScrollPane(this.expressionField));
    this.expressionField.getDocument().addDocumentListener(this);
    final AbstractRecordLayer layer = getLayer();
    final List<String> fieldNames = layer.getFieldNames();
    final ComboBox<String> fieldNamesField = ComboBox.newComboBox("fieldNames", fieldNames, (final Object name) -> {
        return layer.getFieldTitle((String) name);
    });
    toolBar.addComponent("fieldName", fieldNamesField);
    toolBar.add(fieldNamesField);
    fieldNamesField.setMaximumSize(new Dimension(250, 30));
    final Runnable addFieldAction = () -> {
        final String selectedFieldName = fieldNamesField.getFieldValue();
        insertText(selectedFieldName);
    };
    toolBar.addButton("fieldName", "Add field name", "add", addFieldAction);
    for (final String text : Arrays.asList("+", "-", "*", "/")) {
        addTextButton("operators", toolBar, text, text);
    }
    addTextButton("condition", toolBar, "if", "if (expression) {\n  newValue;\n} else {\n  " + fieldName + ";\n}");
    addTextButton("codeTable", toolBar, "Code ID", "codeId('codeFieldName', codeValue)");
    addTextButton("codeTable", toolBar, "Code Value", "codeValue('codeFieldName', codeValue)");
    return fieldPanel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) TextArea(com.revolsys.swing.field.TextArea) JTextArea(javax.swing.JTextArea) FieldDefinition(com.revolsys.record.schema.FieldDefinition) Dimension(java.awt.Dimension) ToolBar(com.revolsys.swing.toolbar.ToolBar) VerticalLayout(org.jdesktop.swingx.VerticalLayout) 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