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);
}
}
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);
}
}
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));
}
}
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"));
}
}
Aggregations