From c55799567ad4dfb25ded439ecfe430c899344614 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 3 Oct 2010 12:43:30 -0700 Subject: [PATCH] Added some JavaDoc/minor cleanup. --- src/WorldEdit.java | 25 +++++++++ src/WorldEditSession.java | 84 +++++++++++++++++++++++++++++- src/com/sk89q/worldedit/Point.java | 20 +++++++ 3 files changed, 128 insertions(+), 1 deletion(-) diff --git a/src/WorldEdit.java b/src/WorldEdit.java index bcad2f44a..daf071c0a 100644 --- a/src/WorldEdit.java +++ b/src/WorldEdit.java @@ -599,6 +599,20 @@ public class WorldEdit extends Plugin { return false; } + /** + * Fills an area recursively in the X/Z directions. + * + * @param editSession + * @param x + * @param z + * @param cx + * @param cy + * @param cz + * @param blockType + * @param radius + * @param minY + * @return + */ private int fill(EditSession editSession, int x, int z, int cx, int cy, int cz, int blockType, int radius, int minY) { double dist = Math.sqrt(Math.pow(cx - x, 2) + Math.pow(cz - z, 2)); @@ -622,6 +636,17 @@ public class WorldEdit extends Plugin { return affected; } + /** + * Recursively fills a block and below until it hits another block. + * + * @param editSession + * @param x + * @param cy + * @param z + * @param blockType + * @param minY + * @return + */ private int fillY(EditSession editSession, int x, int cy, int z, int blockType, int minY) { int affected = 0; diff --git a/src/WorldEditSession.java b/src/WorldEditSession.java index ad65fbcbf..68f94510f 100644 --- a/src/WorldEditSession.java +++ b/src/WorldEditSession.java @@ -93,74 +93,152 @@ public class WorldEditSession { return false; } + /** + * Checks to make sure that position 1 is defined. + * + * @throws IncompleteRegionException + */ private void checkPos1() throws IncompleteRegionException { if (!hasSetPos1) { throw new IncompleteRegionException(); } } - + + /** + * Checks to make sure that position 2 is defined. + * + * @throws IncompleteRegionException + */ private void checkPos2() throws IncompleteRegionException { if (!hasSetPos2) { throw new IncompleteRegionException(); } } + /** + * Gets defined position 1. + * + * @return + * @throws IncompleteRegionException + */ public int[] getPos1() throws IncompleteRegionException { checkPos1(); return pos1; } + /** + * Sets postiion 1. + * + * @param x + * @param y + * @param z + */ public void setPos1(int x, int y, int z) { hasSetPos1 = true; pos1 = new int[]{x, y, z}; } + /** + * Gets position 2. + * + * @return + * @throws IncompleteRegionException + */ public int[] getPos2() throws IncompleteRegionException { checkPos2(); return pos2; } + /** + * Sets position 2. + * + * @param x + * @param y + * @param z + */ public void setPos2(int x, int y, int z) { hasSetPos2 = true; pos2 = new int[]{x, y, z}; } + /** + * Get lower X bound. + * + * @return + * @throws IncompleteRegionException + */ public int getLowerX() throws IncompleteRegionException { checkPos1(); checkPos2(); return Math.min(pos1[0], pos2[0]); } + /** + * Get upper X bound. + * + * @return + * @throws IncompleteRegionException + */ public int getUpperX() throws IncompleteRegionException { checkPos1(); checkPos2(); return Math.max(pos1[0], pos2[0]); } + /** + * Get lower Y bound. + * + * @return + * @throws IncompleteRegionException + */ public int getLowerY() throws IncompleteRegionException { checkPos1(); checkPos2(); return Math.min(pos1[1], pos2[1]); } + /** + * Get upper Y bound. + * + * @return + * @throws IncompleteRegionException + */ public int getUpperY() throws IncompleteRegionException { checkPos1(); checkPos2(); return Math.max(pos1[1], pos2[1]); } + /** + * Get lower Z bound. + * + * @return + * @throws IncompleteRegionException + */ public int getLowerZ() throws IncompleteRegionException { checkPos1(); checkPos2(); return Math.min(pos1[2], pos2[2]); } + /** + * Get upper Z bound. + * + * @return + * @throws IncompleteRegionException + */ public int getUpperZ() throws IncompleteRegionException { checkPos1(); checkPos2(); return Math.max(pos1[2], pos2[2]); } + /** + * Gets the size of the region as the number of blocks. + * + * @return + * @throws IncompleteRegionException + */ public int getSize() throws IncompleteRegionException { return (getUpperX() - getLowerX() + 1) * (getUpperY() - getLowerY() + 1) * @@ -168,6 +246,8 @@ public class WorldEditSession { } /** + * Gets the clipboard. + * * @return */ public RegionClipboard getClipboard() { @@ -175,6 +255,8 @@ public class WorldEditSession { } /** + * Sets the clipboard. + * * @param clipboard */ public void setClipboard(RegionClipboard clipboard) { diff --git a/src/com/sk89q/worldedit/Point.java b/src/com/sk89q/worldedit/Point.java index 5f14962c9..29d6d5360 100644 --- a/src/com/sk89q/worldedit/Point.java +++ b/src/com/sk89q/worldedit/Point.java @@ -28,6 +28,13 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; public final class Point { private final T x, y, z; + /** + * Construct the Point object. + * + * @param x + * @param y + * @param z + */ public Point(T x, T y, T z) { this.x = x; this.y = y; @@ -56,6 +63,13 @@ public final class Point { return z; } + /** + * Checks if another object is equivalent. + * + * @param obj + * @return + */ + @Override public boolean equals(Object obj) { if (!(obj instanceof Point)) { return false; @@ -64,6 +78,12 @@ public final class Point { return other.x == x && other.y == y && other.z == z; } + /** + * Gets the hash code. + * + * @return + */ + @Override public int hashCode() { return new HashCodeBuilder(451, 41). append(x).