From a878ce7cd1dd5e2751fa53dd6764484d2c7403a3 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Fri, 22 Jul 2011 01:42:10 -0500 Subject: [PATCH] Improve progress messages, make sure HDMaps that share render only render once --- src/main/java/org/dynmap/MapManager.java | 38 ++++++++++++++++--- src/main/java/org/dynmap/MapType.java | 5 +++ src/main/java/org/dynmap/flat/FlatMap.java | 15 +++++++- src/main/java/org/dynmap/hdmap/HDMap.java | 33 ++++++++++++++++ .../java/org/dynmap/hdmap/HDMapManager.java | 2 +- .../dynmap/kzedmap/DefaultTileRenderer.java | 9 ++++- src/main/java/org/dynmap/kzedmap/KzedMap.java | 18 +++++++++ .../java/org/dynmap/kzedmap/KzedMapTile.java | 10 ++--- .../org/dynmap/kzedmap/KzedZoomedMapTile.java | 10 ++--- .../org/dynmap/kzedmap/MapTileRenderer.java | 1 + web/js/flatmap.js | 2 +- web/js/kzedmaps.js | 2 +- 12 files changed, 124 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/dynmap/MapManager.java b/src/main/java/org/dynmap/MapManager.java index 6a4ef42f..2cf5530a 100644 --- a/src/main/java/org/dynmap/MapManager.java +++ b/src/main/java/org/dynmap/MapManager.java @@ -160,6 +160,9 @@ public class MapManager { int rendercnt = 0; CommandSender sender; long timeaccum; + HashSet renderedmaps = new HashSet(); + String activemaps; + List activemaplist; /* Full world, all maps render */ FullWorldRenderState(DynmapWorld dworld, Location l, CommandSender sender) { @@ -195,21 +198,40 @@ public class MapManager { /* If render queue is empty, start next map */ if(renderQueue.isEmpty()) { if(map_index >= 0) { /* Finished a map? */ - double msecpertile = (double)timeaccum / (double)((rendercnt>0)?rendercnt:1); - sender.sendMessage("Full render of map '" + world.maps.get(map_index).getClass().getSimpleName() + "' of world '" + + double msecpertile = (double)timeaccum / (double)((rendercnt>0)?rendercnt:1)/(double)activemaplist.size(); + if(activemaplist.size() > 1) + sender.sendMessage("Full render of maps [" + activemaps + "] of '" + + world.world.getName() + "' completed - " + rendercnt + " tiles rendered each (" + String.format("%.2f", msecpertile) + " msec/map-tile)."); + else + sender.sendMessage("Full render of map '" + activemaps + "' of '" + world.world.getName() + "' completed - " + rendercnt + " tiles rendered (" + String.format("%.2f", msecpertile) + " msec/tile)."); } found.clear(); rendered.clear(); rendercnt = 0; timeaccum = 0; - map_index++; /* Next map */ + /* Advance to next unrendered map */ + while(map_index < world.maps.size()) { + map_index++; /* Move to next one */ + if((map_index < world.maps.size()) && (renderedmaps.contains(world.maps.get(map_index)) == false)) + break; + } if(map_index >= world.maps.size()) { /* Last one done? */ sender.sendMessage("Full render of '" + world.world.getName() + "' finished."); cleanup(); return; } map = world.maps.get(map_index); + activemaplist = map.getMapNamesSharingRender(world); + /* Build active map list */ + activemaps = ""; + for(String n : activemaplist) { + if(activemaps.length() > 0) + activemaps += ","; + activemaps += n; + } + /* Mark all the concurrently rendering maps rendered */ + renderedmaps.addAll(map.getMapsSharingRender(world)); /* Now, prime the render queue */ for (MapTile mt : map.getTiles(loc)) { @@ -264,9 +286,13 @@ public class MapManager { rendercnt++; timeaccum += System.currentTimeMillis() - tstart; if((rendercnt % 100) == 0) { - double msecpertile = (double)timeaccum / (double)rendercnt; - sender.sendMessage("Full render of map '" + world.maps.get(map_index).getClass().getSimpleName() + "' on world '" + - w.getName() + "' in progress - " + rendercnt + " tiles rendered (" + String.format("%.2f", msecpertile) + " msec/tile)."); + double msecpertile = (double)timeaccum / (double)rendercnt / (double)activemaplist.size(); + if(activemaplist.size() > 1) + sender.sendMessage("Full render of maps [" + activemaps + "] of '" + + w.getName() + "' in progress - " + rendercnt + " tiles rendered each (" + String.format("%.2f", msecpertile) + " msec/map-tile)."); + else + sender.sendMessage("Full render of map '" + activemaps + "' of '" + + w.getName() + "' in progress - " + rendercnt + " tiles rendered (" + String.format("%.2f", msecpertile) + " msec/tile)."); } } } diff --git a/src/main/java/org/dynmap/MapType.java b/src/main/java/org/dynmap/MapType.java index 723dc5eb..3515147e 100644 --- a/src/main/java/org/dynmap/MapType.java +++ b/src/main/java/org/dynmap/MapType.java @@ -20,6 +20,11 @@ public abstract class MapType { } public abstract String getName(); + + /* Get maps rendered concurrently with this map in this world */ + public abstract List getMapsSharingRender(DynmapWorld w); + /* Get names of maps rendered concurrently with this map type in this world */ + public abstract List getMapNamesSharingRender(DynmapWorld w); public enum MapStep { X_PLUS_Y_PLUS, diff --git a/src/main/java/org/dynmap/flat/FlatMap.java b/src/main/java/org/dynmap/flat/FlatMap.java index 8e0eee35..ac844aa6 100644 --- a/src/main/java/org/dynmap/flat/FlatMap.java +++ b/src/main/java/org/dynmap/flat/FlatMap.java @@ -6,6 +6,7 @@ import static org.dynmap.JSONUtils.s; import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import javax.imageio.ImageIO; @@ -35,6 +36,7 @@ import org.json.simple.JSONObject; public class FlatMap extends MapType { private ConfigurationNode configuration; private String prefix; + private String name; private ColorScheme colorScheme; private int maximumHeight = 127; private int ambientlight = 15;; @@ -47,7 +49,8 @@ public class FlatMap extends MapType { public FlatMap(ConfigurationNode configuration) { this.configuration = configuration; - prefix = (String) configuration.get("prefix"); + name = configuration.getString("name", null); + prefix = configuration.getString("prefix", name); colorScheme = ColorScheme.getScheme((String) configuration.get("colorscheme")); Object o = configuration.get("maximumheight"); if (o != null) { @@ -412,6 +415,16 @@ public class FlatMap extends MapType { public String getName() { return prefix; } + + /* Get maps rendered concurrently with this map in this world */ + public List getMapsSharingRender(DynmapWorld w) { + return Collections.singletonList((MapType)this); + } + + /* Get names of maps rendered concurrently with this map type in this world */ + public List getMapNamesSharingRender(DynmapWorld w) { + return Collections.singletonList(name); + } public List baseZoomFilePrefixes() { ArrayList s = new ArrayList(); diff --git a/src/main/java/org/dynmap/hdmap/HDMap.java b/src/main/java/org/dynmap/hdmap/HDMap.java index 15b6004c..0106388d 100644 --- a/src/main/java/org/dynmap/hdmap/HDMap.java +++ b/src/main/java/org/dynmap/hdmap/HDMap.java @@ -14,6 +14,7 @@ import org.dynmap.Log; import org.dynmap.MapManager; import org.dynmap.MapTile; import org.dynmap.MapType; +import org.dynmap.kzedmap.MapTileRenderer; import org.dynmap.utils.MapChunkCache; import org.json.simple.JSONObject; @@ -130,6 +131,38 @@ public class HDMap extends MapType { return prefix; } + /* Get maps rendered concurrently with this map in this world */ + public List getMapsSharingRender(DynmapWorld w) { + ArrayList maps = new ArrayList(); + for(MapType mt : w.maps) { + if(mt instanceof HDMap) { + HDMap hdmt = (HDMap)mt; + if(hdmt.perspective == this.perspective) { /* Same perspective */ + maps.add(hdmt); + } + } + } + return maps; + } + + /* Get names of maps rendered concurrently with this map type in this world */ + public List getMapNamesSharingRender(DynmapWorld w) { + ArrayList lst = new ArrayList(); + for(MapType mt : w.maps) { + if(mt instanceof HDMap) { + HDMap hdmt = (HDMap)mt; + if(hdmt.perspective == this.perspective) { /* Same perspective */ + if(hdmt.lighting.isNightAndDayEnabled()) + lst.add(hdmt.getName() + "(night/day)"); + else + lst.add(hdmt.getName()); + } + } + } + return lst; + } + + @Override public void buildClientConfiguration(JSONObject worldObject, DynmapWorld world) { ConfigurationNode c = configuration; diff --git a/src/main/java/org/dynmap/hdmap/HDMapManager.java b/src/main/java/org/dynmap/hdmap/HDMapManager.java index 92cda092..bb7bd41c 100644 --- a/src/main/java/org/dynmap/hdmap/HDMapManager.java +++ b/src/main/java/org/dynmap/hdmap/HDMapManager.java @@ -147,7 +147,7 @@ public class HDMapManager { } return shaders.toArray(new HDShaderState[shaders.size()]); } - + private static final int BIOMEDATAFLAG = 0; private static final int HIGHESTZFLAG = 1; private static final int RAWBIOMEFLAG = 2; diff --git a/src/main/java/org/dynmap/kzedmap/DefaultTileRenderer.java b/src/main/java/org/dynmap/kzedmap/DefaultTileRenderer.java index 0e374c64..a2296230 100644 --- a/src/main/java/org/dynmap/kzedmap/DefaultTileRenderer.java +++ b/src/main/java/org/dynmap/kzedmap/DefaultTileRenderer.java @@ -30,6 +30,7 @@ import org.json.simple.JSONObject; public class DefaultTileRenderer implements MapTileRenderer { protected static final Color translucent = new Color(0, 0, 0, 0); protected String name; + protected String prefix; protected ConfigurationNode configuration; protected int maximumHeight = 127; protected ColorScheme colorScheme; @@ -45,7 +46,12 @@ public class DefaultTileRenderer implements MapTileRenderer { NONE, BIOME, TEMPERATURE, RAINFALL } protected BiomeColorOption biomecolored = BiomeColorOption.NONE; /* Use biome for coloring */ + @Override + public String getPrefix() { + return prefix; + } + public String getName() { return name; } @@ -54,7 +60,8 @@ public class DefaultTileRenderer implements MapTileRenderer { public DefaultTileRenderer(ConfigurationNode configuration) { this.configuration = configuration; - name = (String) configuration.get("prefix"); + name = configuration.getString("name", null); + prefix = configuration.getString("prefix", name); Object o = configuration.get("maximumheight"); if (o != null) { maximumHeight = Integer.parseInt(String.valueOf(o)); diff --git a/src/main/java/org/dynmap/kzedmap/KzedMap.java b/src/main/java/org/dynmap/kzedmap/KzedMap.java index 73867937..9f8c92f4 100644 --- a/src/main/java/org/dynmap/kzedmap/KzedMap.java +++ b/src/main/java/org/dynmap/kzedmap/KzedMap.java @@ -5,6 +5,7 @@ import java.awt.image.BufferedImage; import java.io.File; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -358,6 +359,23 @@ public class KzedMap extends MapType { return "KzedMap"; } + /* Get maps rendered concurrently with this map in this world */ + public List getMapsSharingRender(DynmapWorld w) { + return Collections.singletonList((MapType)this); + } + + /* Get names of maps rendered concurrently with this map type in this world */ + public List getMapNamesSharingRender(DynmapWorld w) { + ArrayList lst = new ArrayList(); + for(MapTileRenderer rend : renderers) { + if(rend.isNightAndDayEnabled()) + lst.add(rend.getName() + "(night/day)"); + else + lst.add(rend.getName()); + } + return lst; + } + @Override public void buildClientConfiguration(JSONObject worldObject, DynmapWorld world) { for(MapTileRenderer renderer : renderers) { diff --git a/src/main/java/org/dynmap/kzedmap/KzedMapTile.java b/src/main/java/org/dynmap/kzedmap/KzedMapTile.java index 24c25a23..451f27d3 100644 --- a/src/main/java/org/dynmap/kzedmap/KzedMapTile.java +++ b/src/main/java/org/dynmap/kzedmap/KzedMapTile.java @@ -32,9 +32,9 @@ public class KzedMapTile extends MapTile { public String getFilename() { if(fname == null) { if(map.isBigWorldMap(world)) - fname = renderer.getName() + "/" + (px >> 12) + '_' + (py >> 12) + '/' + px + "_" + py + ".png"; + fname = renderer.getPrefix() + "/" + (px >> 12) + '_' + (py >> 12) + '/' + px + "_" + py + ".png"; else - fname = renderer.getName() + "_" + px + "_" + py + ".png"; + fname = renderer.getPrefix() + "_" + px + "_" + py + ".png"; } return fname; } @@ -43,9 +43,9 @@ public class KzedMapTile extends MapTile { public String getDayFilename() { if(fname_day == null) { if(map.isBigWorldMap(world)) - fname_day = renderer.getName() + "_day/" + (px >> 12) + '_' + (py >> 12) + '/' + px + "_" + py + ".png"; + fname_day = renderer.getPrefix() + "_day/" + (px >> 12) + '_' + (py >> 12) + '/' + px + "_" + py + ".png"; else - fname_day = renderer.getName() + "_day_" + px + "_" + py + ".png"; + fname_day = renderer.getPrefix() + "_day_" + px + "_" + py + ".png"; } return fname_day; } @@ -68,7 +68,7 @@ public class KzedMapTile extends MapTile { } public String getKey() { - return getWorld().getName() + "." + renderer.getName(); + return getWorld().getName() + "." + renderer.getPrefix(); } public String toString() { diff --git a/src/main/java/org/dynmap/kzedmap/KzedZoomedMapTile.java b/src/main/java/org/dynmap/kzedmap/KzedZoomedMapTile.java index 04edfc4b..89f8c148 100644 --- a/src/main/java/org/dynmap/kzedmap/KzedZoomedMapTile.java +++ b/src/main/java/org/dynmap/kzedmap/KzedZoomedMapTile.java @@ -15,10 +15,10 @@ public class KzedZoomedMapTile extends MapTile { public String getFilename() { if(fname == null) { if(world.bigworld) - fname = "z" + originalTile.renderer.getName() + "/" + (getTileX()>>12) + '_' + + fname = "z" + originalTile.renderer.getPrefix() + "/" + (getTileX()>>12) + '_' + (getTileY() >> 12) + '/' + getTileX() + "_" + getTileY() + ".png"; else - fname = "z" + originalTile.renderer.getName() + "_" + getTileX() + "_" + getTileY() + ".png"; + fname = "z" + originalTile.renderer.getPrefix() + "_" + getTileX() + "_" + getTileY() + ".png"; } return fname; } @@ -27,10 +27,10 @@ public class KzedZoomedMapTile extends MapTile { public String getDayFilename() { if(fname_day == null) { if(world.bigworld) - fname_day = "z" + originalTile.renderer.getName() + "_day/" + (getTileX()>>12) + '_' + + fname_day = "z" + originalTile.renderer.getPrefix() + "_day/" + (getTileX()>>12) + '_' + (getTileY() >> 12) + '/' + getTileX() + "_" + getTileY() + ".png"; else - fname_day = "z" + originalTile.renderer.getName() + "_day_" + getTileX() + "_" + getTileY() + ".png"; + fname_day = "z" + originalTile.renderer.getPrefix() + "_day_" + getTileX() + "_" + getTileY() + ".png"; } return fname_day; } @@ -80,7 +80,7 @@ public class KzedZoomedMapTile extends MapTile { public String getKey() { - return getWorld().getName() + ".z" + originalTile.renderer.getName(); + return getWorld().getName() + ".z" + originalTile.renderer.getPrefix(); } @Override diff --git a/src/main/java/org/dynmap/kzedmap/MapTileRenderer.java b/src/main/java/org/dynmap/kzedmap/MapTileRenderer.java index bccec2b9..55722c4d 100644 --- a/src/main/java/org/dynmap/kzedmap/MapTileRenderer.java +++ b/src/main/java/org/dynmap/kzedmap/MapTileRenderer.java @@ -8,6 +8,7 @@ import org.dynmap.utils.MapChunkCache; import org.json.simple.JSONObject; public interface MapTileRenderer { + String getPrefix(); String getName(); boolean render(MapChunkCache cache, KzedMapTile tile, File outputFile); diff --git a/web/js/flatmap.js b/web/js/flatmap.js index a771d4ad..11cbf3b8 100644 --- a/web/js/flatmap.js +++ b/web/js/flatmap.js @@ -72,7 +72,7 @@ FlatMapType.prototype = $.extend(new DynMapType(), { updateTileSize: function(zoom) { var size; var extrazoom = this.dynmap.world.extrazoomout; - var mapzoomin = this.dynmap.world.mapzoomin; + var mapzoomin = this.mapzoomin; this.projection.extrazoom = extrazoom; this.maxZoom = mapzoomin + extrazoom; if (zoom <= extrazoom) { diff --git a/web/js/kzedmaps.js b/web/js/kzedmaps.js index f61482a6..96ed4f94 100644 --- a/web/js/kzedmaps.js +++ b/web/js/kzedmaps.js @@ -115,7 +115,7 @@ KzedMapType.prototype = $.extend(new DynMapType(), { updateTileSize: function(zoom) { var size; var extrazoom = this.dynmap.world.extrazoomout; - var mapzoomin = this.dynmap.world.mapzoomin; + var mapzoomin = this.mapzoomin; this.projection.extrazoom = extrazoom; this.maxZoom = mapzoomin + extrazoom; if (zoom <= extrazoom) {