//***********************************************************
//*
//* File:           Vertex.java
//* Author:         Abhinav Kamra
//* Contact:        kamra-at-cs.columbia.edu
//* Update:         11.9.2002
//*
//* Description:    Basic Vertex object.  An array form
//*                 polygons.
//*
//***********************************************************

package CookieCutter;

import java.io.Serializable;
import java.text.NumberFormat;

public class Vertex implements Serializable {

    double      _xpos;
    double      _ypos;
    char        _type;
    static NumberFormat _nf;
    static { _nf = NumberFormat.getInstance();
             _nf.setMinimumFractionDigits(2);
             _nf.setMaximumFractionDigits(2);
             _nf.setMinimumIntegerDigits(1);
           }

	public Vertex(Vertex copy)
	{
		_xpos = copy.xpos();
		_ypos = copy.ypos();
	}

    public Vertex(double __xpos, double __ypos) {
        _xpos = __xpos;
        _ypos = __ypos;
    }

    public Vertex(double __xpos, double __ypos, char __type) {
        _xpos = __xpos;
        _ypos = __ypos;
        _type = __type;
    }

    public double xpos() {
        return _xpos;
    }
    
    public void setXpos(double __xpos) {
        _xpos = __xpos;
    }
    
    public double ypos() {
        return _ypos;
    }
    
    public void setYpos(double __ypos) {
        _ypos = __ypos;
    }

    public char type() {
        return _type;
    }

    public void setType(char __type) {
        _type= __type;
    }
    
    public Vertex copy() {
        return new Vertex(_xpos, _ypos, _type);
    }
    
    public boolean equals(Object __o) {
        Vertex v;
        
        if (__o == null) {
            return false;
        }
        v = (Vertex) __o;

        if (_xpos == v._xpos &&
            _ypos == v._ypos &&
            _type == v._type) {
            return true;
        }
        return false;
    }
    
    public String toString() {
        StringBuffer sb = new StringBuffer();

        sb.append("[ ");
        sb.append(_nf.format(_xpos));
        sb.append(", ");
        sb.append(_nf.format(_ypos));
        sb.append(", ");
        sb.append(_nf.format(_type));
        sb.append("]");
        
        return new String(sb);
    }
}
