com.twelvemonkeys.servlet.image.aoi.AreaOfInterestFactory Maven / Gradle / Ivy
package com.twelvemonkeys.servlet.image.aoi;
import java.util.concurrent.atomic.AtomicReference;
/**
* @author Erlend Hamnaberg
* @version $Revision: $
*/
public class AreaOfInterestFactory {
private final static AtomicReference DEFAULT =
new AtomicReference(new AreaOfInterestFactory());
public static void setDefault(AreaOfInterestFactory factory) {
DEFAULT.set(factory);
}
public static AreaOfInterestFactory getDefault() {
return DEFAULT.get();
}
public AreaOfInterest createAreaOfInterest(int pDefaultWidth, int pDefaultHeight, boolean aoiPercent, boolean aoiUniform) {
if (aoiPercent && aoiUniform) {
throw new IllegalArgumentException("Cannot be both uniform and percent Area of Interest");
}
if (aoiPercent) {
return new PercentAreaOfInterest(pDefaultWidth, pDefaultHeight);
}
else if (aoiUniform) {
return new UniformAreaOfInterest(pDefaultWidth, pDefaultHeight);
}
return new DefaultAreaOfInterest(pDefaultWidth, pDefaultHeight);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy