/** * Creates an instance of the options serializer * * @return the options serializer */ public static TransformationSourceOptionsSerializer createSerializerInstance() { return (new CropSourceOptions()).new CropSourceOptionsSerializer(); }
/** * Creates an instance of the options serializer * * @return the options serializer */ public static TransformationSourceOptionsSerializer createSerializerInstance() { return (new CropSourceOptions()).new CropSourceOptionsSerializer(); }
CropSourceOptions cropSourceOptions = new CropSourceOptions(); sourceOptionsList.add(cropSourceOptions); ifSet(options, CROP_GRAVITY, (v) -> cropSourceOptions.setGravity(v));
CropSourceOptions cropSourceOptions = new CropSourceOptions(); sourceOptionsList.add(cropSourceOptions); ifSet(options, CROP_GRAVITY, (v) -> cropSourceOptions.setGravity(v));
@Override public TransformationSourceOptions deserialize(SerializedTransformationOptionsAccessor serializedOptions) { int newWidth = serializedOptions.getIntegerParam(PARAM_CROP_WIDTH, -1); int newHeight = serializedOptions.getIntegerParam(PARAM_CROP_HEIGHT, -1); if (newHeight == -1 && newWidth == -1) { return null; } int xOffset = serializedOptions.getIntegerParam(PARAM_CROP_X_OFFSET, 0); int yOffset = serializedOptions.getIntegerParam(PARAM_CROP_Y_OFFSET, 0); boolean isPercentCrop = serializedOptions.getParamWithDefault(PARAM_IS_PERCENT_CROP, false); String gravity = serializedOptions.getCheckedParam(PARAM_CROP_GRAVITY, String.class); CropSourceOptions cropOptions = new CropSourceOptions(); cropOptions.setGravity(gravity); cropOptions.setHeight(newHeight); cropOptions.setPercentageCrop(isPercentCrop); cropOptions.setWidth(newWidth); cropOptions.setXOffset(xOffset); cropOptions.setYOffset(yOffset); return cropOptions; }
@Override public TransformationSourceOptions deserialize(SerializedTransformationOptionsAccessor serializedOptions) { int newWidth = serializedOptions.getIntegerParam(PARAM_CROP_WIDTH, -1); int newHeight = serializedOptions.getIntegerParam(PARAM_CROP_HEIGHT, -1); if (newHeight == -1 && newWidth == -1) { return null; } int xOffset = serializedOptions.getIntegerParam(PARAM_CROP_X_OFFSET, 0); int yOffset = serializedOptions.getIntegerParam(PARAM_CROP_Y_OFFSET, 0); boolean isPercentCrop = serializedOptions.getParamWithDefault(PARAM_IS_PERCENT_CROP, false); String gravity = serializedOptions.getCheckedParam(PARAM_CROP_GRAVITY, String.class); CropSourceOptions cropOptions = new CropSourceOptions(); cropOptions.setGravity(gravity); cropOptions.setHeight(newHeight); cropOptions.setPercentageCrop(isPercentCrop); cropOptions.setWidth(newWidth); cropOptions.setXOffset(xOffset); cropOptions.setYOffset(yOffset); return cropOptions; }