use of com.enonic.xp.image.FocalPoint in project xp by enonic.
the class Media method getFocalPoint.
public FocalPoint getFocalPoint() {
final PropertyTree contentData = getData();
final Property mediaProperty = contentData.getProperty(ContentPropertyNames.MEDIA);
if (mediaProperty == null) {
return FocalPoint.DEFAULT;
}
final ValueType mediaPropertyType = mediaProperty.getType();
if (!mediaPropertyType.equals(ValueTypes.PROPERTY_SET)) {
return FocalPoint.DEFAULT;
}
final PropertySet mediaData = getData().getSet(ContentPropertyNames.MEDIA);
final PropertySet focalPointData = mediaData.getSet(ContentPropertyNames.MEDIA_FOCAL_POINT);
if (focalPointData == null) {
return FocalPoint.DEFAULT;
}
final Double focalX = focalPointData.getDouble(ContentPropertyNames.MEDIA_FOCAL_POINT_X);
final Double focalY = focalPointData.getDouble(ContentPropertyNames.MEDIA_FOCAL_POINT_Y);
if (focalX == null || focalY == null) {
return FocalPoint.DEFAULT;
}
return new FocalPoint(focalX, focalY);
}
use of com.enonic.xp.image.FocalPoint in project xp by enonic.
the class ImageScales method height.
public ImageScaleFunction height(FocalPoint focalPoint, Object... args) {
Preconditions.checkArgument(args.length <= 1, "Too many arguments %s", args.length);
final int size = CommandArgumentParser.getIntArg(args, 0, 100);
Preconditions.checkArgument(size > 0 && size <= maxSideLength, "size value must be between 0 and %s : %s", maxSideLength, size);
return adaptScaleCalculator(ScaleCalculator.height(size));
}
use of com.enonic.xp.image.FocalPoint in project xp by enonic.
the class ImageScales method block.
public ImageScaleFunction block(FocalPoint focalPoint, Object... args) {
Preconditions.checkArgument(args.length <= 2, "Too many arguments %s", args.length);
final int width = CommandArgumentParser.getIntArg(args, 0, 0);
final int height = CommandArgumentParser.getIntArg(args, 1, 0);
final double xOffset = focalPoint.xOffset();
final double yOffset = focalPoint.yOffset();
Preconditions.checkArgument(width > 0 && width <= maxSideLength, "width value must be between 0 and %s : %s", maxSideLength, width);
Preconditions.checkArgument(height > 0 && height <= maxSideLength, "height value must be between 0 and %s : %s", maxSideLength, height);
return adaptScaleCalculator(ScaleCalculator.block(width, height, xOffset, yOffset));
}
use of com.enonic.xp.image.FocalPoint in project xp by enonic.
the class ImageScales method max.
public ImageScaleFunction max(FocalPoint focalPoint, Object... args) {
Preconditions.checkArgument(args.length <= 1, "Too many arguments %s", args.length);
final int size = CommandArgumentParser.getIntArg(args, 0, 0);
Preconditions.checkArgument(size > 0 && size <= maxSideLength, "size value must be between 0 and %s : %s", maxSideLength, size);
return adaptScaleCalculator(ScaleCalculator.max(size));
}
use of com.enonic.xp.image.FocalPoint in project xp by enonic.
the class ImageScales method square.
public ImageScaleFunction square(FocalPoint focalPoint, Object... args) {
Preconditions.checkArgument(args.length <= 1, "Too many arguments %s", args.length);
final int size = CommandArgumentParser.getIntArg(args, 0, 0);
final double xOffset = focalPoint.xOffset();
final double yOffset = focalPoint.yOffset();
Preconditions.checkArgument(size > 0 && size <= maxSideLength, "size value must be between 0 and %s : %s", maxSideLength, size);
return adaptScaleCalculator(ScaleCalculator.block(size, size, xOffset, yOffset));
}
Aggregations