Class EditTransaction
java.lang.Object
com.vividsolutions.jump.workbench.ui.EditTransaction
Takes care of "rollback" (if any geometries are invalid) and undo,
for PlugIns and CursorTools that modify geometries.
Also:
- warns the user if invalid geometries are found
- invalidates the layer envelope cache
- invalidates the geometry envelope caches
- (undoably) removes features from the layer when their geometries are made empty
- (undoably) adds features to the layer when they start with empty geometries
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.locationtech.jts.geom.Geometrystatic final String -
Constructor Summary
ConstructorsConstructorDescriptionEditTransaction(Collection<Feature> features, String name, Layer layer, boolean rollingBackInvalidEdits, boolean allowAddingAndRemovingFeatures, LayerViewPanel layerViewPanel) Creates a new EditTransaction modifying features.EditTransaction(Collection<Feature> features, String name, Layer layer, boolean rollingBackInvalidEdits, boolean allowAddingAndRemovingFeatures, LayerViewPanelContext layerViewPanelContext) If you want to delete a feature, you can either (1) include the feature in the features parameter, set allowAddingAndRemovingFeatures to true, then call #setGeometry(feature, empty geometry); or (2) not include the feature in the features parameter, instead using #deleteFeature -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleancommit()booleancommit(EditTransaction.SuccessAction successAction) static booleancommit(Collection<EditTransaction> editTransactions) static booleancommit(Collection<EditTransaction> editTransactions, EditTransaction.SuccessAction successAction) Commits several EditTransactions if their proposed geometries are all valid.protected UndoableCommandvoidcreateFeature(Feature feature) static EditTransactioncreateTransactionOnSelection(EditTransaction.SelectionEditor editor, SelectionManagerProxy selectionManagerProxy, LayerViewPanelContext layerViewPanelContext, String name, Layer layer, boolean rollingBackInvalidEdits, boolean allowAddingAndRemovingFeatures) A utility class creating a transaction able to rollback selected features after they have been edited according to the SelectionEditor definition.voiddeleteFeature(Feature feature) static intemptyGeometryCount(Collection<EditTransaction> transactions) featureToNewGeometryMap(EditTransaction.SelectionEditor editor, SelectionManagerProxy selectionManagerProxy, Layer layer) Utility method to create a map between features and there modified geometry.getFeature(int i) Deprecated.Returns the features modified by this transaction [mmichaud 2011-09-17]org.locationtech.jts.geom.GeometrygetGeometry(int i) Deprecated.org.locationtech.jts.geom.GeometrygetGeometry(Feature feature) getLayer()voidmodifyFeatureGeometry(Feature feature, org.locationtech.jts.geom.Geometry newGeometry) booleanvoidsetGeometries(Map<Feature, org.locationtech.jts.geom.Geometry> featureToGeometryMap) voidsetGeometry(int i, org.locationtech.jts.geom.Geometry geometry) Deprecated.voidsetGeometry(Feature feature, org.locationtech.jts.geom.Geometry geometry) intsize()
-
Field Details
-
ROLLING_BACK_INVALID_EDITS_KEY
-
EMPTY_GEOMETRY
public static final org.locationtech.jts.geom.Geometry EMPTY_GEOMETRY
-
-
Constructor Details
-
EditTransaction
public EditTransaction(Collection<Feature> features, String name, Layer layer, boolean rollingBackInvalidEdits, boolean allowAddingAndRemovingFeatures, LayerViewPanel layerViewPanel) Creates a new EditTransaction modifying features.- Parameters:
features- features to be modifiedname- display name for undo. Use PlugIn#getName or CursorTool#getName.layer- the layer to which the features belongrollingBackInvalidEdits- is true if we want to roll back transaction in case of invalid editsallowAddingAndRemovingFeatures- whether to treat empty geometries as indications to add/remove features or as in fact empty geometrieslayerViewPanel- the view where editing operations take place.
-
EditTransaction
public EditTransaction(Collection<Feature> features, String name, Layer layer, boolean rollingBackInvalidEdits, boolean allowAddingAndRemovingFeatures, LayerViewPanelContext layerViewPanelContext) If you want to delete a feature, you can either (1) include the feature in the features parameter, set allowAddingAndRemovingFeatures to true, then call #setGeometry(feature, empty geometry); or (2) not include the feature in the features parameter, instead using #deleteFeature- Parameters:
features- features to be modifiedname- display name for undo. Use PlugIn#getName or CursorTool#getName.layer- the layer to which the features belongrollingBackInvalidEdits- is true if we want to roll back transaction in case of invalid editsallowAddingAndRemovingFeatures- whether to treat empty geometries as indications to add/remove features or as in fact empty geometrieslayerViewPanelContext- the view where editing operations take place.
-
-
Method Details
-
createTransactionOnSelection
public static EditTransaction createTransactionOnSelection(EditTransaction.SelectionEditor editor, SelectionManagerProxy selectionManagerProxy, LayerViewPanelContext layerViewPanelContext, String name, Layer layer, boolean rollingBackInvalidEdits, boolean allowAddingAndRemovingFeatures) A utility class creating a transaction able to rollback selected features after they have been edited according to the SelectionEditor definition. -
featureToNewGeometryMap
public static Map<Feature, org.locationtech.jts.geom.Geometry> featureToNewGeometryMap(EditTransaction.SelectionEditor editor, SelectionManagerProxy selectionManagerProxy, Layer layer) Utility method to create a map between features and there modified geometry. -
getGeometry
public org.locationtech.jts.geom.Geometry getGeometry(int i) Deprecated.Returns the geometry of element i of the transaction. This method is deprecated, now that transaction features are held in a This method is deprecated. Use getGeometry(Feature) instead. -
getGeometry
-
setGeometry
-
setGeometries
-
setGeometry
public void setGeometry(int i, org.locationtech.jts.geom.Geometry geometry) Deprecated.This method is deprecated. Use getGeometry(Feature) instead. -
commit
public boolean commit() -
commit
-
commit
public static boolean commit(Collection<EditTransaction> editTransactions, EditTransaction.SuccessAction successAction) Commits several EditTransactions if their proposed geometries are all valid. Useful for committing changes to several layers because an EditTransaction handles one layer only. Gets the undo name and the UndoManager from the first EditTransaction.- Parameters:
successAction- run after the first execution (i.e. not after redos) if all proposed geometries are valid (or rollingBackInvalidEdits is false)
-
commit
- Parameters:
successAction- will be run if the geometries are valid (or OptionsPlugIn#isRollingBackInvalidEdits returns false), before the layer-change events are fired. Useful for animations and other visual indicators which would be slowed down if the layer-change events were fired first.- Returns:
- true if all the proposed geometries are valid
-
clearEnvelopeCaches
public void clearEnvelopeCaches() -
proposedGeometriesValid
public boolean proposedGeometriesValid() -
createCommand
-
size
public int size() -
getFeature
Deprecated.Returns the feature of element i of the transaction. This method is deprecated, use getFeatures() to iterate over the whole set of features. -
getFeatures
Returns the features modified by this transaction [mmichaud 2011-09-17] -
createFeature
-
deleteFeature
- Parameters:
feature- must not have been passed into the constructor
-
modifyFeatureGeometry
-
getLayer
-
emptyGeometryCount
-