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

java.awt.Dimension Maven / Gradle / Ivy

Go to download

JVM AOT compiler currently generating JavaScript, C++, Haxe, with initial focus on Kotlin and games.

There is a newer version: 0.6.8
Show newest version
package java.awt;

@SuppressWarnings("WeakerAccess")
public class Dimension {
	public int width;
	public int height;

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

	public Dimension(Dimension d) {
		this(d.width, d.height);
	}

	public Dimension(int width, int height) {
		this.width = width;
		this.height = height;
	}

	public double getWidth() {
		return width;
	}

	public double getHeight() {
		return height;
	}

	public void setSize(double width, double height) {
		this.width = (int) Math.ceil(width);
		this.height = (int) Math.ceil(height);
	}

	public Dimension getSize() {
		return new Dimension(width, height);
	}

	public void setSize(Dimension d) {
		setSize(d.width, d.height);
	}

	public void setSize(int width, int height) {
		this.width = width;
		this.height = height;
	}

	public boolean equals(Object obj) {
		if (this == obj) return true;
		if (obj instanceof Dimension) {
			Dimension that = (Dimension) obj;
			return (this.width == that.width) && (this.height == that.height);
		}
		return false;
	}

	public int hashCode() {
		return width + height << 16;
	}

	public String toString() {
		return "Dimension[width=" + width + ",height=" + height + "]";
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy