Skip to content

Commit

Permalink
Suppress output of region schematic
Browse files Browse the repository at this point in the history
 - but output total tiles generated
  • Loading branch information
Simon Hunt committed Jun 29, 2016
1 parent 9196e42 commit ac2d5ca
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 13 deletions.
12 changes: 9 additions & 3 deletions core/src/main/java/com/meowster/mcquad/BaseQuadLevelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ public void createDirectory() {
}

@Override
public void generateTiles() {
genTiles(false);
public long generateTiles() {
return genTiles(false);
}

/**
* Generate tiles. The boolean is to facilitate simpler unit testing.
*
* @param suppressWrite if true, don't write image files to disk
*/
private void genTiles(boolean suppressWrite) {
private long genTiles(boolean suppressWrite) {
/*
NOTE:
Since we will have the region data in memory, it makes sense
Expand All @@ -120,6 +120,8 @@ private void genTiles(boolean suppressWrite) {
+---+---+---+---+
*/

long totalTilesGenerated = 0;

levelZoomPlus0.startTracker();
levelZoomPlus1.startTracker();
levelZoomPlus2.startTracker();
Expand All @@ -146,6 +148,8 @@ private void genTiles(boolean suppressWrite) {
tiles1 = tileZoomIn(tiles0, levelZoomPlus1, suppressWrite);
tiles2 = tileZoomIn(tiles1, levelZoomPlus2, suppressWrite);

totalTilesGenerated += tiles0.size() + tiles1.size() + tiles2.size();

printMark(regionCount);

releaseTiles(tiles0);
Expand All @@ -161,6 +165,8 @@ private void genTiles(boolean suppressWrite) {
printOut(levelZoomPlus2.getStats().toString());
printOut(levelZoomPlus1.getStats().toString());
printOut(levelZoomPlus0.getStats().toString());

return totalTilesGenerated;
}

private boolean noChangeSinceLastTime(Region r) {
Expand Down
7 changes: 4 additions & 3 deletions core/src/main/java/com/meowster/mcquad/McQuad.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int process() {
QuadData quad = new QuadData(regionData);
printOut(quad);
print(EOL);
printOut(quad.schematic());
// printOut(quad.schematic());
boolean flushAll = meta.updateQuadShift(quad.calibration());
meta.persist();
printOut(meta);
Expand All @@ -83,8 +83,9 @@ int process() {
Set<Coord> stale = flushAll ? null : quad.adjust(meta.stale());

// ...render those tiles that need rendering...
TileRenderer tr = new TileRenderer(quad, outputUtils.tilesDir())
.render(stale);
TileRenderer tr =
new TileRenderer(quad, outputUtils.tilesDir()).render(stale);
printOut("\nTOTAL Tiles Rendered: {}", tr.totalTilesRendered());

// Create today's heatmap
HeatMapGenerator hmg =
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/com/meowster/mcquad/QuadLevelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ abstract class QuadLevelBuilder {
/**
* This instructs the builder to create the image tiles, placing them
* in the appropriate directory.
*
* @return the total number of tiles generated
*/
abstract void generateTiles();
abstract long generateTiles();

/**
* Returns the quad level that the builder built; to be used for creating
Expand Down
15 changes: 13 additions & 2 deletions core/src/main/java/com/meowster/mcquad/TileRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class TileRenderer {

private final List<LevelStats> stats = new ArrayList<>();

private long totalTilesRendered = 0L;


/**
* Creates a tile renderer for the specified quad data, creating tiles
Expand Down Expand Up @@ -66,7 +68,7 @@ TileRenderer render(Set<Coord> stale) {
QuadLevelBuilder builder = factory.createBuilder(quadData);
builder.prepare(stale);
builder.createDirectory();
builder.generateTiles();
totalTilesRendered += builder.generateTiles();
builder.saveStats(stats);
QuadLevel level = builder.getLevel();
Set<Coord> zoomedOutStale = builder.zoomedOutStale();
Expand All @@ -76,7 +78,7 @@ TileRenderer render(Set<Coord> stale) {
builder = factory.createBuilder(level);
builder.prepare(zoomedOutStale);
builder.createDirectory();
builder.generateTiles();
totalTilesRendered += builder.generateTiles();
builder.saveStats(stats);
level = builder.getLevel();
zoomedOutStale = builder.zoomedOutStale();
Expand All @@ -102,4 +104,13 @@ private StringBuilder reportHeader() {
return new StringBuilder(EOL).append(HEADER).append(EOL)
.append(HEADER_LINE).append(EOL);
}

/**
* Returns the total number of tiles rendered by the renderer.
*
* @return number of tiles rendered
*/
long totalTilesRendered() {
return totalTilesRendered;
}
}
10 changes: 6 additions & 4 deletions core/src/main/java/com/meowster/mcquad/ZoomQuadLevelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ public void createDirectory() {
}

@Override
public void generateTiles() {
genTiles(false);
public long generateTiles() {
return genTiles(false);
}

private void genTiles(boolean suppressWrite) {
private long genTiles(boolean suppressWrite) {
final int dim = sourceLevel.dim();
List<QuadTile> tiles = new ArrayList<>();
long totalTilesGenerated = 0;
QuadTile tile;

q.startTracker();
Expand Down Expand Up @@ -94,14 +95,15 @@ private void genTiles(boolean suppressWrite) {

printMark(a + 2);

totalTilesGenerated += tiles.size();
releaseTiles(tiles);
tiles.clear();
}

print(EOL);

q.stopTracker();
printOut(q.getStats().toString());
return totalTilesGenerated;
}

private QuadTile gimmeATile(int a, int b) {
Expand Down

0 comments on commit ac2d5ca

Please sign in to comment.