Class Crop
java.lang.Object
is.galia.operation.Crop
- All Implemented Interfaces:
Operation
- Direct Known Subclasses:
CropByPercent,CropByPixels,CropToSquare
Abstract cropping operation.
The basic idea is that getRegion(is.galia.image.Size) is used to compute a source
image region based on arguments supplied to it and to subclasses' mutator
methods.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidfreeze()Makes the instance unmodifiable.abstract RegiongetRegion(Size reducedSize, ReductionFactor reductionFactor, ScaleConstraint scaleConstraint) Computes an effective crop rectangle in source image coordinates.getRegion(Size fullSize, ScaleConstraint scaleConstraint) getResultingSize(Size fullSize, ScaleConstraint scaleConstraint) This default implementation returns thefullSizeargument.abstract booleanThis method may produce false positives.abstract booleanhasEffect(Size fullSize, OperationList opList) Context-aware counterpart toOperation.hasEffect().inthashCode()toMap(Size fullSize, ScaleConstraint scaleConstraint) voidvalidate(Size fullSize, ScaleConstraint scaleConstraint) Checks the intersection and dimensions.
-
Constructor Details
-
Crop
public Crop()
-
-
Method Details
-
equals
-
freeze
public void freeze()Description copied from interface:OperationMakes the instance unmodifiable. When frozen, mutation methods should throw anIllegalStateExceptionand getters should return immutable values, if possible. (But they should do that anyway.) -
getRegion
-
getRegion
- Parameters:
fullSize- Full-sized image dimensions.scaleConstraint- Scale constraint yet to be applied to the input image. The instance is expressed relative to this constraint rather than tofullSize.- Returns:
- Region relative to the given full dimensions.
-
getRegion
public abstract Region getRegion(Size reducedSize, ReductionFactor reductionFactor, ScaleConstraint scaleConstraint) Computes an effective crop rectangle in source image coordinates.- Parameters:
reducedSize- Size of the input image, reduced byreductionFactor.reductionFactor- Factor by which the full-sized image has been reduced to becomereducedSize.scaleConstraint- Scale constraint yet to be applied to the input image. The instance is expressed relative to this constraint rather than toreducedSizeor the full image size.- Returns:
- Region relative to the given reduced dimensions.
-
getResultingSize
Description copied from interface:OperationThis default implementation returns thefullSizeargument. It will need to be overridden by operations that could change the image's resulting size.- Specified by:
getResultingSizein interfaceOperation- 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
public abstract boolean hasEffect()This method may produce false positives.hasEffect(Size, OperationList)should be used instead where possible, unless overrides mention otherwise. -
hasEffect
Description copied from interface:OperationContext-aware counterpart toOperation.hasEffect(). For example, a scale operation specifying a scale to 300×200, when the given operation list contains a crop of 300×200, would returnfalse. -
hashCode
-
toMap
- Specified by:
toMapin interfaceOperation- 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:
- Map with
class,x,y,width, andheightkeys and integer values corresponding to the instance coordinates.
-
validate
Checks the intersection and dimensions.
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.
- Specified by:
validatein interfaceOperation- 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.
-