use of org.pepsoft.worldpainter.dynmap.DynMapPreviewer in project WorldPainter by Captain-Chaos.
the class LayerPreviewCreator method main.
public static void main(String[] args) throws IOException, ClassNotFoundException {
Configuration config = Configuration.load();
if (config == null) {
config = new Configuration();
}
Configuration.setInstance(config);
WPPluginManager.initialise(config.getUuid());
Dimension dimension = WorldFactory.createDefaultWorldWithoutTiles(config, 0L).getDimension(DIM_NORMAL);
for (Layer layer : LayerManager.getInstance().getLayers()) {
// Layer layer = Caverns.INSTANCE;
LayerPreviewCreator renderer = createPreviewerForLayer(layer, dimension);
long start = System.currentTimeMillis();
MinecraftWorldObject preview = renderer.renderPreview();
System.out.println("Total: " + (System.currentTimeMillis() - start) + " ms");
// JFrame frame = new JFrame("LayerPreviewCreator Test");
// frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
DynMapPreviewer previewer = new DynMapPreviewer();
previewer.setZoom(-2);
previewer.setInclination(30.0);
previewer.setAzimuth(60.0);
if ((layer instanceof Caverns) || (layer instanceof Chasms) || (layer instanceof TunnelLayer)) {
previewer.setCaves(true);
}
previewer.setObject(preview, dimension);
// frame.getContentPane().add(previewer, BorderLayout.CENTER);
// frame.setSize(800, 600);
// frame.setLocationRelativeTo(null); // Center on screen
// frame.setVisible(true);
start = System.currentTimeMillis();
BufferedImage image = previewer.createImage();
System.out.println("Creating image took " + (System.currentTimeMillis() - start) + " ms");
ImageIO.write(image, "png", new File(layer.getName().toLowerCase().replaceAll("\\s", "") + "-preview.png"));
}
}
Aggregations