use of com.revolsys.geometry.model.GeometryDataType in project com.revolsys.open by revolsys.
the class EditRecordGeometryOverlay method getVertexGeometry.
protected Geometry getVertexGeometry(final MouseEvent event, final CloseLocation location) {
final Geometry geometry = location.getGeometry();
final DataType geometryDataType = DataTypes.getDataType(geometry);
final DataType geometryPartDataType = getGeometryPartDataType(geometryDataType);
int previousPointOffset;
int[] vertexId = location.getVertexId();
if (vertexId == null) {
previousPointOffset = 0;
vertexId = location.getSegmentId();
} else {
previousPointOffset = -1;
}
final GeometryFactory geometryFactory = location.getGeometryFactory();
if (DataTypes.GEOMETRY.equals(geometryPartDataType)) {
} else if (DataTypes.POINT.equals(geometryPartDataType)) {
} else {
final Point point = getPoint(geometryFactory, event);
final Vertex vertex = geometry.getVertex(vertexId);
Point previousPoint = null;
Point nextPoint = null;
if (DataTypes.LINE_STRING.equals(geometryPartDataType) || DataTypes.POLYGON.equals(geometryPartDataType)) {
if (previousPointOffset == 0) {
previousPoint = vertex;
} else {
previousPoint = vertex.getLinePrevious();
}
nextPoint = vertex.getLineNext();
}
final List<LineString> lines = new ArrayList<>();
if (previousPoint != null && !previousPoint.isEmpty()) {
lines.add(newXorLine(geometryFactory, previousPoint, point));
}
if (nextPoint != null && !nextPoint.isEmpty()) {
lines.add(newXorLine(geometryFactory, nextPoint, point));
}
if (!lines.isEmpty()) {
return geometryFactory.lineal(lines);
}
}
return null;
}
use of com.revolsys.geometry.model.GeometryDataType in project com.revolsys.open by revolsys.
the class EditRecordGeometryOverlay method addRecord.
/**
* Set the addLayer that a new feature is to be added to.
*
* @param addLayer
*/
@SuppressWarnings("unchecked")
public void addRecord(final AbstractRecordLayer layer, final AddGeometryCompleteAction addCompleteAction) {
if (layer != null) {
final RecordDefinition recordDefinition = layer.getRecordDefinition();
final FieldDefinition geometryField = recordDefinition.getGeometryField();
if (geometryField != null) {
this.addLayer = layer;
this.addCompleteAction = addCompleteAction;
final GeometryFactory geometryFactory = recordDefinition.getGeometryFactory();
this.setGeometryFactory(geometryFactory);
clearUndoHistory();
setOverlayAction(ACTION_ADD_GEOMETRY);
final GeometryDataType<Geometry, GeometryEditor<?>> geometryDataType = (GeometryDataType<Geometry, GeometryEditor<?>>) geometryField.getDataType();
setAddGeometryDataType(geometryDataType, geometryFactory);
setMapCursor(CURSOR_NODE_ADD);
}
}
}
Aggregations