public static final String COMPRESS_QUALITY = ".CompressQuality";
private static final Map /* UserProperties */defaultProperties = new HashMap();
public static Properties getDefaultProperties(String format) {
UserProperties properties = (UserProperties) defaultProperties
.get(format);
if (properties == null) {
properties = new UserProperties();
defaultProperties.put(format, properties);
String formatKey = rootKey + "." + format;
// set our parameters
if (canWriteTransparent(format)) {
properties.setProperty(formatKey + TRANSPARENT, true);
properties.setProperty(formatKey + BACKGROUND, false);
properties
.setProperty(formatKey + BACKGROUND_COLOR, Color.GRAY);
} else {
properties.setProperty(formatKey + BACKGROUND, false);
properties
.setProperty(formatKey + BACKGROUND_COLOR, Color.GRAY);
}
// set our parameters
properties.setProperty(formatKey + ANTIALIAS, true);
properties.setProperty(formatKey + ANTIALIAS_TEXT, true);
// copy parameters from specific format
ImageWriter writer = getPreferredImageWriter(format);
if (writer != null) {
ImageWriteParam param = writer.getDefaultWriteParam();
// compression
if (param.canWriteCompressed()) {
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
properties.setProperty(formatKey + COMPRESS, true);
String[] compressionTypes = param.getCompressionTypes();
String compressionType = param.getCompressionType();
properties.setProperty(formatKey + COMPRESS_MODE, compressionType != null ? compressionType : compressionTypes[0]);
properties.setProperty(formatKey + COMPRESS_DESCRIPTION,
"Custom");
float compressionQuality = 0.0f;
try {
compressionQuality = param.getCompressionQuality();
} catch (IllegalStateException e) {
// ignored
}
properties.setProperty(formatKey + COMPRESS_QUALITY, compressionQuality);
} else {
properties.setProperty(formatKey + COMPRESS, false);
properties.setProperty(formatKey + COMPRESS_MODE, "");
properties.setProperty(formatKey + COMPRESS_DESCRIPTION,
"Custom");
properties.setProperty(formatKey + COMPRESS_QUALITY, 0.0f);
}
// progressive
if (param.canWriteProgressive()) {
properties
.setProperty(
formatKey + PROGRESSIVE,
param.getProgressiveMode() != ImageWriteParam.MODE_DISABLED);
} else {
properties.setProperty(formatKey + PROGRESSIVE, false);
}
} else {
System.err.println(ImageGraphics2D.class
+ ": No writer for format '" + format + "'.");
}