/** * Check whether focal point parameters have been set. * * @return */ default boolean hasFocalPoint() { String x = getParameter(FOCAL_POINT_X_QUERY_PARAM_KEY); String y = getParameter(FOCAL_POINT_Y_QUERY_PARAM_KEY); return x != null && y != null; }
/** * Return the focal point debug flag. * * @return */ default boolean getFocalPointDebug() { String flag = getParameter(FOCAL_POINT_DEBUG_PARAM_KEY); return Boolean.valueOf(flag); }
/** * Get the focal point zoom factor. * * @return */ default Float getFocalPointZoom() { String z = getParameter(FOCAL_POINT_Z_QUERY_PARAM_KEY); if (z == null) { return null; } else { return Float.valueOf(z); } }
/** * Get the focal point that has been set in the image parameter. * * @return */ default FocalPoint getFocalPoint() { String x = getParameter(FOCAL_POINT_X_QUERY_PARAM_KEY); String y = getParameter(FOCAL_POINT_Y_QUERY_PARAM_KEY); // If either x or y has not been set, use the center of the image for the respective focal point part. Float fpx = x != null ? Float.valueOf(x) : 0.5F; Float fpy = y != null ? Float.valueOf(y) : 0.5F; return new FocalPoint(fpx, fpy); }
/** * Return the crop mode parameter value. * * @return */ default CropMode getCropMode() { String mode = getParameter(CROP_MODE_QUERY_PARAM_KEY); return CropMode.get(mode); }
/** * Returns the rect crop area parameter value. * * @return Configured image crop area rectangle */ default ImageRect getRect() { String rect = getParameter(RECT_QUERY_PARAM_KEY); return rect == null ? null : new ImageRect(rect); }
/** * Return the image width. * * @return */ default Integer getWidth() { return toInteger(getParameter(WIDTH_QUERY_PARAM_KEY), null); }
/** * Return the image height. * * @return */ default Integer getHeight() { return toInteger(getParameter(HEIGHT_QUERY_PARAM_KEY), null); }
/** * Validates whether the focal point was fully specified. * * @return Fluent API */ default ImageManipulationParameters validateFocalPointParameter() { String x = getParameter(FOCAL_POINT_X_QUERY_PARAM_KEY); String y = getParameter(FOCAL_POINT_Y_QUERY_PARAM_KEY); if (x == null && y != null) { throw error(BAD_REQUEST, "image_error_incomplete_focalpoint_parameters", FOCAL_POINT_X_QUERY_PARAM_KEY); } else if (y == null && x != null) { throw error(BAD_REQUEST, "image_error_incomplete_focalpoint_parameters", FOCAL_POINT_Y_QUERY_PARAM_KEY); } return this; }