String errMsg = "Please enter Text.";
request.setAttribute("_ERROR_MESSAGE_", errMsg);
return "error";
}
WatermarkerSettings watermarkerSettings = WatermarkerSettings.DEFAULT;
if (UtilValidate.isNotEmpty(fontColor)) {
Color graphicsColor = setFontColor(fontColor);
watermarkerSettings.setGraphicsColor(graphicsColor);
} else {
String errMsg = "Please select Text Color.";
request.setAttribute("_ERROR_MESSAGE_", errMsg);
return "error";
}
DecimalFormat decimalFormat = new DecimalFormat();
decimalFormat.applyPattern("0.00");
if (UtilValidate.isNotEmpty(fontSize)) {
BigDecimal widthBase = new BigDecimal(600.00);
BigDecimal picWidth = new BigDecimal(decimalFormat.format(Float.parseFloat(width)));
Font graphicsFont = setFontSize(fontSize, picWidth.divide(widthBase, 2));
watermarkerSettings.setGraphicsFont(graphicsFont);
} else {
String errMsg = "Please select Text Size.";
request.setAttribute("_ERROR_MESSAGE_", errMsg);
return "error";
}
WatermarkSettings position = new WatermarkSettings();
if (UtilValidate.isNotEmpty(x) && UtilValidate.isNotEmpty(y)) {
BigDecimal positionX = new BigDecimal(decimalFormat.format(Float.parseFloat(x)));
BigDecimal positionY = new BigDecimal(decimalFormat.format(Float.parseFloat(y)));
position.setX(positionX.floatValue());
position.setY(positionY.floatValue());
watermarkerSettings.setWatermarkSettings(position);
} else {
String errMsg = "Please select Text Position.";
request.setAttribute("_ERROR_MESSAGE_", errMsg);
return "error";
}
AlphaComposite alphaComposite = null;
if (UtilValidate.isNotEmpty(opacity)) {
BigDecimal opa = new BigDecimal(opacity);
alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opa.floatValue());
watermarkerSettings.setAlphaComposite(alphaComposite);
}
if (UtilValidate.isNotEmpty(imageUrl)) {
Map<String, Object> contentCtx = FastMap.newInstance();