com.javaranch.common
Class DPoint

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

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

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

Should the day ever arise that everyone supports Java 1.2 or higher, this class should inherit Point2D.Double.

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

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
DPoint()
          Create a double point object initialized to 0.0,0.0.
DPoint(double x, double y)
          Create a double point object initialized to x,y.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 double getX()
           
 double getY()
           
 void incX(double inc)
          Increment x (negative numbers decrement x).
 void incY(double inc)
          Increment y (negative numbers decrement y).
 void set(double x, double y)
           
 void setX(double x)
           
 void setY(double y)
           
 java.lang.String toString()
          returns something like "(35.8765,20.0042)".
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DPoint

public DPoint()
Create a double point object initialized to 0.0,0.0.


DPoint

public DPoint(double x,
              double y)
Create a double point object initialized to x,y.

Parameters:
x - The x coordinate.

y - The y coordinate.

Method Detail

setX

public void setX(double x)

getX

public double getX()

setY

public void setY(double y)

getY

public double getY()

set

public void set(double x,
                double y)

incX

public void incX(double inc)
Increment x (negative numbers decrement x).

Parameters:
inc - The amount to adjust x.


incY

public void incY(double inc)
Increment y (negative numbers decrement y).

Parameters:
inc - The amount to adjust y.


toString

public java.lang.String toString()
returns something like "(35.8765,20.0042)".

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