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

com.patternity.graphic.Rectangle Maven / Gradle / Ivy

Go to download

Extensions of the RestFixture. An extension is a RestFixture with some specific/bespoke behaviour not generic enough to make it to the RestFixture itself.

There is a newer version: 3.1
Show newest version
package com.patternity.graphic;

/**
 * Represents a simple 2D bounding box (width, height) with a position (x,y)
 * 
 * @author cyrille martraire
 */
public class Rectangle {

	private final Position position;
	private final BoundingBox box;

	public final static Rectangle NONE = new Rectangle(Position.NONE, BoundingBox.NONE);

	public Rectangle(int x, int y, int width, int height) {
		this(new Position(x, y), width, height);
	}

	public Rectangle(Position position, int width, int height) {
		this(position, new BoundingBox(width, height));
	}

	public Rectangle(Position position, BoundingBox box) {
		this.position = position;
		this.box = box;
	}

	public Position getPosition() {
		return position;
	}

	public BoundingBox getBox() {
		return box;
	}

	public double getX() {
		return position.getX();
	}

	public double getY() {
		return position.getY();
	}

	public int getWidth() {
		return box.getWidth();
	}

	public int getHeight() {
		return box.getHeight();
	}

	public Position getPort(Orientation orientation) {
		return orientation == null ? Orientation.EAST.getPort(this) : orientation.getPort(this);
	}

	public String toString() {
		return position + " " + box;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy