001/**   
002* @Title: FInt2.java 
003* @Package net.gdface.sdk 
004* @author guyadong   
005* @date 2016年7月8日 上午9:35:59 
006* @version V1.0   
007*/
008package net.gdface.sdk;
009
010import java.io.ByteArrayOutputStream;
011import java.io.PrintStream;
012import java.io.Serializable;
013
014/**
015 * 通用整数2维向量对象(表示坐标,尺寸)
016 * @author guyadong
017 *
018 */
019public class FInt2 implements Serializable{
020        /**
021         * 
022         */
023        private static final long serialVersionUID = 1L;
024        private int x,y;
025        /**
026         * 
027         */
028        public FInt2() {
029                this(0,0);
030        }
031        public FInt2(int x, int y) {
032                this.x = x;
033                this.y = y;
034        }
035        /**
036         * @return x
037         */
038        public int getX() {
039                return x;
040        }
041        /**
042         * @param x 要设置的 x
043         */
044        public void setX(int x) {
045                this.x = x;
046        }
047        /**
048         * @return y
049         */
050        public int getY() {
051                return y;
052        }
053        /**
054         * @param y 要设置的 y
055         */
056        public void setY(int y) {
057                this.y = y;
058        }
059        
060        @Override
061        public String toString() {
062                ByteArrayOutputStream bo = new ByteArrayOutputStream();
063                toStream(new PrintStream(bo));
064                return bo.toString();
065        }
066        /**
067         * 以文本形式向{@link PrintStream}输出对象内容 
068         * @param stream
069         */
070        public void toStream(PrintStream stream) {
071                stream.printf("[%d,%d]",this.x,this.y);
072        }
073        @Override
074        public int hashCode() {
075                final int prime = 31;
076                int result = 1;
077                result = prime * result + x;
078                result = prime * result + y;
079                return result;
080        }
081        @Override
082        public boolean equals(Object obj) {
083                if (this == obj) {
084                        return true;
085                }
086                if (obj == null) {
087                        return false;
088                }
089                if (!(obj instanceof FInt2)) {
090                        return false;
091                }
092                FInt2 other = (FInt2) obj;
093                if (x != other.x) {
094                        return false;
095                }
096                if (y != other.y) {
097                        return false;
098                }
099                return true;
100        }
101}