/*
* $Id: SoTPoint.java,v 1.6 2003/08/22 23:02:40 dwd Exp $
*
* This software is provided by NOAA for full, free and open release. It is
* understood by the recipient/user that NOAA assumes no liability for any
* errors contained in the code. Although this software is released without
* conditions or restrictions in its use, it is expected that appropriate
* credit be given to its author and to the National Oceanic and Atmospheric
* Administration should the software be included by the recipient as an
* element in other product development.
*/
package sgtplot.util;
import java.io.Serializable;
/**
* SoTPoint has two coordinates which are of
* type SoTValue. SoT stands for
* space or time, but being basically lazy I've abbreviated it.
*
* @author Donald Denbo
* @version $Revision: 1.6 $, $Date: 2003/08/22 23:02:40 $
* @sgtplot 2.0
*/
public class SoTPoint implements Serializable, Cloneable {
/** X coordinate */
private SoTValue x_;
/** Y coordinate */
private SoTValue y_;
/**
* Default constructor.
*/
public SoTPoint() {
}
/**
* Construct a SoTPoint from SoTValues.
*
* @param x space or time coordinate
* @param y space or time coordinate
*/
public SoTPoint(SoTValue x, SoTValue y) {
x_ = x;
y_ = y;
}
/**
* Construct a SoTPoint from doubles.
*/
public SoTPoint(double x, double y) {
this(new SoTValue.Double(x), new SoTValue.Double(y));
}
/**
* Construct a SoTPoint from a double and
* a GeoDate.
*/
public SoTPoint(double x, GeoDate y) {
this(new SoTValue.Double(x), new SoTValue.Time(y));
}
/**
* @since sgtplot 3.0
*/
public SoTPoint(double x, long y) {
this(new SoTValue.Double(x), new SoTValue.Time(y));
}
/**
* Construct a SoTPoint from a GeoDate and
* a double.
*/
public SoTPoint(GeoDate x, double y) {
this(new SoTValue.Time(x), new SoTValue.Double(y));
}
/**
* @since sgtplot 3.0
*/
public SoTPoint(long x, double y) {
this(new SoTValue.Time(x), new SoTValue.Double(y));
}
/**
* Construct a SoTPoint from a SoTPoint.
*/
public SoTPoint(SoTPoint pt) {
this(pt.getX(), pt.getY());
}
/**
* Get x value
*/
public SoTValue getX() {
return x_;
}
/**
* Set x value
* @since sgtplot 3.0
*/
public void setX(SoTValue x) {
x_ = x;
}
/**
* Get y value
*/
public SoTValue getY() {
return y_;
}
/**
* Set y value
* @since sgtplot 3.0
*/
public void setY(SoTValue y) {
y_ = y;
}
/**
* Test for equality. For equality both x and y values must be
* equal.
*/
public boolean equals(SoTPoint stp) {
return (x_.equals(stp.getX()) &&
y_.equals(stp.getY()));
}
/**
* Test if x value is time
*/
public boolean isXTime() {
return x_.isTime();
}
/**
* Test if y value is time
*/
public boolean isYTime() {
return y_.isTime();
}
/**
* Add to point.
*
* @since sgtplot 3.0
*/
public void add(SoTPoint point) {
x_.add(point.getX());
y_.add(point.getY());
}
/**
* Make a copy of the SoTRange.
* @since sgtplot 3.0
*/
public SoTPoint copy() {
try {
return (SoTPoint)clone();
} catch (CloneNotSupportedException e) {
return null;
}
}
/**
* Convert SoTPoint to a default string
*
* @return string representation of the SoTPoint.
*/
public String toString() {
return new String("(" + x_ + ", " + y_ + ")");
}
}
Ads help maintain this website.