Search in sources :

Example 1 with Operation

use of org.broadleafcommerce.openadmin.server.service.artifact.image.Operation in project BroadleafCommerce by BroadleafCommerce.

the class AlterRGB method buildOperation.

@Override
public Operation buildOperation(Map<String, String> parameterMap, InputStream artifactStream, String mimeType) {
    String key = FilterTypeEnum.ALTERRGB.toString().toLowerCase();
    if (!containsMyFilterParams(key, parameterMap)) {
        return null;
    }
    Operation operation = new Operation();
    operation.setName(key);
    String factor = parameterMap.get(key + "-factor");
    operation.setFactor(factor == null ? null : Double.valueOf(factor));
    UnmarshalledParameter red = new UnmarshalledParameter();
    String redApplyFactor = parameterMap.get(key + "-red-apply-factor");
    red.setApplyFactor(redApplyFactor == null ? false : Boolean.valueOf(redApplyFactor));
    red.setName("red");
    red.setType(ParameterTypeEnum.INT.toString());
    red.setValue(parameterMap.get(key + "-red-amount"));
    UnmarshalledParameter green = new UnmarshalledParameter();
    String greenApplyFactor = parameterMap.get(key + "-green-apply-factor");
    green.setApplyFactor(greenApplyFactor == null ? false : Boolean.valueOf(greenApplyFactor));
    green.setName("green");
    green.setType(ParameterTypeEnum.INT.toString());
    green.setValue(parameterMap.get(key + "-green-amount"));
    UnmarshalledParameter blue = new UnmarshalledParameter();
    String blueApplyFactor = parameterMap.get(key + "-blue-apply-factor");
    blue.setApplyFactor(blueApplyFactor == null ? false : Boolean.valueOf(blueApplyFactor));
    blue.setName("blue");
    blue.setType(ParameterTypeEnum.INT.toString());
    blue.setValue(parameterMap.get(key + "-blue-amount"));
    operation.setParameters(new UnmarshalledParameter[] { red, green, blue });
    return operation;
}
Also used : UnmarshalledParameter(org.broadleafcommerce.openadmin.server.service.artifact.image.effects.chain.UnmarshalledParameter) Operation(org.broadleafcommerce.openadmin.server.service.artifact.image.Operation)

Example 2 with Operation

use of org.broadleafcommerce.openadmin.server.service.artifact.image.Operation in project BroadleafCommerce by BroadleafCommerce.

the class Resize method buildOperation.

@Override
public Operation buildOperation(Map<String, String> parameterMap, InputStream artifactStream, String mimeType) {
    String key = FilterTypeEnum.RESIZE.toString().toLowerCase();
    if (!containsMyFilterParams(key, parameterMap)) {
        return null;
    }
    Operation operation = new Operation();
    operation.setName(key);
    String factor = parameterMap.get(key + "-factor");
    operation.setFactor(factor == null ? null : Double.valueOf(factor));
    UnmarshalledParameter targetWidth = new UnmarshalledParameter();
    String targetWidthApplyFactor = parameterMap.get(key + "-width-apply-factor");
    targetWidth.setApplyFactor(targetWidthApplyFactor == null ? false : Boolean.valueOf(targetWidthApplyFactor));
    targetWidth.setName("target-width");
    targetWidth.setType(ParameterTypeEnum.INT.toString());
    targetWidth.setValue(parameterMap.get(key + "-width-amount"));
    UnmarshalledParameter targetHeight = new UnmarshalledParameter();
    String targetHeightApplyFactor = parameterMap.get(key + "-height-apply-factor");
    targetHeight.setApplyFactor(targetHeightApplyFactor == null ? false : Boolean.valueOf(targetHeightApplyFactor));
    targetHeight.setName("target-height");
    targetHeight.setType(ParameterTypeEnum.INT.toString());
    targetHeight.setValue(parameterMap.get(key + "-height-amount"));
    UnmarshalledParameter highQuality = new UnmarshalledParameter();
    highQuality.setName("high-quality");
    highQuality.setType(ParameterTypeEnum.BOOLEAN.toString());
    highQuality.setValue(parameterMap.get(key + "-high-quality") == null ? "false" : parameterMap.get(key + "-high-quality"));
    UnmarshalledParameter maintainAspectRatio = new UnmarshalledParameter();
    maintainAspectRatio.setName("maintain-aspect-ratio");
    maintainAspectRatio.setType(ParameterTypeEnum.BOOLEAN.toString());
    maintainAspectRatio.setValue(parameterMap.get(key + "-maintain-aspect-ratio") == null ? "false" : parameterMap.get(key + "-maintain-aspect-ratio"));
    UnmarshalledParameter reduceOnly = new UnmarshalledParameter();
    reduceOnly.setName("reduce-only");
    reduceOnly.setType(ParameterTypeEnum.BOOLEAN.toString());
    reduceOnly.setValue(parameterMap.get(key + "-reduce-only") == null ? "false" : parameterMap.get(key + "-reduce-only"));
    operation.setParameters(new UnmarshalledParameter[] { targetWidth, targetHeight, highQuality, maintainAspectRatio, reduceOnly });
    return operation;
}
Also used : UnmarshalledParameter(org.broadleafcommerce.openadmin.server.service.artifact.image.effects.chain.UnmarshalledParameter) Operation(org.broadleafcommerce.openadmin.server.service.artifact.image.Operation)

Example 3 with Operation

