These simple geometry primitives have been removed from narya to elsewhere.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6651 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
package com.threerings.geom;
|
||||
|
||||
import com.samskivert.util.Logger;
|
||||
|
||||
/**
|
||||
* A very simple representation of the geometric concept, because sometimes we can't use awt.
|
||||
*/
|
||||
public class Point
|
||||
{
|
||||
/** The x-coordinate. */
|
||||
public int x;
|
||||
|
||||
/** The y-coordinate. */
|
||||
public int y;
|
||||
|
||||
public Point ()
|
||||
{
|
||||
this(0, 0);
|
||||
}
|
||||
|
||||
public Point (int x, int y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
return Logger.format(getClass().getName(), "x", x, "y", y);
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package com.threerings.geom;
|
||||
|
||||
import com.samskivert.util.Logger;
|
||||
|
||||
/**
|
||||
* A very simple representation of the geometric shape, because sometimes we can't use awt.
|
||||
*/
|
||||
public class Rectangle
|
||||
{
|
||||
/** The left-most x-coordinate. */
|
||||
public int x;
|
||||
|
||||
/** The top-most y-coordinate. */
|
||||
public int y;
|
||||
|
||||
/** The width of the rectangle. */
|
||||
public int width;
|
||||
|
||||
/** The height of the rectangle. */
|
||||
public int height;
|
||||
|
||||
public Rectangle ()
|
||||
{
|
||||
this(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public Rectangle (int x, int y, int width, int height)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public Rectangle (Rectangle other)
|
||||
{
|
||||
x = other.x;
|
||||
y = other.y;
|
||||
width = other.width;
|
||||
height = other.height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the area of intersection of ourselves and another rectangle.
|
||||
*/
|
||||
public Rectangle intersect (Rectangle other)
|
||||
{
|
||||
int x1 = Math.max(x, other.x), y1 = Math.max(y, other.y),
|
||||
x2 = Math.min(x + width, other.x + other.width),
|
||||
y2 = Math.min(y + height, other.y + other.height);
|
||||
return new Rectangle(x1, y1, Math.max(0, x2 - x1), Math.max(0, y2 - y1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the specified coordinates are within the rectangle.
|
||||
*/
|
||||
public boolean contains (int x, int y)
|
||||
{
|
||||
return (x >= this.x && x <= (this.x + width) && y >= this.y && y <= (this.y + height));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this rectangle covers any area.
|
||||
*/
|
||||
public boolean isEmpty ()
|
||||
{
|
||||
return width <= 0 || height <= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets our position and size.
|
||||
*/
|
||||
public void set (int x, int y, int width, int height)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
return Logger.format(getClass().getName(), "x", x, "y", y, "w", width, "h", height);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user