Search in sources :

Example 1 with DynMapPreviewer

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"));
    }
}
Also used : DynMapPreviewer(org.pepsoft.worldpainter.dynmap.DynMapPreviewer) MinecraftWorldObject(org.pepsoft.worldpainter.objects.MinecraftWorldObject) TunnelLayer(org.pepsoft.worldpainter.layers.tunnel.TunnelLayer) Dimension(org.pepsoft.worldpainter.Dimension) TunnelLayer(org.pepsoft.worldpainter.layers.tunnel.TunnelLayer) UndergroundPocketsLayer(org.pepsoft.worldpainter.layers.pockets.UndergroundPocketsLayer) File(java.io.File) BufferedImage(java.awt.image.BufferedImage)

Aggregations

BufferedImage (java.awt.image.BufferedImage)1 File (java.io.File)1 Dimension (org.pepsoft.worldpainter.Dimension)1 DynMapPreviewer (org.pepsoft.worldpainter.dynmap.DynMapPreviewer)1 UndergroundPocketsLayer (org.pepsoft.worldpainter.layers.pockets.UndergroundPocketsLayer)1 TunnelLayer (org.pepsoft.worldpainter.layers.tunnel.TunnelLayer)1 MinecraftWorldObject (org.pepsoft.worldpainter.objects.MinecraftWorldObject)1