Search in sources :

Example 1 with FocalPoint

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);
}
Also used : FocalPoint(com.enonic.xp.image.FocalPoint) ValueType(com.enonic.xp.data.ValueType) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Property(com.enonic.xp.data.Property)

Example 2 with FocalPoint

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));
}
Also used : FocalPoint(com.enonic.xp.image.FocalPoint)

Example 3 with FocalPoint

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));
}
Also used : FocalPoint(com.enonic.xp.image.FocalPoint)

Example 4 with FocalPoint

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));
}
Also used : FocalPoint(com.enonic.xp.image.FocalPoint)

Example 5 with FocalPoint

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));
}
Also used : FocalPoint(com.enonic.xp.image.FocalPoint)

Aggregations

FocalPoint (com.enonic.xp.image.FocalPoint)7 Property (com.enonic.xp.data.Property)1 PropertySet (com.enonic.xp.data.PropertySet)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 ValueType (com.enonic.xp.data.ValueType)1