use of org.broadleafcommerce.openadmin.server.service.artifact.image.Operation in project BroadleafCommerce by BroadleafCommerce.

the class AlterHSB method buildOperation.

@Override
public Operation buildOperation(Map<String, String> parameterMap, InputStream artifactStream, String mimeType) {
    String key = FilterTypeEnum.ALTERHSB.toString().toLowerCase();
    if (!containsMyFilterParams(key, parameterMap)) {
        return null;
    }
    Operation operation = new Operation();
    operation.setName(key);
    String factor = parameterMap.get(key + "-factor");
    operation.setFactor(factor == null ? null : Double.valueOf(factor));
    UnmarshalledParameter hue = new UnmarshalledParameter();
    String hueApplyFactor = parameterMap.get(key + "-hue-apply-factor");
    hue.setApplyFactor(hueApplyFactor == null ? false : Boolean.valueOf(hueApplyFactor));
    hue.setName("hue");
    hue.setType(ParameterTypeEnum.FLOAT.toString());
    hue.setValue(parameterMap.get(key + "-hue-amount"));
    UnmarshalledParameter saturation = new UnmarshalledParameter();
    String saturationApplyFactor = parameterMap.get(key + "-saturation-apply-factor");
    saturation.setApplyFactor(saturationApplyFactor == null ? false : Boolean.valueOf(saturationApplyFactor));
    saturation.setName("saturation");
    saturation.setType(ParameterTypeEnum.FLOAT.toString());
    saturation.setValue(parameterMap.get(key + "-saturation-amount"));
    UnmarshalledParameter brightness = new UnmarshalledParameter();
    String brightnessApplyFactor = parameterMap.get(key + "-brightness-apply-factor");
    brightness.setApplyFactor(brightnessApplyFactor == null ? false : Boolean.valueOf(brightnessApplyFactor));
    brightness.setName("brightness");
    brightness.setType(ParameterTypeEnum.FLOAT.toString());
    brightness.setValue(parameterMap.get(key + "-brightness-amount"));
    operation.setParameters(new UnmarshalledParameter[] { hue, saturation, brightness });
    return operation;
}
Also used : UnmarshalledParameter(org.broadleafcommerce.openadmin.server.service.artifact.image.effects.chain.UnmarshalledParameter) Operation(org.broadleafcommerce.openadmin.server.service.artifact.image.Operation)

Example 4 with Operation

use of org.broadleafcommerce.openadmin.server.service.artifact.image.Operation in project BroadleafCommerce by BroadleafCommerce.

the class AutoLevelsRGB method buildOperation.

@Override
public Operation buildOperation(Map<String, String> parameterMap, InputStream artifactStream, String mimeType) {
    String key = FilterTypeEnum.AUTOLEVELSRGB.toString().toLowerCase();
    if (!containsMyFilterParams(key, parameterMap)) {
        return null;
    }
    Operation operation = new Operation();
    operation.setName(key);
    return operation;
}
Also used : Operation(org.broadleafcommerce.openadmin.server.service.artifact.image.Operation)

Example 5 with Operation

use of org.broadleafcommerce.openadmin.server.service.artifact.image.Operation in project BroadleafCommerce by BroadleafCommerce.

the class Crop method buildOperation.

@Override
public Operation buildOperation(Map<String, String> parameterMap, InputStream artifactStream, String mimeType) {
    String key = FilterTypeEnum.CROP.toString().toLowerCase();
    if (!containsMyFilterParams(key, parameterMap)) {
        return null;
    }
    Operation operation = new Operation();
    operation.setName(key);
    String factor = parameterMap.get(key + "-factor");
    operation.setFactor(factor == null ? null : Double.valueOf(factor));
    UnmarshalledParameter rectangle = new UnmarshalledParameter();
    String rectangleApplyFactor = parameterMap.get(key + "-apply-factor");
    rectangle.setApplyFactor(rectangleApplyFactor == null ? false : Boolean.valueOf(rectangleApplyFactor));
    rectangle.setName("rectangle");
    rectangle.setType(ParameterTypeEnum.RECTANGLE.toString());
    StringBuffer sb = new StringBuffer();
    sb.append(parameterMap.get(key + "-x-amount"));
    sb.append(",");
    sb.append(parameterMap.get(key + "-y-amount"));
    sb.append(",");
    sb.append(parameterMap.get(key + "-width-amount"));
    sb.append(",");
    sb.append(parameterMap.get(key + "-height-amount"));
    rectangle.setValue(sb.toString());
    operation.setParameters(new UnmarshalledParameter[] { rectangle });
    return operation;
}
Also used : UnmarshalledParameter(org.broadleafcommerce.openadmin.server.service.artifact.image.effects.chain.UnmarshalledParameter) Operation(org.broadleafcommerce.openadmin.server.service.artifact.image.Operation)

Aggregations

Operation (org.broadleafcommerce.openadmin.server.service.artifact.image.Operation)9 UnmarshalledParameter (org.broadleafcommerce.openadmin.server.service.artifact.image.effects.chain.UnmarshalledParameter)7 BufferedInputStream (java.io.BufferedInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 AssetNotFoundException (org.broadleafcommerce.cms.common.AssetNotFoundException)1 StaticAsset (org.broadleafcommerce.cms.file.domain.StaticAsset)1 GloballySharedInputStream (org.broadleafcommerce.common.file.service.GloballySharedInputStream)1 MultipartFile (org.springframework.web.multipart.MultipartFile)1