Re: [sdljava-users] Here is my patch for the week
Status: Beta
Brought to you by:
ivan_ganza
|
From: Ivan Z. G. <iva...@ya...> - 2005-03-29 02:47:35
|
Chris,
I've integrated this patch. Thanks.
-Ivan/
Chris Dennett wrote:
> Hi everybody ;)
>
> The attached patch fixes a minor bug in SDLRect regarding the use of
> SDLPoint, introduces scaling and descaling methods in SDLRect. Also
> cleans up a lot of Javadoc comments which took me a while to do,
> including spelling mistakes and anomalies.
>
> The scaling and descaling stuff is especially useful for me, since I
> have a grid, with grid objects on that grid, and the grid rect is
> stored in a field within each grid object. When a grid object is
> created, I have to generate the grid rect by scaling the surface
> height and width down using the grid point size. This might make
> things easier for me and other people to do such things later on.
>
> There are also the getRect() methods in SDLSurface which have proven
> their use time and time again in pygame. This allows you to create a
> new SDLRect which has the height and width of the surface, and x = 0,
> y = 0, or the same but with a user-defined x and y, or the same but
> using an SDLPoint to specify the topleft point.
>
> Anyway, I hope you find these changes useful ;)
>
> Regards,
> Chris
>
>------------------------------------------------------------------------
>
>Index: .cvsignore
>===================================================================
>RCS file: /cvsroot/sdljava/sdljava/.cvsignore,v
>retrieving revision 1.3
>diff -u -r1.3 .cvsignore
>--- .cvsignore 23 Dec 2004 04:43:23 -0000 1.3
>+++ .cvsignore 18 Mar 2005 22:52:17 -0000
>@@ -1 +1,3 @@
> classes
>+.classpath
>+.project
>Index: src/sdljava/video/SDLPoint.java
>===================================================================
>RCS file: /cvsroot/sdljava/sdljava/src/sdljava/video/SDLPoint.java,v
>retrieving revision 1.1
>diff -u -r1.1 SDLPoint.java
>--- src/sdljava/video/SDLPoint.java 13 Mar 2005 16:16:50 -0000 1.1
>+++ src/sdljava/video/SDLPoint.java 18 Mar 2005 22:52:17 -0000
>@@ -29,118 +29,117 @@
> * @version 0.2
> */
> public class SDLPoint implements Cloneable {
>- /** The x coordinate of the point. */
>- public int x;
>+ /** The x coordinate of the point. */
>+ public int x;
>
>- /** The y coordiate of the point. */
>- public int y;
>+ /** The y coordiate of the point. */
>+ public int y;
>
>- /**
>- * Creates a new SDLPoint object.
>- * @param x The x coordiante of the point.
>- * @param y The y coordinate of the point.
>- */
>- public SDLPoint(int x, int y) {
>- this.x = x;
>- this.y = y;
>- }
>-
>- /**
>- * Gets the x coordiante of the point.
>- * @return Returns the x coordiante.
>- */
>- public int getX() {
>- return x;
>- }
>-
>- /**
>- * Sets the x coordiante of the point.
>- * @param x The x coordinate.
>- */
>- public void setX(int x) {
>- this.x = x;
>- }
>-
>- /**
>- * Gets the y coordiante of the point.
>- * @return Returns the y coordinate.
>- */
>- public int getY() {
>- return y;
>- }
>-
>- /**
>- * Sets the x coordiante of the point.
>- * @param y The y coordiante.
>- */
>- public void setY(int y) {
>- this.y = y;
>- }
>-
>- /**
>- * Sets the location of the point.
>- * @param x The x coordinate.
>- * @param y The y coordiate.
>- */
>- public void setLocation(int x, int y) {
>- this.x = x;
>- this.y = y;
>- }
>-
>- /**
>- * Returns the string represenation of this point.
>- *
>- * @return The string represenation of this point.
>- */
>- public String toString() {
>- StringBuffer buf = new StringBuffer();
>-
>- buf.append("SDLPoint[").
>- append("x=").append(getX()).
>- append(", y=").append(getY()).
>- append("]");
>+ /**
>+ * Creates a new SDLPoint object.
>+ * @param x The x coordiante of the point.
>+ * @param y The y coordinate of the point.
>+ */
>+ public SDLPoint(int x, int y) {
>+ this.x = x;
>+ this.y = y;
>+ }
>+
>+ /**
>+ * Gets the x coordiante of the point.
>+ * @return Returns the x coordiante.
>+ */
>+ public int getX() {
>+ return x;
>+ }
>+
>+ /**
>+ * Sets the x coordiante of the point.
>+ * @param x The x coordinate.
>+ */
>+ public void setX(int x) {
>+ this.x = x;
>+ }
>+
>+ /**
>+ * Gets the y coordiante of the point.
>+ * @return Returns the y coordinate.
>+ */
>+ public int getY() {
>+ return y;
>+ }
>+
>+ /**
>+ * Sets the x coordiante of the point.
>+ * @param y The y coordiante.
>+ */
>+ public void setY(int y) {
>+ this.y = y;
>+ }
>+
>+ /**
>+ * Sets the location of the point.
>+ * @param x The x coordinate.
>+ * @param y The y coordiate.
>+ */
>+ public void setLocation(int x, int y) {
>+ this.x = x;
>+ this.y = y;
>+ }
>+
>+ /**
>+ * Returns the string represenation of this point.
>+ *
>+ * @return The string represenation of this point.
>+ */
>+ public String toString() {
>+ StringBuffer buf = new StringBuffer();
>
>- return buf.toString();
>- }
>+ buf.append("SDLPoint[").
>+ append("x=").append(getX()).
>+ append(", y=").append(getY()).
>+ append("]");
>+
>+ return buf.toString();
>+ }
>
>- /**
>- * Checks whether this point lies within the specified rect.
>- * @param rect The rect to test.
>- * @return True if the point lies within the rect, false if it dosen't.
>- *
>- * @see SDLPoint
>- */
>- public boolean liesWithin(SDLRect rect) {
>- SDLPoint rectTopLeft = rect.getLocation();
>- SDLPoint rectBottomRight = rect.getBottomRight();
>+ /**
>+ * Checks whether this point lies within the specified rect.
>+ * @param rect The rect to test.
>+ * @return True if the point lies within the rect, false if it doesn't.
>+ *
>+ * @see SDLPoint
>+ */
>+ public boolean liesWithin(SDLRect rect) {
>+ SDLPoint rectBottomRight = rect.getBottomRight();
>
>- int rectTL_X = rectTopLeft.getX();
>- int rectTL_Y = rectTopLeft.getY();
>- int rectBR_X = rectBottomRight.getX();
>- int rectBR_Y = rectBottomRight.getY();
>+ int rectTL_X = rect.getX();
>+ int rectTL_Y = rect.getY();
>+ int rectBR_X = rectBottomRight.getX();
>+ int rectBR_Y = rectBottomRight.getY();
>
>- return (
>- (
>- (x >= rectTL_X) && (x <= rectBR_X)
>- ) && (
>- (y >= rectTL_Y) && (y <= rectBR_Y)
>- )
>+ return (
>+ (
>+ (x >= rectTL_X) && (x <= rectBR_X)
>+ ) && (
>+ (y >= rectTL_Y) && (y <= rectBR_Y)
>+ )
> );
>- }
>+ }
>
>- /**
>- * Creates a clone of the SDLPoint.
>- *
>- * @return A clone of this SDLPoint instance.
>- * @see java.lang.Object#clone()
>- * @author Chris Dennett (Des...@nt...)
>- */
>- public Object clone() {
>- Object o = null;
>- try {
>- o = super.clone();
>- // Clone should always be supported.
>- } catch (CloneNotSupportedException e) {}
>- return o;
>- }
>+ /**
>+ * Creates a clone of the SDLPoint.
>+ *
>+ * @return A clone of this SDLPoint instance.
>+ * @see java.lang.Object#clone()
>+ * @author Chris Dennett (Des...@nt...)
>+ */
>+ public Object clone() {
>+ Object o = null;
>+ try {
>+ o = super.clone();
>+ // Clone should always be supported.
>+ } catch (CloneNotSupportedException e) {}
>+ return o;
>+ }
> }
>Index: src/sdljava/video/SDLRect.java
>===================================================================
>RCS file: /cvsroot/sdljava/sdljava/src/sdljava/video/SDLRect.java,v
>retrieving revision 1.5
>diff -u -r1.5 SDLRect.java
>--- src/sdljava/video/SDLRect.java 13 Mar 2005 16:16:51 -0000 1.5
>+++ src/sdljava/video/SDLRect.java 18 Mar 2005 22:52:18 -0000
>@@ -29,250 +29,332 @@
> * @version $Id: SDLRect.java,v 1.5 2005/03/13 16:16:51 ivan_ganza Exp $
> */
> public class SDLRect {
>-
>- public int x, y, width, height;
>-
>- public SDLRect() {
>- }
>-
>- public SDLRect(int x, int y) {
>- this.x = x;
>- this.y = y;
>- }
>-
>- public SDLRect(int x, int y, int width, int height) {
>- this(x,y);
>- this.width = width;
>- this.height = height;
>- }
>-
>- /**
>- * Creates an SDLRect with the specified topleft point, height and width.
>- *
>- * @param pos The topleft position of the rectangle.
>- * @param width The width of the rectangle.
>- * @param height The height of the rectangle.
>- */
>- public SDLRect(SDLPoint pos, int width, int height) {
>- this.x = pos.getX();
>- this.y = pos.getY();
>- }
>-
>- /**
>- * Gets the value of x
>- *
>- * @return the value of x
>- */
>- public int getX() {
>- return this.x;
>- }
>-
>- /**
>- * Sets the value of x
>- *
>- * @param argX Value to assign to this.x
>- */
>- public void setX(int argX) {
>- this.x = argX;
>- }
>-
>- /**
>- * Gets the value of y
>- *
>- * @return the value of y
>- */
>- public int getY() {
>- return this.y;
>- }
>-
>- /**
>- * Sets the value of y
>- *
>- * @param argY Value to assign to this.y
>- */
>- public void setY(int argY) {
>- this.y = argY;
>- }
>-
>- /**
>- * Gets the value of width
>- *
>- * @return the value of width
>- */
>- public int getWidth() {
>- return this.width;
>- }
>-
>- /**
>- * Sets the value of width
>- *
>- * @param argWidth Value to assign to this.width
>- */
>- public void setWidth(int argWidth) {
>- this.width = argWidth;
>- }
>-
>- /**
>- * Gets the value of height
>- *
>- * @return the value of height
>- */
>- public int getHeight() {
>- return this.height;
>- }
>-
>- /**
>- * Sets the value of height
>- *
>- * @param argHeight Value to assign to this.height
>- */
>- public void setHeight(int argHeight) {
>- this.height = argHeight;
>- }
>-
>- public void setLocation(int x, int y) {
>- this.x = x;
>- this.y = y;
>- }
>-
>- public void setSize(int width, int height) {
>- this.width = width;
>- this.height = height;
>- }
>-
>- /**
>- * Sets the topleft point of the rectangle.
>- *
>- * @param pos The new topleft point of the rectangle.
>- *
>- * @see SDLPoint
>- */
>- public void setLocation(SDLPoint pos) {
>- x = pos.getX();
>- y = pos.getY();
>- }
>-
>- /**
>- * Gets the point at the top left of the rectangle.
>- *
>- * @return An SDLPoint object containing the top left point of the
>- * rectangle.
>- *
>- * @see SDLPoint
>- */
>- public SDLPoint getLocation() {
>- return new SDLPoint(x, y);
>- }
>-
>- /**
>- * Gets the point at the top right of the rectangle.
>- *
>- * @return An SDLPoint object containing the top right point of the
>- * rectangle.
>- *
>- * @see SDLPoint
>- */
>- public SDLPoint getTopRight() {
>- return new SDLPoint(x + width, y);
>- }
>-
>- /**
>- * Gets the point at the center of the rectangle. The point is rounded to
>- * the nearest point.
>- *
>- * @return An SDLPoint object containing the point in the center of the
>- * rectangle.
>- *
>- * @see SDLPoint
>- */
>- public SDLPoint getCenter() {
>- int cX = x + (Math.round(width / 2));
>- int cY = y + (Math.round(height / 2));
>-
>- return new SDLPoint(cX, cY);
>- }
>-
>- /**
>- * Sets the center point of the rectangle using integer X and Y coordinates.
>- *
>- * @param x The new center x coordiante of the rectangle.
>- * @param y The new center y coordiante of the rectangle.
>- *
>- * @see SDLPoint
>- */
>- public void setCenter(int x, int y) {
>- SDLPoint center = getCenter();
>- this.x = x - center.getX();
>- this.y = y - center.getY();
>- }
>-
>- /**
>- * Sets the center point of the rectangle using an SDLPoint.
>- *
>- * @param pos The new center point of the rectangle.
>- *
>- * @see SDLPoint
>- */
>- public void setCenter(SDLPoint pos) {
>- setCenter(pos.getX(), pos.getY());
>- }
>-
>- /**
>- * Gets the point at the bottom right of the rectangle.
>- *
>- * @return An SDLPoint object containing the bottom right point of the
>- * rectangle.
>- *
>- * @see SDLPoint
>- */
>- public SDLPoint getBottomRight() {
>- return new SDLPoint(x + width, y + height);
>- }
>-
>- /**
>- * Gets the point at the bottom left of the rectangle.
>- *
>- * @return An SDLPoint object containing the bottom left point of the
>- * rectangle.
>- *
>- * @see SDLPoint
>- */
>- public SDLPoint getBottomLeft() {
>- return new SDLPoint(x, y + height);
>- }
>-
>- /**
>- * Creates a clone of the SDLRect.
>- *
>- * @return A clone of this SDLRect instance.
>- * @see java.lang.Object#clone()
>- */
>- public Object clone() {
>- // If this class ever uses SDLPoint for X and Y, or any immutables,
>- // then they must be cloned also, or the clone will be shallow.
>- Object o = null;
>- try {
>- o = super.clone();
>- // Clone should always be supported.
>- } catch (CloneNotSupportedException e) {}
>- return o;
>- }
>-
>- /**
>- * Return a string represenation of this object
>- *
>- * @return a String represenation of this object
>- */
>- public String toString() {
>- StringBuffer buf = new StringBuffer();
>-
>- buf.append("SDLRect[").
>- append("x=").append(getX()).
>- append(", y=").append(getY()).
>- append(", width=").append(getWidth()).
>- append(", height=").append(getHeight()).
>- append("]");
>
>- return buf.toString();
>- }
>+ /** The topleft x coordinate of the rectangle. */
>+ public int x;
>+
>+ /** The topleft y coordinate of the rectangle. */
>+ public int y;
>+
>+ /** The width of the rectangle. */
>+ public int width;
>+
>+ /** The height of the rectangle. */
>+ public int height;
>+
>+ /**
>+ * Creates an SDLRect with the specified topleft x and y coordinates,
>+ * width and height.
>+ *
>+ * @param x The topleft x coordinate of the SDLRect.
>+ * @param y The topleft y coordinate of the SDLRect.
>+ * @param width The width of the SDLRect.
>+ * @param height The height of the SDLRect.
>+ */
>+ public SDLRect(int x, int y, int width, int height) {
>+ this.x = x;
>+ this.y = y;
>+ this.width = width;
>+ this.height = height;
>+ }
>+
>+ /**
>+ * Creates an SDLRect with the specified topleft point, height and width.
>+ *
>+ * @param pos The topleft position of the rectangle.
>+ * @param width The width of the rectangle.
>+ * @param height The height of the rectangle.
>+ *
>+ * @see SDLPoint
>+ */
>+ public SDLRect(SDLPoint pos, int width, int height) {
>+ this(pos.getX(), pos.getY(), width, height);
>+ }
>+
>+ /**
>+ * Gets the topleft x coordiante of the SDLRect.
>+ *
>+ * @return The topleft x coordinate.
>+ */
>+ public int getX() {
>+ return this.x;
>+ }
>+
>+ /**
>+ * Sets the topleft x coordiante of the SDLRect.
>+ *
>+ * @param x The new topleft x coordinate.
>+ */
>+ public void setX(int x) {
>+ this.x = x;
>+ }
>+
>+ /**
>+ * Gets the topleft y coordiante of the SDLRect.
>+ *
>+ * @return The topleft y coordinate.
>+ */
>+ public int getY() {
>+ return this.y;
>+ }
>+
>+ /**
>+ * Sets the topleft y coordinate of the SDLRect.
>+ *
>+ * @param y The new topleft y coordinate.
>+ */
>+ public void setY(int y) {
>+ this.y = y;
>+ }
>+
>+ /**
>+ * Gets the width of the SDLRect.
>+ *
>+ * @return The width of the SDLRect.
>+ */
>+ public int getWidth() {
>+ return this.width;
>+ }
>+
>+ /**
>+ * Sets the width of the SDLRect.
>+ *
>+ * @param width The new width of the SDLRect.
>+ */
>+ public void setWidth(int width) {
>+ this.width = width;
>+ }
>+
>+ /**
>+ * Gets the height of the SDLRect.
>+ *
>+ * @return The height of the SDLRect.
>+ */
>+ public int getHeight() {
>+ return this.height;
>+ }
>+
>+ /**
>+ * Sets the height of the SDLRect.
>+ *
>+ * @param height The new height of the SDLRect.
>+ */
>+ public void setHeight(int height) {
>+ this.height = height;
>+ }
>+
>+ /**
>+ * Sets the topleft position of the SDLRect, using the topleft x and y
>+ * coordiantes.
>+ *
>+ * @param x The topleft x coordinate.
>+ * @param y The topleft y coordinate.
>+ */
>+ public void setLocation(int x, int y) {
>+ this.x = x;
>+ this.y = y;
>+ }
>+
>+ /**
>+ * Sets the size of the SDLRect, using width and height values.
>+ *
>+ * @param width The new width of the SDLRect.
>+ * @param height The new height of the SDLRect.
>+ */
>+ public void setSize(int width, int height) {
>+ this.width = width;
>+ this.height = height;
>+ }
>+
>+ /**
>+ * Sets the topleft point of the rectangle.
>+ *
>+ * @param pos The new topleft point of the rectangle.
>+ *
>+ * @see SDLPoint
>+ */
>+ public void setLocation(SDLPoint pos) {
>+ x = pos.getX();
>+ y = pos.getY();
>+ }
>+
>+ /**
>+ * Gets the point at the top left of the rectangle.
>+ *
>+ * @return An SDLPoint object containing the top left point of the
>+ * rectangle.
>+ *
>+ * @see SDLPoint
>+ */
>+ public SDLPoint getLocation() {
>+ return new SDLPoint(x, y);
>+ }
>+
>+ /**
>+ * Gets the point at the top right of the rectangle.
>+ *
>+ * @return An SDLPoint object containing the top right point of the
>+ * rectangle.
>+ *
>+ * @see SDLPoint
>+ */
>+ public SDLPoint getTopRight() {
>+ return new SDLPoint(x + width, y);
>+ }
>+
>+ /**
>+ * Gets the point at the center of the rectangle. The point is rounded to
>+ * the nearest point.
>+ *
>+ * @return An SDLPoint object containing the point in the center of the
>+ * rectangle.
>+ *
>+ * @see SDLPoint
>+ */
>+ public SDLPoint getCenter() {
>+ int cX = x + (Math.round(width / 2));
>+ int cY = y + (Math.round(height / 2));
>+
>+ return new SDLPoint(cX, cY);
>+ }
>+
>+ /**
>+ * Sets the center point of the rectangle using integer X and Y coordinates.
>+ *
>+ * @param x The new center x coordiante of the rectangle.
>+ * @param y The new center y coordiante of the rectangle.
>+ *
>+ * @see SDLPoint
>+ */
>+ public void setCenter(int x, int y) {
>+ SDLPoint center = getCenter();
>+ this.x = x - center.getX();
>+ this.y = y - center.getY();
>+ }
>+
>+ /**
>+ * Sets the center point of the rectangle using an SDLPoint.
>+ *
>+ * @param pos The new center point of the rectangle.
>+ *
>+ * @see SDLPoint
>+ */
>+ public void setCenter(SDLPoint pos) {
>+ setCenter(pos.getX(), pos.getY());
>+ }
>+
>+ /**
>+ * Gets the point at the bottom right of the rectangle.
>+ *
>+ * @return An SDLPoint object containing the bottom right point of the
>+ * rectangle.
>+ *
>+ * @see SDLPoint
>+ */
>+ public SDLPoint getBottomRight() {
>+ return new SDLPoint(x + width, y + height);
>+ }
>+
>+ /**
>+ * Gets the point at the bottom left of the rectangle.
>+ *
>+ * @return An SDLPoint object containing the bottom left point of the
>+ * rectangle.
>+ *
>+ * @see SDLPoint
>+ */
>+ public SDLPoint getBottomLeft() {
>+ return new SDLPoint(x, y + height);
>+ }
>+
>+ /**
>+ * Creates a clone of the SDLRect.
>+ *
>+ * @return A clone of this SDLRect instance.
>+ * @see java.lang.Object#clone()
>+ */
>+ public Object clone() {
>+ // If this class ever uses SDLPoint for X and Y, or any immutables,
>+ // then they must be cloned also, or the clone will be shallow.
>+ Object o = null;
>+ try {
>+ o = super.clone();
>+ // Clone should always be supported.
>+ } catch (CloneNotSupportedException e) {}
>+ return o;
>+ }
>+
>+ /**
>+ * Returns a string represenation of this object.
>+ *
>+ * @return A string represenation of this object.
>+ */
>+ public String toString() {
>+ StringBuffer buf = new StringBuffer();
>+
>+ buf.append("SDLRect[").
>+ append("x=").append(getX()).
>+ append(", y=").append(getY()).
>+ append(", width=").append(getWidth()).
>+ append(", height=").append(getHeight()).
>+ append("]");
>+
>+ return buf.toString();
>+ }
>+
>+ /**
>+ * Scales this rect by the given x and y factors. This affects the x, y,
>+ * width and height of the rect.
>+ * (i.e. x:2, y:6, w:10, h:16 becomes x:1, y:3, w:5, h:8 with factor 2)
>+ *
>+ * @param xFactor The x factor to scale this rect by.
>+ * @param yFactor The y factor to scale this rect by.
>+ */
>+ public void scaleAll(int xFactor, int yFactor) {
>+ x = Math.round(x / xFactor);
>+ y = Math.round(y / yFactor);
>+ width = Math.round(width / xFactor);
>+ height = Math.round(height / yFactor);
>+ }
>+
>+ /**
>+ * Descales (small to big) this rect by the given x and y factors. This
>+ * affects the x, y, width and height of the rect.
>+ * (i.e. x:2, y:6, w:10, h:16 becomes x:4, y:12, w:20, h:32 with factor 2)
>+ *
>+ * @param xFactor The x factor to scale this rect by.
>+ * @param yFactor The y factor to scale this rect by.
>+ */
>+ public void descaleAll(int xFactor, int yFactor) {
>+ x *= xFactor;
>+ y *= yFactor;
>+ width *= xFactor;
>+ height *= yFactor;
>+ }
>+
>+ /**
>+ * Scales (big to small) this rect by the given x and y factors. This
>+ * affects the width and height of the rect only.
>+ * (i.e. x:2, y:6, w:10, h:16 becomes x:2, y:6, w:5, h:8 with factor 2)
>+ *
>+ * @param xFactor The x factor to scale this rect by.
>+ * @param yFactor The y factor to scale this rect by.
>+ */
>+ public void scale(int xFactor, int yFactor) {
>+ width = Math.round(width / xFactor);
>+ height = Math.round(height / yFactor);
>+ }
>+
>+ /**
>+ * Descales (small to big) this rect by the given x and y factors. This
>+ * affects the width and height of the rect only.
>+ * (i.e. x:2, y:6, w:10, h:16 becomes x:2, y:6, w:20, h:32 with factor 2)
>+ *
>+ * @param xFactor The x factor to scale this rect by.
>+ * @param yFactor The y factor to scale this rect by.
>+ */
>+ public void descale(int xFactor, int yFactor) {
>+ width *= xFactor;
>+ height *= yFactor;
>+ }
> }
>\ No newline at end of file
>Index: src/sdljava/video/SDLSurface.java
>===================================================================
>RCS file: /cvsroot/sdljava/sdljava/src/sdljava/video/SDLSurface.java,v
>retrieving revision 1.31
>diff -u -r1.31 SDLSurface.java
>--- src/sdljava/video/SDLSurface.java 26 Jan 2005 02:52:52 -0000 1.31
>+++ src/sdljava/video/SDLSurface.java 18 Mar 2005 22:52:21 -0000
>@@ -68,7 +68,7 @@
> *
> */
> GL gl;
>-
>+
> /**
> * Creates a new <code>SDLSurface</code> instance.
> *
>@@ -1008,6 +1008,46 @@
> e.printStackTrace();
> }
> }
>+
>+ /**
>+ * Returns an SDLRect which has the same size as this surface, but has
>+ * topleft x and y at the given coordinates.
>+ *
>+ * @param x The x coordiante of the created SDLRect.
>+ * @param y The y coordiante of the created SDLRect.
>+ *
>+ * @return An SDLRect which has the given x and y, but the width and height
>+ * of the surface.
>+ */
>+ public SDLRect getRect(int x, int y) {
>+ return new SDLRect(x, y, getWidth(), getHeight());
>+ }
>+
>+ /**
>+ * Returns an SDLRect which has the same size as this surface, but has
>+ * topleft x and y at 0.
>+ *
>+ * @return An SDLRect which has the x and y at 0, and the width and height
>+ * of the surface.
>+ */
>+ public SDLRect getRect() {
>+ return getRect(0, 0);
>+ }
>+
>+ /**
>+ * Returns an SDLRect which has the same size as this surface, but has
>+ * topleft x and y at the position defined by the given SDLPoint instance.
>+ *
>+ * @param pos An SDLPoint which defines the topleft position of the new
>+ * SDLRect.
>+ *
>+ * @return An SDLRect that has the topleft position defined in the SDLPoint.
>+ *
>+ * @see SDLPoint
>+ */
>+ public SDLRect getRect(SDLPoint pos) {
>+ return getRect(pos.getX(), pos.getY());
>+ }
>
> /**
> * Return a string represenation of this object
>Index: .settings/org.eclipse.jdt.ui.prefs
>===================================================================
>RCS file: .settings/org.eclipse.jdt.ui.prefs
>diff -N .settings/org.eclipse.jdt.ui.prefs
>--- /dev/null 1 Jan 1970 00:00:00 -0000
>+++ .settings/org.eclipse.jdt.ui.prefs 1 Jan 1970 00:00:00 -0000
>@@ -0,0 +1,3 @@
>+#Wed Mar 09 04:38:37 GMT 2005
>+eclipse.preferences.version=1
>+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates/>
>
>
|