Interface MeasurementValueConfigurationEditor
-
- All Implemented Interfaces:
public interface MeasurementValueConfigurationEditor
Interface that allows you to modify the list of MeasurementValueConfigurations stored in the document. You can obtain an instance of it by calling getMeasurementValueConfigurationEditor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
MeasurementValueConfigurationEditor.ChangeListener
Listener interface to observe changes in the document's MeasurementValueConfiguration list
-
Method Summary
Modifier and Type Method Description abstract boolean
modify(@NonNull() Context context, @NonNull() MeasurementValueConfiguration oldValue, @NonNull() MeasurementValueConfiguration newValue, @NonNull() MeasurementValueConfigurationPickerListener onSelectedExistingConfiguration)
Modifies an existing MeasurementValueConfiguration in the current document. abstract void
modify(@NonNull() MeasurementValueConfiguration oldValue, @NonNull() MeasurementValueConfiguration newValue, boolean modifyAssociatedAnnotations, boolean addToUndo)
Replaces the `oldValue` configuration straightforward in the document's configuration list with `newValue`. abstract boolean
remove(@NonNull() Context context, @NonNull() MeasurementValueConfiguration value)
Deletes the provided configuration from the document. abstract void
remove(@NonNull() MeasurementValueConfiguration value, boolean deleteAssociatedAnnotations, boolean addToUndo)
Deletes the `value` configuration from the document's configuration list. abstract boolean
add(@NonNull() Context context, @NonNull() MeasurementValueConfiguration value, @NonNull() MeasurementValueConfigurationPickerListener onSelectedExistingConfiguration)
Adds the provided configuration to the document. abstract void
add(@NonNull() MeasurementValueConfiguration value, boolean addToUndo)
Adds the `value` configuration to the document's configuration list. abstract List<MeasurementValueConfiguration>
getConfigurations()
Query all MeasurementValueConfiguration
s currently existing in the document.abstract void
startCalibrationTool()
Starts the scale calibration tool. abstract int
getUsageCount(MeasurementValueConfiguration configuration)
Checks how many annotations are using the provided configuration. abstract List<Annotation>
getAnnotationsForConfiguration(@Nullable() MeasurementValueConfiguration configuration)
Similar as getUsageCount but returns a list of all annotations that abstract void
addChangeListener(@NonNull() MeasurementValueConfigurationEditor.ChangeListener listener)
Register a ChangeListener to get notified when the document's MeasurementValueConfiguration list get's updated. abstract void
removeChangeListener(@NonNull() MeasurementValueConfigurationEditor.ChangeListener listener)
Remove a previously registered ChangeListener. -
-
Method Detail
-
modify
abstract boolean modify(@NonNull() Context context, @NonNull() MeasurementValueConfiguration oldValue, @NonNull() MeasurementValueConfiguration newValue, @NonNull() MeasurementValueConfigurationPickerListener onSelectedExistingConfiguration)
Modifies an existing MeasurementValueConfiguration in the current document. Any measurement annotations that use the original configuration will be updated, too. On top of that, it is checked if the modified value matches an already existing configuration. In that case a dialog is displayed and asks how to proceed. If the dialog is confirmed with "Use Existing" the provided callback `onSelectedExistingConfiguration` informs about the used configuration. The original configuration will be deleted in this case.
- Parameters:
context
- The context to be used if we need to show a dialog.oldValue
- The original MeasurementValueConfiguration to be changed.newValue
- The value to change it to.onSelectedExistingConfiguration
- callback which is called if `newValue` matches an already existing configuration and the user decides to use that one instead of `newValue`.- Returns:
true
if the configuration could be modified to `newValue`, otherwisefalse
which indicates that a dialog was displayed to resolve the conflict.
-
modify
abstract void modify(@NonNull() MeasurementValueConfiguration oldValue, @NonNull() MeasurementValueConfiguration newValue, boolean modifyAssociatedAnnotations, boolean addToUndo)
Replaces the `oldValue` configuration straightforward in the document's configuration list with `newValue`. No checks are being made, no dialogs displayed.
- Parameters:
oldValue
- The original MeasurementValueConfiguration to be changed.newValue
- The value to change it to.modifyAssociatedAnnotations
- iftrue
all measurement annotations that use the scale and precision of `oldValue` will be updated to the scale and precision of `newValue`.addToUndo
- Set totrue
if the modification is supposed to be recorded to the undo stack.
-
remove
abstract boolean remove(@NonNull() Context context, @NonNull() MeasurementValueConfiguration value)
Deletes the provided configuration from the document. If it's currently in use by any measurement annotations, a dialog is displayed and this function returns false. If the user decides via the dialog to delete the configuration anyways, the operation proceeds and will also delete those affected annotations. If the function returns true, the configuration was not in use and was deleted without further ado.
- Parameters:
context
- The context to be used if we need to show a dialog.value
- The MeasurementValueConfiguration to be removed from the document.- Returns:
true
if the configuration could be deleted right away, otherwisefalse
which indicates that a dialog was displayed, informing the user that the configuration is used by at least one measurement annotation.
-
remove
abstract void remove(@NonNull() MeasurementValueConfiguration value, boolean deleteAssociatedAnnotations, boolean addToUndo)
Deletes the `value` configuration from the document's configuration list. No checks are being made, no dialogs displayed.
- Parameters:
value
- The MeasurementValueConfiguration to be removed from the document.deleteAssociatedAnnotations
- iftrue
all measurement annotations that use the scale and precision of `value` will be deleted as well.addToUndo
- Set totrue
if the delete operation is supposed to be recorded to the undo stack.
-
add
abstract boolean add(@NonNull() Context context, @NonNull() MeasurementValueConfiguration value, @NonNull() MeasurementValueConfigurationPickerListener onSelectedExistingConfiguration)
Adds the provided configuration to the document. If it's already present in the document, a dialog is displayed and this function returns false. If the user decides via the dialog to use the already existing configuration, `value` will not be added to the document, `onDeletedUsedConfiguration` is called with the existing configuration as parameter and this function returns false.
If the function returns true, the configuration was not in use and was deleted without further ado.
- Parameters:
context
- The context to be used if we need to show a dialog.value
- The MeasurementValueConfiguration to be removed from the document.onSelectedExistingConfiguration
- callback which is called if `value` matches an already existing configuration and the user decides to use that one.- Returns:
true
if the configuration could be added right away, otherwisefalse
which indicates that a dialog was displayed, informing the user that an identical configuration is already present in the document.
-
add
abstract void add(@NonNull() MeasurementValueConfiguration value, boolean addToUndo)
Adds the `value` configuration to the document's configuration list. No checks are being made, no dialogs displayed.
- Parameters:
value
- The MeasurementValueConfiguration to be added to the document.addToUndo
- Set totrue
if this add operation is supposed to be recorded to the undo stack.
-
getConfigurations
@NonNull() abstract List<MeasurementValueConfiguration> getConfigurations()
Query all
MeasurementValueConfiguration
s currently existing in the document.- Returns:
A list of available MeasurementValueConfigurations
-
startCalibrationTool
abstract void startCalibrationTool()
Starts the scale calibration tool. (Same as activating the calibration tool from the AnnotationCreationToolBar)
-
getUsageCount
abstract int getUsageCount(MeasurementValueConfiguration configuration)
Checks how many annotations are using the provided configuration.
- Parameters:
configuration
- The MeasurementValueConfiguration we want to know how many annotations it is used in- Returns:
The amount of annotations which use both the scale and precision of the provided configuration.
-
getAnnotationsForConfiguration
abstract List<Annotation> getAnnotationsForConfiguration(@Nullable() MeasurementValueConfiguration configuration)
Similar as getUsageCount but returns a list of all annotations that
- Parameters:
configuration
- The MeasurementValueConfiguration we want to which annotations are using it.- Returns:
A list of annotations which use both the scale and precision of the provided configuration.
-
addChangeListener
abstract void addChangeListener(@NonNull() MeasurementValueConfigurationEditor.ChangeListener listener)
Register a ChangeListener to get notified when the document's MeasurementValueConfiguration list get's updated. If the provider has been registered previously, this method will be a no-op.
- Parameters:
listener
- Listener to register.
-
removeChangeListener
abstract void removeChangeListener(@NonNull() MeasurementValueConfigurationEditor.ChangeListener listener)
Remove a previously registered ChangeListener. If the listener hasn't been registered previously, this method will be a no-op.
- Parameters:
listener
- Listener to unregister.
-
-
-
-