[DEV] some updates
This commit is contained in:
parent
565c436b6d
commit
40484df7ff
@ -16,13 +16,13 @@ public record DimensionBorderRadius(
|
||||
BorderRadius size,
|
||||
Distance type) {
|
||||
final static Logger LOGGER = LoggerFactory.getLogger(DimensionBorderRadius.class);
|
||||
|
||||
|
||||
public static final DimensionBorderRadius ZERO = new DimensionBorderRadius(BorderRadius.ZERO, Distance.PIXEL);
|
||||
private static BorderRadius ratio = new BorderRadius(9999999, 888888, 7777777, 66666666);
|
||||
private static BorderRadius invRatio = BorderRadius.ONE;
|
||||
private static DimensionBorderRadius windowsSize = new DimensionBorderRadius(BorderRadius.MAX_VALUE,
|
||||
Distance.PIXEL);
|
||||
|
||||
|
||||
public static final float INCH_TO_MILLIMETER = 1.0f / 25.4f;
|
||||
public static final float FOOT_TO_MILLIMETER = 1.0f / 304.8f;
|
||||
public static final float METER_TO_MILLIMETER = 1.0f / 1000.0f;
|
||||
@ -44,7 +44,7 @@ public record DimensionBorderRadius(
|
||||
1.0f / ratio.bottomLeft());
|
||||
windowsSize = new DimensionBorderRadius(new BorderRadius(200, 200, 200, 200), Distance.PIXEL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the current Windows size
|
||||
* @param size size of the current windows in pixel.
|
||||
@ -52,14 +52,14 @@ public record DimensionBorderRadius(
|
||||
public static void setPixelWindowsSize(final BorderRadius size) {
|
||||
windowsSize = new DimensionBorderRadius(size);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor (default :0,0 mode pixel)
|
||||
*/
|
||||
public DimensionBorderRadius() {
|
||||
this(BorderRadius.ZERO, Distance.PIXEL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param size Requested dimension
|
||||
@ -68,15 +68,20 @@ public record DimensionBorderRadius(
|
||||
this(new BorderRadius(size, size, size, size), Distance.PIXEL);
|
||||
}
|
||||
|
||||
public DimensionBorderRadius(final float topLeft, final float topRight, final float bottomRight,
|
||||
final float bottomLeft) {
|
||||
this(new BorderRadius(topLeft, topRight, bottomRight, bottomLeft), Distance.PIXEL);
|
||||
}
|
||||
|
||||
public DimensionBorderRadius(final BorderRadius size) {
|
||||
this(size, Distance.PIXEL);
|
||||
}
|
||||
|
||||
|
||||
public DimensionBorderRadius(final BorderRadius size, final Distance type) {
|
||||
this.size = size;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in requested type
|
||||
* @param type Type of unit requested.
|
||||
@ -103,7 +108,7 @@ public record DimensionBorderRadius(
|
||||
default -> throw new IllegalArgumentException("Unexpected value: " + type);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in Centimeter
|
||||
* @return dimension in Centimeter
|
||||
@ -111,7 +116,7 @@ public record DimensionBorderRadius(
|
||||
public BorderRadius getCentimeter() {
|
||||
return getMillimeter().multiply(MILLIMETER_TO_CENTIMETER);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in Foot
|
||||
* @return dimension in Foot
|
||||
@ -119,7 +124,7 @@ public record DimensionBorderRadius(
|
||||
public BorderRadius getFoot() {
|
||||
return getMillimeter().multiply(MILLIMETER_TO_FOOT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in Inch
|
||||
* @return dimension in Inch
|
||||
@ -127,7 +132,7 @@ public record DimensionBorderRadius(
|
||||
public BorderRadius getInch() {
|
||||
return getMillimeter().multiply(MILLIMETER_TO_INCH);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in Kilometer
|
||||
* @return dimension in Kilometer
|
||||
@ -135,7 +140,7 @@ public record DimensionBorderRadius(
|
||||
public BorderRadius getKilometer() {
|
||||
return getMillimeter().multiply(MILLIMETER_TO_KILOMETER);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in Meter
|
||||
* @return dimension in Meter
|
||||
@ -143,7 +148,7 @@ public record DimensionBorderRadius(
|
||||
public BorderRadius getMeter() {
|
||||
return getMillimeter().multiply(MILLIMETER_TO_METER);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in Millimeter
|
||||
* @return dimension in Millimeter
|
||||
@ -152,7 +157,7 @@ public record DimensionBorderRadius(
|
||||
return new BorderRadius(getPixel().topLeft() * invRatio.topLeft(), getPixel().topRight() * invRatio.topRight(),
|
||||
getPixel().bottomRight() * invRatio.bottomRight(), getPixel().bottomLeft() * invRatio.bottomLeft());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in pixel
|
||||
* @return dimension in Pixel
|
||||
@ -163,7 +168,7 @@ public record DimensionBorderRadius(
|
||||
}
|
||||
return getPixel(windowsSize.getPixel());
|
||||
}
|
||||
|
||||
|
||||
public BorderRadius getPixel(final BorderRadius uppersize) {
|
||||
if (this.type != Distance.POURCENT) {
|
||||
return this.size;
|
||||
@ -175,7 +180,7 @@ public record DimensionBorderRadius(
|
||||
//GALE_DEBUG("Get % : " + m_data + " / " + windDim + " == > " + res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in Pourcent
|
||||
* @return dimension in Pourcent
|
||||
@ -194,7 +199,7 @@ public record DimensionBorderRadius(
|
||||
return new BorderRadius(this.size.topLeft() * 100.0f, this.size.topRight() * 100.0f,
|
||||
this.size.bottomRight() * 100.0f, this.size.bottomLeft() * 100.0f);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the dimension type
|
||||
* @return the type
|
||||
@ -202,7 +207,7 @@ public record DimensionBorderRadius(
|
||||
public Distance getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the current dimension in requested type
|
||||
* @param config dimension configuration.
|
||||
@ -218,15 +223,15 @@ public record DimensionBorderRadius(
|
||||
final DimensionBorderRadius ret = new DimensionBorderRadius(tmp, type);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public DimensionBorderRadius withSize(final BorderRadius size) {
|
||||
return new DimensionBorderRadius(size, this.type);
|
||||
}
|
||||
|
||||
|
||||
public DimensionBorderRadius withType(final Distance type) {
|
||||
return new DimensionBorderRadius(this.size, type);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* string cast :
|
||||
*/
|
||||
@ -234,29 +239,29 @@ public record DimensionBorderRadius(
|
||||
public String toString() {
|
||||
return get(getType()).toString() + getType().toSmallString();
|
||||
}
|
||||
|
||||
|
||||
public static DimensionBorderRadius valueOf(
|
||||
String contentX,
|
||||
final String contentY,
|
||||
final String contentZ,
|
||||
final String contentW) {
|
||||
|
||||
|
||||
final Distance typeX = Distance.parseEndSmallString(contentX);
|
||||
contentX = typeX.removeEndString(contentX);
|
||||
final float tmpX = Float.valueOf(contentX);
|
||||
|
||||
|
||||
final Distance typeY = Distance.parseEndSmallString(contentY);
|
||||
contentX = typeY.removeEndString(contentY);
|
||||
final float tmpY = Float.valueOf(contentY);
|
||||
|
||||
|
||||
final Distance typeZ = Distance.parseEndSmallString(contentZ);
|
||||
contentX = typeZ.removeEndString(contentZ);
|
||||
final float tmpZ = Float.valueOf(contentZ);
|
||||
|
||||
|
||||
final Distance typeW = Distance.parseEndSmallString(contentW);
|
||||
contentX = typeW.removeEndString(contentZ);
|
||||
final float tmpW = Float.valueOf(contentZ);
|
||||
|
||||
|
||||
if (typeX != Distance.UNKNOW) {
|
||||
return new DimensionBorderRadius(new BorderRadius(tmpX, tmpY, tmpZ, tmpW), typeX);
|
||||
}
|
||||
@ -271,5 +276,5 @@ public record DimensionBorderRadius(
|
||||
}
|
||||
return new DimensionBorderRadius(new BorderRadius(tmpX, tmpY, tmpZ, tmpW), Distance.PIXEL);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -16,12 +16,12 @@ public record DimensionInsets(
|
||||
Insets size,
|
||||
Distance type) {
|
||||
final static Logger LOGGER = LoggerFactory.getLogger(DimensionInsets.class);
|
||||
|
||||
|
||||
public static final DimensionInsets ZERO = new DimensionInsets(Insets.ZERO, Distance.PIXEL);
|
||||
private static Insets ratio = new Insets(9999999, 888888, 7777777, 66666666);
|
||||
private static Insets invRatio = Insets.ONE;
|
||||
private static DimensionInsets windowsSize = new DimensionInsets(Insets.MAX_VALUE, Distance.PIXEL);
|
||||
|
||||
|
||||
public static final float INCH_TO_MILLIMETER = 1.0f / 25.4f;
|
||||
public static final float FOOT_TO_MILLIMETER = 1.0f / 304.8f;
|
||||
public static final float METER_TO_MILLIMETER = 1.0f / 1000.0f;
|
||||
@ -41,7 +41,7 @@ public record DimensionInsets(
|
||||
invRatio = new Insets(1.0f / ratio.top(), 1.0f / ratio.right(), 1.0f / ratio.bottom(), 1.0f / ratio.left());
|
||||
windowsSize = new DimensionInsets(new Insets(200, 200, 200, 200), Distance.PIXEL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the current Windows size
|
||||
* @param size size of the current windows in pixel.
|
||||
@ -56,7 +56,7 @@ public record DimensionInsets(
|
||||
public DimensionInsets() {
|
||||
this(Insets.ZERO, Distance.PIXEL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param size Requested dimension
|
||||
@ -65,15 +65,27 @@ public record DimensionInsets(
|
||||
this(new Insets(size, size, size, size), Distance.PIXEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param size Requested dimension
|
||||
*/
|
||||
public DimensionInsets(final float top, final float right, final float bottom, final float left) {
|
||||
this(new Insets(top, right, bottom, left), Distance.PIXEL);
|
||||
}
|
||||
|
||||
public DimensionInsets(final float yyy, final float xxx) {
|
||||
this(new Insets(yyy, xxx, yyy, xxx), Distance.PIXEL);
|
||||
}
|
||||
|
||||
public DimensionInsets(final Insets size) {
|
||||
this(size, Distance.PIXEL);
|
||||
}
|
||||
|
||||
|
||||
public DimensionInsets(final Insets size, final Distance type) {
|
||||
this.size = size;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in requested type
|
||||
* @param type Type of unit requested.
|
||||
@ -100,7 +112,7 @@ public record DimensionInsets(
|
||||
default -> throw new IllegalArgumentException("Unexpected value: " + type);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in Centimeter
|
||||
* @return dimension in Centimeter
|
||||
@ -108,7 +120,7 @@ public record DimensionInsets(
|
||||
public Insets getCentimeter() {
|
||||
return getMillimeter().multiply(MILLIMETER_TO_CENTIMETER);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in Foot
|
||||
* @return dimension in Foot
|
||||
@ -116,7 +128,7 @@ public record DimensionInsets(
|
||||
public Insets getFoot() {
|
||||
return getMillimeter().multiply(MILLIMETER_TO_FOOT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in Inch
|
||||
* @return dimension in Inch
|
||||
@ -124,7 +136,7 @@ public record DimensionInsets(
|
||||
public Insets getInch() {
|
||||
return getMillimeter().multiply(MILLIMETER_TO_INCH);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in Kilometer
|
||||
* @return dimension in Kilometer
|
||||
@ -132,7 +144,7 @@ public record DimensionInsets(
|
||||
public Insets getKilometer() {
|
||||
return getMillimeter().multiply(MILLIMETER_TO_KILOMETER);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in Meter
|
||||
* @return dimension in Meter
|
||||
@ -140,7 +152,7 @@ public record DimensionInsets(
|
||||
public Insets getMeter() {
|
||||
return getMillimeter().multiply(MILLIMETER_TO_METER);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in Millimeter
|
||||
* @return dimension in Millimeter
|
||||
@ -149,7 +161,7 @@ public record DimensionInsets(
|
||||
return new Insets(getPixel().top() * invRatio.top(), getPixel().right() * invRatio.right(),
|
||||
getPixel().bottom() * invRatio.bottom(), getPixel().left() * invRatio.left());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in pixel
|
||||
* @return dimension in Pixel
|
||||
@ -160,7 +172,7 @@ public record DimensionInsets(
|
||||
}
|
||||
return getPixel(windowsSize.getPixel());
|
||||
}
|
||||
|
||||
|
||||
public Insets getPixel(final Insets uppersize) {
|
||||
if (this.type != Distance.POURCENT) {
|
||||
return this.size;
|
||||
@ -171,7 +183,7 @@ public record DimensionInsets(
|
||||
//GALE_DEBUG("Get % : " + m_data + " / " + windDim + " == > " + res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the current dimension in Pourcent
|
||||
* @return dimension in Pourcent
|
||||
@ -191,7 +203,7 @@ public record DimensionInsets(
|
||||
this.size.bottom() * 100.0f, //
|
||||
this.size.left() * 100.0f);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the dimension type
|
||||
* @return the type
|
||||
@ -199,7 +211,7 @@ public record DimensionInsets(
|
||||
public Distance getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the current dimension in requested type
|
||||
* @param config dimension configuration.
|
||||
@ -215,15 +227,15 @@ public record DimensionInsets(
|
||||
final DimensionInsets ret = new DimensionInsets(tmp, type);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public DimensionInsets withSize(final Insets size) {
|
||||
return new DimensionInsets(size, this.type);
|
||||
}
|
||||
|
||||
|
||||
public DimensionInsets withType(final Distance type) {
|
||||
return new DimensionInsets(this.size, type);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* string cast :
|
||||
*/
|
||||
@ -231,29 +243,29 @@ public record DimensionInsets(
|
||||
public String toString() {
|
||||
return get(getType()).toString() + getType().toSmallString();
|
||||
}
|
||||
|
||||
|
||||
public static DimensionInsets valueOf(
|
||||
String contentX,
|
||||
final String contentY,
|
||||
final String contentZ,
|
||||
final String contentW) {
|
||||
|
||||
|
||||
final Distance typeX = Distance.parseEndSmallString(contentX);
|
||||
contentX = typeX.removeEndString(contentX);
|
||||
final float tmpX = Float.valueOf(contentX);
|
||||
|
||||
|
||||
final Distance typeY = Distance.parseEndSmallString(contentX);
|
||||
contentX = typeY.removeEndString(contentY);
|
||||
final float tmpY = Float.valueOf(contentY);
|
||||
|
||||
|
||||
final Distance typeZ = Distance.parseEndSmallString(contentX);
|
||||
contentX = typeZ.removeEndString(contentZ);
|
||||
final float tmpZ = Float.valueOf(contentZ);
|
||||
|
||||
|
||||
final Distance typeW = Distance.parseEndSmallString(contentX);
|
||||
contentX = typeW.removeEndString(contentW);
|
||||
final float tmpW = Float.valueOf(contentW);
|
||||
|
||||
|
||||
if (typeX != Distance.UNKNOW) {
|
||||
return new DimensionInsets(new Insets(tmpX, tmpY, tmpZ, tmpW), typeX);
|
||||
}
|
||||
@ -268,5 +280,5 @@ public record DimensionInsets(
|
||||
}
|
||||
return new DimensionInsets(new Insets(tmpX, tmpY, tmpZ, tmpW), Distance.PIXEL);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -14,11 +14,19 @@ public record Insets(
|
||||
float bottom,
|
||||
float left) {
|
||||
final static Logger LOGGER = LoggerFactory.getLogger(Insets.class);
|
||||
|
||||
|
||||
public Vector2f toVector2f() {
|
||||
return new Vector2f(this.left + this.right, this.top + this.bottom);
|
||||
}
|
||||
|
||||
public Vector2f getOrigin() {
|
||||
return new Vector2f(this.left, this.bottom);
|
||||
}
|
||||
|
||||
public Vector2f getEnd() {
|
||||
return new Vector2f(this.right, this.top);
|
||||
}
|
||||
|
||||
public static Insets valueOf(String value) {
|
||||
float val1 = 0;
|
||||
float val2 = 0;
|
||||
@ -62,7 +70,7 @@ public record Insets(
|
||||
}
|
||||
return new Insets(val1, val2, val3, val4);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor from scalars
|
||||
* @param value unique value for X,Y and Z value
|
||||
@ -70,14 +78,14 @@ public record Insets(
|
||||
public Insets(final float value) {
|
||||
this(value, value, value, value);
|
||||
}
|
||||
|
||||
|
||||
public Insets(final float top, final float right, final float bottom, final float left) {
|
||||
this.top = top;
|
||||
this.right = right;
|
||||
this.bottom = bottom;
|
||||
this.left = left;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a vector will the absolute values of each element
|
||||
* @return the curent reference
|
||||
@ -86,22 +94,22 @@ public record Insets(
|
||||
public Insets abs() {
|
||||
return new Insets(Math.abs(this.top), Math.abs(this.right), Math.abs(this.bottom), Math.abs(this.left));
|
||||
}
|
||||
|
||||
|
||||
@CheckReturnValue
|
||||
public Insets add(final float value) {
|
||||
return new Insets(this.top + value, this.right + value, this.bottom + value, this.left + value);
|
||||
}
|
||||
|
||||
|
||||
@CheckReturnValue
|
||||
public Insets add(final float xxx, final float yyy, final float zzz, final float www) {
|
||||
return new Insets(this.top + xxx, this.right + yyy, this.bottom + zzz, this.left + www);
|
||||
}
|
||||
|
||||
|
||||
@CheckReturnValue
|
||||
public Insets clipInteger() {
|
||||
return new Insets((int) this.top, (int) this.right, (int) this.bottom, (int) this.left);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a vector to this one
|
||||
* @param obj The vector to add to this one
|
||||
@ -110,7 +118,7 @@ public record Insets(
|
||||
public Insets add(final Insets obj) {
|
||||
return new Insets(this.top + obj.top, this.right + obj.right, this.bottom + obj.left, this.bottom + obj.left);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the axis with the largest ABSOLUTE value
|
||||
* @return values 0,1,2 for x, y, or z
|
||||
@ -119,7 +127,7 @@ public record Insets(
|
||||
public int closestAxis() {
|
||||
return abs().getMaxAxis();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the distance between the ends of this and another vector This
|
||||
* is symantically treating the vector like a point
|
||||
@ -130,7 +138,7 @@ public record Insets(
|
||||
public float distance(final Insets obj) {
|
||||
return (float) Math.sqrt(distance2(obj));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the distance squared between the ends of this and another
|
||||
* vector This is symantically treating the vector like a point
|
||||
@ -145,7 +153,7 @@ public record Insets(
|
||||
final float deltaW = obj.left - this.left;
|
||||
return deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ + deltaW * deltaW;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inversely scale the vector
|
||||
* @param val Scale factor to divide by
|
||||
@ -157,7 +165,7 @@ public record Insets(
|
||||
}
|
||||
throw new IllegalArgumentException("divice by 0 (Vector4f)");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inversely scale the vector
|
||||
* @param val Scale factor to divide by
|
||||
@ -166,7 +174,7 @@ public record Insets(
|
||||
public Insets divide(final Insets val) {
|
||||
return new Insets(this.top / val.top, this.right / val.right, this.bottom / val.left, this.bottom / val.left);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the dot product
|
||||
* @param obj The other vector in the dot product
|
||||
@ -176,7 +184,7 @@ public record Insets(
|
||||
public float dot(final Insets obj) {
|
||||
return this.top * obj.top + this.right * obj.right + this.bottom * obj.bottom + this.left * obj.left;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the axis with the smallest ABSOLUTE value
|
||||
* @return values 0,1,2 for x, y, or z
|
||||
@ -185,7 +193,7 @@ public record Insets(
|
||||
public int furthestAxis() {
|
||||
return abs().getMinAxis();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the value with his index
|
||||
* @param index Index of the value (0: x, 1: y, 2: z)
|
||||
@ -204,7 +212,7 @@ public record Insets(
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown index: " + index);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the maximum value of the vector (x, y, z)
|
||||
* @return The max value
|
||||
@ -213,7 +221,7 @@ public record Insets(
|
||||
public float getMax() {
|
||||
return Math.max(Math.max(Math.max(this.top, this.right), this.bottom), this.left);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the Axis id with the maximum value
|
||||
* @return Axis ID 0,1,2
|
||||
@ -224,7 +232,7 @@ public record Insets(
|
||||
? (this.right < this.bottom ? (this.left < this.bottom ? 2 : 3) : (this.left < this.right ? 1 : 3))
|
||||
: (this.top < this.bottom ? (this.left < this.bottom ? 2 : 3) : (this.left < this.top ? 0 : 3)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the minimum value of the vector (x, y, z)
|
||||
* @return The min value
|
||||
@ -233,7 +241,7 @@ public record Insets(
|
||||
public float getMin() {
|
||||
return Math.min(Math.min(Math.min(this.top, this.right), this.bottom), this.left);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the Axis id with the minimum value
|
||||
* @return Axis ID 0,1,2
|
||||
@ -244,13 +252,13 @@ public record Insets(
|
||||
? (this.top < this.bottom ? (this.left < this.top ? 3 : 0) : (this.left < this.bottom ? 3 : 2))
|
||||
: (this.right < this.bottom ? (this.left < this.right ? 3 : 1) : (this.left < this.bottom ? 3 : 2)));
|
||||
}
|
||||
|
||||
|
||||
// Overloaded operator for the negative of a vector
|
||||
@CheckReturnValue
|
||||
public Insets invert() {
|
||||
return new Insets(-this.top, -this.right, -this.bottom, -this.left);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* In-Equality compare operator with an other object.
|
||||
* @param obj Reference on the comparing object
|
||||
@ -262,7 +270,7 @@ public record Insets(
|
||||
return ((this.bottom != obj.bottom) || (this.right != obj.right) || (this.top != obj.top)
|
||||
|| (this.left != obj.left));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Equality compare operator with an other object.
|
||||
* @param obj Reference on the comparing object
|
||||
@ -274,7 +282,7 @@ public record Insets(
|
||||
return ((this.bottom == obj.bottom) && (this.right == obj.right) && (this.top == obj.top)
|
||||
&& (this.left == obj.left));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the linear interpolation between this and another vector
|
||||
* @param obj The other vector
|
||||
@ -287,17 +295,17 @@ public record Insets(
|
||||
return new Insets(this.top + (obj.top - this.top) * ratio, this.right + (obj.right - this.right) * ratio,
|
||||
this.bottom + (obj.bottom - this.bottom) * ratio, this.left + (obj.left - this.left) * ratio);
|
||||
}
|
||||
|
||||
|
||||
@CheckReturnValue
|
||||
public Insets less(final float value) {
|
||||
return new Insets(this.top - value, this.right - value, this.bottom - value, this.left - value);
|
||||
}
|
||||
|
||||
|
||||
@CheckReturnValue
|
||||
public Insets less(final float xxx, final float yyy, final float zzz, final float www) {
|
||||
return new Insets(this.top - xxx, this.right - yyy, this.bottom - zzz, this.left - www);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Subtract a vector from this one
|
||||
* @param obj The vector to subtract
|
||||
@ -307,7 +315,7 @@ public record Insets(
|
||||
public Insets less(final Insets obj) {
|
||||
return new Insets(this.top - obj.top, this.right - obj.right, this.bottom - obj.bottom, this.left - obj.left);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scale the vector
|
||||
* @param val Scale factor
|
||||
@ -317,7 +325,7 @@ public record Insets(
|
||||
public Insets multiply(final float val) {
|
||||
return new Insets(this.top * val, this.right * val, this.bottom * val, this.left * val);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Elementwise multiply this vector by the other
|
||||
* @param obj The other vector
|
||||
@ -326,7 +334,7 @@ public record Insets(
|
||||
public Insets multiply(final Insets obj) {
|
||||
return new Insets(this.top * obj.top, this.right * obj.right, this.bottom * obj.left, this.bottom * obj.left);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set each element to the max of the current values and the values of
|
||||
* another Vector4f
|
||||
@ -337,19 +345,19 @@ public record Insets(
|
||||
return new Insets(Math.max(this.top, obj.top), Math.max(this.right, obj.right),
|
||||
Math.max(this.bottom, obj.bottom), Math.max(this.left, obj.left));
|
||||
}
|
||||
|
||||
|
||||
@CheckReturnValue
|
||||
public static Insets max(final Insets obj1, final Insets obj2) {
|
||||
return new Insets(Math.max(obj1.top, obj2.top), Math.max(obj1.right, obj2.right),
|
||||
Math.max(obj1.bottom, obj2.bottom), Math.max(obj1.left, obj2.left));
|
||||
}
|
||||
|
||||
|
||||
@CheckReturnValue
|
||||
public static Insets min(final Insets obj1, final Insets obj2) {
|
||||
return new Insets(Math.min(obj1.top, obj2.top), Math.min(obj1.right, obj2.right),
|
||||
Math.min(obj1.bottom, obj2.bottom), Math.min(obj1.left, obj2.left));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set each element to the min of the current values and the values of
|
||||
* another Vector4f
|
||||
@ -360,27 +368,27 @@ public record Insets(
|
||||
return new Insets(Math.min(this.top, obj.top), Math.min(this.right, obj.right),
|
||||
Math.min(this.bottom, obj.bottom), Math.min(this.left, obj.left));
|
||||
}
|
||||
|
||||
|
||||
@CheckReturnValue
|
||||
public Insets withTop(final float value) {
|
||||
return new Insets(value, this.right, this.bottom, this.left);
|
||||
}
|
||||
|
||||
|
||||
@CheckReturnValue
|
||||
public Insets withRight(final float value) {
|
||||
return new Insets(this.top, value, this.bottom, this.left);
|
||||
}
|
||||
|
||||
|
||||
@CheckReturnValue
|
||||
public Insets withBottom(final float value) {
|
||||
return new Insets(this.top, this.right, value, this.left);
|
||||
}
|
||||
|
||||
|
||||
@CheckReturnValue
|
||||
public Insets withLeft(final float value) {
|
||||
return new Insets(this.top, this.right, this.bottom, value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set 0 value on all the vector
|
||||
*/
|
||||
@ -399,13 +407,13 @@ public record Insets(
|
||||
public static final Insets VALUE_1024 = new Insets(1024, 1024, 1024, 1024);
|
||||
public static final Insets MAX_VALUE = new Insets(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE,
|
||||
Float.MAX_VALUE);
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Vector4f(" + FMath.floatToString(this.top) + "," + FMath.floatToString(this.right) + ","
|
||||
+ FMath.floatToString(this.bottom) + ")";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the triple product between this and another vector and another
|
||||
* @param obj1 The other vector 1
|
||||
@ -418,7 +426,7 @@ public record Insets(
|
||||
+ this.right * (obj1.bottom * obj2.top - obj1.top * obj2.bottom)
|
||||
+ this.bottom * (obj1.top * obj2.right - obj1.right * obj2.top);
|
||||
}
|
||||
|
||||
|
||||
public static Insets valueOf(
|
||||
final String valuesX,
|
||||
final String valuesY,
|
||||
@ -430,4 +438,9 @@ public record Insets(
|
||||
final float val4 = Float.valueOf(valuesW);
|
||||
return new Insets(val1, val2, val3, val4);
|
||||
}
|
||||
|
||||
@CheckReturnValue
|
||||
public boolean isZero() {
|
||||
return this.top == 0.0f && this.right == 0.0f && this.bottom == 0.0f && this.left == 0.0f;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user