javalib.worldimages
Class Posn

java.lang.Object
  extended by javalib.worldimages.Posn

public class Posn
extends Object

To represent a point on the drawing WorldCanvas or AppletCanvaas

Since:
August 2, 2007
Author:
Viera K.

Field Summary
static Posn origin
           
 int x
           
 int y
           
 
Constructor Summary
Posn(int x, int y)
           
 
Method Summary
 boolean equals(Object other)
           
 int getX()
           
 int getY()
           
 int hashCode()
           
 Posn minus(Posn other)
          Subtract another Posn from this one.
 Posn moved(int dx, int dy)
          Get a translated version of the given posn.
 Posn plus(Posn other)
          Add another Posn to this one.
 String toIndentedString(String indent)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

origin

public static final Posn origin

x

public int x

y

public int y
Constructor Detail

Posn

public Posn(int x,
            int y)
Method Detail

equals

public boolean equals(Object other)
Overrides:
equals in class Object

getX

public int getX()

getY

public int getY()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

minus

public Posn minus(Posn other)
Subtract another Posn from this one. Functional: does NOT modify this!

Parameters:
other - another Posn
Returns:
a new Posn whose coordinates are the pointwise difference of this and other
Since:
Dec. 12, 2012

moved

public Posn moved(int dx,
                  int dy)
Get a translated version of the given posn. Functional: does NOT modify this!

Parameters:
dx - the amount to translate in x dimension
dy - the amount to translate in y dimension
Returns:
a new Posn
Since:
Dec. 2, 2012

plus

public Posn plus(Posn other)
Add another Posn to this one. Functional: does NOT modify this!

Parameters:
other - another Posn
Returns:
a new Posn whose coordinates are the pointwise sum of this and other
Since:
Dec. 12, 2012

toIndentedString

public String toIndentedString(String indent)

toString

public String toString()
Overrides:
toString in class Object