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 TypeMethodDescriptionboolean
void
freeze()
Makes the instance unmodifiable.abstract Region
getRegion
(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 thefullSize
argument.abstract boolean
This method may produce false positives.abstract boolean
hasEffect
(Size fullSize, OperationList opList) Context-aware counterpart toOperation.hasEffect()
.int
hashCode()
toMap
(Size fullSize, ScaleConstraint scaleConstraint) void
validate
(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:Operation
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.) -
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 toreducedSize
or the full image size.- Returns:
- Region relative to the given reduced dimensions.
-
getResultingSize
Description copied from interface:Operation
This default implementation returns thefullSize
argument. It will need to be overridden by operations that could change the image's resulting size.- Specified by:
getResultingSize
in 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:Operation
Context-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:
toMap
in 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
, andheight
keys 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:
validate
in 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.
-