use of org.pepsoft.worldpainter.brushes.BitmapBrush in project WorldPainter by Captain-Chaos.
the class App method loadCustomBrushes.
private void loadCustomBrushes(String category, File brushesDir) {
File[] files = brushesDir.listFiles(new java.io.FileFilter() {
@Override
public boolean accept(File pathname) {
if (pathname.isDirectory()) {
return true;
}
String name = pathname.getName();
for (String extension : extensions) {
if (name.toLowerCase().endsWith(extension)) {
return true;
}
}
return false;
}
private final String[] extensions = ImageIO.getReaderFileSuffixes();
});
List<Brush> brushes = new ArrayList<>();
for (File file : files) {
if (file.isDirectory()) {
loadCustomBrushes(file.getName(), file);
} else {
try {
brushes.add(new BitmapBrush(file));
} catch (RuntimeException e) {
logger.error("There was an error loading custom brush image file " + file.getName() + "; skipping file", e);
}
}
}
if (!brushes.isEmpty()) {
customBrushes.put(category, brushes);
}
}
Aggregations