Point.java
/**
* Copyright 2010,2021 Nikolas S Boyd.
Permission is granted to copy this work provided this copyright statement is retained in all copies.
*/
package Hoot.Geometry;
import Hoot.Runtime.Functions.*;
import Hoot.Runtime.Faces.*;
import Hoot.Runtime.Values.*;
import Hoot.Runtime.Blocks.*;
import Smalltalk.Core.*;
import Smalltalk.Blocks.*;
import Smalltalk.Magnitudes.*;
import Hoot.Behaviors.*;
import Hoot.Behaviors.Nil;
import Hoot.Behaviors.Object;
import Hoot.Behaviors.True;
import Hoot.Behaviors.False;
import Hoot.Behaviors.Boolean;
import Hoot.Magnitudes.*;
import Hoot.Magnitudes.Integer;
import Hoot.Magnitudes.Character;
import Hoot.Magnitudes.Float;
import Hoot.Magnitudes.Double;
import Hoot.Collections.*;
import Hoot.Collections.String;
import Hoot.Magnitudes.Number;
import Hoot.Magnitudes.Magnitude;
import Smalltalk.Magnitudes.Scalar;
import Smalltalk.Magnitudes.Numeric;
public class Point extends Magnitude
{
public static Metaclass type() { return (Metaclass)Metaclass.$class; }
@Override public Metaclass $class() { return (Metaclass)Metaclass.$class; }
public static class Metaclass extends Magnitude.Metaclass
{
static final Point.Metaclass $class = new Point.Metaclass();
public Metaclass() {
this(Point.Metaclass.class);
}
public Metaclass(java.lang.Class aClass) {
super(aClass);
}
@Override public java.lang.Class outerClass() { return Point.class; }
/**
* @return
*/
public Point $new()
{
java.lang.String exitID = "PointMetatype>>$new";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Point)f0.exit(exitID, new Point().x_y(SmallInteger.from(0), SmallInteger.from(0)));
});
}
/**
* @return
*/
public Point x_y(final Number x, final Number y)
{
java.lang.String exitID = "PointMetatype>>x_y";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Point)f0.exit(exitID, new Point().x_y(x, y));
});
}
}
protected Number x = SmallInteger.from(0);
public Number x() { return this.x; }
public Object getX() { return (Object)this.x; }
public Point x(Number value) { this.x = value; return this; }
public void setX(Object value) { this.x = (Number)value; }
;
protected Number y = SmallInteger.from(0);
public Number y() { return this.y; }
public Object getY() { return (Object)this.y; }
public Point y(Number value) { this.y = value; return this; }
public void setY(Object value) { this.y = (Number)value; }
;
/**
* @return
*/
public Numeric xAsNumeric()
{
java.lang.String exitID = "Point>>xAsNumeric";
Frame f0 = new Frame(exitID);
return (Numeric)((Numeric)x);
}
/**
* @return
*/
public Numeric yAsNumeric()
{
java.lang.String exitID = "Point>>yAsNumeric";
Frame f0 = new Frame(exitID);
return (Numeric)((Numeric)y);
}
/**
* @return
*/
public Point x_y(final Number x, final Number y)
{
java.lang.String exitID = "Point>>x_y";
Frame f0 = new Frame(exitID);
{
Point prime = this;
prime.x(x);
prime.y(y);
return prime.yourself();
}
}
/**
* @return
*/
public static Point from(final Number scalar)
{
java.lang.String exitID = "Point>>$from";
Frame f0 = new Frame(exitID);
return (Point)new Point().x_y(scalar, scalar);
}
/**
* @return
*/
public Point plus(final Point aPoint)
{
java.lang.String exitID = "Point>>plus";
Frame f0 = new Frame(exitID);
return (Point)this.$class().x_y((x.plus(aPoint.x())), (y.plus(aPoint.y())));
}
/**
* @return
*/
public Point minus(final Point aPoint)
{
java.lang.String exitID = "Point>>minus";
Frame f0 = new Frame(exitID);
return (Point)this.$class().x_y((x.minus(aPoint.x())), (y.minus(aPoint.y())));
}
/**
* @return
*/
public Point times(final Point aPoint)
{
java.lang.String exitID = "Point>>times";
Frame f0 = new Frame(exitID);
return (Point)this.$class().x_y((x.times(aPoint.x())), (y.times(aPoint.y())));
}
/**
* @return
*/
public Point divideWith(final Point aPoint)
{
java.lang.String exitID = "Point>>divideWith";
Frame f0 = new Frame(exitID);
return (Point)this.$class().x_y((x.divideWith(aPoint.x())), (y.divideWith(aPoint.y())));
}
/**
* @return
*/
public Point truncateWith(final Point aPoint)
{
java.lang.String exitID = "Point>>truncateWith";
Frame f0 = new Frame(exitID);
return (Point)this.$class().x_y((x.truncateWith(aPoint.x())), (y.truncateWith(aPoint.y())));
}
/**
* @return
*/
public Point remainderFrom(final Point aPoint)
{
java.lang.String exitID = "Point>>remainderFrom";
Frame f0 = new Frame(exitID);
return (Point)this.$class().x_y((x.remainderFrom(aPoint.x())), (y.remainderFrom(aPoint.y())));
}
/**
* @return
*/
public Point plus(final Number scalar)
{
java.lang.String exitID = "Point>>plus";
Frame f0 = new Frame(exitID);
return (Point)(this.plus(Point.from(scalar)));
}
/**
* @return
*/
public Point minus(final Number scalar)
{
java.lang.String exitID = "Point>>minus";
Frame f0 = new Frame(exitID);
return (Point)(this.minus(Point.from(scalar)));
}
/**
* @return
*/
public Point times(final Number scalar)
{
java.lang.String exitID = "Point>>times";
Frame f0 = new Frame(exitID);
return (Point)(this.times(Point.from(scalar)));
}
/**
* @return
*/
public Point divideWith(final Number scalar)
{
java.lang.String exitID = "Point>>divideWith";
Frame f0 = new Frame(exitID);
return (Point)(this.divideWith(Point.from(scalar)));
}
/**
* @return
*/
public Point truncateWith(final Number scalar)
{
java.lang.String exitID = "Point>>truncateWith";
Frame f0 = new Frame(exitID);
return (Point)(this.truncateWith(Point.from(scalar)));
}
/**
* @return
*/
public Point remainderFrom(final Number scalar)
{
java.lang.String exitID = "Point>>remainderFrom";
Frame f0 = new Frame(exitID);
return (Point)(this.remainderFrom(Point.from(scalar)));
}
/**
* @return
*/
public Boolean equals(final Point aPoint)
{
java.lang.String exitID = "Point>>equals";
Frame f0 = new Frame(exitID);
return (Boolean)((Boolean)(this.xAsNumeric().equals(aPoint.x())).and(Predicate.with(f2 -> {
return (this.yAsNumeric().equals(aPoint.y()));
}, "")));
}
/**
* @return
*/
public Boolean lessThan(final Point aPoint)
{
java.lang.String exitID = "Point>>lessThan";
Frame f0 = new Frame(exitID);
return (Boolean)((Boolean)(x.lessThan(aPoint.x())).and(Predicate.with(f2 -> {
return (y.lessThan(aPoint.y()));
}, "")));
}
/**
* @return
*/
public Boolean moreThan(final Point aPoint)
{
java.lang.String exitID = "Point>>moreThan";
Frame f0 = new Frame(exitID);
return (Boolean)((Boolean)(x.moreThan(aPoint.x())).and(Predicate.with(f2 -> {
return (y.moreThan(aPoint.y()));
}, "")));
}
/**
* @return
*/
public Boolean notMore(final Point aPoint)
{
java.lang.String exitID = "Point>>notMore";
Frame f0 = new Frame(exitID);
return (Boolean)((Boolean)(aPoint.x().lessThan(x)).not().and(Predicate.with(f2 -> {
return (aPoint.y().lessThan(y)).not();
}, "")));
}
/**
* @return
*/
public Boolean notLess(final Point aPoint)
{
java.lang.String exitID = "Point>>notLess";
Frame f0 = new Frame(exitID);
return (Boolean)((Boolean)(aPoint.x().moreThan(x)).not().and(Predicate.with(f2 -> {
return (aPoint.y().moreThan(y)).not();
}, "")));
}
/**
* @return
*/
@Override public Point min(final Scalar aPoint)
{
java.lang.String exitID = "Point>>min";
Frame f0 = new Frame(exitID);
return (Point)this.min(((Point)aPoint));
}
/**
* @return
*/
@Override public Point max(final Scalar aPoint)
{
java.lang.String exitID = "Point>>max";
Frame f0 = new Frame(exitID);
return (Point)this.max(((Point)aPoint));
}
/**
* @return
*/
public Point min(final Point aPoint)
{
java.lang.String exitID = "Point>>min";
Frame f0 = new Frame(exitID);
if ((aPoint == null)) {
return this;
};
if (this.lessThan(aPoint).primitiveBoolean()) {
return this;
};
return (Point)aPoint;
}
/**
* @return
*/
public Point max(final Point aPoint)
{
java.lang.String exitID = "Point>>max";
Frame f0 = new Frame(exitID);
if ((aPoint == null)) {
return this;
};
if (this.moreThan(aPoint).primitiveBoolean()) {
return this;
};
return (Point)aPoint;
}
/**
* @return
*/
public Boolean equals(final Magnitude value)
{
java.lang.String exitID = "Point>>equals";
Frame f0 = new Frame(exitID);
return (Boolean)Point.type().accepts(value).and(Predicate.with(f2 -> {
return (this.equals(((Point)value)));
}, ""));
}
/**
* @return
*/
public Boolean lessThan(final Scalar value)
{
java.lang.String exitID = "Point>>lessThan";
Frame f0 = new Frame(exitID);
return (Boolean)Point.type().accepts(value).and(Predicate.with(f2 -> {
return (this.lessThan(((Point)value)));
}, ""));
}
/**
* @return
*/
public Boolean notMore(final Scalar value)
{
java.lang.String exitID = "Point>>notMore";
Frame f0 = new Frame(exitID);
return (Boolean)Point.type().accepts(value).and(Predicate.with(f2 -> {
return (this.notMore(((Point)value)));
}, ""));
}
/**
* @return
*/
public Boolean moreThan(final Scalar value)
{
java.lang.String exitID = "Point>>moreThan";
Frame f0 = new Frame(exitID);
return (Boolean)Point.type().accepts(value).and(Predicate.with(f2 -> {
return (this.moreThan(((Point)value)));
}, ""));
}
/**
* @return
*/
public Boolean notLess(final Scalar value)
{
java.lang.String exitID = "Point>>notLess";
Frame f0 = new Frame(exitID);
return (Boolean)Point.type().accepts(value).and(Predicate.with(f2 -> {
return (this.notLess(((Point)value)));
}, ""));
}
/**
* @return
*/
public Point asPoint()
{
java.lang.String exitID = "Point>>asPoint";
Frame f0 = new Frame(exitID);
return (Point)this;
}
/**
* @return
*/
public String printString()
{
java.lang.String exitID = "Point>>printString";
Frame f0 = new Frame(exitID);
return (String)x.printString().append(String.from(" @ ")).append(y.printString());
}
/**
* @return
*/
public java.lang.String toString()
{
java.lang.String exitID = "Point>>toString";
Frame f0 = new Frame(exitID);
return (java.lang.String)this.printTerm().toString();
}
/**
* @return
*/
public java.awt.Point primitivePoint()
{
java.lang.String exitID = "Point>>primitivePoint";
Frame f0 = new Frame(exitID);
return (java.awt.Point)new java.awt.Point(x.primitiveInteger(), y.primitiveInteger());
}
/**
* @return
*/
public java.awt.Dimension primitiveDimension()
{
java.lang.String exitID = "Point>>primitiveDimension";
Frame f0 = new Frame(exitID);
return (java.awt.Dimension)new java.awt.Dimension(x.primitiveInteger(), y.primitiveInteger());
}
/**
* @return
*/
@Override public int hashCode()
{
java.lang.String exitID = "Point>>hashCode";
Frame f0 = new Frame(exitID);
return (int)x.hash().bitXor(y.hash()).primitiveInteger();
}
/**
* @return
*/
public Rectangle extent(final Point extentPoint)
{
java.lang.String exitID = "Point>>extent";
Frame f0 = new Frame(exitID);
return (Rectangle)Rectangle.origin_extent(this, extentPoint);
}
/**
* @return
*/
public Rectangle corner(final Point cornerPoint)
{
java.lang.String exitID = "Point>>corner";
Frame f0 = new Frame(exitID);
return (Rectangle)Rectangle.origin_corner(this, cornerPoint);
}
/**
* @return
*/
public Point abs()
{
java.lang.String exitID = "Point>>abs";
Frame f0 = new Frame(exitID);
return (Point)(x.abs().at(y.abs()));
}
/**
* @return
*/
public Point negated()
{
java.lang.String exitID = "Point>>negated";
Frame f0 = new Frame(exitID);
return (Point)(x.negated().at(y.negated()));
}
/**
* @return
*/
public Point truncated()
{
java.lang.String exitID = "Point>>truncated";
Frame f0 = new Frame(exitID);
return (Point)(x.truncated().at(y.truncated()));
}
/**
* @return
*/
public Point truncatedTo(final Number aNumber)
{
java.lang.String exitID = "Point>>truncatedTo";
Frame f0 = new Frame(exitID);
return (Point)(x.truncatedTo(aNumber).at(y.truncatedTo(aNumber)));
}
/**
* @return
*/
public Number dotProduct(final Point aPoint)
{
java.lang.String exitID = "Point>>dotProduct";
Frame f0 = new Frame(exitID);
return (Number)((x.times(aPoint.x())).plus((y.times(aPoint.y()))));
}
/**
* @return
*/
public Point rounded()
{
java.lang.String exitID = "Point>>rounded";
Frame f0 = new Frame(exitID);
return (Point)(x.rounded().at(y.rounded()));
}
/**
* @return
*/
public Point transpose()
{
java.lang.String exitID = "Point>>transpose";
Frame f0 = new Frame(exitID);
return (Point)(y.at(x));
}
}