Compare commits
2 Commits
84f92a1841
...
e53ed45d42
Author | SHA1 | Date | |
---|---|---|---|
e53ed45d42 | |||
3c2cf9ca2b |
@ -233,7 +233,7 @@ public class Uri {
|
|||||||
public static Uri valueOf(String value) {
|
public static Uri valueOf(String value) {
|
||||||
String group = null;
|
String group = null;
|
||||||
String path = null;
|
String path = null;
|
||||||
String lib = null;
|
Map<String, String> prop = new HashMap<>();
|
||||||
if (value.contains(":")) {
|
if (value.contains(":")) {
|
||||||
final String[] ret = value.split(":", 2);
|
final String[] ret = value.split(":", 2);
|
||||||
group = ret[0].toUpperCase();
|
group = ret[0].toUpperCase();
|
||||||
@ -241,17 +241,30 @@ public class Uri {
|
|||||||
} else {
|
} else {
|
||||||
group = "DATA";
|
group = "DATA";
|
||||||
}
|
}
|
||||||
if (value.contains("?lib=")) {
|
int index = value.indexOf('?');
|
||||||
final String[] ret = value.split("\\?lib=", 2);
|
if (index != -1) {
|
||||||
path = ret[0];
|
final String valuesMetadata = value.substring(index + 1);
|
||||||
lib = ret[1].toLowerCase();
|
final String[] elementMetaData = valuesMetadata.split("&");
|
||||||
|
for (int iii = 0; iii < elementMetaData.length; iii++) {
|
||||||
|
final String[] keyVal = elementMetaData[iii].split("=", 2);
|
||||||
|
if (keyVal.length == 1) {
|
||||||
|
prop.put(keyVal[0], "");
|
||||||
|
} else {
|
||||||
|
if (keyVal[0].equals("lib")) {
|
||||||
|
prop.put(keyVal[0], keyVal[1].toLowerCase());
|
||||||
|
} else {
|
||||||
|
prop.put(keyVal[0], keyVal[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
path = value.substring(0, index);
|
||||||
} else {
|
} else {
|
||||||
path = value;
|
path = value;
|
||||||
}
|
}
|
||||||
return new Uri(group, path, lib);
|
return new Uri(group, path, prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeAll(final Uri uri, final String data) throws IOException {
|
public static void writeAll(final Uri uri, final String data) throws IOException {
|
||||||
BufferedWriter out = null;
|
BufferedWriter out = null;
|
||||||
try {
|
try {
|
||||||
FileWriter fstream = new FileWriter(uri.getPath(), false); //true tells to append data.
|
FileWriter fstream = new FileWriter(uri.getPath(), false); //true tells to append data.
|
||||||
@ -358,29 +371,30 @@ public class Uri {
|
|||||||
return ret[ret.length - 1];
|
return ret[ret.length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGroup() {
|
|
||||||
return this.group;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Uri getParent() {
|
|
||||||
String path = this.path.substring(0, this.path.lastIndexOf("/"));
|
|
||||||
return new Uri(getGroup(), path, this.properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the filename of the URI with the extension "plop.txt"
|
* Get the filename of the URI with the extension "plop.txt"
|
||||||
* @return simple filename
|
* @return simple filename
|
||||||
*/
|
*/
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
return this.path.substring(this.path.lastIndexOf("/")+1);
|
return this.path.substring(this.path.lastIndexOf("/") + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the filename of the URI without the extension "plop"
|
* Get the filename of the URI without the extension "plop"
|
||||||
* @return simple filename
|
* @return simple filename
|
||||||
*/
|
*/
|
||||||
public String getFileNameNoExt() {
|
public String getFileNameNoExt() {
|
||||||
String ext = getExtention();
|
String ext = getExtention();
|
||||||
return this.path.substring(this.path.lastIndexOf("/")+1, this.path.length()-ext.length()+1);
|
return this.path.substring(this.path.lastIndexOf("/") + 1, this.path.length() - ext.length() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroup() {
|
||||||
|
return this.group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Uri getParent() {
|
||||||
|
String path = this.path.substring(0, this.path.lastIndexOf("/"));
|
||||||
|
return new Uri(getGroup(), path, this.properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPath() {
|
public String getPath() {
|
||||||
@ -391,7 +405,7 @@ public class Uri {
|
|||||||
return this.properties;
|
return this.properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getproperty(final String key) {
|
public String getProperty(final String key) {
|
||||||
return this.properties.get(key);
|
return this.properties.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,6 +413,10 @@ public class Uri {
|
|||||||
return toString();
|
return toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasProperty(final String key) {
|
||||||
|
return this.properties.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return this.path == null || this.path.isEmpty();
|
return this.path == null || this.path.isEmpty();
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ public record Vector3i(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor from scalars
|
* Constructor from scalars
|
||||||
* @param value unique value for X,Y and Z value
|
* @param value unique value for X,Y and Z value
|
||||||
*/
|
*/
|
||||||
public Vector3i(final int value) {
|
public Vector3i(final int value) {
|
||||||
@ -86,7 +86,7 @@ public record Vector3i(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a vector to this one
|
* Add a vector to this one
|
||||||
* @param obj The vector to add to this one
|
* @param obj The vector to add to this one
|
||||||
*/
|
*/
|
||||||
@CheckReturnValue
|
@CheckReturnValue
|
||||||
@ -138,7 +138,7 @@ public record Vector3i(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inversely scale the vector
|
* Inversely scale the vector
|
||||||
* @param val Scale factor to divide by
|
* @param val Scale factor to divide by
|
||||||
*/
|
*/
|
||||||
@CheckReturnValue
|
@CheckReturnValue
|
||||||
@ -151,20 +151,33 @@ public record Vector3i(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the distance between the ends of this and another vector
|
* Return the distance between the ends of this and another vector
|
||||||
* This is symantically treating the vector like a point
|
* This is semantically treating the vector like a point
|
||||||
* @param obj The other vector to compare distance
|
* @param obj The other vector to compare distance
|
||||||
* @return the distance of the 2 points
|
* @return the distance of the 2 points
|
||||||
*/
|
*/
|
||||||
@CheckReturnValue
|
@CheckReturnValue
|
||||||
public int distance(final Vector3i obj) {
|
public float distance(final Vector3i obj) {
|
||||||
return (int) Math.sqrt(distance2(obj));
|
return FMath.sqrt(distance2(obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the distance between the ends of this and another vector
|
||||||
|
* This is semantically treating the vector like a point
|
||||||
|
* @param xxx X position.
|
||||||
|
* @param yyy Y position.
|
||||||
|
* @param zzz Z position.
|
||||||
|
* @return the distance of the 2 points
|
||||||
|
*/
|
||||||
|
@CheckReturnValue
|
||||||
|
public float distance(final int xxx, final int yyy, final int zzz) {
|
||||||
|
return FMath.sqrt(distance2(xxx, yyy, zzz));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the distance squared between the ends of this and another vector
|
* Return the distance squared between the ends of this and another vector
|
||||||
* This is symantically treating the vector like a point
|
* This is semantically treating the vector like a point
|
||||||
* @param obj The other vector to compare distance
|
* @param obj The other vector to compare distance
|
||||||
* @return the square distance of the 2 points
|
* @return The square distance of the 2 points.
|
||||||
*/
|
*/
|
||||||
@CheckReturnValue
|
@CheckReturnValue
|
||||||
public int distance2(final Vector3i obj) {
|
public int distance2(final Vector3i obj) {
|
||||||
@ -174,6 +187,22 @@ public record Vector3i(
|
|||||||
return deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;
|
return deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the distance squared between the ends of this and another vector
|
||||||
|
* This is semantically treating the vector like a point
|
||||||
|
* @param xxx X position.
|
||||||
|
* @param yyy Y position.
|
||||||
|
* @param zzz Z position.
|
||||||
|
* @return The square distance of the 2 points.
|
||||||
|
*/
|
||||||
|
@CheckReturnValue
|
||||||
|
public int distance2(final int xxx, final int yyy, final int zzz) {
|
||||||
|
final int deltaX = xxx - this.x;
|
||||||
|
final int deltaY = yyy - this.y;
|
||||||
|
final int deltaZ = zzz - this.z;
|
||||||
|
return deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the dot product
|
* Return the dot product
|
||||||
* @param obj The other vector in the dot product
|
* @param obj The other vector in the dot product
|
||||||
@ -296,7 +325,7 @@ public record Vector3i(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the linear interpolation between this and another vector
|
* Return the linear interpolation between this and another vector
|
||||||
* @param obj The other vector
|
* @param obj The other vector
|
||||||
* @param ratio The ratio of this to obj (ratio = 0 => return copy of this, ratio=1 => return other)
|
* @param ratio The ratio of this to obj (ratio = 0 => return copy of this, ratio=1 => return other)
|
||||||
* @return New vector containing the value
|
* @return New vector containing the value
|
||||||
*/
|
*/
|
||||||
@ -399,7 +428,7 @@ public record Vector3i(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set each element to the max of the current values and the values of another Vector3i
|
* Set each element to the max of the current values and the values of another Vector3i
|
||||||
* @param obj The other Vector3i to compare with
|
* @param obj The other Vector3i to compare with
|
||||||
*/
|
*/
|
||||||
@CheckReturnValue
|
@CheckReturnValue
|
||||||
public Vector3i max(final Vector3i obj) {
|
public Vector3i max(final Vector3i obj) {
|
||||||
@ -408,7 +437,7 @@ public record Vector3i(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set each element to the min of the current values and the values of another Vector3i
|
* Set each element to the min of the current values and the values of another Vector3i
|
||||||
* @param obj The other Vector3i to compare with
|
* @param obj The other Vector3i to compare with
|
||||||
*/
|
*/
|
||||||
@CheckReturnValue
|
@CheckReturnValue
|
||||||
public Vector3i min(final Vector3i obj) {
|
public Vector3i min(final Vector3i obj) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user