Search in sources :

Example 36 with Dimension

use of org.pepsoft.worldpainter.Dimension in project WorldPainter by Captain-Chaos.

the class SprayPaint method tick.

@Override
protected void tick(int centreX, int centreY, boolean inverse, boolean first, float dynamicLevel) {
    painter.setUndo(inverse);
    Dimension dimension = getDimension();
    dimension.setEventsInhibited(true);
    try {
        painter.drawPoint(dimension, centreX, centreY, dynamicLevel);
    } finally {
        dimension.setEventsInhibited(false);
    }
}
Also used : Dimension(org.pepsoft.worldpainter.Dimension)

Example 37 with Dimension

use of org.pepsoft.worldpainter.Dimension in project WorldPainter by Captain-Chaos.

the class CopySelectionOperation method tick.

@Override
protected void tick(int centreX, int centreY, boolean inverse, boolean first, float dynamicLevel) {
    selectionHelper.setOptions(options);
    Dimension dimension = getDimension();
    dimension.setEventsInhibited(true);
    try {
        // TODO: opening the progress dialog (and presumeably any dialog)
        // causes the JIDE docking framework to malfunction
        // ProgressDialog.executeTask(SwingUtilities.getWindowAncestor(getView()), new ProgressTask<Void>() {
        // @Override
        // public String getName() {
        // return "Copying selection";
        // }
        // 
        // @Override
        // public Void execute(ProgressReceiver progressReceiver) throws ProgressReceiver.OperationCancelled {
        selectionHelper.copySelection(centreX, centreY, null);
    // return null;
    // }
    // }, false);
    } catch (ProgressReceiver.OperationCancelled e) {
        throw new InternalError(e);
    } finally {
        dimension.setEventsInhibited(false);
    }
}
Also used : ProgressReceiver(org.pepsoft.util.ProgressReceiver) Dimension(org.pepsoft.worldpainter.Dimension)

Example 38 with Dimension

use of org.pepsoft.worldpainter.Dimension in project WorldPainter by Captain-Chaos.

the class SetSpawnPoint method tick.

@Override
protected void tick(int centreX, int centreY, boolean inverse, boolean first, float dynamicLevel) {
    if (first) {
        Dimension dimension = getDimension();
        if ((dimension.getDim() != Constants.DIM_NORMAL) && (dimension.getDim() != Constants.DIM_NORMAL_CEILING)) {
            throw new IllegalArgumentException("Cannot set spawn point on dimensions other than 0");
        }
        World2 world = dimension.getWorld();
        int spawnHeight = dimension.getIntHeightAt(centreX, centreY);
        if (spawnHeight == -1) {
            // No tile
            if (JOptionPane.showConfirmDialog(getView(), "<html>Are you sure you want to set the spawn <em>outside</em> the boundary of the world?</html>") != JOptionPane.OK_OPTION) {
                return;
            }
        }
        world.setSpawnPoint(new Point(centreX, centreY));
    }
}
Also used : World2(org.pepsoft.worldpainter.World2) Dimension(org.pepsoft.worldpainter.Dimension) Point(java.awt.Point) Point(java.awt.Point)

Example 39 with Dimension

use of org.pepsoft.worldpainter.Dimension 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

Dimension (org.pepsoft.worldpainter.Dimension)39 File (java.io.File)9 Tile (org.pepsoft.worldpainter.Tile)7 World2 (org.pepsoft.worldpainter.World2)6 EventVO (org.pepsoft.worldpainter.vo.EventVO)6 FileOutputStream (java.io.FileOutputStream)5 ProgressReceiver (org.pepsoft.util.ProgressReceiver)5 java.awt (java.awt)4 FileInputStream (java.io.FileInputStream)4 ObjectInputStream (java.io.ObjectInputStream)4 GZIPInputStream (java.util.zip.GZIPInputStream)4 SubProgressReceiver (org.pepsoft.util.SubProgressReceiver)4 ObjectOutputStream (java.io.ObjectOutputStream)3 java.util (java.util)3 List (java.util.List)3 Map (java.util.Map)3 GZIPOutputStream (java.util.zip.GZIPOutputStream)3 FileInUseException (org.pepsoft.worldpainter.util.FileInUseException)3 java.awt.event (java.awt.event)2 PropertyVetoException (java.beans.PropertyVetoException)2