com.javaranch.common
Class IPoint

java.lang.Object
  |
  +--com.javaranch.common.IPoint
All Implemented Interfaces:
java.io.Serializable

public class IPoint
extends java.lang.Object
implements java.io.Serializable

A very lean serialized point type where X and Y are of type int.

- - - - - - - - - - - - - - - - -

Copyright (c) 1998-2004 Paul Wheaton

You are welcome to do whatever you want to with this source file provided that you maintain this comment fragment (between the dashed lines). Modify it, change the package name, change the class name ... personal or business use ... sell it, share it ... add a copyright for the portions you add ...

My goal in giving this away and maintaining the copyright is to hopefully direct developers back to JavaRanch.

The original source can be found at JavaRanch

- - - - - - - - - - - - - - - - -

Author:
Paul Wheaton
See Also:
Serialized Form

Constructor Summary
IPoint()
          Create an int point object initialized to 0,0.
IPoint(int x, int y)
          Create an int point object initialized to x,y.
IPoint(IPoint p)
          Create a new int point object containing the same value and another int point object.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 int getX()
           
 int getY()
           
 void inc(IPoint p)
          Increment the X value and the Y value with the x and y (respectively) of p.
 void incX(int val)
          Increment the X value without modifying Y.
 void incY(int val)
          Increment the Y value without modifying X.
 void set(int x, int y)
           
 void set(IPoint p)
           
 void setX(int x)
           
 void setY(int y)
           
 java.lang.String toString()
          returns something like "(35,20)".
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IPoint

public IPoint()
Create an int point object initialized to 0,0.


IPoint

public IPoint(int x,
              int y)
Create an int point object initialized to x,y.

Parameters:
x - The x coordinate.

y - The y coordinate.


IPoint

public IPoint(IPoint p)
Create a new int point object containing the same value and another int point object.

Method Detail

set

public void set(IPoint p)

setX

public void setX(int x)

getX

public int getX()

setY

public void setY(int y)

getY

public int getY()

set

public void set(int x,
                int y)

incX

public void incX(int val)
Increment the X value without modifying Y.


incY

public void incY(int val)
Increment the Y value without modifying X.


inc

public void inc(IPoint p)
Increment the X value and the Y value with the x and y (respectively) of p.


toString

public java.lang.String toString()
returns something like "(35,20)".

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


Copyright ©2004 Paul Wheaton All Rights Reserved