Add minimum/maximumY to FlatRegion and fix a typo in Polygonal2DRegion

This commit is contained in:
aumgn 2012-04-16 07:41:14 +02:00
parent 6915244ab9
commit a7b49ff793
4 changed files with 30 additions and 3 deletions

View File

@ -87,6 +87,14 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
Math.max(pos1.getZ(), pos2.getZ()));
}
public int getMinimumY() {
return Math.min(pos1.getBlockX(), pos2.getBlockY());
}
public int getMaximumY() {
return Math.max(pos1.getBlockX(), pos2.getBlockY());
}
/**
* Get the number of blocks in the region.
*

View File

@ -23,5 +23,19 @@ import com.sk89q.worldedit.Vector2D;
public interface FlatRegion extends Region {
/**
* Gets the minimum Y value
*
* @return
*/
public int getMinimumY();
/**
* Gets the maximum Y value
*
* @return
*/
public int getMaximumY();
public Iterable<Vector2D> asFlatRegion();
}

View File

@ -167,6 +167,11 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
*
* @return min y
*/
public int getMinimumY() {
return minY;
}
@Deprecated
public int getMininumY() {
return minY;
}

View File

@ -124,14 +124,14 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
session.dispatchCUIEvent(player, new SelectionShapeEvent(getTypeID()));
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(0, pos, getArea()));
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMininumY(), region.getMaximumY()));
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
}
public void explainSecondarySelection(LocalPlayer player, LocalSession session, Vector pos) {
player.print("Added point #" + region.size() + " at " + pos + ".");
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(region.size() - 1, pos, getArea()));
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMininumY(), region.getMaximumY()));
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
}
public void explainRegionAdjust(LocalPlayer player, LocalSession session) {
@ -195,7 +195,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(id, points.get(id), getArea()));
}
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMininumY(), region.getMaximumY()));
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
}
public void describeLegacyCUI(LocalSession session, LocalPlayer player) {