Interface Operation
- All Known Implementing Classes:
ColorTransform
,Crop
,CropByPercent
,CropByPixels
,CropToSquare
,Encode
,ImageOverlay
,Overlay
,Redaction
,Rotate
,Scale
,Scale.Filter
,ScaleByPercent
,ScaleByPixels
,Sharpen
,StringOverlay
,Transpose
public interface Operation
Interface to be implemented by all image-processing operations. Clients
should check instances' type and recast.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
freeze()
Makes the instance unmodifiable.default Size
getResultingSize
(Size fullSize, ScaleConstraint scaleConstraint) This default implementation returns thefullSize
argument.boolean
Simpler but less-accurate counterpart ofhasEffect(Size, OperationList)
.boolean
hasEffect
(Size fullSize, OperationList opList) Context-aware counterpart tohasEffect()
.toMap
(Size fullSize, ScaleConstraint scaleConstraint) default void
validate
(Size fullSize, ScaleConstraint scaleConstraint) Validates the instance, throwing an exception if invalid.
-
Method Details
-
freeze
void freeze()Makes the instance unmodifiable. When frozen, mutation methods should throw anIllegalStateException
and getters should return immutable values, if possible. (But they should do that anyway.) -
getResultingSize
This default implementation returns thefullSize
argument. It will need to be overridden by operations that could change the image's resulting size.- Parameters:
fullSize
- Full size of the source image on which the operation is being applied.scaleConstraint
- Scale constraint applied to the given full size.- Returns:
- Resulting dimensions when the operation is applied.
-
hasEffect
boolean hasEffect()Simpler but less-accurate counterpart ofhasEffect(Size, OperationList)
.- Returns:
- Whether applying the operation on its own would result in a changed image.
-
hasEffect
Context-aware counterpart tohasEffect()
. For example, a scale operation specifying a scale to 300×200, when the given operation list contains a crop of 300×200, would returnfalse
.- Parameters:
fullSize
- Full size of the source image.opList
- Operation list of which the operation may or may not be a member.- Returns:
- Whether applying the operation in the context of the given full size and operation list would result in a changed image.
-
toMap
- Parameters:
fullSize
- Full size of the source image on which the operation is being applied.scaleConstraint
- Scale constraint applied to the given full size.- Returns:
- Unmodifiable representation of the operation for
human consumption. The map includes a
class
key pointing to the operation's class name.
-
validate
Validates the instance, throwing an exception if invalid.
Implementations can also throw exceptions from property setters as an alternative to using this method.
This default implementation does nothing.
- Parameters:
fullSize
- Full size of the source image on which the operation is being applied.scaleConstraint
- Scale constraint applied to the given full size.- Throws:
OperationException
- if the instance is invalid.
-