use of org.pepsoft.util.swing.TileProvider in project WorldPainter by Captain-Chaos.
the class MapViewer method main.
public static void main(String[] args) throws IOException {
File mySavesDir = null;
File minecraftDir = MinecraftUtil.findMinecraftDir();
if (minecraftDir != null) {
mySavesDir = new File(minecraftDir, "saves");
}
File levelDatFile = FileUtils.selectFileForOpen(null, "Select Minecraft map level.dat file", mySavesDir, new FileFilter() {
@Override
public boolean accept(File f) {
return f.isDirectory() || f.getName().equalsIgnoreCase("level.dat");
}
@Override
public String getDescription() {
return "Minecraft levels (level.dat)";
}
});
if (levelDatFile != null) {
final File worldDir = levelDatFile.getParentFile();
TileProvider tileProvider = new MinecraftMapTileProvider(worldDir);
JFrame frame = new JFrame("Map Viewer");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final TiledImageViewer viewer = new TiledImageViewer(true, Math.max(Runtime.getRuntime().availableProcessors() - 1, 1), true);
viewer.setTileProvider(tileProvider);
viewer.addMouseWheelListener(e -> {
int zoom = viewer.getZoom();
zoom -= e.getWheelRotation();
// System.out.println("Setting zoom to " + zoom);
viewer.setZoom(zoom);
});
frame.getContentPane().add(viewer, BorderLayout.CENTER);
frame.setSize(800, 600);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
Aggregations