All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.gdface.sdk.FRect Maven / Gradle / Ivy

package net.gdface.sdk;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.Serializable;

/**
 * 通用矩形定义对象
 * @author guyadong
 */
public class FRect implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int left;
	private int top;
	private int width;
	private int height;

	public FRect() {
		this(0,0,0,0);
	}

	public FRect(int left, int top, int width, int height) {
		this.left = left;
		this.top = top;
		this.width = width;
		this.height = height;
	}

	public int getLeft() {
		return this.left;
	}

	public void setLeft(int left) {
		this.left = left;
	}

	public int getTop() {
		return this.top;
	}

	public void setTop(int top) {
		this.top = top;
	}

	public int getWidth() {
		return this.width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getHeight() {
		return this.height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	@Override
	public String toString() {
		ByteArrayOutputStream bo = new ByteArrayOutputStream();
		toStream(new PrintStream(bo));
		return bo.toString();
	}
	/**
	 * 以文本形式向{@link PrintStream}输出对象内容 
	 * @param stream
	 */
	public void toStream(PrintStream stream) {
		stream.printf("[%d,%d,%d,%d]",this.left,this.top, this.width,this.height);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + height;
		result = prime * result + left;
		result = prime * result + top;
		result = prime * result + width;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof FRect)) {
			return false;
		}
		FRect other = (FRect) obj;
		if (height != other.height) {
			return false;
		}
		if (left != other.left) {
			return false;
		}
		if (top != other.top) {
			return false;
		}
		if (width != other.width) {
			return false;
		}
		return true;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy