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