Class EditTransaction
- java.lang.Object
-
- org.locationtech.jts.jump.workbench.ui.EditTransaction
-
public class EditTransaction extends Object
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 Classes Modifier and Type Class Description static interface
EditTransaction.SelectionEditor
static interface
EditTransaction.SuccessAction
-
Field Summary
Fields Modifier and Type Field Description static String
ROLLING_BACK_INVALID_EDITS_KEY
-
Constructor Summary
Constructors Constructor Description EditTransaction(Collection features, String name, Layer layer, boolean rollingBackInvalidEdits, boolean allowAddingAndRemovingFeatures, LayerViewPanel layerViewPanel)
EditTransaction(Collection 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearEnvelopeCaches()
boolean
commit()
static boolean
commit(Collection editTransactions)
static boolean
commit(Collection editTransactions, EditTransaction.SuccessAction successAction)
Commits several EditTransactions if their proposed geometries are all valid.boolean
commit(EditTransaction.SuccessAction successAction)
void
createFeature(Feature feature)
static EditTransaction
createTransactionOnSelection(EditTransaction.SelectionEditor editor, SelectionManagerProxy selectionManagerProxy, LayerViewPanelContext layerViewPanelContext, String name, Layer layer, boolean rollingBackInvalidEdits, boolean allowAddingAndRemovingFeatures)
void
deleteFeature(Feature feature)
static int
emptyGeometryCount(Collection transactions)
static Map
featureToNewGeometryMap(EditTransaction.SelectionEditor editor, SelectionManagerProxy selectionManagerProxy, Layer layer)
Feature
getFeature(int i)
org.locationtech.jts.geom.Geometry
getGeometry(int i)
org.locationtech.jts.geom.Geometry
getGeometry(Feature feature)
Layer
getLayer()
boolean
proposedGeometriesValid()
void
setGeometries(Map featureToGeometryMap)
void
setGeometry(int i, org.locationtech.jts.geom.Geometry geometry)
void
setGeometry(Feature feature, org.locationtech.jts.geom.Geometry geometry)
int
size()
-
-
-
Field Detail
-
ROLLING_BACK_INVALID_EDITS_KEY
public static final String ROLLING_BACK_INVALID_EDITS_KEY
-
-
Constructor Detail
-
EditTransaction
public EditTransaction(Collection features, String name, Layer layer, boolean rollingBackInvalidEdits, boolean allowAddingAndRemovingFeatures, LayerViewPanel layerViewPanel)
-
EditTransaction
public EditTransaction(Collection 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:
name
- Display name for undo. Use PlugIn#getName or CursorTool#getName.layer
- the layer to which the features belongallowAddingAndRemovingFeatures
- whether to treat empty geometries as indications to add/remove features or as in fact empty geometries
-
-
Method Detail
-
createTransactionOnSelection
public static EditTransaction createTransactionOnSelection(EditTransaction.SelectionEditor editor, SelectionManagerProxy selectionManagerProxy, LayerViewPanelContext layerViewPanelContext, String name, Layer layer, boolean rollingBackInvalidEdits, boolean allowAddingAndRemovingFeatures)
-
featureToNewGeometryMap
public static Map featureToNewGeometryMap(EditTransaction.SelectionEditor editor, SelectionManagerProxy selectionManagerProxy, Layer layer)
-
getGeometry
public org.locationtech.jts.geom.Geometry getGeometry(int i)
-
getGeometry
public org.locationtech.jts.geom.Geometry getGeometry(Feature feature)
-
setGeometry
public void setGeometry(Feature feature, org.locationtech.jts.geom.Geometry geometry)
-
setGeometries
public void setGeometries(Map featureToGeometryMap)
-
setGeometry
public void setGeometry(int i, org.locationtech.jts.geom.Geometry geometry)
-
commit
public boolean commit()
-
commit
public static boolean commit(Collection editTransactions)
-
commit
public static boolean commit(Collection 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
public boolean commit(EditTransaction.SuccessAction successAction)
- 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()
-
size
public int size()
-
getFeature
public Feature getFeature(int i)
-
createFeature
public void createFeature(Feature feature)
-
deleteFeature
public void deleteFeature(Feature feature)
- Parameters:
feature
- must not have been passed into the constructor
-
getLayer
public Layer getLayer()
-
emptyGeometryCount
public static int emptyGeometryCount(Collection transactions)
-
-