mirror of
https://github.com/webbukkit/dynmap.git
synced 2025-02-15 03:15:30 +01:00
Replaced tabs with spaces to conform the Bukkit standards.
This commit is contained in:
parent
daa2d0f186
commit
84d01c530a
@ -18,7 +18,7 @@ public class ColorScheme {
|
|||||||
|
|
||||||
public String name;
|
public String name;
|
||||||
/* Switch to arrays - faster than map */
|
/* Switch to arrays - faster than map */
|
||||||
public Color[][] colors; /* [blk-type][step] */
|
public Color[][] colors; /* [blk-type][step] */
|
||||||
public Color[][][] datacolors; /* [bkt-type][blk-dat][step] */
|
public Color[][][] datacolors; /* [bkt-type][blk-dat][step] */
|
||||||
|
|
||||||
public ColorScheme(String name, Color[][] colors, Color[][][] datacolors) {
|
public ColorScheme(String name, Color[][] colors, Color[][][] datacolors) {
|
||||||
@ -67,12 +67,12 @@ public class ColorScheme {
|
|||||||
Integer id;
|
Integer id;
|
||||||
Integer dat = null;
|
Integer dat = null;
|
||||||
int idx = split[0].indexOf(':');
|
int idx = split[0].indexOf(':');
|
||||||
if(idx > 0) { /* ID:data - data color */
|
if(idx > 0) { /* ID:data - data color */
|
||||||
id = new Integer(split[0].substring(0, idx));
|
id = new Integer(split[0].substring(0, idx));
|
||||||
dat = new Integer(split[0].substring(idx+1));
|
dat = new Integer(split[0].substring(idx+1));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
id = new Integer(split[0]);
|
id = new Integer(split[0]);
|
||||||
}
|
}
|
||||||
Color[] c = new Color[4];
|
Color[] c = new Color[4];
|
||||||
|
|
||||||
@ -83,36 +83,36 @@ public class ColorScheme {
|
|||||||
c[2] = new Color(Integer.parseInt(split[13]), Integer.parseInt(split[14]), Integer.parseInt(split[15]), Integer.parseInt(split[16]));
|
c[2] = new Color(Integer.parseInt(split[13]), Integer.parseInt(split[14]), Integer.parseInt(split[15]), Integer.parseInt(split[16]));
|
||||||
|
|
||||||
if(dat != null) {
|
if(dat != null) {
|
||||||
if(enab_datacolor) {
|
if(enab_datacolor) {
|
||||||
Color[][] dcolor = datacolors[id]; /* Existing list? */
|
Color[][] dcolor = datacolors[id]; /* Existing list? */
|
||||||
if(dcolor == null) {
|
if(dcolor == null) {
|
||||||
dcolor = new Color[16][]; /* Make 16 index long list */
|
dcolor = new Color[16][]; /* Make 16 index long list */
|
||||||
datacolors[id] = dcolor;
|
datacolors[id] = dcolor;
|
||||||
}
|
}
|
||||||
if((dat >= 0) && (dat < 16)) { /* Add color to list */
|
if((dat >= 0) && (dat < 16)) { /* Add color to list */
|
||||||
dcolor[dat] = c;
|
dcolor[dat] = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(dat == 0) { /* Index zero is base color too */
|
if(dat == 0) { /* Index zero is base color too */
|
||||||
colors[id] = c;
|
colors[id] = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
colors[id] = c;
|
colors[id] = c;
|
||||||
}
|
}
|
||||||
nc += 1;
|
nc += 1;
|
||||||
}
|
}
|
||||||
scanner.close();
|
scanner.close();
|
||||||
/* Last, push base color into any open slots in data colors list */
|
/* Last, push base color into any open slots in data colors list */
|
||||||
for(int k = 0; k < 256; k++) {
|
for(int k = 0; k < 256; k++) {
|
||||||
Color[][] dc = datacolors[k]; /* see if data colors too */
|
Color[][] dc = datacolors[k]; /* see if data colors too */
|
||||||
if(dc != null) {
|
if(dc != null) {
|
||||||
Color[] c = colors[k];
|
Color[] c = colors[k];
|
||||||
for(int i = 0; i < 16; i++) {
|
for(int i = 0; i < 16; i++) {
|
||||||
if(dc[i] == null)
|
if(dc[i] == null)
|
||||||
dc[i] = c;
|
dc[i] = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
log.log(Level.SEVERE, "Could not load colors '" + name + "' ('" + colorSchemeFile + "').", e);
|
log.log(Level.SEVERE, "Could not load colors '" + name + "' ('" + colorSchemeFile + "').", e);
|
||||||
|
@ -354,13 +354,13 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
for (int i = 1; i < args.length; i++) {
|
for (int i = 1; i < args.length; i++) {
|
||||||
World w = getServer().getWorld(args[i]);
|
World w = getServer().getWorld(args[i]);
|
||||||
if(w != null)
|
if(w != null)
|
||||||
mapManager.renderFullWorld(new Location(w, 0, 0, 0));
|
mapManager.renderFullWorld(new Location(w, 0, 0, 0));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (player != null) {
|
} else if (player != null) {
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
if(loc != null)
|
if(loc != null)
|
||||||
mapManager.renderFullWorld(loc);
|
mapManager.renderFullWorld(loc);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,24 +40,24 @@ public class MapManager {
|
|||||||
private DynmapPlugin plug_in;
|
private DynmapPlugin plug_in;
|
||||||
private boolean do_timesliced_render = false;
|
private boolean do_timesliced_render = false;
|
||||||
private double timeslice_interval = 0.0;
|
private double timeslice_interval = 0.0;
|
||||||
private boolean do_sync_render = false; /* Do incremental renders on sync thread too */
|
private boolean do_sync_render = false; /* Do incremental renders on sync thread too */
|
||||||
/* Which timesliced renders are active */
|
/* Which timesliced renders are active */
|
||||||
private HashMap<String, FullWorldRenderState> active_renders = new HashMap<String, FullWorldRenderState>();
|
private HashMap<String, FullWorldRenderState> active_renders = new HashMap<String, FullWorldRenderState>();
|
||||||
|
|
||||||
/* lock for our data structures */
|
/* lock for our data structures */
|
||||||
public static final Object lock = new Object();
|
public static final Object lock = new Object();
|
||||||
|
|
||||||
public static MapManager mapman; /* Our singleton */
|
public static MapManager mapman; /* Our singleton */
|
||||||
|
|
||||||
private static class ImageWriter {
|
private static class ImageWriter {
|
||||||
Runnable run;
|
Runnable run;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FullWorldRenderState implements Runnable {
|
private class FullWorldRenderState implements Runnable {
|
||||||
DynmapWorld world; /* Which world are we rendering */
|
DynmapWorld world; /* Which world are we rendering */
|
||||||
Location loc; /* Start location */
|
Location loc; /* Start location */
|
||||||
int map_index = -1; /* Which map are we on */
|
int map_index = -1; /* Which map are we on */
|
||||||
MapType map;
|
MapType map;
|
||||||
HashSet<MapTile> found = null;
|
HashSet<MapTile> found = null;
|
||||||
HashSet<MapTile> rendered = null;
|
HashSet<MapTile> rendered = null;
|
||||||
LinkedList<MapTile> renderQueue = null;
|
LinkedList<MapTile> renderQueue = null;
|
||||||
@ -65,8 +65,8 @@ public class MapManager {
|
|||||||
|
|
||||||
/* Full world, all maps render */
|
/* Full world, all maps render */
|
||||||
FullWorldRenderState(DynmapWorld dworld, Location l) {
|
FullWorldRenderState(DynmapWorld dworld, Location l) {
|
||||||
world = dworld;
|
world = dworld;
|
||||||
loc = l;
|
loc = l;
|
||||||
found = new HashSet<MapTile>();
|
found = new HashSet<MapTile>();
|
||||||
rendered = new HashSet<MapTile>();
|
rendered = new HashSet<MapTile>();
|
||||||
renderQueue = new LinkedList<MapTile>();
|
renderQueue = new LinkedList<MapTile>();
|
||||||
@ -74,39 +74,39 @@ public class MapManager {
|
|||||||
|
|
||||||
/* Single tile render - used for incremental renders */
|
/* Single tile render - used for incremental renders */
|
||||||
FullWorldRenderState(MapTile t) {
|
FullWorldRenderState(MapTile t) {
|
||||||
world = worlds.get(t.getWorld().getName());
|
world = worlds.get(t.getWorld().getName());
|
||||||
tile0 = t;
|
tile0 = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
MapTile tile;
|
MapTile tile;
|
||||||
|
|
||||||
if(tile0 == null) { /* Not single tile render */
|
if(tile0 == null) { /* Not single tile render */
|
||||||
/* If render queue is empty, start next map */
|
/* If render queue is empty, start next map */
|
||||||
if(renderQueue.isEmpty()) {
|
if(renderQueue.isEmpty()) {
|
||||||
found.clear();
|
found.clear();
|
||||||
rendered.clear();
|
rendered.clear();
|
||||||
map_index++; /* Next map */
|
map_index++; /* Next map */
|
||||||
if(map_index >= world.maps.size()) { /* Last one done? */
|
if(map_index >= world.maps.size()) { /* Last one done? */
|
||||||
log.info("Full render finished.");
|
log.info("Full render finished.");
|
||||||
active_renders.remove(world.world.getName());
|
active_renders.remove(world.world.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
map = world.maps.get(map_index);
|
map = world.maps.get(map_index);
|
||||||
|
|
||||||
/* Now, prime the render queue */
|
/* Now, prime the render queue */
|
||||||
for (MapTile mt : map.getTiles(loc)) {
|
for (MapTile mt : map.getTiles(loc)) {
|
||||||
if (!found.contains(mt)) {
|
if (!found.contains(mt)) {
|
||||||
found.add(mt);
|
found.add(mt);
|
||||||
renderQueue.add(mt);
|
renderQueue.add(mt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tile = renderQueue.pollFirst();
|
tile = renderQueue.pollFirst();
|
||||||
}
|
}
|
||||||
else { /* Else, single tile render */
|
else { /* Else, single tile render */
|
||||||
tile = tile0;
|
tile = tile0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DynmapChunk[] requiredChunks = tile.getMap().getRequiredChunks(tile);
|
DynmapChunk[] requiredChunks = tile.getMap().getRequiredChunks(tile);
|
||||||
LinkedList<DynmapChunk> loadedChunks = new LinkedList<DynmapChunk>();
|
LinkedList<DynmapChunk> loadedChunks = new LinkedList<DynmapChunk>();
|
||||||
@ -118,21 +118,21 @@ public class MapManager {
|
|||||||
if ((!wasLoaded) && didload)
|
if ((!wasLoaded) && didload)
|
||||||
loadedChunks.add(chunk);
|
loadedChunks.add(chunk);
|
||||||
}
|
}
|
||||||
if(tile0 != null) { /* Single tile? */
|
if(tile0 != null) { /* Single tile? */
|
||||||
render(tile); /* Just render */
|
render(tile); /* Just render */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (render(tile)) {
|
if (render(tile)) {
|
||||||
found.remove(tile);
|
found.remove(tile);
|
||||||
rendered.add(tile);
|
rendered.add(tile);
|
||||||
for (MapTile adjTile : map.getAdjecentTiles(tile)) {
|
for (MapTile adjTile : map.getAdjecentTiles(tile)) {
|
||||||
if (!found.contains(adjTile) && !rendered.contains(adjTile)) {
|
if (!found.contains(adjTile) && !rendered.contains(adjTile)) {
|
||||||
found.add(adjTile);
|
found.add(adjTile);
|
||||||
renderQueue.add(adjTile);
|
renderQueue.add(adjTile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
found.remove(tile);
|
found.remove(tile);
|
||||||
}
|
}
|
||||||
/* And unload what we loaded */
|
/* And unload what we loaded */
|
||||||
while (!loadedChunks.isEmpty()) {
|
while (!loadedChunks.isEmpty()) {
|
||||||
@ -141,45 +141,45 @@ public class MapManager {
|
|||||||
* when chunks are unloaded but not saved - removing them seems to do the trick */
|
* when chunks are unloaded but not saved - removing them seems to do the trick */
|
||||||
Chunk cc = w.getChunkAt(c.x, c.z);
|
Chunk cc = w.getChunkAt(c.x, c.z);
|
||||||
if(cc != null) {
|
if(cc != null) {
|
||||||
for(Entity e: cc.getEntities())
|
for(Entity e: cc.getEntities())
|
||||||
e.remove();
|
e.remove();
|
||||||
}
|
}
|
||||||
/* Since we only remember ones we loaded, and we're synchronous, no player has
|
/* Since we only remember ones we loaded, and we're synchronous, no player has
|
||||||
* moved, so it must be safe (also prevent chunk leak, which appears to happen
|
* moved, so it must be safe (also prevent chunk leak, which appears to happen
|
||||||
* because isChunkInUse defined "in use" as being within 256 blocks of a player,
|
* because isChunkInUse defined "in use" as being within 256 blocks of a player,
|
||||||
* while the actual in-use chunk area for a player where the chunks are managed
|
* while the actual in-use chunk area for a player where the chunks are managed
|
||||||
* by the MC base server is 21x21 (or about a 160 block radius) */
|
* by the MC base server is 21x21 (or about a 160 block radius) */
|
||||||
w.unloadChunk(c.x, c.z, false, false);
|
w.unloadChunk(c.x, c.z, false, false);
|
||||||
}
|
}
|
||||||
if(tile0 == null) { /* fullrender */
|
if(tile0 == null) { /* fullrender */
|
||||||
/* Schedule the next tile to be worked */
|
/* Schedule the next tile to be worked */
|
||||||
scheduler.scheduleSyncDelayedTask(plug_in, this, (int)(timeslice_interval*20));
|
scheduler.scheduleSyncDelayedTask(plug_in, this, (int)(timeslice_interval*20));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapManager(DynmapPlugin plugin, ConfigurationNode configuration) {
|
public MapManager(DynmapPlugin plugin, ConfigurationNode configuration) {
|
||||||
|
|
||||||
mapman = this;
|
mapman = this;
|
||||||
|
|
||||||
this.tileQueue = new AsynchronousQueue<MapTile>(new Handler<MapTile>() {
|
this.tileQueue = new AsynchronousQueue<MapTile>(new Handler<MapTile>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(MapTile t) {
|
public void handle(MapTile t) {
|
||||||
if(do_sync_render)
|
if(do_sync_render)
|
||||||
scheduler.scheduleSyncDelayedTask(plug_in,
|
scheduler.scheduleSyncDelayedTask(plug_in,
|
||||||
new FullWorldRenderState(t), 1);
|
new FullWorldRenderState(t), 1);
|
||||||
else
|
else
|
||||||
render(t);
|
render(t);
|
||||||
}
|
}
|
||||||
}, (int) (configuration.getDouble("renderinterval", 0.5) * 1000));
|
}, (int) (configuration.getDouble("renderinterval", 0.5) * 1000));
|
||||||
|
|
||||||
this.writeQueue = new AsynchronousQueue<ImageWriter>(
|
this.writeQueue = new AsynchronousQueue<ImageWriter>(
|
||||||
new Handler<ImageWriter>() {
|
new Handler<ImageWriter>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(ImageWriter w) {
|
public void handle(ImageWriter w) {
|
||||||
w.run.run();
|
w.run.run();
|
||||||
}
|
}
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
do_timesliced_render = configuration.getBoolean("timeslicerender", true);
|
do_timesliced_render = configuration.getBoolean("timeslicerender", true);
|
||||||
timeslice_interval = configuration.getDouble("timesliceinterval", 0.5);
|
timeslice_interval = configuration.getDouble("timesliceinterval", 0.5);
|
||||||
@ -217,16 +217,16 @@ public class MapManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(do_timesliced_render) {
|
if(do_timesliced_render) {
|
||||||
String wname = l.getWorld().getName();
|
String wname = l.getWorld().getName();
|
||||||
FullWorldRenderState rndr = active_renders.get(wname);
|
FullWorldRenderState rndr = active_renders.get(wname);
|
||||||
if(rndr != null) {
|
if(rndr != null) {
|
||||||
log.info("Full world render of world '" + wname + "' already active.");
|
log.info("Full world render of world '" + wname + "' already active.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rndr = new FullWorldRenderState(world,l); /* Make new activation record */
|
rndr = new FullWorldRenderState(world,l); /* Make new activation record */
|
||||||
active_renders.put(wname, rndr); /* Add to active table */
|
active_renders.put(wname, rndr); /* Add to active table */
|
||||||
/* Schedule first tile to be worked */
|
/* Schedule first tile to be worked */
|
||||||
scheduler.scheduleSyncDelayedTask(plug_in, rndr, (int)(timeslice_interval*20));
|
scheduler.scheduleSyncDelayedTask(plug_in, rndr, (int)(timeslice_interval*20));
|
||||||
log.info("Full render starting on world '" + wname + "' (timesliced)...");
|
log.info("Full render starting on world '" + wname + "' (timesliced)...");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -355,7 +355,7 @@ public class MapManager {
|
|||||||
|
|
||||||
public void startRendering() {
|
public void startRendering() {
|
||||||
tileQueue.start();
|
tileQueue.start();
|
||||||
writeQueue.start();
|
writeQueue.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopRendering() {
|
public void stopRendering() {
|
||||||
@ -407,12 +407,12 @@ public class MapManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void enqueueImageWrite(Runnable run) {
|
public void enqueueImageWrite(Runnable run) {
|
||||||
ImageWriter handler = new ImageWriter();
|
ImageWriter handler = new ImageWriter();
|
||||||
handler.run = run;
|
handler.run = run;
|
||||||
writeQueue.push(handler);
|
writeQueue.push(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean doSyncRender() {
|
public boolean doSyncRender() {
|
||||||
return do_sync_render;
|
return do_sync_render;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,19 +127,19 @@ public class FlatMap extends MapType {
|
|||||||
final MapTile mtile = tile;
|
final MapTile mtile = tile;
|
||||||
final BufferedImage img = im;
|
final BufferedImage img = im;
|
||||||
MapManager.mapman.enqueueImageWrite(new Runnable() {
|
MapManager.mapman.enqueueImageWrite(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Debug.debug("saving image " + fname.getPath());
|
Debug.debug("saving image " + fname.getPath());
|
||||||
try {
|
try {
|
||||||
ImageIO.write(img, "png", fname);
|
ImageIO.write(img, "png", fname);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Debug.error("Failed to save image: " + fname.getPath(), e);
|
Debug.error("Failed to save image: " + fname.getPath(), e);
|
||||||
} catch (java.lang.NullPointerException e) {
|
} catch (java.lang.NullPointerException e) {
|
||||||
Debug.error("Failed to save image (NullPointerException): " + fname.getPath(), e);
|
Debug.error("Failed to save image (NullPointerException): " + fname.getPath(), e);
|
||||||
}
|
}
|
||||||
img.flush();
|
img.flush();
|
||||||
MapManager.mapman.pushUpdate(mtile.getWorld(),
|
MapManager.mapman.pushUpdate(mtile.getWorld(),
|
||||||
new Client.Tile(mtile.getFilename()));
|
new Client.Tile(mtile.getFilename()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return rendered;
|
return rendered;
|
||||||
|
@ -29,22 +29,22 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||||||
protected Color highlightColor = new Color(255, 0, 0);
|
protected Color highlightColor = new Color(255, 0, 0);
|
||||||
|
|
||||||
private static final Color[] woolshades = {
|
private static final Color[] woolshades = {
|
||||||
Color.WHITE,
|
Color.WHITE,
|
||||||
Color.ORANGE,
|
Color.ORANGE,
|
||||||
Color.MAGENTA,
|
Color.MAGENTA,
|
||||||
new Color(51,204,255),
|
new Color(51,204,255),
|
||||||
Color.YELLOW,
|
Color.YELLOW,
|
||||||
new Color(102,255,102),
|
new Color(102,255,102),
|
||||||
Color.PINK,
|
Color.PINK,
|
||||||
Color.GRAY,
|
Color.GRAY,
|
||||||
Color.LIGHT_GRAY,
|
Color.LIGHT_GRAY,
|
||||||
Color.CYAN,
|
Color.CYAN,
|
||||||
new Color(255,0,255),
|
new Color(255,0,255),
|
||||||
Color.BLUE,
|
Color.BLUE,
|
||||||
new Color(102,51,51),
|
new Color(102,51,51),
|
||||||
Color.GREEN,
|
Color.GREEN,
|
||||||
Color.RED,
|
Color.RED,
|
||||||
Color.BLACK
|
Color.BLACK
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -132,88 +132,88 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||||||
final File fname = outputFile;
|
final File fname = outputFile;
|
||||||
final KzedMapTile mtile = tile;
|
final KzedMapTile mtile = tile;
|
||||||
final BufferedImage img = im;
|
final BufferedImage img = im;
|
||||||
final KzedZoomedMapTile zmtile = new KzedZoomedMapTile(mtile.getWorld(),
|
final KzedZoomedMapTile zmtile = new KzedZoomedMapTile(mtile.getWorld(),
|
||||||
(KzedMap) mtile.getMap(), mtile);
|
(KzedMap) mtile.getMap(), mtile);
|
||||||
final File zoomFile = MapManager.mapman.getTileFile(zmtile);
|
final File zoomFile = MapManager.mapman.getTileFile(zmtile);
|
||||||
|
|
||||||
MapManager.mapman.enqueueImageWrite(new Runnable() {
|
MapManager.mapman.enqueueImageWrite(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
doFileWrites(fname, mtile, img, zmtile, zoomFile);
|
doFileWrites(fname, mtile, img, zmtile, zoomFile);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return !isempty;
|
return !isempty;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doFileWrites(final File fname, final KzedMapTile mtile,
|
private void doFileWrites(final File fname, final KzedMapTile mtile,
|
||||||
final BufferedImage img, final KzedZoomedMapTile zmtile, final File zoomFile) {
|
final BufferedImage img, final KzedZoomedMapTile zmtile, final File zoomFile) {
|
||||||
Debug.debug("saving image " + fname.getPath());
|
Debug.debug("saving image " + fname.getPath());
|
||||||
try {
|
try {
|
||||||
ImageIO.write(img, "png", fname);
|
ImageIO.write(img, "png", fname);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Debug.error("Failed to save image: " + fname.getPath(), e);
|
Debug.error("Failed to save image: " + fname.getPath(), e);
|
||||||
} catch (java.lang.NullPointerException e) {
|
} catch (java.lang.NullPointerException e) {
|
||||||
Debug.error("Failed to save image (NullPointerException): " + fname.getPath(), e);
|
Debug.error("Failed to save image (NullPointerException): " + fname.getPath(), e);
|
||||||
}
|
}
|
||||||
mtile.file = fname;
|
mtile.file = fname;
|
||||||
// Since we've already got the new tile, and we're on an async thread, just
|
// Since we've already got the new tile, and we're on an async thread, just
|
||||||
// make the zoomed tile here
|
// make the zoomed tile here
|
||||||
int px = mtile.px;
|
int px = mtile.px;
|
||||||
int py = mtile.py;
|
int py = mtile.py;
|
||||||
int zpx = zmtile.getTileX();
|
int zpx = zmtile.getTileX();
|
||||||
int zpy = zmtile.getTileY();
|
int zpy = zmtile.getTileY();
|
||||||
|
|
||||||
/* scaled size */
|
/* scaled size */
|
||||||
int scw = KzedMap.tileWidth / 2;
|
int scw = KzedMap.tileWidth / 2;
|
||||||
int sch = KzedMap.tileHeight / 2;
|
int sch = KzedMap.tileHeight / 2;
|
||||||
|
|
||||||
/* origin in zoomed-out tile */
|
/* origin in zoomed-out tile */
|
||||||
int ox = 0;
|
int ox = 0;
|
||||||
int oy = 0;
|
int oy = 0;
|
||||||
|
|
||||||
if (zpx != px)
|
if (zpx != px)
|
||||||
ox = scw;
|
ox = scw;
|
||||||
if (zpy != py)
|
if (zpy != py)
|
||||||
oy = sch;
|
oy = sch;
|
||||||
|
|
||||||
BufferedImage zIm = null;
|
BufferedImage zIm = null;
|
||||||
try {
|
try {
|
||||||
zIm = ImageIO.read(zoomFile);
|
zIm = ImageIO.read(zoomFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
} catch (IndexOutOfBoundsException e) {
|
} catch (IndexOutOfBoundsException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zIm == null) {
|
if (zIm == null) {
|
||||||
/* create new one */
|
/* create new one */
|
||||||
zIm = new BufferedImage(KzedMap.tileWidth, KzedMap.tileHeight, BufferedImage.TYPE_INT_RGB);
|
zIm = new BufferedImage(KzedMap.tileWidth, KzedMap.tileHeight, BufferedImage.TYPE_INT_RGB);
|
||||||
Debug.debug("New zoom-out tile created " + zmtile.getFilename());
|
Debug.debug("New zoom-out tile created " + zmtile.getFilename());
|
||||||
} else {
|
} else {
|
||||||
Debug.debug("Loaded zoom-out tile from " + zmtile.getFilename());
|
Debug.debug("Loaded zoom-out tile from " + zmtile.getFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* blit scaled rendered tile onto zoom-out tile */
|
/* blit scaled rendered tile onto zoom-out tile */
|
||||||
Graphics2D g2 = zIm.createGraphics();
|
Graphics2D g2 = zIm.createGraphics();
|
||||||
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||||
g2.drawImage(img, ox, oy, scw, sch, null);
|
g2.drawImage(img, ox, oy, scw, sch, null);
|
||||||
|
|
||||||
img.flush();
|
img.flush();
|
||||||
|
|
||||||
/* save zoom-out tile */
|
/* save zoom-out tile */
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ImageIO.write(zIm, "png", zoomFile);
|
ImageIO.write(zIm, "png", zoomFile);
|
||||||
Debug.debug("Saved zoom-out tile at " + zoomFile.getName());
|
Debug.debug("Saved zoom-out tile at " + zoomFile.getName());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Debug.error("Failed to save zoom-out tile: " + zoomFile.getName(), e);
|
Debug.error("Failed to save zoom-out tile: " + zoomFile.getName(), e);
|
||||||
} catch (java.lang.NullPointerException e) {
|
} catch (java.lang.NullPointerException e) {
|
||||||
Debug.error("Failed to save zoom-out tile (NullPointerException): " + zoomFile.getName(), e);
|
Debug.error("Failed to save zoom-out tile (NullPointerException): " + zoomFile.getName(), e);
|
||||||
}
|
}
|
||||||
zIm.flush();
|
zIm.flush();
|
||||||
/* Push updates for both files.*/
|
/* Push updates for both files.*/
|
||||||
MapManager.mapman.pushUpdate(mtile.getWorld(),
|
MapManager.mapman.pushUpdate(mtile.getWorld(),
|
||||||
new Client.Tile(mtile.getFilename()));
|
new Client.Tile(mtile.getFilename()));
|
||||||
MapManager.mapman.pushUpdate(zmtile.getWorld(),
|
MapManager.mapman.pushUpdate(zmtile.getWorld(),
|
||||||
new Client.Tile(zmtile.getFilename()));
|
new Client.Tile(zmtile.getFilename()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -224,8 +224,8 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||||||
|
|
||||||
int id = world.getBlockTypeIdAt(x, y, z);
|
int id = world.getBlockTypeIdAt(x, y, z);
|
||||||
byte data = 0;
|
byte data = 0;
|
||||||
if(colorScheme.datacolors[id] != null) { /* If data colored */
|
if(colorScheme.datacolors[id] != null) { /* If data colored */
|
||||||
data = world.getBlockAt(x, y, z).getData();
|
data = world.getBlockAt(x, y, z).getData();
|
||||||
}
|
}
|
||||||
switch (seq) {
|
switch (seq) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -250,9 +250,9 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||||||
}
|
}
|
||||||
Color[] colors;
|
Color[] colors;
|
||||||
if(data != 0)
|
if(data != 0)
|
||||||
colors = colorScheme.datacolors[id][data];
|
colors = colorScheme.datacolors[id][data];
|
||||||
else
|
else
|
||||||
colors = colorScheme.colors[id];
|
colors = colorScheme.colors[id];
|
||||||
if (colors != null) {
|
if (colors != null) {
|
||||||
Color c = colors[seq];
|
Color c = colors[seq];
|
||||||
if (c.getAlpha() > 0) {
|
if (c.getAlpha() > 0) {
|
||||||
|
@ -32,8 +32,8 @@ public class HighlightTileRenderer extends DefaultTileRenderer {
|
|||||||
|
|
||||||
int id = world.getBlockTypeIdAt(x, y, z);
|
int id = world.getBlockTypeIdAt(x, y, z);
|
||||||
byte data = 0;
|
byte data = 0;
|
||||||
if(colorScheme.datacolors[id] != null) { /* If data colored */
|
if(colorScheme.datacolors[id] != null) { /* If data colored */
|
||||||
data = world.getBlockAt(x, y, z).getData();
|
data = world.getBlockAt(x, y, z).getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (seq) {
|
switch (seq) {
|
||||||
@ -56,9 +56,9 @@ public class HighlightTileRenderer extends DefaultTileRenderer {
|
|||||||
if (id != 0) {
|
if (id != 0) {
|
||||||
Color[] colors;
|
Color[] colors;
|
||||||
if(data != 0)
|
if(data != 0)
|
||||||
colors = colorScheme.datacolors[id][data];
|
colors = colorScheme.datacolors[id][data];
|
||||||
else
|
else
|
||||||
colors = colorScheme.colors[id];
|
colors = colorScheme.colors[id];
|
||||||
if (colors != null) {
|
if (colors != null) {
|
||||||
Color c = colors[seq];
|
Color c = colors[seq];
|
||||||
|
|
||||||
|
@ -18,6 +18,6 @@ public class ZoomedTileRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void render(final KzedZoomedMapTile zt, final File outputPath) {
|
public void render(final KzedZoomedMapTile zt, final File outputPath) {
|
||||||
return; /* Doing this in Default render, since image already loaded */
|
return; /* Doing this in Default render, since image already loaded */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user