repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
gallandarakhneorg/afc | advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Vector2dfx.java | Vector2dfx.convert | public static Vector2dfx convert(Tuple2D<?> tuple) {
if (tuple instanceof Vector2dfx) {
return (Vector2dfx) tuple;
}
return new Vector2dfx(tuple.getX(), tuple.getY());
} | java | public static Vector2dfx convert(Tuple2D<?> tuple) {
if (tuple instanceof Vector2dfx) {
return (Vector2dfx) tuple;
}
return new Vector2dfx(tuple.getX(), tuple.getY());
} | [
"public",
"static",
"Vector2dfx",
"convert",
"(",
"Tuple2D",
"<",
"?",
">",
"tuple",
")",
"{",
"if",
"(",
"tuple",
"instanceof",
"Vector2dfx",
")",
"{",
"return",
"(",
"Vector2dfx",
")",
"tuple",
";",
"}",
"return",
"new",
"Vector2dfx",
"(",
"tuple",
".",
"getX",
"(",
")",
",",
"tuple",
".",
"getY",
"(",
")",
")",
";",
"}"
] | Convert the given tuple to a real Vector2dfx.
<p>If the given tuple is already a Vector2dfx, it is replied.
@param tuple the tuple.
@return the Vector2dfx.
@since 14.0 | [
"Convert",
"the",
"given",
"tuple",
"to",
"a",
"real",
"Vector2dfx",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Vector2dfx.java#L134-L139 | train |
gallandarakhneorg/afc | core/maths/mathgeom/src/main/java/org/arakhne/afc/math/geometry/d2/d/Point2d.java | Point2d.convert | public static Point2d convert(Tuple2D<?> tuple) {
if (tuple instanceof Point2d) {
return (Point2d) tuple;
}
return new Point2d(tuple.getX(), tuple.getY());
} | java | public static Point2d convert(Tuple2D<?> tuple) {
if (tuple instanceof Point2d) {
return (Point2d) tuple;
}
return new Point2d(tuple.getX(), tuple.getY());
} | [
"public",
"static",
"Point2d",
"convert",
"(",
"Tuple2D",
"<",
"?",
">",
"tuple",
")",
"{",
"if",
"(",
"tuple",
"instanceof",
"Point2d",
")",
"{",
"return",
"(",
"Point2d",
")",
"tuple",
";",
"}",
"return",
"new",
"Point2d",
"(",
"tuple",
".",
"getX",
"(",
")",
",",
"tuple",
".",
"getY",
"(",
")",
")",
";",
"}"
] | Convert the given tuple to a real Point2d.
<p>If the given tuple is already a Point2d, it is replied.
@param tuple the tuple.
@return the Point2d.
@since 14.0 | [
"Convert",
"the",
"given",
"tuple",
"to",
"a",
"real",
"Point2d",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/src/main/java/org/arakhne/afc/math/geometry/d2/d/Point2d.java#L112-L117 | train |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/collections/TableUtils.java | TableUtils.columnTransformerByCell | public static <R, C, V, C2> ImmutableTable<R, C2, V> columnTransformerByCell(
final Table<R, C, V> table,
final Function<Table.Cell<R, C, V>, C2> columnTransformer) {
final ImmutableTable.Builder<R, C2, V> newTable = ImmutableTable.builder();
for(Table.Cell<R, C, V> cell : table.cellSet()) {
C2 col = columnTransformer.apply(cell);
newTable.put(cell.getRowKey(), col, cell.getValue());
}
return newTable.build();
} | java | public static <R, C, V, C2> ImmutableTable<R, C2, V> columnTransformerByCell(
final Table<R, C, V> table,
final Function<Table.Cell<R, C, V>, C2> columnTransformer) {
final ImmutableTable.Builder<R, C2, V> newTable = ImmutableTable.builder();
for(Table.Cell<R, C, V> cell : table.cellSet()) {
C2 col = columnTransformer.apply(cell);
newTable.put(cell.getRowKey(), col, cell.getValue());
}
return newTable.build();
} | [
"public",
"static",
"<",
"R",
",",
"C",
",",
"V",
",",
"C2",
">",
"ImmutableTable",
"<",
"R",
",",
"C2",
",",
"V",
">",
"columnTransformerByCell",
"(",
"final",
"Table",
"<",
"R",
",",
"C",
",",
"V",
">",
"table",
",",
"final",
"Function",
"<",
"Table",
".",
"Cell",
"<",
"R",
",",
"C",
",",
"V",
">",
",",
"C2",
">",
"columnTransformer",
")",
"{",
"final",
"ImmutableTable",
".",
"Builder",
"<",
"R",
",",
"C2",
",",
"V",
">",
"newTable",
"=",
"ImmutableTable",
".",
"builder",
"(",
")",
";",
"for",
"(",
"Table",
".",
"Cell",
"<",
"R",
",",
"C",
",",
"V",
">",
"cell",
":",
"table",
".",
"cellSet",
"(",
")",
")",
"{",
"C2",
"col",
"=",
"columnTransformer",
".",
"apply",
"(",
"cell",
")",
";",
"newTable",
".",
"put",
"(",
"cell",
".",
"getRowKey",
"(",
")",
",",
"col",
",",
"cell",
".",
"getValue",
"(",
")",
")",
";",
"}",
"return",
"newTable",
".",
"build",
"(",
")",
";",
"}"
] | columnTransformer has access to Key, Value information in each Table.Cell
@param table
@param columnTransformer
@param <R>
@param <C>
@param <V>
@param <C2>
@return | [
"columnTransformer",
"has",
"access",
"to",
"Key",
"Value",
"information",
"in",
"each",
"Table",
".",
"Cell"
] | d618652674d647867306e2e4b987a21b7c29c015 | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/collections/TableUtils.java#L52-L61 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/location/GeoLocationUtil.java | GeoLocationUtil.setDistanceEpsilon | public static double setDistanceEpsilon(double newPrecisionValue) {
if ((newPrecisionValue >= 1) || (newPrecisionValue <= 0)) {
throw new IllegalArgumentException();
}
final double old = distancePrecision;
distancePrecision = newPrecisionValue;
return old;
} | java | public static double setDistanceEpsilon(double newPrecisionValue) {
if ((newPrecisionValue >= 1) || (newPrecisionValue <= 0)) {
throw new IllegalArgumentException();
}
final double old = distancePrecision;
distancePrecision = newPrecisionValue;
return old;
} | [
"public",
"static",
"double",
"setDistanceEpsilon",
"(",
"double",
"newPrecisionValue",
")",
"{",
"if",
"(",
"(",
"newPrecisionValue",
">=",
"1",
")",
"||",
"(",
"newPrecisionValue",
"<=",
"0",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"final",
"double",
"old",
"=",
"distancePrecision",
";",
"distancePrecision",
"=",
"newPrecisionValue",
";",
"return",
"old",
";",
"}"
] | Replies the precision used to test a distance value.
@param newPrecisionValue the new precision value (in meters).
@return the old precision value. | [
"Replies",
"the",
"precision",
"used",
"to",
"test",
"a",
"distance",
"value",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/location/GeoLocationUtil.java#L81-L88 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/location/GeoLocationUtil.java | GeoLocationUtil.epsilonEqualsDistance | @Pure
public static boolean epsilonEqualsDistance(double value1, double value2) {
return value1 >= (value2 - distancePrecision) && value1 <= (value2 + distancePrecision);
} | java | @Pure
public static boolean epsilonEqualsDistance(double value1, double value2) {
return value1 >= (value2 - distancePrecision) && value1 <= (value2 + distancePrecision);
} | [
"@",
"Pure",
"public",
"static",
"boolean",
"epsilonEqualsDistance",
"(",
"double",
"value1",
",",
"double",
"value2",
")",
"{",
"return",
"value1",
">=",
"(",
"value2",
"-",
"distancePrecision",
")",
"&&",
"value1",
"<=",
"(",
"value2",
"+",
"distancePrecision",
")",
";",
"}"
] | Replies if the specified distances are approximatively equal.
@param value1 the first value.
@param value2 the second value.
@return <code>true</code> if both values are equal, otherwise <code>false</code> | [
"Replies",
"if",
"the",
"specified",
"distances",
"are",
"approximatively",
"equal",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/location/GeoLocationUtil.java#L143-L146 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/location/GeoLocationUtil.java | GeoLocationUtil.epsilonCompareToDistance | @Pure
public static int epsilonCompareToDistance(double distance1, double distance2) {
final double min = distance2 - distancePrecision;
final double max = distance2 + distancePrecision;
if (distance1 >= min && distance1 <= max) {
return 0;
}
if (distance1 < min) {
return -1;
}
return 1;
} | java | @Pure
public static int epsilonCompareToDistance(double distance1, double distance2) {
final double min = distance2 - distancePrecision;
final double max = distance2 + distancePrecision;
if (distance1 >= min && distance1 <= max) {
return 0;
}
if (distance1 < min) {
return -1;
}
return 1;
} | [
"@",
"Pure",
"public",
"static",
"int",
"epsilonCompareToDistance",
"(",
"double",
"distance1",
",",
"double",
"distance2",
")",
"{",
"final",
"double",
"min",
"=",
"distance2",
"-",
"distancePrecision",
";",
"final",
"double",
"max",
"=",
"distance2",
"+",
"distancePrecision",
";",
"if",
"(",
"distance1",
">=",
"min",
"&&",
"distance1",
"<=",
"max",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"distance1",
"<",
"min",
")",
"{",
"return",
"-",
"1",
";",
"}",
"return",
"1",
";",
"}"
] | Replies if the specified distances are approximatively equal,
less or greater than.
@param distance1 the first distance.
@param distance2 the second distance.
@return a negative value if the parameter <var>distance1</var> is
lower than <var>distance2</var>, a positive if <var>distance1</var>
is greater than <var>distance2</var>, zero if the two parameters
are approximatively equal. | [
"Replies",
"if",
"the",
"specified",
"distances",
"are",
"approximatively",
"equal",
"less",
"or",
"greater",
"than",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/location/GeoLocationUtil.java#L177-L188 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/location/GeoLocationUtil.java | GeoLocationUtil.makeInternalId | @Pure
public static String makeInternalId(float x, float y) {
final StringBuilder buf = new StringBuilder("point"); //$NON-NLS-1$
buf.append(x);
buf.append(';');
buf.append(y);
return Encryption.md5(buf.toString());
} | java | @Pure
public static String makeInternalId(float x, float y) {
final StringBuilder buf = new StringBuilder("point"); //$NON-NLS-1$
buf.append(x);
buf.append(';');
buf.append(y);
return Encryption.md5(buf.toString());
} | [
"@",
"Pure",
"public",
"static",
"String",
"makeInternalId",
"(",
"float",
"x",
",",
"float",
"y",
")",
"{",
"final",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
"\"point\"",
")",
";",
"//$NON-NLS-1$",
"buf",
".",
"append",
"(",
"x",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"buf",
".",
"append",
"(",
"y",
")",
";",
"return",
"Encryption",
".",
"md5",
"(",
"buf",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Compute and replies the internal identifier that may
be used to create a GeoId from the given point.
@param x x coordinate.
@param y y coordinate
@return the internal identifier. | [
"Compute",
"and",
"replies",
"the",
"internal",
"identifier",
"that",
"may",
"be",
"used",
"to",
"create",
"a",
"GeoId",
"from",
"the",
"given",
"point",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/location/GeoLocationUtil.java#L343-L350 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/location/GeoLocationUtil.java | GeoLocationUtil.makeInternalId | @Pure
public static String makeInternalId(UUID uid) {
final StringBuilder buf = new StringBuilder("nowhere(?"); //$NON-NLS-1$
buf.append(uid.toString());
buf.append("?)"); //$NON-NLS-1$
return Encryption.md5(buf.toString());
} | java | @Pure
public static String makeInternalId(UUID uid) {
final StringBuilder buf = new StringBuilder("nowhere(?"); //$NON-NLS-1$
buf.append(uid.toString());
buf.append("?)"); //$NON-NLS-1$
return Encryption.md5(buf.toString());
} | [
"@",
"Pure",
"public",
"static",
"String",
"makeInternalId",
"(",
"UUID",
"uid",
")",
"{",
"final",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
"\"nowhere(?\"",
")",
";",
"//$NON-NLS-1$",
"buf",
".",
"append",
"(",
"uid",
".",
"toString",
"(",
")",
")",
";",
"buf",
".",
"append",
"(",
"\"?)\"",
")",
";",
"//$NON-NLS-1$",
"return",
"Encryption",
".",
"md5",
"(",
"buf",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Compute and replies the internal identifier that may
be used to create a GeoId from the given identifier.
The replied identifier is not geolocalized.
@param uid the identifier
@return the internal identifier. | [
"Compute",
"and",
"replies",
"the",
"internal",
"identifier",
"that",
"may",
"be",
"used",
"to",
"create",
"a",
"GeoId",
"from",
"the",
"given",
"identifier",
".",
"The",
"replied",
"identifier",
"is",
"not",
"geolocalized",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/location/GeoLocationUtil.java#L359-L365 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/location/GeoLocationUtil.java | GeoLocationUtil.makeInternalId | @Pure
public static String makeInternalId(float minx, float miny, float maxx, float maxy) {
final StringBuilder buf = new StringBuilder("rectangle"); //$NON-NLS-1$
buf.append('(');
buf.append(minx);
buf.append(';');
buf.append(miny);
buf.append(")-("); //$NON-NLS-1$
buf.append(maxx);
buf.append(';');
buf.append(maxy);
buf.append(')');
return Encryption.md5(buf.toString());
} | java | @Pure
public static String makeInternalId(float minx, float miny, float maxx, float maxy) {
final StringBuilder buf = new StringBuilder("rectangle"); //$NON-NLS-1$
buf.append('(');
buf.append(minx);
buf.append(';');
buf.append(miny);
buf.append(")-("); //$NON-NLS-1$
buf.append(maxx);
buf.append(';');
buf.append(maxy);
buf.append(')');
return Encryption.md5(buf.toString());
} | [
"@",
"Pure",
"public",
"static",
"String",
"makeInternalId",
"(",
"float",
"minx",
",",
"float",
"miny",
",",
"float",
"maxx",
",",
"float",
"maxy",
")",
"{",
"final",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
"\"rectangle\"",
")",
";",
"//$NON-NLS-1$",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"buf",
".",
"append",
"(",
"minx",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"buf",
".",
"append",
"(",
"miny",
")",
";",
"buf",
".",
"append",
"(",
"\")-(\"",
")",
";",
"//$NON-NLS-1$",
"buf",
".",
"append",
"(",
"maxx",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"buf",
".",
"append",
"(",
"maxy",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"return",
"Encryption",
".",
"md5",
"(",
"buf",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Compute and replies the internal identifier that may
be used to create a GeoId from the given rectangle.
@param minx minimum x coordinate of the bounding rectangle.
@param miny minimum y coordinate of the bounding rectangle.
@param maxx maximum x coordinate of the bounding rectangle.
@param maxy maximum y coordinate of the bounding rectangle.
@return the internal identifier. | [
"Compute",
"and",
"replies",
"the",
"internal",
"identifier",
"that",
"may",
"be",
"used",
"to",
"create",
"a",
"GeoId",
"from",
"the",
"given",
"rectangle",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/location/GeoLocationUtil.java#L376-L389 | train |
agmip/translator-dssat | src/main/java/org/agmip/translators/dssat/DssatCRIDHelper.java | DssatCRIDHelper.get2BitCrid | public static String get2BitCrid(String str) {
if (str != null) {
String crid = LookupCodes.lookupCode("CRID", str, "DSSAT");
if (crid.equals(str) && crid.length() > 2) {
crid = def2BitVal;
}
return crid.toUpperCase();
} else {
return def2BitVal;
}
// if (str == null) {
// return def2BitVal;
// } else if (str.length() == 2) {
// return str;
// }
// String ret = crids.get(str);
// if (ret == null || ret.equals("")) {
// return str;
// } else {
// return ret;
// }
} | java | public static String get2BitCrid(String str) {
if (str != null) {
String crid = LookupCodes.lookupCode("CRID", str, "DSSAT");
if (crid.equals(str) && crid.length() > 2) {
crid = def2BitVal;
}
return crid.toUpperCase();
} else {
return def2BitVal;
}
// if (str == null) {
// return def2BitVal;
// } else if (str.length() == 2) {
// return str;
// }
// String ret = crids.get(str);
// if (ret == null || ret.equals("")) {
// return str;
// } else {
// return ret;
// }
} | [
"public",
"static",
"String",
"get2BitCrid",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
"!=",
"null",
")",
"{",
"String",
"crid",
"=",
"LookupCodes",
".",
"lookupCode",
"(",
"\"CRID\"",
",",
"str",
",",
"\"DSSAT\"",
")",
";",
"if",
"(",
"crid",
".",
"equals",
"(",
"str",
")",
"&&",
"crid",
".",
"length",
"(",
")",
">",
"2",
")",
"{",
"crid",
"=",
"def2BitVal",
";",
"}",
"return",
"crid",
".",
"toUpperCase",
"(",
")",
";",
"}",
"else",
"{",
"return",
"def2BitVal",
";",
"}",
"// if (str == null) {",
"// return def2BitVal;",
"// } else if (str.length() == 2) {",
"// return str;",
"// }",
"// String ret = crids.get(str);",
"// if (ret == null || ret.equals(\"\")) {",
"// return str;",
"// } else {",
"// return ret;",
"// }",
"}"
] | get 2-bit version of crop id by given string
@param str input string of 3-bit crid
@return 2-bit version of crop id | [
"get",
"2",
"-",
"bit",
"version",
"of",
"crop",
"id",
"by",
"given",
"string"
] | 4be61d998f106eb7234ea8701b63c3746ae688f4 | https://github.com/agmip/translator-dssat/blob/4be61d998f106eb7234ea8701b63c3746ae688f4/src/main/java/org/agmip/translators/dssat/DssatCRIDHelper.java#L105-L126 | train |
agmip/translator-dssat | src/main/java/org/agmip/translators/dssat/DssatCRIDHelper.java | DssatCRIDHelper.get3BitCrid | public static String get3BitCrid(String str) {
if (str != null) {
// return LookupCodes.modelLookupCode("DSSAT", "CRID", str).toUpperCase();
return LookupCodes.lookupCode("CRID", str, "code", "DSSAT").toUpperCase();
} else {
return def3BitVal;
}
// if (str == null || !crids.containsValue(str)) {
// return def3BitVal;
// } else if (str.length() == 3) {
// return str;
// }
// for (String key : crids.keySet()) {
// if (str.equals(crids.get(key))) {
// return key;
// }
// }
// return str;
} | java | public static String get3BitCrid(String str) {
if (str != null) {
// return LookupCodes.modelLookupCode("DSSAT", "CRID", str).toUpperCase();
return LookupCodes.lookupCode("CRID", str, "code", "DSSAT").toUpperCase();
} else {
return def3BitVal;
}
// if (str == null || !crids.containsValue(str)) {
// return def3BitVal;
// } else if (str.length() == 3) {
// return str;
// }
// for (String key : crids.keySet()) {
// if (str.equals(crids.get(key))) {
// return key;
// }
// }
// return str;
} | [
"public",
"static",
"String",
"get3BitCrid",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
"!=",
"null",
")",
"{",
"// return LookupCodes.modelLookupCode(\"DSSAT\", \"CRID\", str).toUpperCase();",
"return",
"LookupCodes",
".",
"lookupCode",
"(",
"\"CRID\"",
",",
"str",
",",
"\"code\"",
",",
"\"DSSAT\"",
")",
".",
"toUpperCase",
"(",
")",
";",
"}",
"else",
"{",
"return",
"def3BitVal",
";",
"}",
"// if (str == null || !crids.containsValue(str)) {",
"// return def3BitVal;",
"// } else if (str.length() == 3) {",
"// return str;",
"// }",
"// for (String key : crids.keySet()) {",
"// if (str.equals(crids.get(key))) {",
"// return key;",
"// }",
"// }",
"// return str;",
"}"
] | get 3-bit version of crop id by given string
@param str input string of 2-bit crop id
@return 3-bit version of crop id | [
"get",
"3",
"-",
"bit",
"version",
"of",
"crop",
"id",
"by",
"given",
"string"
] | 4be61d998f106eb7234ea8701b63c3746ae688f4 | https://github.com/agmip/translator-dssat/blob/4be61d998f106eb7234ea8701b63c3746ae688f4/src/main/java/org/agmip/translators/dssat/DssatCRIDHelper.java#L134-L152 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/locale/Locale.java | Locale.decodeString | private static CharBuffer decodeString(byte[] bytes, Charset charset, int referenceLength) {
try {
final Charset autodetectedCharset;
final CharsetDecoder decoder = charset.newDecoder();
final CharBuffer buffer = decoder.decode(ByteBuffer.wrap(bytes));
if ((decoder.isAutoDetecting())
&& (decoder.isCharsetDetected())) {
autodetectedCharset = decoder.detectedCharset();
if (charset.contains(autodetectedCharset)) {
buffer.position(0);
if ((referenceLength >= 0) && (buffer.remaining() == referenceLength)) {
return buffer;
}
return null;
}
}
// Apply a proprietary detection
buffer.position(0);
char c;
int type;
while (buffer.hasRemaining()) {
c = buffer.get();
type = Character.getType(c);
switch (type) {
case Character.UNASSIGNED:
case Character.CONTROL:
case Character.FORMAT:
case Character.PRIVATE_USE:
case Character.SURROGATE:
// Character not supported?
return null;
default:
}
}
buffer.position(0);
if ((referenceLength >= 0) && (buffer.remaining() == referenceLength)) {
return buffer;
}
} catch (CharacterCodingException e) {
//
}
return null;
} | java | private static CharBuffer decodeString(byte[] bytes, Charset charset, int referenceLength) {
try {
final Charset autodetectedCharset;
final CharsetDecoder decoder = charset.newDecoder();
final CharBuffer buffer = decoder.decode(ByteBuffer.wrap(bytes));
if ((decoder.isAutoDetecting())
&& (decoder.isCharsetDetected())) {
autodetectedCharset = decoder.detectedCharset();
if (charset.contains(autodetectedCharset)) {
buffer.position(0);
if ((referenceLength >= 0) && (buffer.remaining() == referenceLength)) {
return buffer;
}
return null;
}
}
// Apply a proprietary detection
buffer.position(0);
char c;
int type;
while (buffer.hasRemaining()) {
c = buffer.get();
type = Character.getType(c);
switch (type) {
case Character.UNASSIGNED:
case Character.CONTROL:
case Character.FORMAT:
case Character.PRIVATE_USE:
case Character.SURROGATE:
// Character not supported?
return null;
default:
}
}
buffer.position(0);
if ((referenceLength >= 0) && (buffer.remaining() == referenceLength)) {
return buffer;
}
} catch (CharacterCodingException e) {
//
}
return null;
} | [
"private",
"static",
"CharBuffer",
"decodeString",
"(",
"byte",
"[",
"]",
"bytes",
",",
"Charset",
"charset",
",",
"int",
"referenceLength",
")",
"{",
"try",
"{",
"final",
"Charset",
"autodetectedCharset",
";",
"final",
"CharsetDecoder",
"decoder",
"=",
"charset",
".",
"newDecoder",
"(",
")",
";",
"final",
"CharBuffer",
"buffer",
"=",
"decoder",
".",
"decode",
"(",
"ByteBuffer",
".",
"wrap",
"(",
"bytes",
")",
")",
";",
"if",
"(",
"(",
"decoder",
".",
"isAutoDetecting",
"(",
")",
")",
"&&",
"(",
"decoder",
".",
"isCharsetDetected",
"(",
")",
")",
")",
"{",
"autodetectedCharset",
"=",
"decoder",
".",
"detectedCharset",
"(",
")",
";",
"if",
"(",
"charset",
".",
"contains",
"(",
"autodetectedCharset",
")",
")",
"{",
"buffer",
".",
"position",
"(",
"0",
")",
";",
"if",
"(",
"(",
"referenceLength",
">=",
"0",
")",
"&&",
"(",
"buffer",
".",
"remaining",
"(",
")",
"==",
"referenceLength",
")",
")",
"{",
"return",
"buffer",
";",
"}",
"return",
"null",
";",
"}",
"}",
"// Apply a proprietary detection",
"buffer",
".",
"position",
"(",
"0",
")",
";",
"char",
"c",
";",
"int",
"type",
";",
"while",
"(",
"buffer",
".",
"hasRemaining",
"(",
")",
")",
"{",
"c",
"=",
"buffer",
".",
"get",
"(",
")",
";",
"type",
"=",
"Character",
".",
"getType",
"(",
"c",
")",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"Character",
".",
"UNASSIGNED",
":",
"case",
"Character",
".",
"CONTROL",
":",
"case",
"Character",
".",
"FORMAT",
":",
"case",
"Character",
".",
"PRIVATE_USE",
":",
"case",
"Character",
".",
"SURROGATE",
":",
"// Character not supported?",
"return",
"null",
";",
"default",
":",
"}",
"}",
"buffer",
".",
"position",
"(",
"0",
")",
";",
"if",
"(",
"(",
"referenceLength",
">=",
"0",
")",
"&&",
"(",
"buffer",
".",
"remaining",
"(",
")",
"==",
"referenceLength",
")",
")",
"{",
"return",
"buffer",
";",
"}",
"}",
"catch",
"(",
"CharacterCodingException",
"e",
")",
"{",
"//",
"}",
"return",
"null",
";",
"}"
] | Decode the specified array of bytes with the specified charset.
@param bytes is the array of bytes to decode.
@param charset is the charset to use for decoding
@param referenceLength is the length of the attempted result. If negative, this parameter is ignored.
@return the decoded string with the appropriate charset set,
or <code>null</code> if the specified charset cannot be
used to decode all the characters inside the byte array. | [
"Decode",
"the",
"specified",
"array",
"of",
"bytes",
"with",
"the",
"specified",
"charset",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/locale/Locale.java#L467-L509 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/maplayer/ArrayMapElementLayer.java | ArrayMapElementLayer.iterator | @Override
@Pure
public Iterator<E> iterator(Rectangle2afp<?, ?, ?, ?, ?, ?> bounds) {
return new BoundedElementIterator<>(bounds, iterator());
} | java | @Override
@Pure
public Iterator<E> iterator(Rectangle2afp<?, ?, ?, ?, ?, ?> bounds) {
return new BoundedElementIterator<>(bounds, iterator());
} | [
"@",
"Override",
"@",
"Pure",
"public",
"Iterator",
"<",
"E",
">",
"iterator",
"(",
"Rectangle2afp",
"<",
"?",
",",
"?",
",",
"?",
",",
"?",
",",
"?",
",",
"?",
">",
"bounds",
")",
"{",
"return",
"new",
"BoundedElementIterator",
"<>",
"(",
"bounds",
",",
"iterator",
"(",
")",
")",
";",
"}"
] | Iterates on the elements that intersect the specified bounds.
@param bounds is the rectangle inside which the replied elements must be located | [
"Iterates",
"on",
"the",
"elements",
"that",
"intersect",
"the",
"specified",
"bounds",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/maplayer/ArrayMapElementLayer.java#L261-L265 | train |
agmip/translator-dssat | src/main/java/org/agmip/translators/dssat/DssatTFileInput.java | DssatTFileInput.readFile | @Override
protected HashMap readFile(HashMap brMap) throws IOException {
HashMap ret = new HashMap();
ArrayList<HashMap> expArr = new ArrayList<HashMap>();
HashMap<String, HashMap> files = readObvData(brMap);
// compressData(file);
ArrayList<HashMap> obvData;
HashMap obv;
HashMap expData;
for (String exname : files.keySet()) {
obvData = (ArrayList) files.get(exname).get(obvDataKey);
for (HashMap obvSub : obvData) {
expData = new HashMap();
obv = new HashMap();
copyItem(expData, files.get(exname), "exname");
copyItem(expData, files.get(exname), "crid");
copyItem(expData, files.get(exname), "local_name");
expData.put(jsonKey, obv);
obv.put(obvFileKey, obvSub.get(obvDataKey));
expArr.add(expData);
}
}
// remove index variables
ArrayList idNames = new ArrayList();
idNames.add("trno_t");
removeIndex(expArr, idNames);
ret.put("experiments", expArr);
return ret;
} | java | @Override
protected HashMap readFile(HashMap brMap) throws IOException {
HashMap ret = new HashMap();
ArrayList<HashMap> expArr = new ArrayList<HashMap>();
HashMap<String, HashMap> files = readObvData(brMap);
// compressData(file);
ArrayList<HashMap> obvData;
HashMap obv;
HashMap expData;
for (String exname : files.keySet()) {
obvData = (ArrayList) files.get(exname).get(obvDataKey);
for (HashMap obvSub : obvData) {
expData = new HashMap();
obv = new HashMap();
copyItem(expData, files.get(exname), "exname");
copyItem(expData, files.get(exname), "crid");
copyItem(expData, files.get(exname), "local_name");
expData.put(jsonKey, obv);
obv.put(obvFileKey, obvSub.get(obvDataKey));
expArr.add(expData);
}
}
// remove index variables
ArrayList idNames = new ArrayList();
idNames.add("trno_t");
removeIndex(expArr, idNames);
ret.put("experiments", expArr);
return ret;
} | [
"@",
"Override",
"protected",
"HashMap",
"readFile",
"(",
"HashMap",
"brMap",
")",
"throws",
"IOException",
"{",
"HashMap",
"ret",
"=",
"new",
"HashMap",
"(",
")",
";",
"ArrayList",
"<",
"HashMap",
">",
"expArr",
"=",
"new",
"ArrayList",
"<",
"HashMap",
">",
"(",
")",
";",
"HashMap",
"<",
"String",
",",
"HashMap",
">",
"files",
"=",
"readObvData",
"(",
"brMap",
")",
";",
"// compressData(file);",
"ArrayList",
"<",
"HashMap",
">",
"obvData",
";",
"HashMap",
"obv",
";",
"HashMap",
"expData",
";",
"for",
"(",
"String",
"exname",
":",
"files",
".",
"keySet",
"(",
")",
")",
"{",
"obvData",
"=",
"(",
"ArrayList",
")",
"files",
".",
"get",
"(",
"exname",
")",
".",
"get",
"(",
"obvDataKey",
")",
";",
"for",
"(",
"HashMap",
"obvSub",
":",
"obvData",
")",
"{",
"expData",
"=",
"new",
"HashMap",
"(",
")",
";",
"obv",
"=",
"new",
"HashMap",
"(",
")",
";",
"copyItem",
"(",
"expData",
",",
"files",
".",
"get",
"(",
"exname",
")",
",",
"\"exname\"",
")",
";",
"copyItem",
"(",
"expData",
",",
"files",
".",
"get",
"(",
"exname",
")",
",",
"\"crid\"",
")",
";",
"copyItem",
"(",
"expData",
",",
"files",
".",
"get",
"(",
"exname",
")",
",",
"\"local_name\"",
")",
";",
"expData",
".",
"put",
"(",
"jsonKey",
",",
"obv",
")",
";",
"obv",
".",
"put",
"(",
"obvFileKey",
",",
"obvSub",
".",
"get",
"(",
"obvDataKey",
")",
")",
";",
"expArr",
".",
"add",
"(",
"expData",
")",
";",
"}",
"}",
"// remove index variables",
"ArrayList",
"idNames",
"=",
"new",
"ArrayList",
"(",
")",
";",
"idNames",
".",
"add",
"(",
"\"trno_t\"",
")",
";",
"removeIndex",
"(",
"expArr",
",",
"idNames",
")",
";",
"ret",
".",
"put",
"(",
"\"experiments\"",
",",
"expArr",
")",
";",
"return",
"ret",
";",
"}"
] | DSSAT TFile Data input method for Controller using
@param brMap The holder for BufferReader objects for all files
@return result data holder object
@throws java.io.IOException | [
"DSSAT",
"TFile",
"Data",
"input",
"method",
"for",
"Controller",
"using"
] | 4be61d998f106eb7234ea8701b63c3746ae688f4 | https://github.com/agmip/translator-dssat/blob/4be61d998f106eb7234ea8701b63c3746ae688f4/src/main/java/org/agmip/translators/dssat/DssatTFileInput.java#L38-L70 | train |
digitalfondue/stampo | src/main/java/ch/digitalfondue/stampo/processor/FileResourceProcessor.java | FileResourceProcessor.normalizeOutputPath | public Path normalizeOutputPath(FileResource resource) {
Path resourcePath = resource.getPath();
Path rel = Optional.ofNullable((contentDir.relativize(resourcePath)).getParent())//
.orElseGet(() -> resourcePath.getFileSystem().getPath(""));
String finalOutput = rel.resolve(finalOutputName(resource)).toString();
// outputDir and contentDir can have different underlying FileSystems
return outputDir.resolve(finalOutput);
} | java | public Path normalizeOutputPath(FileResource resource) {
Path resourcePath = resource.getPath();
Path rel = Optional.ofNullable((contentDir.relativize(resourcePath)).getParent())//
.orElseGet(() -> resourcePath.getFileSystem().getPath(""));
String finalOutput = rel.resolve(finalOutputName(resource)).toString();
// outputDir and contentDir can have different underlying FileSystems
return outputDir.resolve(finalOutput);
} | [
"public",
"Path",
"normalizeOutputPath",
"(",
"FileResource",
"resource",
")",
"{",
"Path",
"resourcePath",
"=",
"resource",
".",
"getPath",
"(",
")",
";",
"Path",
"rel",
"=",
"Optional",
".",
"ofNullable",
"(",
"(",
"contentDir",
".",
"relativize",
"(",
"resourcePath",
")",
")",
".",
"getParent",
"(",
")",
")",
"//",
".",
"orElseGet",
"(",
"(",
")",
"->",
"resourcePath",
".",
"getFileSystem",
"(",
")",
".",
"getPath",
"(",
"\"\"",
")",
")",
";",
"String",
"finalOutput",
"=",
"rel",
".",
"resolve",
"(",
"finalOutputName",
"(",
"resource",
")",
")",
".",
"toString",
"(",
")",
";",
"// outputDir and contentDir can have different underlying FileSystems",
"return",
"outputDir",
".",
"resolve",
"(",
"finalOutput",
")",
";",
"}"
] | Generate the output path given the resource and the output dir.
E.g.: /content/test/test.html -> /output/test/test.html
@param resource
@return | [
"Generate",
"the",
"output",
"path",
"given",
"the",
"resource",
"and",
"the",
"output",
"dir",
"."
] | 5a41f20acd9211cf3951c30d0e0825994ae95573 | https://github.com/digitalfondue/stampo/blob/5a41f20acd9211cf3951c30d0e0825994ae95573/src/main/java/ch/digitalfondue/stampo/processor/FileResourceProcessor.java#L184-L195 | train |
gallandarakhneorg/afc | core/util/src/main/java/org/arakhne/afc/progress/ProgressionConsoleMonitor.java | ProgressionConsoleMonitor.setModel | public void setModel(Progression model) {
this.model.removeProgressionListener(new WeakListener(this, this.model));
if (model == null) {
this.model = new DefaultProgression();
} else {
this.model = model;
}
this.previousValue = this.model.getValue();
this.model.addProgressionListener(new WeakListener(this, this.model));
} | java | public void setModel(Progression model) {
this.model.removeProgressionListener(new WeakListener(this, this.model));
if (model == null) {
this.model = new DefaultProgression();
} else {
this.model = model;
}
this.previousValue = this.model.getValue();
this.model.addProgressionListener(new WeakListener(this, this.model));
} | [
"public",
"void",
"setModel",
"(",
"Progression",
"model",
")",
"{",
"this",
".",
"model",
".",
"removeProgressionListener",
"(",
"new",
"WeakListener",
"(",
"this",
",",
"this",
".",
"model",
")",
")",
";",
"if",
"(",
"model",
"==",
"null",
")",
"{",
"this",
".",
"model",
"=",
"new",
"DefaultProgression",
"(",
")",
";",
"}",
"else",
"{",
"this",
".",
"model",
"=",
"model",
";",
"}",
"this",
".",
"previousValue",
"=",
"this",
".",
"model",
".",
"getValue",
"(",
")",
";",
"this",
".",
"model",
".",
"addProgressionListener",
"(",
"new",
"WeakListener",
"(",
"this",
",",
"this",
".",
"model",
")",
")",
";",
"}"
] | Change the task progression model.
@param model - the task progression model. | [
"Change",
"the",
"task",
"progression",
"model",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/util/src/main/java/org/arakhne/afc/progress/ProgressionConsoleMonitor.java#L69-L78 | train |
gallandarakhneorg/afc | core/util/src/main/java/org/arakhne/afc/progress/ProgressionConsoleMonitor.java | ProgressionConsoleMonitor.buildMessage | @SuppressWarnings("static-method")
protected String buildMessage(double progress, String comment, boolean isRoot, boolean isFinished,
NumberFormat numberFormat) {
final StringBuilder txt = new StringBuilder();
txt.append('[');
txt.append(numberFormat.format(progress));
txt.append("] "); //$NON-NLS-1$
if (comment != null) {
txt.append(comment);
}
return txt.toString();
} | java | @SuppressWarnings("static-method")
protected String buildMessage(double progress, String comment, boolean isRoot, boolean isFinished,
NumberFormat numberFormat) {
final StringBuilder txt = new StringBuilder();
txt.append('[');
txt.append(numberFormat.format(progress));
txt.append("] "); //$NON-NLS-1$
if (comment != null) {
txt.append(comment);
}
return txt.toString();
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"String",
"buildMessage",
"(",
"double",
"progress",
",",
"String",
"comment",
",",
"boolean",
"isRoot",
",",
"boolean",
"isFinished",
",",
"NumberFormat",
"numberFormat",
")",
"{",
"final",
"StringBuilder",
"txt",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"txt",
".",
"append",
"(",
"'",
"'",
")",
";",
"txt",
".",
"append",
"(",
"numberFormat",
".",
"format",
"(",
"progress",
")",
")",
";",
"txt",
".",
"append",
"(",
"\"] \"",
")",
";",
"//$NON-NLS-1$",
"if",
"(",
"comment",
"!=",
"null",
")",
"{",
"txt",
".",
"append",
"(",
"comment",
")",
";",
"}",
"return",
"txt",
".",
"toString",
"(",
")",
";",
"}"
] | Build the logging message from the given data.
This function is defined for enabling overriding in sub classes.
@param progress - progression indicator between 0 and 1.
@param comment - associated comment.
@param isRoot - indicates if the progression model is a root model.
@param isFinished - indicates if the task is finished.
@param numberFormat - instance of the number formatter.
@return the message. | [
"Build",
"the",
"logging",
"message",
"from",
"the",
"given",
"data",
".",
"This",
"function",
"is",
"defined",
"for",
"enabling",
"overriding",
"in",
"sub",
"classes",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/util/src/main/java/org/arakhne/afc/progress/ProgressionConsoleMonitor.java#L128-L139 | train |
gallandarakhneorg/afc | core/maths/mathtree/src/main/java/org/arakhne/afc/math/tree/node/TernaryTreeNode.java | TernaryTreeNode.setLeftChild | public boolean setLeftChild(N newChild) {
final N oldChild = this.left;
if (oldChild == newChild) {
return false;
}
if (oldChild != null) {
oldChild.setParentNodeReference(null, true);
--this.notNullChildCount;
firePropertyChildRemoved(0, oldChild);
}
if (newChild != null) {
final N oldParent = newChild.getParentNode();
if (oldParent != this) {
newChild.removeFromParent();
}
}
this.left = newChild;
if (newChild != null) {
newChild.setParentNodeReference(toN(), true);
++this.notNullChildCount;
firePropertyChildAdded(0, newChild);
}
return true;
} | java | public boolean setLeftChild(N newChild) {
final N oldChild = this.left;
if (oldChild == newChild) {
return false;
}
if (oldChild != null) {
oldChild.setParentNodeReference(null, true);
--this.notNullChildCount;
firePropertyChildRemoved(0, oldChild);
}
if (newChild != null) {
final N oldParent = newChild.getParentNode();
if (oldParent != this) {
newChild.removeFromParent();
}
}
this.left = newChild;
if (newChild != null) {
newChild.setParentNodeReference(toN(), true);
++this.notNullChildCount;
firePropertyChildAdded(0, newChild);
}
return true;
} | [
"public",
"boolean",
"setLeftChild",
"(",
"N",
"newChild",
")",
"{",
"final",
"N",
"oldChild",
"=",
"this",
".",
"left",
";",
"if",
"(",
"oldChild",
"==",
"newChild",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"oldChild",
"!=",
"null",
")",
"{",
"oldChild",
".",
"setParentNodeReference",
"(",
"null",
",",
"true",
")",
";",
"--",
"this",
".",
"notNullChildCount",
";",
"firePropertyChildRemoved",
"(",
"0",
",",
"oldChild",
")",
";",
"}",
"if",
"(",
"newChild",
"!=",
"null",
")",
"{",
"final",
"N",
"oldParent",
"=",
"newChild",
".",
"getParentNode",
"(",
")",
";",
"if",
"(",
"oldParent",
"!=",
"this",
")",
"{",
"newChild",
".",
"removeFromParent",
"(",
")",
";",
"}",
"}",
"this",
".",
"left",
"=",
"newChild",
";",
"if",
"(",
"newChild",
"!=",
"null",
")",
"{",
"newChild",
".",
"setParentNodeReference",
"(",
"toN",
"(",
")",
",",
"true",
")",
";",
"++",
"this",
".",
"notNullChildCount",
";",
"firePropertyChildAdded",
"(",
"0",
",",
"newChild",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Set the left child of this node.
@param newChild the new child.
@return <code>true</code> on success, otherwise <code>false</code> | [
"Set",
"the",
"left",
"child",
"of",
"this",
"node",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathtree/src/main/java/org/arakhne/afc/math/tree/node/TernaryTreeNode.java#L213-L241 | train |
gallandarakhneorg/afc | core/maths/mathtree/src/main/java/org/arakhne/afc/math/tree/node/TernaryTreeNode.java | TernaryTreeNode.setMiddleChild | public boolean setMiddleChild(N newChild) {
final N oldChild = this.middle;
if (oldChild == newChild) {
return false;
}
if (oldChild != null) {
oldChild.setParentNodeReference(null, true);
--this.notNullChildCount;
firePropertyChildRemoved(1, oldChild);
}
if (newChild != null) {
final N oldParent = newChild.getParentNode();
if (oldParent != this) {
newChild.removeFromParent();
}
}
this.middle = newChild;
if (newChild != null) {
newChild.setParentNodeReference(toN(), true);
++this.notNullChildCount;
firePropertyChildAdded(1, newChild);
}
return true;
} | java | public boolean setMiddleChild(N newChild) {
final N oldChild = this.middle;
if (oldChild == newChild) {
return false;
}
if (oldChild != null) {
oldChild.setParentNodeReference(null, true);
--this.notNullChildCount;
firePropertyChildRemoved(1, oldChild);
}
if (newChild != null) {
final N oldParent = newChild.getParentNode();
if (oldParent != this) {
newChild.removeFromParent();
}
}
this.middle = newChild;
if (newChild != null) {
newChild.setParentNodeReference(toN(), true);
++this.notNullChildCount;
firePropertyChildAdded(1, newChild);
}
return true;
} | [
"public",
"boolean",
"setMiddleChild",
"(",
"N",
"newChild",
")",
"{",
"final",
"N",
"oldChild",
"=",
"this",
".",
"middle",
";",
"if",
"(",
"oldChild",
"==",
"newChild",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"oldChild",
"!=",
"null",
")",
"{",
"oldChild",
".",
"setParentNodeReference",
"(",
"null",
",",
"true",
")",
";",
"--",
"this",
".",
"notNullChildCount",
";",
"firePropertyChildRemoved",
"(",
"1",
",",
"oldChild",
")",
";",
"}",
"if",
"(",
"newChild",
"!=",
"null",
")",
"{",
"final",
"N",
"oldParent",
"=",
"newChild",
".",
"getParentNode",
"(",
")",
";",
"if",
"(",
"oldParent",
"!=",
"this",
")",
"{",
"newChild",
".",
"removeFromParent",
"(",
")",
";",
"}",
"}",
"this",
".",
"middle",
"=",
"newChild",
";",
"if",
"(",
"newChild",
"!=",
"null",
")",
"{",
"newChild",
".",
"setParentNodeReference",
"(",
"toN",
"(",
")",
",",
"true",
")",
";",
"++",
"this",
".",
"notNullChildCount",
";",
"firePropertyChildAdded",
"(",
"1",
",",
"newChild",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Set the middle child of this node.
@param newChild the new child.
@return <code>true</code> on success, otherwise <code>false</code> | [
"Set",
"the",
"middle",
"child",
"of",
"this",
"node",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathtree/src/main/java/org/arakhne/afc/math/tree/node/TernaryTreeNode.java#L257-L285 | train |
gallandarakhneorg/afc | core/maths/mathtree/src/main/java/org/arakhne/afc/math/tree/node/TernaryTreeNode.java | TernaryTreeNode.hasChild | @Pure
public boolean hasChild(N potentialChild) {
if ((this.left == potentialChild) || (this.middle == potentialChild) || (this.right == potentialChild)) {
return true;
}
return false;
} | java | @Pure
public boolean hasChild(N potentialChild) {
if ((this.left == potentialChild) || (this.middle == potentialChild) || (this.right == potentialChild)) {
return true;
}
return false;
} | [
"@",
"Pure",
"public",
"boolean",
"hasChild",
"(",
"N",
"potentialChild",
")",
"{",
"if",
"(",
"(",
"this",
".",
"left",
"==",
"potentialChild",
")",
"||",
"(",
"this",
".",
"middle",
"==",
"potentialChild",
")",
"||",
"(",
"this",
".",
"right",
"==",
"potentialChild",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Returns true if the specified node is effectively a child of this node, false otherwise.
@param potentialChild - the node to test
@return a boolean, true if the specified node is effectively a child of this node, false otherwise | [
"Returns",
"true",
"if",
"the",
"specified",
"node",
"is",
"effectively",
"a",
"child",
"of",
"this",
"node",
"false",
"otherwise",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathtree/src/main/java/org/arakhne/afc/math/tree/node/TernaryTreeNode.java#L434-L440 | train |
gallandarakhneorg/afc | core/maths/mathtree/src/main/java/org/arakhne/afc/math/tree/node/TernaryTreeNode.java | TernaryTreeNode.getHeights | @Override
protected void getHeights(int currentHeight, List<Integer> heights) {
if (isLeaf()) {
heights.add(new Integer(currentHeight));
} else {
if (this.left != null) {
this.left.getHeights(currentHeight + 1, heights);
}
if (this.middle != null) {
this.middle.getHeights(currentHeight + 1, heights);
}
if (this.right != null) {
this.right.getHeights(currentHeight + 1, heights);
}
}
} | java | @Override
protected void getHeights(int currentHeight, List<Integer> heights) {
if (isLeaf()) {
heights.add(new Integer(currentHeight));
} else {
if (this.left != null) {
this.left.getHeights(currentHeight + 1, heights);
}
if (this.middle != null) {
this.middle.getHeights(currentHeight + 1, heights);
}
if (this.right != null) {
this.right.getHeights(currentHeight + 1, heights);
}
}
} | [
"@",
"Override",
"protected",
"void",
"getHeights",
"(",
"int",
"currentHeight",
",",
"List",
"<",
"Integer",
">",
"heights",
")",
"{",
"if",
"(",
"isLeaf",
"(",
")",
")",
"{",
"heights",
".",
"add",
"(",
"new",
"Integer",
"(",
"currentHeight",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"this",
".",
"left",
"!=",
"null",
")",
"{",
"this",
".",
"left",
".",
"getHeights",
"(",
"currentHeight",
"+",
"1",
",",
"heights",
")",
";",
"}",
"if",
"(",
"this",
".",
"middle",
"!=",
"null",
")",
"{",
"this",
".",
"middle",
".",
"getHeights",
"(",
"currentHeight",
"+",
"1",
",",
"heights",
")",
";",
"}",
"if",
"(",
"this",
".",
"right",
"!=",
"null",
")",
"{",
"this",
".",
"right",
".",
"getHeights",
"(",
"currentHeight",
"+",
"1",
",",
"heights",
")",
";",
"}",
"}",
"}"
] | Replies the heights of all the leaf nodes.
The order of the heights is given by a depth-first iteration.
@param currentHeight is the current height of this node.
@param heights is the list of heights to fill | [
"Replies",
"the",
"heights",
"of",
"all",
"the",
"leaf",
"nodes",
".",
"The",
"order",
"of",
"the",
"heights",
"is",
"given",
"by",
"a",
"depth",
"-",
"first",
"iteration",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathtree/src/main/java/org/arakhne/afc/math/tree/node/TernaryTreeNode.java#L481-L496 | train |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/files/SplitCorpus.java | SplitCorpus.splitToNChunks | private static Iterable<List<Map.Entry<Symbol, File>>> splitToNChunks(
final ImmutableMap<Symbol, File> inputMap, int numChunks) {
checkArgument(numChunks > 0);
final List<Map.Entry<Symbol, File>> emptyChunk = ImmutableList.of();
if (inputMap.isEmpty()) {
return Collections.nCopies(numChunks, emptyChunk);
}
final int chunkSize = IntMath.divide(inputMap.size(), numChunks, RoundingMode.UP);
final ImmutableList<List<Map.Entry<Symbol, File>>> chunks =
ImmutableList.copyOf(splitToChunksOfFixedSize(inputMap, chunkSize));
if (chunks.size() == numChunks) {
return chunks;
} else {
// there weren't enough elements to make the desired number of chunks, so we need to
// pad with empty chunks
final int shortage = numChunks - chunks.size();
final List<List<Map.Entry<Symbol, File>>> padding = Collections.nCopies(shortage, emptyChunk);
return Iterables.concat(chunks, padding);
}
} | java | private static Iterable<List<Map.Entry<Symbol, File>>> splitToNChunks(
final ImmutableMap<Symbol, File> inputMap, int numChunks) {
checkArgument(numChunks > 0);
final List<Map.Entry<Symbol, File>> emptyChunk = ImmutableList.of();
if (inputMap.isEmpty()) {
return Collections.nCopies(numChunks, emptyChunk);
}
final int chunkSize = IntMath.divide(inputMap.size(), numChunks, RoundingMode.UP);
final ImmutableList<List<Map.Entry<Symbol, File>>> chunks =
ImmutableList.copyOf(splitToChunksOfFixedSize(inputMap, chunkSize));
if (chunks.size() == numChunks) {
return chunks;
} else {
// there weren't enough elements to make the desired number of chunks, so we need to
// pad with empty chunks
final int shortage = numChunks - chunks.size();
final List<List<Map.Entry<Symbol, File>>> padding = Collections.nCopies(shortage, emptyChunk);
return Iterables.concat(chunks, padding);
}
} | [
"private",
"static",
"Iterable",
"<",
"List",
"<",
"Map",
".",
"Entry",
"<",
"Symbol",
",",
"File",
">",
">",
">",
"splitToNChunks",
"(",
"final",
"ImmutableMap",
"<",
"Symbol",
",",
"File",
">",
"inputMap",
",",
"int",
"numChunks",
")",
"{",
"checkArgument",
"(",
"numChunks",
">",
"0",
")",
";",
"final",
"List",
"<",
"Map",
".",
"Entry",
"<",
"Symbol",
",",
"File",
">",
">",
"emptyChunk",
"=",
"ImmutableList",
".",
"of",
"(",
")",
";",
"if",
"(",
"inputMap",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"Collections",
".",
"nCopies",
"(",
"numChunks",
",",
"emptyChunk",
")",
";",
"}",
"final",
"int",
"chunkSize",
"=",
"IntMath",
".",
"divide",
"(",
"inputMap",
".",
"size",
"(",
")",
",",
"numChunks",
",",
"RoundingMode",
".",
"UP",
")",
";",
"final",
"ImmutableList",
"<",
"List",
"<",
"Map",
".",
"Entry",
"<",
"Symbol",
",",
"File",
">",
">",
">",
"chunks",
"=",
"ImmutableList",
".",
"copyOf",
"(",
"splitToChunksOfFixedSize",
"(",
"inputMap",
",",
"chunkSize",
")",
")",
";",
"if",
"(",
"chunks",
".",
"size",
"(",
")",
"==",
"numChunks",
")",
"{",
"return",
"chunks",
";",
"}",
"else",
"{",
"// there weren't enough elements to make the desired number of chunks, so we need to",
"// pad with empty chunks",
"final",
"int",
"shortage",
"=",
"numChunks",
"-",
"chunks",
".",
"size",
"(",
")",
";",
"final",
"List",
"<",
"List",
"<",
"Map",
".",
"Entry",
"<",
"Symbol",
",",
"File",
">",
">",
">",
"padding",
"=",
"Collections",
".",
"nCopies",
"(",
"shortage",
",",
"emptyChunk",
")",
";",
"return",
"Iterables",
".",
"concat",
"(",
"chunks",
",",
"padding",
")",
";",
"}",
"}"
] | If there are fewer files than chunks, fewer than numChunks will be returned. | [
"If",
"there",
"are",
"fewer",
"files",
"than",
"chunks",
"fewer",
"than",
"numChunks",
"will",
"be",
"returned",
"."
] | d618652674d647867306e2e4b987a21b7c29c015 | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/files/SplitCorpus.java#L160-L181 | train |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/files/SplitCorpus.java | SplitCorpus.loadDocIdToFileMap | private static ImmutableMap<Symbol, File> loadDocIdToFileMap(
final Optional<File> inputFileListFile,
final Optional<File> inputFileMapFile) throws IOException {
checkArgument(inputFileListFile.isPresent() || inputFileMapFile.isPresent());
final Optional<ImmutableList<File>> fileList;
if (inputFileListFile.isPresent()) {
fileList = Optional.of(FileUtils.loadFileList(inputFileListFile.get()));
} else {
fileList = Optional.absent();
}
final Optional<ImmutableMap<Symbol, File>> fileMap;
if (inputFileMapFile.isPresent()) {
fileMap = Optional.of(FileUtils.loadSymbolToFileMap(inputFileMapFile.get()));
} else {
fileMap = Optional.absent();
}
// sanity checks
if (fileList.isPresent()) {
// file list may not contain duplicates
final boolean containsDuplicates =
ImmutableSet.copyOf(fileList.get()).size() != fileList.get().size();
if (containsDuplicates) {
throw new RuntimeException("Input file list contains duplicates");
}
}
// if both a file map and a file list are given, they must be compatible.
if (fileList.isPresent() && fileMap.isPresent()) {
if (fileList.get().size() != fileMap.get().size()) {
throw new RuntimeException("Input file list and file map do not match in size ("
+ fileList.get().size() + " vs " + fileMap.get().size());
}
final boolean haveExactlyTheSameFiles =
ImmutableSet.copyOf(fileList.get()).equals(ImmutableSet.copyOf(fileMap.get().values()));
if (!haveExactlyTheSameFiles) {
throw new RuntimeException(
"Input file list and file map do not containe exactly the same files");
}
}
// output
if (fileMap.isPresent()) {
return fileMap.get();
} else {
// if we only had a file list as input, we make a fake doc-id-to-file-map using
// the absolute path as the document ID. This won't get output, so it doesn't matter
// that this is a little hacky
final Function<File, Symbol> fileNameAsSymbolFunction =
compose(SymbolUtils.symbolizeFunction(), FileUtils.toAbsolutePathFunction());
return Maps.uniqueIndex(fileList.get(), fileNameAsSymbolFunction);
}
} | java | private static ImmutableMap<Symbol, File> loadDocIdToFileMap(
final Optional<File> inputFileListFile,
final Optional<File> inputFileMapFile) throws IOException {
checkArgument(inputFileListFile.isPresent() || inputFileMapFile.isPresent());
final Optional<ImmutableList<File>> fileList;
if (inputFileListFile.isPresent()) {
fileList = Optional.of(FileUtils.loadFileList(inputFileListFile.get()));
} else {
fileList = Optional.absent();
}
final Optional<ImmutableMap<Symbol, File>> fileMap;
if (inputFileMapFile.isPresent()) {
fileMap = Optional.of(FileUtils.loadSymbolToFileMap(inputFileMapFile.get()));
} else {
fileMap = Optional.absent();
}
// sanity checks
if (fileList.isPresent()) {
// file list may not contain duplicates
final boolean containsDuplicates =
ImmutableSet.copyOf(fileList.get()).size() != fileList.get().size();
if (containsDuplicates) {
throw new RuntimeException("Input file list contains duplicates");
}
}
// if both a file map and a file list are given, they must be compatible.
if (fileList.isPresent() && fileMap.isPresent()) {
if (fileList.get().size() != fileMap.get().size()) {
throw new RuntimeException("Input file list and file map do not match in size ("
+ fileList.get().size() + " vs " + fileMap.get().size());
}
final boolean haveExactlyTheSameFiles =
ImmutableSet.copyOf(fileList.get()).equals(ImmutableSet.copyOf(fileMap.get().values()));
if (!haveExactlyTheSameFiles) {
throw new RuntimeException(
"Input file list and file map do not containe exactly the same files");
}
}
// output
if (fileMap.isPresent()) {
return fileMap.get();
} else {
// if we only had a file list as input, we make a fake doc-id-to-file-map using
// the absolute path as the document ID. This won't get output, so it doesn't matter
// that this is a little hacky
final Function<File, Symbol> fileNameAsSymbolFunction =
compose(SymbolUtils.symbolizeFunction(), FileUtils.toAbsolutePathFunction());
return Maps.uniqueIndex(fileList.get(), fileNameAsSymbolFunction);
}
} | [
"private",
"static",
"ImmutableMap",
"<",
"Symbol",
",",
"File",
">",
"loadDocIdToFileMap",
"(",
"final",
"Optional",
"<",
"File",
">",
"inputFileListFile",
",",
"final",
"Optional",
"<",
"File",
">",
"inputFileMapFile",
")",
"throws",
"IOException",
"{",
"checkArgument",
"(",
"inputFileListFile",
".",
"isPresent",
"(",
")",
"||",
"inputFileMapFile",
".",
"isPresent",
"(",
")",
")",
";",
"final",
"Optional",
"<",
"ImmutableList",
"<",
"File",
">",
">",
"fileList",
";",
"if",
"(",
"inputFileListFile",
".",
"isPresent",
"(",
")",
")",
"{",
"fileList",
"=",
"Optional",
".",
"of",
"(",
"FileUtils",
".",
"loadFileList",
"(",
"inputFileListFile",
".",
"get",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"fileList",
"=",
"Optional",
".",
"absent",
"(",
")",
";",
"}",
"final",
"Optional",
"<",
"ImmutableMap",
"<",
"Symbol",
",",
"File",
">",
">",
"fileMap",
";",
"if",
"(",
"inputFileMapFile",
".",
"isPresent",
"(",
")",
")",
"{",
"fileMap",
"=",
"Optional",
".",
"of",
"(",
"FileUtils",
".",
"loadSymbolToFileMap",
"(",
"inputFileMapFile",
".",
"get",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"fileMap",
"=",
"Optional",
".",
"absent",
"(",
")",
";",
"}",
"// sanity checks",
"if",
"(",
"fileList",
".",
"isPresent",
"(",
")",
")",
"{",
"// file list may not contain duplicates",
"final",
"boolean",
"containsDuplicates",
"=",
"ImmutableSet",
".",
"copyOf",
"(",
"fileList",
".",
"get",
"(",
")",
")",
".",
"size",
"(",
")",
"!=",
"fileList",
".",
"get",
"(",
")",
".",
"size",
"(",
")",
";",
"if",
"(",
"containsDuplicates",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Input file list contains duplicates\"",
")",
";",
"}",
"}",
"// if both a file map and a file list are given, they must be compatible.",
"if",
"(",
"fileList",
".",
"isPresent",
"(",
")",
"&&",
"fileMap",
".",
"isPresent",
"(",
")",
")",
"{",
"if",
"(",
"fileList",
".",
"get",
"(",
")",
".",
"size",
"(",
")",
"!=",
"fileMap",
".",
"get",
"(",
")",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Input file list and file map do not match in size (\"",
"+",
"fileList",
".",
"get",
"(",
")",
".",
"size",
"(",
")",
"+",
"\" vs \"",
"+",
"fileMap",
".",
"get",
"(",
")",
".",
"size",
"(",
")",
")",
";",
"}",
"final",
"boolean",
"haveExactlyTheSameFiles",
"=",
"ImmutableSet",
".",
"copyOf",
"(",
"fileList",
".",
"get",
"(",
")",
")",
".",
"equals",
"(",
"ImmutableSet",
".",
"copyOf",
"(",
"fileMap",
".",
"get",
"(",
")",
".",
"values",
"(",
")",
")",
")",
";",
"if",
"(",
"!",
"haveExactlyTheSameFiles",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Input file list and file map do not containe exactly the same files\"",
")",
";",
"}",
"}",
"// output",
"if",
"(",
"fileMap",
".",
"isPresent",
"(",
")",
")",
"{",
"return",
"fileMap",
".",
"get",
"(",
")",
";",
"}",
"else",
"{",
"// if we only had a file list as input, we make a fake doc-id-to-file-map using",
"// the absolute path as the document ID. This won't get output, so it doesn't matter",
"// that this is a little hacky",
"final",
"Function",
"<",
"File",
",",
"Symbol",
">",
"fileNameAsSymbolFunction",
"=",
"compose",
"(",
"SymbolUtils",
".",
"symbolizeFunction",
"(",
")",
",",
"FileUtils",
".",
"toAbsolutePathFunction",
"(",
")",
")",
";",
"return",
"Maps",
".",
"uniqueIndex",
"(",
"fileList",
".",
"get",
"(",
")",
",",
"fileNameAsSymbolFunction",
")",
";",
"}",
"}"
] | Gets a doc-id-to-file map for the input, either directly or making a fake one based on an input
file list. | [
"Gets",
"a",
"doc",
"-",
"id",
"-",
"to",
"-",
"file",
"map",
"for",
"the",
"input",
"either",
"directly",
"or",
"making",
"a",
"fake",
"one",
"based",
"on",
"an",
"input",
"file",
"list",
"."
] | d618652674d647867306e2e4b987a21b7c29c015 | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/files/SplitCorpus.java#L187-L243 | train |
agmip/translator-dssat | src/main/java/org/agmip/translators/dssat/DssatCulFileOutput.java | DssatCulFileOutput.writeFile | @Override
public void writeFile(String arg0, Map result) {
// Initial variables
HashMap culData; // Data holder for one site of cultivar data
ArrayList<HashMap> culArr; // Data holder for one site of cultivar data
BufferedWriter bwC; // output object
StringBuilder sbData = new StringBuilder(); // construct the data info in the output
try {
// Set default value for missing data
setDefVal();
culData = getObjectOr(result, "dssat_cultivar_info", new HashMap());
culArr = getObjectOr(culData, "data", new ArrayList());
if (culArr.isEmpty()) {
return;
}
// decompressData(culArr);
// Initial BufferedWriter
// Get File name
String fileName = getFileName(result, "X");
if (fileName.matches("TEMP\\d{4}\\.\\w{2}X")) {
fileName = "Cultivar.CUL";
} else {
try {
fileName = fileName.replaceAll("\\.", "_") + ".CUL";
} catch (Exception e) {
fileName = "Cultivar.CUL";
}
}
arg0 = revisePath(arg0);
outputFile = new File(arg0 + fileName);
bwC = new BufferedWriter(new FileWriter(outputFile, outputFile.exists()));
// Output Cultivar File
String lastHeaderInfo = "";
String lastTitles = "";
for (HashMap culSubData : culArr) {
// If come to new header, add header line and title line
if (!getObjectOr(culSubData, "header_info", "").equals(lastHeaderInfo)) {
lastHeaderInfo = getObjectOr(culSubData, "header_info", "");
sbData.append(lastHeaderInfo).append("\r\n");
lastTitles = getObjectOr(culSubData, "cul_titles", "");
sbData.append(lastTitles).append("\r\n");
}
// If come to new title line, add title line
if (!getObjectOr(culSubData, "cul_titles", "").equals(lastTitles)) {
lastTitles = getObjectOr(culSubData, "cul_titles", "");
sbData.append(lastTitles).append("\r\n");
}
// Write data line
sbData.append(getObjectOr(culSubData, "cul_info", "")).append("\r\n");
}
// Output finish
bwC.write(sbError.toString());
bwC.write(sbData.toString());
bwC.close();
} catch (IOException e) {
LOG.error(DssatCommonOutput.getStackTrace(e));
}
} | java | @Override
public void writeFile(String arg0, Map result) {
// Initial variables
HashMap culData; // Data holder for one site of cultivar data
ArrayList<HashMap> culArr; // Data holder for one site of cultivar data
BufferedWriter bwC; // output object
StringBuilder sbData = new StringBuilder(); // construct the data info in the output
try {
// Set default value for missing data
setDefVal();
culData = getObjectOr(result, "dssat_cultivar_info", new HashMap());
culArr = getObjectOr(culData, "data", new ArrayList());
if (culArr.isEmpty()) {
return;
}
// decompressData(culArr);
// Initial BufferedWriter
// Get File name
String fileName = getFileName(result, "X");
if (fileName.matches("TEMP\\d{4}\\.\\w{2}X")) {
fileName = "Cultivar.CUL";
} else {
try {
fileName = fileName.replaceAll("\\.", "_") + ".CUL";
} catch (Exception e) {
fileName = "Cultivar.CUL";
}
}
arg0 = revisePath(arg0);
outputFile = new File(arg0 + fileName);
bwC = new BufferedWriter(new FileWriter(outputFile, outputFile.exists()));
// Output Cultivar File
String lastHeaderInfo = "";
String lastTitles = "";
for (HashMap culSubData : culArr) {
// If come to new header, add header line and title line
if (!getObjectOr(culSubData, "header_info", "").equals(lastHeaderInfo)) {
lastHeaderInfo = getObjectOr(culSubData, "header_info", "");
sbData.append(lastHeaderInfo).append("\r\n");
lastTitles = getObjectOr(culSubData, "cul_titles", "");
sbData.append(lastTitles).append("\r\n");
}
// If come to new title line, add title line
if (!getObjectOr(culSubData, "cul_titles", "").equals(lastTitles)) {
lastTitles = getObjectOr(culSubData, "cul_titles", "");
sbData.append(lastTitles).append("\r\n");
}
// Write data line
sbData.append(getObjectOr(culSubData, "cul_info", "")).append("\r\n");
}
// Output finish
bwC.write(sbError.toString());
bwC.write(sbData.toString());
bwC.close();
} catch (IOException e) {
LOG.error(DssatCommonOutput.getStackTrace(e));
}
} | [
"@",
"Override",
"public",
"void",
"writeFile",
"(",
"String",
"arg0",
",",
"Map",
"result",
")",
"{",
"// Initial variables",
"HashMap",
"culData",
";",
"// Data holder for one site of cultivar data",
"ArrayList",
"<",
"HashMap",
">",
"culArr",
";",
"// Data holder for one site of cultivar data",
"BufferedWriter",
"bwC",
";",
"// output object",
"StringBuilder",
"sbData",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"// construct the data info in the output",
"try",
"{",
"// Set default value for missing data",
"setDefVal",
"(",
")",
";",
"culData",
"=",
"getObjectOr",
"(",
"result",
",",
"\"dssat_cultivar_info\"",
",",
"new",
"HashMap",
"(",
")",
")",
";",
"culArr",
"=",
"getObjectOr",
"(",
"culData",
",",
"\"data\"",
",",
"new",
"ArrayList",
"(",
")",
")",
";",
"if",
"(",
"culArr",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"// decompressData(culArr);",
"// Initial BufferedWriter",
"// Get File name",
"String",
"fileName",
"=",
"getFileName",
"(",
"result",
",",
"\"X\"",
")",
";",
"if",
"(",
"fileName",
".",
"matches",
"(",
"\"TEMP\\\\d{4}\\\\.\\\\w{2}X\"",
")",
")",
"{",
"fileName",
"=",
"\"Cultivar.CUL\"",
";",
"}",
"else",
"{",
"try",
"{",
"fileName",
"=",
"fileName",
".",
"replaceAll",
"(",
"\"\\\\.\"",
",",
"\"_\"",
")",
"+",
"\".CUL\"",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"fileName",
"=",
"\"Cultivar.CUL\"",
";",
"}",
"}",
"arg0",
"=",
"revisePath",
"(",
"arg0",
")",
";",
"outputFile",
"=",
"new",
"File",
"(",
"arg0",
"+",
"fileName",
")",
";",
"bwC",
"=",
"new",
"BufferedWriter",
"(",
"new",
"FileWriter",
"(",
"outputFile",
",",
"outputFile",
".",
"exists",
"(",
")",
")",
")",
";",
"// Output Cultivar File",
"String",
"lastHeaderInfo",
"=",
"\"\"",
";",
"String",
"lastTitles",
"=",
"\"\"",
";",
"for",
"(",
"HashMap",
"culSubData",
":",
"culArr",
")",
"{",
"// If come to new header, add header line and title line",
"if",
"(",
"!",
"getObjectOr",
"(",
"culSubData",
",",
"\"header_info\"",
",",
"\"\"",
")",
".",
"equals",
"(",
"lastHeaderInfo",
")",
")",
"{",
"lastHeaderInfo",
"=",
"getObjectOr",
"(",
"culSubData",
",",
"\"header_info\"",
",",
"\"\"",
")",
";",
"sbData",
".",
"append",
"(",
"lastHeaderInfo",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"lastTitles",
"=",
"getObjectOr",
"(",
"culSubData",
",",
"\"cul_titles\"",
",",
"\"\"",
")",
";",
"sbData",
".",
"append",
"(",
"lastTitles",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"}",
"// If come to new title line, add title line",
"if",
"(",
"!",
"getObjectOr",
"(",
"culSubData",
",",
"\"cul_titles\"",
",",
"\"\"",
")",
".",
"equals",
"(",
"lastTitles",
")",
")",
"{",
"lastTitles",
"=",
"getObjectOr",
"(",
"culSubData",
",",
"\"cul_titles\"",
",",
"\"\"",
")",
";",
"sbData",
".",
"append",
"(",
"lastTitles",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"}",
"// Write data line",
"sbData",
".",
"append",
"(",
"getObjectOr",
"(",
"culSubData",
",",
"\"cul_info\"",
",",
"\"\"",
")",
")",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"}",
"// Output finish",
"bwC",
".",
"write",
"(",
"sbError",
".",
"toString",
"(",
")",
")",
";",
"bwC",
".",
"write",
"(",
"sbData",
".",
"toString",
"(",
")",
")",
";",
"bwC",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"DssatCommonOutput",
".",
"getStackTrace",
"(",
"e",
")",
")",
";",
"}",
"}"
] | DSSAT Cultivar Data Output method
@param arg0 file output path
@param result data holder object | [
"DSSAT",
"Cultivar",
"Data",
"Output",
"method"
] | 4be61d998f106eb7234ea8701b63c3746ae688f4 | https://github.com/agmip/translator-dssat/blob/4be61d998f106eb7234ea8701b63c3746ae688f4/src/main/java/org/agmip/translators/dssat/DssatCulFileOutput.java#L30-L95 | train |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/CodepointMatcher.java | CodepointMatcher.anyOf | public static CodepointMatcher anyOf(final String sequence) {
switch (sequence.length()) {
case 0:
return none();
case 1:
return is(sequence);
default:
return new AnyOf(sequence);
}
} | java | public static CodepointMatcher anyOf(final String sequence) {
switch (sequence.length()) {
case 0:
return none();
case 1:
return is(sequence);
default:
return new AnyOf(sequence);
}
} | [
"public",
"static",
"CodepointMatcher",
"anyOf",
"(",
"final",
"String",
"sequence",
")",
"{",
"switch",
"(",
"sequence",
".",
"length",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"none",
"(",
")",
";",
"case",
"1",
":",
"return",
"is",
"(",
"sequence",
")",
";",
"default",
":",
"return",
"new",
"AnyOf",
"(",
"sequence",
")",
";",
"}",
"}"
] | Matches any character in the sequence | [
"Matches",
"any",
"character",
"in",
"the",
"sequence"
] | d618652674d647867306e2e4b987a21b7c29c015 | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/CodepointMatcher.java#L58-L67 | train |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/CodepointMatcher.java | CodepointMatcher.removeFrom | public final String removeFrom(String s) {
final StringBuilder sb = new StringBuilder();
for (int offset = 0; offset < s.length(); ) {
final int codePoint = s.codePointAt(offset);
if (!matches(codePoint)) {
sb.appendCodePoint(codePoint);
}
offset += Character.charCount(codePoint);
}
return sb.toString();
} | java | public final String removeFrom(String s) {
final StringBuilder sb = new StringBuilder();
for (int offset = 0; offset < s.length(); ) {
final int codePoint = s.codePointAt(offset);
if (!matches(codePoint)) {
sb.appendCodePoint(codePoint);
}
offset += Character.charCount(codePoint);
}
return sb.toString();
} | [
"public",
"final",
"String",
"removeFrom",
"(",
"String",
"s",
")",
"{",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"offset",
"=",
"0",
";",
"offset",
"<",
"s",
".",
"length",
"(",
")",
";",
")",
"{",
"final",
"int",
"codePoint",
"=",
"s",
".",
"codePointAt",
"(",
"offset",
")",
";",
"if",
"(",
"!",
"matches",
"(",
"codePoint",
")",
")",
"{",
"sb",
".",
"appendCodePoint",
"(",
"codePoint",
")",
";",
"}",
"offset",
"+=",
"Character",
".",
"charCount",
"(",
"codePoint",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Returns a copy of the input string with all Unicode codepoints matching this matcher removed | [
"Returns",
"a",
"copy",
"of",
"the",
"input",
"string",
"with",
"all",
"Unicode",
"codepoints",
"matching",
"this",
"matcher",
"removed"
] | d618652674d647867306e2e4b987a21b7c29c015 | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/CodepointMatcher.java#L277-L289 | train |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/CodepointMatcher.java | CodepointMatcher.trimFrom | public final String trimFrom(String s) {
int first;
int last;
// removes leading matches
for (first = 0; first < s.length(); ) {
final int codePoint = s.codePointAt(first);
if (!matches(codePoint)) {
break;
}
first += Character.charCount(codePoint);
}
//remove trailing matches
for (last = s.length() - 1; last >= first; --last) {
if (Character.isLowSurrogate(s.charAt(last))) {
--last;
}
if (!matches(s.codePointAt(last))) {
break;
}
}
return s.substring(first, last + 1);
} | java | public final String trimFrom(String s) {
int first;
int last;
// removes leading matches
for (first = 0; first < s.length(); ) {
final int codePoint = s.codePointAt(first);
if (!matches(codePoint)) {
break;
}
first += Character.charCount(codePoint);
}
//remove trailing matches
for (last = s.length() - 1; last >= first; --last) {
if (Character.isLowSurrogate(s.charAt(last))) {
--last;
}
if (!matches(s.codePointAt(last))) {
break;
}
}
return s.substring(first, last + 1);
} | [
"public",
"final",
"String",
"trimFrom",
"(",
"String",
"s",
")",
"{",
"int",
"first",
";",
"int",
"last",
";",
"// removes leading matches",
"for",
"(",
"first",
"=",
"0",
";",
"first",
"<",
"s",
".",
"length",
"(",
")",
";",
")",
"{",
"final",
"int",
"codePoint",
"=",
"s",
".",
"codePointAt",
"(",
"first",
")",
";",
"if",
"(",
"!",
"matches",
"(",
"codePoint",
")",
")",
"{",
"break",
";",
"}",
"first",
"+=",
"Character",
".",
"charCount",
"(",
"codePoint",
")",
";",
"}",
"//remove trailing matches",
"for",
"(",
"last",
"=",
"s",
".",
"length",
"(",
")",
"-",
"1",
";",
"last",
">=",
"first",
";",
"--",
"last",
")",
"{",
"if",
"(",
"Character",
".",
"isLowSurrogate",
"(",
"s",
".",
"charAt",
"(",
"last",
")",
")",
")",
"{",
"--",
"last",
";",
"}",
"if",
"(",
"!",
"matches",
"(",
"s",
".",
"codePointAt",
"(",
"last",
")",
")",
")",
"{",
"break",
";",
"}",
"}",
"return",
"s",
".",
"substring",
"(",
"first",
",",
"last",
"+",
"1",
")",
";",
"}"
] | Returns a copy of the input string with all leading and trailing codepoints matching this
matcher removed | [
"Returns",
"a",
"copy",
"of",
"the",
"input",
"string",
"with",
"all",
"leading",
"and",
"trailing",
"codepoints",
"matching",
"this",
"matcher",
"removed"
] | d618652674d647867306e2e4b987a21b7c29c015 | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/CodepointMatcher.java#L295-L319 | train |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/StringWithNonBmp.java | StringWithNonBmp.codeUnitOffsetFor | private UTF16Offset codeUnitOffsetFor(final CharOffset codePointOffset) {
int charOffset = 0;
int codePointsConsumed = 0;
for (; charOffset < utf16CodeUnits().length() && codePointsConsumed < codePointOffset.asInt();
++codePointsConsumed) {
final int codePoint = utf16CodeUnits().codePointAt(charOffset);
charOffset += Character.charCount(codePoint);
}
if (codePointsConsumed == codePointOffset.asInt()) {
return UTF16Offset.of(charOffset);
} else {
// this will happen if codePointOffset is negative or equal to or greater than the
// total number of codepoints in the string
throw new IndexOutOfBoundsException();
}
} | java | private UTF16Offset codeUnitOffsetFor(final CharOffset codePointOffset) {
int charOffset = 0;
int codePointsConsumed = 0;
for (; charOffset < utf16CodeUnits().length() && codePointsConsumed < codePointOffset.asInt();
++codePointsConsumed) {
final int codePoint = utf16CodeUnits().codePointAt(charOffset);
charOffset += Character.charCount(codePoint);
}
if (codePointsConsumed == codePointOffset.asInt()) {
return UTF16Offset.of(charOffset);
} else {
// this will happen if codePointOffset is negative or equal to or greater than the
// total number of codepoints in the string
throw new IndexOutOfBoundsException();
}
} | [
"private",
"UTF16Offset",
"codeUnitOffsetFor",
"(",
"final",
"CharOffset",
"codePointOffset",
")",
"{",
"int",
"charOffset",
"=",
"0",
";",
"int",
"codePointsConsumed",
"=",
"0",
";",
"for",
"(",
";",
"charOffset",
"<",
"utf16CodeUnits",
"(",
")",
".",
"length",
"(",
")",
"&&",
"codePointsConsumed",
"<",
"codePointOffset",
".",
"asInt",
"(",
")",
";",
"++",
"codePointsConsumed",
")",
"{",
"final",
"int",
"codePoint",
"=",
"utf16CodeUnits",
"(",
")",
".",
"codePointAt",
"(",
"charOffset",
")",
";",
"charOffset",
"+=",
"Character",
".",
"charCount",
"(",
"codePoint",
")",
";",
"}",
"if",
"(",
"codePointsConsumed",
"==",
"codePointOffset",
".",
"asInt",
"(",
")",
")",
"{",
"return",
"UTF16Offset",
".",
"of",
"(",
"charOffset",
")",
";",
"}",
"else",
"{",
"// this will happen if codePointOffset is negative or equal to or greater than the",
"// total number of codepoints in the string",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"}",
"}"
] | something like LocatedString's like CharacterRegions | [
"something",
"like",
"LocatedString",
"s",
"like",
"CharacterRegions"
] | d618652674d647867306e2e4b987a21b7c29c015 | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/StringWithNonBmp.java#L98-L114 | train |
lightblueseas/swing-components | src/main/java/de/alpharogroup/swing/tree/JTreeExtensions.java | JTreeExtensions.expandAll | public static void expandAll(JTree tree, TreePath path, boolean expand)
{
TreeNode node = (TreeNode)path.getLastPathComponent();
if (node.getChildCount() >= 0)
{
Enumeration<?> enumeration = node.children();
while (enumeration.hasMoreElements())
{
TreeNode n = (TreeNode)enumeration.nextElement();
TreePath p = path.pathByAddingChild(n);
expandAll(tree, p, expand);
}
}
if (expand)
{
tree.expandPath(path);
}
else
{
tree.collapsePath(path);
}
} | java | public static void expandAll(JTree tree, TreePath path, boolean expand)
{
TreeNode node = (TreeNode)path.getLastPathComponent();
if (node.getChildCount() >= 0)
{
Enumeration<?> enumeration = node.children();
while (enumeration.hasMoreElements())
{
TreeNode n = (TreeNode)enumeration.nextElement();
TreePath p = path.pathByAddingChild(n);
expandAll(tree, p, expand);
}
}
if (expand)
{
tree.expandPath(path);
}
else
{
tree.collapsePath(path);
}
} | [
"public",
"static",
"void",
"expandAll",
"(",
"JTree",
"tree",
",",
"TreePath",
"path",
",",
"boolean",
"expand",
")",
"{",
"TreeNode",
"node",
"=",
"(",
"TreeNode",
")",
"path",
".",
"getLastPathComponent",
"(",
")",
";",
"if",
"(",
"node",
".",
"getChildCount",
"(",
")",
">=",
"0",
")",
"{",
"Enumeration",
"<",
"?",
">",
"enumeration",
"=",
"node",
".",
"children",
"(",
")",
";",
"while",
"(",
"enumeration",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"TreeNode",
"n",
"=",
"(",
"TreeNode",
")",
"enumeration",
".",
"nextElement",
"(",
")",
";",
"TreePath",
"p",
"=",
"path",
".",
"pathByAddingChild",
"(",
"n",
")",
";",
"expandAll",
"(",
"tree",
",",
"p",
",",
"expand",
")",
";",
"}",
"}",
"if",
"(",
"expand",
")",
"{",
"tree",
".",
"expandPath",
"(",
"path",
")",
";",
"}",
"else",
"{",
"tree",
".",
"collapsePath",
"(",
"path",
")",
";",
"}",
"}"
] | Expand all nodes recursive
@param tree
the tree
@param path
the path
@param expand
the flag to expand or collapse | [
"Expand",
"all",
"nodes",
"recursive"
] | 4045e85cabd8f0ce985cbfff134c3c9873930c79 | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/tree/JTreeExtensions.java#L51-L75 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/AbstractBusPrimitive.java | AbstractBusPrimitive.fireValidityChangedFor | protected void fireValidityChangedFor(Object changedObject, int index, BusPrimitiveInvalidity oldReason,
BusPrimitiveInvalidity newReason) {
resetBoundingBox();
final BusChangeEvent event = new BusChangeEvent(
// source of the event
this,
// type of the event
BusChangeEventType.VALIDITY,
changedObject,
index,
"validity", //$NON-NLS-1$
oldReason,
newReason);
firePrimitiveChanged(event);
} | java | protected void fireValidityChangedFor(Object changedObject, int index, BusPrimitiveInvalidity oldReason,
BusPrimitiveInvalidity newReason) {
resetBoundingBox();
final BusChangeEvent event = new BusChangeEvent(
// source of the event
this,
// type of the event
BusChangeEventType.VALIDITY,
changedObject,
index,
"validity", //$NON-NLS-1$
oldReason,
newReason);
firePrimitiveChanged(event);
} | [
"protected",
"void",
"fireValidityChangedFor",
"(",
"Object",
"changedObject",
",",
"int",
"index",
",",
"BusPrimitiveInvalidity",
"oldReason",
",",
"BusPrimitiveInvalidity",
"newReason",
")",
"{",
"resetBoundingBox",
"(",
")",
";",
"final",
"BusChangeEvent",
"event",
"=",
"new",
"BusChangeEvent",
"(",
"// source of the event",
"this",
",",
"// type of the event",
"BusChangeEventType",
".",
"VALIDITY",
",",
"changedObject",
",",
"index",
",",
"\"validity\"",
",",
"//$NON-NLS-1$",
"oldReason",
",",
"newReason",
")",
";",
"firePrimitiveChanged",
"(",
"event",
")",
";",
"}"
] | Fire the event that indicates the validity of the object has changed.
@param changedObject is the object for which the validity has changed.
@param index is the index of the changedObject in its parent.
@param oldReason is the old invalidity reason before the change.
@param newReason is the current invalidity reason after the change. | [
"Fire",
"the",
"event",
"that",
"indicates",
"the",
"validity",
"of",
"the",
"object",
"has",
"changed",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/AbstractBusPrimitive.java#L277-L291 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/AbstractBusPrimitive.java | AbstractBusPrimitive.getColor | @Pure
public int getColor(int defaultColor) {
final Integer c = getRawColor();
if (c != null) {
return c;
}
final BusContainer<?> container = getContainer();
if (container != null) {
return container.getColor();
}
return defaultColor;
} | java | @Pure
public int getColor(int defaultColor) {
final Integer c = getRawColor();
if (c != null) {
return c;
}
final BusContainer<?> container = getContainer();
if (container != null) {
return container.getColor();
}
return defaultColor;
} | [
"@",
"Pure",
"public",
"int",
"getColor",
"(",
"int",
"defaultColor",
")",
"{",
"final",
"Integer",
"c",
"=",
"getRawColor",
"(",
")",
";",
"if",
"(",
"c",
"!=",
"null",
")",
"{",
"return",
"c",
";",
"}",
"final",
"BusContainer",
"<",
"?",
">",
"container",
"=",
"getContainer",
"(",
")",
";",
"if",
"(",
"container",
"!=",
"null",
")",
"{",
"return",
"container",
".",
"getColor",
"(",
")",
";",
"}",
"return",
"defaultColor",
";",
"}"
] | Replies the color of this element or the color of the container.
@param defaultColor the default color.
@return the color
@see #getRawColor() | [
"Replies",
"the",
"color",
"of",
"this",
"element",
"or",
"the",
"color",
"of",
"the",
"container",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/AbstractBusPrimitive.java#L396-L407 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/AbstractBusPrimitive.java | AbstractBusPrimitive.setPrimitiveValidity | @SuppressWarnings("unlikely-arg-type")
protected final void setPrimitiveValidity(BusPrimitiveInvalidity invalidityReason) {
if ((invalidityReason == null && this.invalidityReason != null)
|| (invalidityReason != null
&& !invalidityReason.equals(BusPrimitiveInvalidityType.VALIDITY_NOT_CHECKED)
&& !invalidityReason.equals(this.invalidityReason))) {
final BusPrimitiveInvalidity old = this.invalidityReason;
this.invalidityReason = invalidityReason;
fireValidityChanged(old, this.invalidityReason);
}
} | java | @SuppressWarnings("unlikely-arg-type")
protected final void setPrimitiveValidity(BusPrimitiveInvalidity invalidityReason) {
if ((invalidityReason == null && this.invalidityReason != null)
|| (invalidityReason != null
&& !invalidityReason.equals(BusPrimitiveInvalidityType.VALIDITY_NOT_CHECKED)
&& !invalidityReason.equals(this.invalidityReason))) {
final BusPrimitiveInvalidity old = this.invalidityReason;
this.invalidityReason = invalidityReason;
fireValidityChanged(old, this.invalidityReason);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unlikely-arg-type\"",
")",
"protected",
"final",
"void",
"setPrimitiveValidity",
"(",
"BusPrimitiveInvalidity",
"invalidityReason",
")",
"{",
"if",
"(",
"(",
"invalidityReason",
"==",
"null",
"&&",
"this",
".",
"invalidityReason",
"!=",
"null",
")",
"||",
"(",
"invalidityReason",
"!=",
"null",
"&&",
"!",
"invalidityReason",
".",
"equals",
"(",
"BusPrimitiveInvalidityType",
".",
"VALIDITY_NOT_CHECKED",
")",
"&&",
"!",
"invalidityReason",
".",
"equals",
"(",
"this",
".",
"invalidityReason",
")",
")",
")",
"{",
"final",
"BusPrimitiveInvalidity",
"old",
"=",
"this",
".",
"invalidityReason",
";",
"this",
".",
"invalidityReason",
"=",
"invalidityReason",
";",
"fireValidityChanged",
"(",
"old",
",",
"this",
".",
"invalidityReason",
")",
";",
"}",
"}"
] | Set if this component has invalid
or not.
<p>This function is supposed to be invoked at least
from {@link #checkPrimitiveValidity()}.
@param invalidityReason is the reason of the invalidity;
if <code>null</code> the primitive is valid. | [
"Set",
"if",
"this",
"component",
"has",
"invalid",
"or",
"not",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/AbstractBusPrimitive.java#L535-L545 | train |
gallandarakhneorg/afc | advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Parallelogram2dfx.java | Parallelogram2dfx.secondAxisProperty | public UnitVectorProperty secondAxisProperty() {
if (this.saxis == null) {
this.saxis = new UnitVectorProperty(this, MathFXAttributeNames.SECOND_AXIS, getGeomFactory());
}
return this.saxis;
} | java | public UnitVectorProperty secondAxisProperty() {
if (this.saxis == null) {
this.saxis = new UnitVectorProperty(this, MathFXAttributeNames.SECOND_AXIS, getGeomFactory());
}
return this.saxis;
} | [
"public",
"UnitVectorProperty",
"secondAxisProperty",
"(",
")",
"{",
"if",
"(",
"this",
".",
"saxis",
"==",
"null",
")",
"{",
"this",
".",
"saxis",
"=",
"new",
"UnitVectorProperty",
"(",
"this",
",",
"MathFXAttributeNames",
".",
"SECOND_AXIS",
",",
"getGeomFactory",
"(",
")",
")",
";",
"}",
"return",
"this",
".",
"saxis",
";",
"}"
] | Replies the property for the second axis.
@return the property. | [
"Replies",
"the",
"property",
"for",
"the",
"second",
"axis",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Parallelogram2dfx.java#L280-L285 | train |
gallandarakhneorg/afc | advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Parallelogram2dfx.java | Parallelogram2dfx.firstAxisExtentProperty | @Pure
public DoubleProperty firstAxisExtentProperty() {
if (this.extentR == null) {
this.extentR = new SimpleDoubleProperty(this, MathFXAttributeNames.FIRST_AXIS_EXTENT) {
@Override
protected void invalidated() {
if (get() < 0.) {
set(0.);
}
}
};
}
return this.extentR;
} | java | @Pure
public DoubleProperty firstAxisExtentProperty() {
if (this.extentR == null) {
this.extentR = new SimpleDoubleProperty(this, MathFXAttributeNames.FIRST_AXIS_EXTENT) {
@Override
protected void invalidated() {
if (get() < 0.) {
set(0.);
}
}
};
}
return this.extentR;
} | [
"@",
"Pure",
"public",
"DoubleProperty",
"firstAxisExtentProperty",
"(",
")",
"{",
"if",
"(",
"this",
".",
"extentR",
"==",
"null",
")",
"{",
"this",
".",
"extentR",
"=",
"new",
"SimpleDoubleProperty",
"(",
"this",
",",
"MathFXAttributeNames",
".",
"FIRST_AXIS_EXTENT",
")",
"{",
"@",
"Override",
"protected",
"void",
"invalidated",
"(",
")",
"{",
"if",
"(",
"get",
"(",
")",
"<",
"0.",
")",
"{",
"set",
"(",
"0.",
")",
";",
"}",
"}",
"}",
";",
"}",
"return",
"this",
".",
"extentR",
";",
"}"
] | Replies the property for the extent of the first axis.
@return the firstAxisExtent property. | [
"Replies",
"the",
"property",
"for",
"the",
"extent",
"of",
"the",
"first",
"axis",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Parallelogram2dfx.java#L309-L322 | train |
gallandarakhneorg/afc | advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Parallelogram2dfx.java | Parallelogram2dfx.secondAxisExtentProperty | @Pure
public DoubleProperty secondAxisExtentProperty() {
if (this.extentS == null) {
this.extentS = new SimpleDoubleProperty(this, MathFXAttributeNames.SECOND_AXIS_EXTENT) {
@Override
protected void invalidated() {
if (get() < 0.) {
set(0.);
}
}
};
}
return this.extentS;
} | java | @Pure
public DoubleProperty secondAxisExtentProperty() {
if (this.extentS == null) {
this.extentS = new SimpleDoubleProperty(this, MathFXAttributeNames.SECOND_AXIS_EXTENT) {
@Override
protected void invalidated() {
if (get() < 0.) {
set(0.);
}
}
};
}
return this.extentS;
} | [
"@",
"Pure",
"public",
"DoubleProperty",
"secondAxisExtentProperty",
"(",
")",
"{",
"if",
"(",
"this",
".",
"extentS",
"==",
"null",
")",
"{",
"this",
".",
"extentS",
"=",
"new",
"SimpleDoubleProperty",
"(",
"this",
",",
"MathFXAttributeNames",
".",
"SECOND_AXIS_EXTENT",
")",
"{",
"@",
"Override",
"protected",
"void",
"invalidated",
"(",
")",
"{",
"if",
"(",
"get",
"(",
")",
"<",
"0.",
")",
"{",
"set",
"(",
"0.",
")",
";",
"}",
"}",
"}",
";",
"}",
"return",
"this",
".",
"extentS",
";",
"}"
] | Replies the property for the extent of the second axis.
@return the secondAxisExtent property. | [
"Replies",
"the",
"property",
"for",
"the",
"extent",
"of",
"the",
"second",
"axis",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Parallelogram2dfx.java#L340-L353 | train |
lightblueseas/swing-components | src/main/java/de/alpharogroup/generic/mvc/view/AbstractGenericView.java | AbstractGenericView.getRootParentView | public View<?, ?> getRootParentView()
{
View<?, ?> currentView = this;
while (currentView.hasParent())
{
currentView = currentView.getParent();
}
return currentView;
} | java | public View<?, ?> getRootParentView()
{
View<?, ?> currentView = this;
while (currentView.hasParent())
{
currentView = currentView.getParent();
}
return currentView;
} | [
"public",
"View",
"<",
"?",
",",
"?",
">",
"getRootParentView",
"(",
")",
"{",
"View",
"<",
"?",
",",
"?",
">",
"currentView",
"=",
"this",
";",
"while",
"(",
"currentView",
".",
"hasParent",
"(",
")",
")",
"{",
"currentView",
"=",
"currentView",
".",
"getParent",
"(",
")",
";",
"}",
"return",
"currentView",
";",
"}"
] | Gets the root parent view.
@return the root parent view | [
"Gets",
"the",
"root",
"parent",
"view",
"."
] | 4045e85cabd8f0ce985cbfff134c3c9873930c79 | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/generic/mvc/view/AbstractGenericView.java#L100-L108 | train |
BBN-E/bue-common-open | nlp-core-open/src/main/java/com/bbn/nlp/corenlp/CoreNLPParseNode.java | CoreNLPParseNode.terminalHead | public Optional<CoreNLPParseNode> terminalHead() {
if (terminal()) {
return Optional.of(this);
}
if (immediateHead().isPresent()) {
return immediateHead().get().terminalHead();
}
return Optional.absent();
} | java | public Optional<CoreNLPParseNode> terminalHead() {
if (terminal()) {
return Optional.of(this);
}
if (immediateHead().isPresent()) {
return immediateHead().get().terminalHead();
}
return Optional.absent();
} | [
"public",
"Optional",
"<",
"CoreNLPParseNode",
">",
"terminalHead",
"(",
")",
"{",
"if",
"(",
"terminal",
"(",
")",
")",
"{",
"return",
"Optional",
".",
"of",
"(",
"this",
")",
";",
"}",
"if",
"(",
"immediateHead",
"(",
")",
".",
"isPresent",
"(",
")",
")",
"{",
"return",
"immediateHead",
"(",
")",
".",
"get",
"(",
")",
".",
"terminalHead",
"(",
")",
";",
"}",
"return",
"Optional",
".",
"absent",
"(",
")",
";",
"}"
] | Resolves a head down to a terminal node. A terminal node is its own head here. | [
"Resolves",
"a",
"head",
"down",
"to",
"a",
"terminal",
"node",
".",
"A",
"terminal",
"node",
"is",
"its",
"own",
"head",
"here",
"."
] | d618652674d647867306e2e4b987a21b7c29c015 | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/nlp-core-open/src/main/java/com/bbn/nlp/corenlp/CoreNLPParseNode.java#L138-L146 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractPathElement3D.java | AbstractPathElement3D.newInstance | @Pure
public static AbstractPathElement3D newInstance(PathElementType type, Point3d last, Point3d[] coords) {
switch(type) {
case MOVE_TO:
return new MovePathElement3d(coords[0]);
case LINE_TO:
return new LinePathElement3d(last, coords[0]);
case QUAD_TO:
return new QuadPathElement3d(last, coords[0], coords[1]);
case CURVE_TO:
return new CurvePathElement3d(last, coords[0], coords[1], coords[2]);
case CLOSE:
return new ClosePathElement3d(last, coords[0]);
default:
}
throw new IllegalArgumentException();
} | java | @Pure
public static AbstractPathElement3D newInstance(PathElementType type, Point3d last, Point3d[] coords) {
switch(type) {
case MOVE_TO:
return new MovePathElement3d(coords[0]);
case LINE_TO:
return new LinePathElement3d(last, coords[0]);
case QUAD_TO:
return new QuadPathElement3d(last, coords[0], coords[1]);
case CURVE_TO:
return new CurvePathElement3d(last, coords[0], coords[1], coords[2]);
case CLOSE:
return new ClosePathElement3d(last, coords[0]);
default:
}
throw new IllegalArgumentException();
} | [
"@",
"Pure",
"public",
"static",
"AbstractPathElement3D",
"newInstance",
"(",
"PathElementType",
"type",
",",
"Point3d",
"last",
",",
"Point3d",
"[",
"]",
"coords",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"MOVE_TO",
":",
"return",
"new",
"MovePathElement3d",
"(",
"coords",
"[",
"0",
"]",
")",
";",
"case",
"LINE_TO",
":",
"return",
"new",
"LinePathElement3d",
"(",
"last",
",",
"coords",
"[",
"0",
"]",
")",
";",
"case",
"QUAD_TO",
":",
"return",
"new",
"QuadPathElement3d",
"(",
"last",
",",
"coords",
"[",
"0",
"]",
",",
"coords",
"[",
"1",
"]",
")",
";",
"case",
"CURVE_TO",
":",
"return",
"new",
"CurvePathElement3d",
"(",
"last",
",",
"coords",
"[",
"0",
"]",
",",
"coords",
"[",
"1",
"]",
",",
"coords",
"[",
"2",
"]",
")",
";",
"case",
"CLOSE",
":",
"return",
"new",
"ClosePathElement3d",
"(",
"last",
",",
"coords",
"[",
"0",
"]",
")",
";",
"default",
":",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}"
] | Create an instance of path element, associating properties of points to the PathElement.
When the point in parameter are changed, the PathElement will change also.
@param type is the type of the new element.
@param last is the last point.
@param coords are the eventual other points.
@return the instance of path element. | [
"Create",
"an",
"instance",
"of",
"path",
"element",
"associating",
"properties",
"of",
"points",
"to",
"the",
"PathElement",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractPathElement3D.java#L76-L92 | train |
gallandarakhneorg/afc | advanced/bootique/bootique-printconfig/src/main/java/org/arakhne/afc/bootique/printconfig/commands/PrintConfigCommand.java | PrintConfigCommand.extractConfigValues | protected void extractConfigValues(Map<String, Object> yaml, List<ConfigMetadataNode> configs) {
for (final ConfigMetadataNode config : configs) {
Configs.defineConfig(yaml, config, this.injector);
}
} | java | protected void extractConfigValues(Map<String, Object> yaml, List<ConfigMetadataNode> configs) {
for (final ConfigMetadataNode config : configs) {
Configs.defineConfig(yaml, config, this.injector);
}
} | [
"protected",
"void",
"extractConfigValues",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"yaml",
",",
"List",
"<",
"ConfigMetadataNode",
">",
"configs",
")",
"{",
"for",
"(",
"final",
"ConfigMetadataNode",
"config",
":",
"configs",
")",
"{",
"Configs",
".",
"defineConfig",
"(",
"yaml",
",",
"config",
",",
"this",
".",
"injector",
")",
";",
"}",
"}"
] | Extract the definition from the given configurations.
@param yaml the to fill out.
@param configs the configurations. | [
"Extract",
"the",
"definition",
"from",
"the",
"given",
"configurations",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/bootique/bootique-printconfig/src/main/java/org/arakhne/afc/bootique/printconfig/commands/PrintConfigCommand.java#L137-L141 | train |
gallandarakhneorg/afc | advanced/bootique/bootique-printconfig/src/main/java/org/arakhne/afc/bootique/printconfig/commands/PrintConfigCommand.java | PrintConfigCommand.generateYaml | @SuppressWarnings("static-method")
protected String generateYaml(Map<String, Object> map) throws JsonProcessingException {
final YAMLFactory yamlFactory = new YAMLFactory();
yamlFactory.configure(Feature.WRITE_DOC_START_MARKER, false);
final ObjectMapper mapper = new ObjectMapper(yamlFactory);
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(map);
} | java | @SuppressWarnings("static-method")
protected String generateYaml(Map<String, Object> map) throws JsonProcessingException {
final YAMLFactory yamlFactory = new YAMLFactory();
yamlFactory.configure(Feature.WRITE_DOC_START_MARKER, false);
final ObjectMapper mapper = new ObjectMapper(yamlFactory);
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(map);
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"String",
"generateYaml",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
")",
"throws",
"JsonProcessingException",
"{",
"final",
"YAMLFactory",
"yamlFactory",
"=",
"new",
"YAMLFactory",
"(",
")",
";",
"yamlFactory",
".",
"configure",
"(",
"Feature",
".",
"WRITE_DOC_START_MARKER",
",",
"false",
")",
";",
"final",
"ObjectMapper",
"mapper",
"=",
"new",
"ObjectMapper",
"(",
"yamlFactory",
")",
";",
"return",
"mapper",
".",
"writerWithDefaultPrettyPrinter",
"(",
")",
".",
"writeValueAsString",
"(",
"map",
")",
";",
"}"
] | Generate the Yaml representation of the given map.
@param map the map to print out.
@return the Yaml representation.
@throws JsonProcessingException when the Json cannot be processed. | [
"Generate",
"the",
"Yaml",
"representation",
"of",
"the",
"given",
"map",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/bootique/bootique-printconfig/src/main/java/org/arakhne/afc/bootique/printconfig/commands/PrintConfigCommand.java#L149-L155 | train |
gallandarakhneorg/afc | advanced/bootique/bootique-printconfig/src/main/java/org/arakhne/afc/bootique/printconfig/commands/PrintConfigCommand.java | PrintConfigCommand.generateJson | @SuppressWarnings("static-method")
protected String generateJson(Map<String, Object> map) throws JsonProcessingException {
final ObjectMapper mapper = new ObjectMapper();
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(map);
} | java | @SuppressWarnings("static-method")
protected String generateJson(Map<String, Object> map) throws JsonProcessingException {
final ObjectMapper mapper = new ObjectMapper();
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(map);
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"String",
"generateJson",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
")",
"throws",
"JsonProcessingException",
"{",
"final",
"ObjectMapper",
"mapper",
"=",
"new",
"ObjectMapper",
"(",
")",
";",
"return",
"mapper",
".",
"writerWithDefaultPrettyPrinter",
"(",
")",
".",
"writeValueAsString",
"(",
"map",
")",
";",
"}"
] | Generate the Json representation of the given map.
@param map the map to print out.
@return the Json representation.
@throws JsonProcessingException when the Json cannot be processed. | [
"Generate",
"the",
"Json",
"representation",
"of",
"the",
"given",
"map",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/bootique/bootique-printconfig/src/main/java/org/arakhne/afc/bootique/printconfig/commands/PrintConfigCommand.java#L163-L167 | train |
gallandarakhneorg/afc | advanced/bootique/bootique-printconfig/src/main/java/org/arakhne/afc/bootique/printconfig/commands/PrintConfigCommand.java | PrintConfigCommand.generateXml | @SuppressWarnings({"static-method"})
protected String generateXml(Map<String, Object> map) throws JsonProcessingException {
final XmlMapper mapper = new XmlMapper();
return mapper.writerWithDefaultPrettyPrinter().withRootName(XML_ROOT_NAME).writeValueAsString(map);
} | java | @SuppressWarnings({"static-method"})
protected String generateXml(Map<String, Object> map) throws JsonProcessingException {
final XmlMapper mapper = new XmlMapper();
return mapper.writerWithDefaultPrettyPrinter().withRootName(XML_ROOT_NAME).writeValueAsString(map);
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"static-method\"",
"}",
")",
"protected",
"String",
"generateXml",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
")",
"throws",
"JsonProcessingException",
"{",
"final",
"XmlMapper",
"mapper",
"=",
"new",
"XmlMapper",
"(",
")",
";",
"return",
"mapper",
".",
"writerWithDefaultPrettyPrinter",
"(",
")",
".",
"withRootName",
"(",
"XML_ROOT_NAME",
")",
".",
"writeValueAsString",
"(",
"map",
")",
";",
"}"
] | Generate the Xml representation of the given map.
@param map the map to print out.
@return the Xml representation.
@throws JsonProcessingException when XML cannot be processed. | [
"Generate",
"the",
"Xml",
"representation",
"of",
"the",
"given",
"map",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/bootique/bootique-printconfig/src/main/java/org/arakhne/afc/bootique/printconfig/commands/PrintConfigCommand.java#L175-L179 | train |
italiangrid/voms-clients | src/main/java/org/italiangrid/voms/clients/AbstractCLI.java | AbstractCLI.parseOptionsFromFile | @SuppressWarnings("unchecked")
private void parseOptionsFromFile(String optionFileName)
throws ParseException {
List<String> options = OptionsFileLoader.loadOptions(optionFileName);
options.addAll(commandLine.getArgList());
commandLine = cliParser.parse(cliOptions, options.toArray(new String[0]));
} | java | @SuppressWarnings("unchecked")
private void parseOptionsFromFile(String optionFileName)
throws ParseException {
List<String> options = OptionsFileLoader.loadOptions(optionFileName);
options.addAll(commandLine.getArgList());
commandLine = cliParser.parse(cliOptions, options.toArray(new String[0]));
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"parseOptionsFromFile",
"(",
"String",
"optionFileName",
")",
"throws",
"ParseException",
"{",
"List",
"<",
"String",
">",
"options",
"=",
"OptionsFileLoader",
".",
"loadOptions",
"(",
"optionFileName",
")",
";",
"options",
".",
"addAll",
"(",
"commandLine",
".",
"getArgList",
"(",
")",
")",
";",
"commandLine",
"=",
"cliParser",
".",
"parse",
"(",
"cliOptions",
",",
"options",
".",
"toArray",
"(",
"new",
"String",
"[",
"0",
"]",
")",
")",
";",
"}"
] | Parse options from a file. Reload commandLine that after calling this
method contains both options coming from the command line and from the
file.
@param optionFileName
the options file
@throws ParseException
if there an error parsing the options | [
"Parse",
"options",
"from",
"a",
"file",
".",
"Reload",
"commandLine",
"that",
"after",
"calling",
"this",
"method",
"contains",
"both",
"options",
"coming",
"from",
"the",
"command",
"line",
"and",
"from",
"the",
"file",
"."
] | 069cbe324c85286fa454bd78c3f76c23e97e5768 | https://github.com/italiangrid/voms-clients/blob/069cbe324c85286fa454bd78c3f76c23e97e5768/src/main/java/org/italiangrid/voms/clients/AbstractCLI.java#L116-L124 | train |
gallandarakhneorg/afc | core/util/src/main/java/org/arakhne/afc/progress/SubProgressionModel.java | SubProgressionModel.disconnect | void disconnect() {
final DefaultProgression parentInstance = getParent();
if (parentInstance != null) {
parentInstance.disconnectSubTask(this, this.maxValueInParent, this.overwriteCommentWhenDisconnect);
}
this.parent = null;
} | java | void disconnect() {
final DefaultProgression parentInstance = getParent();
if (parentInstance != null) {
parentInstance.disconnectSubTask(this, this.maxValueInParent, this.overwriteCommentWhenDisconnect);
}
this.parent = null;
} | [
"void",
"disconnect",
"(",
")",
"{",
"final",
"DefaultProgression",
"parentInstance",
"=",
"getParent",
"(",
")",
";",
"if",
"(",
"parentInstance",
"!=",
"null",
")",
"{",
"parentInstance",
".",
"disconnectSubTask",
"(",
"this",
",",
"this",
".",
"maxValueInParent",
",",
"this",
".",
"overwriteCommentWhenDisconnect",
")",
";",
"}",
"this",
".",
"parent",
"=",
"null",
";",
"}"
] | Set the parent value and disconnect this subtask from its parent. | [
"Set",
"the",
"parent",
"value",
"and",
"disconnect",
"this",
"subtask",
"from",
"its",
"parent",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/util/src/main/java/org/arakhne/afc/progress/SubProgressionModel.java#L111-L117 | train |
italiangrid/voms-clients | src/main/java/org/italiangrid/voms/clients/VomsProxyDestroy.java | VomsProxyDestroy.initOptions | private void initOptions() {
List<CLIOption> options = new ArrayList<CLIOption>();
options.addAll(Arrays.asList(ProxyDestroyOptions.values()));
initOptions(options);
} | java | private void initOptions() {
List<CLIOption> options = new ArrayList<CLIOption>();
options.addAll(Arrays.asList(ProxyDestroyOptions.values()));
initOptions(options);
} | [
"private",
"void",
"initOptions",
"(",
")",
"{",
"List",
"<",
"CLIOption",
">",
"options",
"=",
"new",
"ArrayList",
"<",
"CLIOption",
">",
"(",
")",
";",
"options",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"ProxyDestroyOptions",
".",
"values",
"(",
")",
")",
")",
";",
"initOptions",
"(",
"options",
")",
";",
"}"
] | Initialize options. | [
"Initialize",
"options",
"."
] | 069cbe324c85286fa454bd78c3f76c23e97e5768 | https://github.com/italiangrid/voms-clients/blob/069cbe324c85286fa454bd78c3f76c23e97e5768/src/main/java/org/italiangrid/voms/clients/VomsProxyDestroy.java#L78-L85 | train |
gallandarakhneorg/afc | advanced/dbasefile/src/main/java/org/arakhne/afc/io/dbase/DBaseFileField.java | DBaseFileField.updateSizes | @SuppressWarnings("checkstyle:cyclomaticcomplexity")
void updateSizes(int fieldLength, int decimalPointPosition) {
switch (this.type) {
case STRING:
if (fieldLength > this.length) {
this.length = fieldLength;
}
break;
case FLOATING_NUMBER:
case NUMBER:
if (decimalPointPosition > this.decimal) {
final int intPart = this.length - this.decimal;
this.decimal = decimalPointPosition;
this.length = intPart + this.decimal;
}
if (fieldLength > this.length) {
this.length = fieldLength;
}
break;
//$CASES-OMITTED$
default:
// Do nothing
}
} | java | @SuppressWarnings("checkstyle:cyclomaticcomplexity")
void updateSizes(int fieldLength, int decimalPointPosition) {
switch (this.type) {
case STRING:
if (fieldLength > this.length) {
this.length = fieldLength;
}
break;
case FLOATING_NUMBER:
case NUMBER:
if (decimalPointPosition > this.decimal) {
final int intPart = this.length - this.decimal;
this.decimal = decimalPointPosition;
this.length = intPart + this.decimal;
}
if (fieldLength > this.length) {
this.length = fieldLength;
}
break;
//$CASES-OMITTED$
default:
// Do nothing
}
} | [
"@",
"SuppressWarnings",
"(",
"\"checkstyle:cyclomaticcomplexity\"",
")",
"void",
"updateSizes",
"(",
"int",
"fieldLength",
",",
"int",
"decimalPointPosition",
")",
"{",
"switch",
"(",
"this",
".",
"type",
")",
"{",
"case",
"STRING",
":",
"if",
"(",
"fieldLength",
">",
"this",
".",
"length",
")",
"{",
"this",
".",
"length",
"=",
"fieldLength",
";",
"}",
"break",
";",
"case",
"FLOATING_NUMBER",
":",
"case",
"NUMBER",
":",
"if",
"(",
"decimalPointPosition",
">",
"this",
".",
"decimal",
")",
"{",
"final",
"int",
"intPart",
"=",
"this",
".",
"length",
"-",
"this",
".",
"decimal",
";",
"this",
".",
"decimal",
"=",
"decimalPointPosition",
";",
"this",
".",
"length",
"=",
"intPart",
"+",
"this",
".",
"decimal",
";",
"}",
"if",
"(",
"fieldLength",
">",
"this",
".",
"length",
")",
"{",
"this",
".",
"length",
"=",
"fieldLength",
";",
"}",
"break",
";",
"//$CASES-OMITTED$",
"default",
":",
"// Do nothing",
"}",
"}"
] | Update the sizes with the given ones if and only if
they are greater than the existing ones.
This test is done according to the type of the field.
@param fieldLength is the size of this field
@param decimalPointPosition is the position of the decimal point. | [
"Update",
"the",
"sizes",
"with",
"the",
"given",
"ones",
"if",
"and",
"only",
"if",
"they",
"are",
"greater",
"than",
"the",
"existing",
"ones",
".",
"This",
"test",
"is",
"done",
"according",
"to",
"the",
"type",
"of",
"the",
"field",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/dbasefile/src/main/java/org/arakhne/afc/io/dbase/DBaseFileField.java#L254-L277 | train |
agmip/translator-dssat | src/main/java/org/agmip/translators/dssat/DssatSortHelper.java | DssatSortHelper.compare | @Override
public int compare(HashMap m1, HashMap m2) {
double val1;
double val2;
for (String sortId : sortIds) {
val1 = getValue(m1, sortId);
val2 = getValue(m2, sortId);
if (val1 > val2) {
return decVal;
} else if (val1 < val2) {
return ascVal;
}
}
return 0;
} | java | @Override
public int compare(HashMap m1, HashMap m2) {
double val1;
double val2;
for (String sortId : sortIds) {
val1 = getValue(m1, sortId);
val2 = getValue(m2, sortId);
if (val1 > val2) {
return decVal;
} else if (val1 < val2) {
return ascVal;
}
}
return 0;
} | [
"@",
"Override",
"public",
"int",
"compare",
"(",
"HashMap",
"m1",
",",
"HashMap",
"m2",
")",
"{",
"double",
"val1",
";",
"double",
"val2",
";",
"for",
"(",
"String",
"sortId",
":",
"sortIds",
")",
"{",
"val1",
"=",
"getValue",
"(",
"m1",
",",
"sortId",
")",
";",
"val2",
"=",
"getValue",
"(",
"m2",
",",
"sortId",
")",
";",
"if",
"(",
"val1",
">",
"val2",
")",
"{",
"return",
"decVal",
";",
"}",
"else",
"if",
"(",
"val1",
"<",
"val2",
")",
"{",
"return",
"ascVal",
";",
"}",
"}",
"return",
"0",
";",
"}"
] | Compare two element in the array, by using sorting IDs.
@param m1 Data record 1st
@param m2 Data record 2nd
@return | [
"Compare",
"two",
"element",
"in",
"the",
"array",
"by",
"using",
"sorting",
"IDs",
"."
] | 4be61d998f106eb7234ea8701b63c3746ae688f4 | https://github.com/agmip/translator-dssat/blob/4be61d998f106eb7234ea8701b63c3746ae688f4/src/main/java/org/agmip/translators/dssat/DssatSortHelper.java#L56-L70 | train |
agmip/translator-dssat | src/main/java/org/agmip/translators/dssat/DssatSortHelper.java | DssatSortHelper.getValue | private double getValue(HashMap m, String key) {
try {
return Double.parseDouble(getValueOr(m, key, ""));
} catch (Exception e) {
return Double.MIN_VALUE;
}
} | java | private double getValue(HashMap m, String key) {
try {
return Double.parseDouble(getValueOr(m, key, ""));
} catch (Exception e) {
return Double.MIN_VALUE;
}
} | [
"private",
"double",
"getValue",
"(",
"HashMap",
"m",
",",
"String",
"key",
")",
"{",
"try",
"{",
"return",
"Double",
".",
"parseDouble",
"(",
"getValueOr",
"(",
"m",
",",
"key",
",",
"\"\"",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"Double",
".",
"MIN_VALUE",
";",
"}",
"}"
] | Get number value by using key from map
@param m Data record
@param key variable name
@return | [
"Get",
"number",
"value",
"by",
"using",
"key",
"from",
"map"
] | 4be61d998f106eb7234ea8701b63c3746ae688f4 | https://github.com/agmip/translator-dssat/blob/4be61d998f106eb7234ea8701b63c3746ae688f4/src/main/java/org/agmip/translators/dssat/DssatSortHelper.java#L79-L85 | train |
lightblueseas/swing-components | src/main/java/de/alpharogroup/swing/wizard/AbstractWizardPanel.java | AbstractWizardPanel.onNext | protected void onNext()
{
stateMachine.next();
updateButtonState();
final String name = getStateMachine().getCurrentState().getName();
final CardLayout cardLayout = getWizardContentPanel().getCardLayout();
cardLayout.show(getWizardContentPanel(), name);
} | java | protected void onNext()
{
stateMachine.next();
updateButtonState();
final String name = getStateMachine().getCurrentState().getName();
final CardLayout cardLayout = getWizardContentPanel().getCardLayout();
cardLayout.show(getWizardContentPanel(), name);
} | [
"protected",
"void",
"onNext",
"(",
")",
"{",
"stateMachine",
".",
"next",
"(",
")",
";",
"updateButtonState",
"(",
")",
";",
"final",
"String",
"name",
"=",
"getStateMachine",
"(",
")",
".",
"getCurrentState",
"(",
")",
".",
"getName",
"(",
")",
";",
"final",
"CardLayout",
"cardLayout",
"=",
"getWizardContentPanel",
"(",
")",
".",
"getCardLayout",
"(",
")",
";",
"cardLayout",
".",
"show",
"(",
"getWizardContentPanel",
"(",
")",
",",
"name",
")",
";",
"}"
] | Callback method for the next action. | [
"Callback",
"method",
"for",
"the",
"next",
"action",
"."
] | 4045e85cabd8f0ce985cbfff134c3c9873930c79 | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/wizard/AbstractWizardPanel.java#L188-L195 | train |
lightblueseas/swing-components | src/main/java/de/alpharogroup/swing/wizard/AbstractWizardPanel.java | AbstractWizardPanel.onPrevious | protected void onPrevious()
{
stateMachine.previous();
updateButtonState();
final String name = getStateMachine().getCurrentState().getName();
final CardLayout cardLayout = getWizardContentPanel().getCardLayout();
cardLayout.show(getWizardContentPanel(), name);
} | java | protected void onPrevious()
{
stateMachine.previous();
updateButtonState();
final String name = getStateMachine().getCurrentState().getName();
final CardLayout cardLayout = getWizardContentPanel().getCardLayout();
cardLayout.show(getWizardContentPanel(), name);
} | [
"protected",
"void",
"onPrevious",
"(",
")",
"{",
"stateMachine",
".",
"previous",
"(",
")",
";",
"updateButtonState",
"(",
")",
";",
"final",
"String",
"name",
"=",
"getStateMachine",
"(",
")",
".",
"getCurrentState",
"(",
")",
".",
"getName",
"(",
")",
";",
"final",
"CardLayout",
"cardLayout",
"=",
"getWizardContentPanel",
"(",
")",
".",
"getCardLayout",
"(",
")",
";",
"cardLayout",
".",
"show",
"(",
"getWizardContentPanel",
"(",
")",
",",
"name",
")",
";",
"}"
] | Callback method for the previous action. | [
"Callback",
"method",
"for",
"the",
"previous",
"action",
"."
] | 4045e85cabd8f0ce985cbfff134c3c9873930c79 | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/wizard/AbstractWizardPanel.java#L200-L207 | train |
lightblueseas/swing-components | src/main/java/de/alpharogroup/swing/wizard/AbstractWizardPanel.java | AbstractWizardPanel.updateButtonState | protected void updateButtonState()
{
getNavigationPanel().getBtnPrevious()
.setEnabled(getStateMachine().getCurrentState().hasPrevious());
getNavigationPanel().getBtnNext().setEnabled(getStateMachine().getCurrentState().hasNext());
} | java | protected void updateButtonState()
{
getNavigationPanel().getBtnPrevious()
.setEnabled(getStateMachine().getCurrentState().hasPrevious());
getNavigationPanel().getBtnNext().setEnabled(getStateMachine().getCurrentState().hasNext());
} | [
"protected",
"void",
"updateButtonState",
"(",
")",
"{",
"getNavigationPanel",
"(",
")",
".",
"getBtnPrevious",
"(",
")",
".",
"setEnabled",
"(",
"getStateMachine",
"(",
")",
".",
"getCurrentState",
"(",
")",
".",
"hasPrevious",
"(",
")",
")",
";",
"getNavigationPanel",
"(",
")",
".",
"getBtnNext",
"(",
")",
".",
"setEnabled",
"(",
"getStateMachine",
"(",
")",
".",
"getCurrentState",
"(",
")",
".",
"hasNext",
"(",
")",
")",
";",
"}"
] | Update the button states. Overwrite this method for activate or disable the navigation
buttons. | [
"Update",
"the",
"button",
"states",
".",
"Overwrite",
"this",
"method",
"for",
"activate",
"or",
"disable",
"the",
"navigation",
"buttons",
"."
] | 4045e85cabd8f0ce985cbfff134c3c9873930c79 | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/wizard/AbstractWizardPanel.java#L213-L218 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java | Quaternion.conjugate | public final void conjugate(Quaternion q1) {
this.x = -q1.x;
this.y = -q1.y;
this.z = -q1.z;
this.w = q1.w;
} | java | public final void conjugate(Quaternion q1) {
this.x = -q1.x;
this.y = -q1.y;
this.z = -q1.z;
this.w = q1.w;
} | [
"public",
"final",
"void",
"conjugate",
"(",
"Quaternion",
"q1",
")",
"{",
"this",
".",
"x",
"=",
"-",
"q1",
".",
"x",
";",
"this",
".",
"y",
"=",
"-",
"q1",
".",
"y",
";",
"this",
".",
"z",
"=",
"-",
"q1",
".",
"z",
";",
"this",
".",
"w",
"=",
"q1",
".",
"w",
";",
"}"
] | Sets the value of this quaternion to the conjugate of quaternion q1.
@param q1 the source vector | [
"Sets",
"the",
"value",
"of",
"this",
"quaternion",
"to",
"the",
"conjugate",
"of",
"quaternion",
"q1",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java#L327-L332 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java | Quaternion.inverse | public final void inverse(Quaternion q1) {
double norm;
norm = 1f/(q1.w*q1.w + q1.x*q1.x + q1.y*q1.y + q1.z*q1.z);
this.w = norm*q1.w;
this.x = -norm*q1.x;
this.y = -norm*q1.y;
this.z = -norm*q1.z;
} | java | public final void inverse(Quaternion q1) {
double norm;
norm = 1f/(q1.w*q1.w + q1.x*q1.x + q1.y*q1.y + q1.z*q1.z);
this.w = norm*q1.w;
this.x = -norm*q1.x;
this.y = -norm*q1.y;
this.z = -norm*q1.z;
} | [
"public",
"final",
"void",
"inverse",
"(",
"Quaternion",
"q1",
")",
"{",
"double",
"norm",
";",
"norm",
"=",
"1f",
"/",
"(",
"q1",
".",
"w",
"*",
"q1",
".",
"w",
"+",
"q1",
".",
"x",
"*",
"q1",
".",
"x",
"+",
"q1",
".",
"y",
"*",
"q1",
".",
"y",
"+",
"q1",
".",
"z",
"*",
"q1",
".",
"z",
")",
";",
"this",
".",
"w",
"=",
"norm",
"*",
"q1",
".",
"w",
";",
"this",
".",
"x",
"=",
"-",
"norm",
"*",
"q1",
".",
"x",
";",
"this",
".",
"y",
"=",
"-",
"norm",
"*",
"q1",
".",
"y",
";",
"this",
".",
"z",
"=",
"-",
"norm",
"*",
"q1",
".",
"z",
";",
"}"
] | Sets the value of this quaternion to quaternion inverse of quaternion q1.
@param q1 the quaternion to be inverted | [
"Sets",
"the",
"value",
"of",
"this",
"quaternion",
"to",
"quaternion",
"inverse",
"of",
"quaternion",
"q1",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java#L422-L430 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java | Quaternion.inverse | public final void inverse() {
double norm;
norm = 1f/(this.w*this.w + this.x*this.x + this.y*this.y + this.z*this.z);
this.w *= norm;
this.x *= -norm;
this.y *= -norm;
this.z *= -norm;
} | java | public final void inverse() {
double norm;
norm = 1f/(this.w*this.w + this.x*this.x + this.y*this.y + this.z*this.z);
this.w *= norm;
this.x *= -norm;
this.y *= -norm;
this.z *= -norm;
} | [
"public",
"final",
"void",
"inverse",
"(",
")",
"{",
"double",
"norm",
";",
"norm",
"=",
"1f",
"/",
"(",
"this",
".",
"w",
"*",
"this",
".",
"w",
"+",
"this",
".",
"x",
"*",
"this",
".",
"x",
"+",
"this",
".",
"y",
"*",
"this",
".",
"y",
"+",
"this",
".",
"z",
"*",
"this",
".",
"z",
")",
";",
"this",
".",
"w",
"*=",
"norm",
";",
"this",
".",
"x",
"*=",
"-",
"norm",
";",
"this",
".",
"y",
"*=",
"-",
"norm",
";",
"this",
".",
"z",
"*=",
"-",
"norm",
";",
"}"
] | Sets the value of this quaternion to the quaternion inverse of itself. | [
"Sets",
"the",
"value",
"of",
"this",
"quaternion",
"to",
"the",
"quaternion",
"inverse",
"of",
"itself",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java#L436-L444 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java | Quaternion.normalize | public final void normalize(Quaternion q1) {
double norm;
norm = (q1.x*q1.x + q1.y*q1.y + q1.z*q1.z + q1.w*q1.w);
if (norm > 0f) {
norm = 1f/Math.sqrt(norm);
this.x = norm*q1.x;
this.y = norm*q1.y;
this.z = norm*q1.z;
this.w = norm*q1.w;
} else {
this.x = 0f;
this.y = 0f;
this.z = 0f;
this.w = 0f;
}
} | java | public final void normalize(Quaternion q1) {
double norm;
norm = (q1.x*q1.x + q1.y*q1.y + q1.z*q1.z + q1.w*q1.w);
if (norm > 0f) {
norm = 1f/Math.sqrt(norm);
this.x = norm*q1.x;
this.y = norm*q1.y;
this.z = norm*q1.z;
this.w = norm*q1.w;
} else {
this.x = 0f;
this.y = 0f;
this.z = 0f;
this.w = 0f;
}
} | [
"public",
"final",
"void",
"normalize",
"(",
"Quaternion",
"q1",
")",
"{",
"double",
"norm",
";",
"norm",
"=",
"(",
"q1",
".",
"x",
"*",
"q1",
".",
"x",
"+",
"q1",
".",
"y",
"*",
"q1",
".",
"y",
"+",
"q1",
".",
"z",
"*",
"q1",
".",
"z",
"+",
"q1",
".",
"w",
"*",
"q1",
".",
"w",
")",
";",
"if",
"(",
"norm",
">",
"0f",
")",
"{",
"norm",
"=",
"1f",
"/",
"Math",
".",
"sqrt",
"(",
"norm",
")",
";",
"this",
".",
"x",
"=",
"norm",
"*",
"q1",
".",
"x",
";",
"this",
".",
"y",
"=",
"norm",
"*",
"q1",
".",
"y",
";",
"this",
".",
"z",
"=",
"norm",
"*",
"q1",
".",
"z",
";",
"this",
".",
"w",
"=",
"norm",
"*",
"q1",
".",
"w",
";",
"}",
"else",
"{",
"this",
".",
"x",
"=",
"0f",
";",
"this",
".",
"y",
"=",
"0f",
";",
"this",
".",
"z",
"=",
"0f",
";",
"this",
".",
"w",
"=",
"0f",
";",
"}",
"}"
] | Sets the value of this quaternion to the normalized value
of quaternion q1.
@param q1 the quaternion to be normalized. | [
"Sets",
"the",
"value",
"of",
"this",
"quaternion",
"to",
"the",
"normalized",
"value",
"of",
"quaternion",
"q1",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java#L451-L468 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java | Quaternion.normalize | public final void normalize() {
double norm;
norm = (this.x*this.x + this.y*this.y + this.z*this.z + this.w*this.w);
if (norm > 0f) {
norm = 1f / Math.sqrt(norm);
this.x *= norm;
this.y *= norm;
this.z *= norm;
this.w *= norm;
} else {
this.x = 0f;
this.y = 0f;
this.z = 0f;
this.w = 0f;
}
} | java | public final void normalize() {
double norm;
norm = (this.x*this.x + this.y*this.y + this.z*this.z + this.w*this.w);
if (norm > 0f) {
norm = 1f / Math.sqrt(norm);
this.x *= norm;
this.y *= norm;
this.z *= norm;
this.w *= norm;
} else {
this.x = 0f;
this.y = 0f;
this.z = 0f;
this.w = 0f;
}
} | [
"public",
"final",
"void",
"normalize",
"(",
")",
"{",
"double",
"norm",
";",
"norm",
"=",
"(",
"this",
".",
"x",
"*",
"this",
".",
"x",
"+",
"this",
".",
"y",
"*",
"this",
".",
"y",
"+",
"this",
".",
"z",
"*",
"this",
".",
"z",
"+",
"this",
".",
"w",
"*",
"this",
".",
"w",
")",
";",
"if",
"(",
"norm",
">",
"0f",
")",
"{",
"norm",
"=",
"1f",
"/",
"Math",
".",
"sqrt",
"(",
"norm",
")",
";",
"this",
".",
"x",
"*=",
"norm",
";",
"this",
".",
"y",
"*=",
"norm",
";",
"this",
".",
"z",
"*=",
"norm",
";",
"this",
".",
"w",
"*=",
"norm",
";",
"}",
"else",
"{",
"this",
".",
"x",
"=",
"0f",
";",
"this",
".",
"y",
"=",
"0f",
";",
"this",
".",
"z",
"=",
"0f",
";",
"this",
".",
"w",
"=",
"0f",
";",
"}",
"}"
] | Normalizes the value of this quaternion in place. | [
"Normalizes",
"the",
"value",
"of",
"this",
"quaternion",
"in",
"place",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java#L474-L491 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java | Quaternion.setFromMatrix | public final void setFromMatrix(Matrix4f m1) {
double ww = 0.25f*(m1.m00 + m1.m11 + m1.m22 + m1.m33);
if (ww >= 0) {
if (ww >= EPS2) {
this.w = Math.sqrt(ww);
ww = 0.25f/this.w;
this.x = (m1.m21 - m1.m12)*ww;
this.y = (m1.m02 - m1.m20)*ww;
this.z = (m1.m10 - m1.m01)*ww;
return;
}
}
else {
this.w = 0;
this.x = 0;
this.y = 0;
this.z = 1;
return;
}
this.w = 0;
ww = -0.5f*(m1.m11 + m1.m22);
if (ww >= 0) {
if (ww >= EPS2) {
this.x = Math.sqrt(ww);
ww = 1.0f/(2.0f*this.x);
this.y = m1.m10*ww;
this.z = m1.m20*ww;
return;
}
} else {
this.x = 0;
this.y = 0;
this.z = 1;
return;
}
this.x = 0;
ww = 0.5f*(1.0f - m1.m22);
if (ww >= EPS2) {
this.y = Math.sqrt(ww);
this.z = m1.m21/(2.0f*this.y);
return;
}
this.y = 0;
this.z = 1;
} | java | public final void setFromMatrix(Matrix4f m1) {
double ww = 0.25f*(m1.m00 + m1.m11 + m1.m22 + m1.m33);
if (ww >= 0) {
if (ww >= EPS2) {
this.w = Math.sqrt(ww);
ww = 0.25f/this.w;
this.x = (m1.m21 - m1.m12)*ww;
this.y = (m1.m02 - m1.m20)*ww;
this.z = (m1.m10 - m1.m01)*ww;
return;
}
}
else {
this.w = 0;
this.x = 0;
this.y = 0;
this.z = 1;
return;
}
this.w = 0;
ww = -0.5f*(m1.m11 + m1.m22);
if (ww >= 0) {
if (ww >= EPS2) {
this.x = Math.sqrt(ww);
ww = 1.0f/(2.0f*this.x);
this.y = m1.m10*ww;
this.z = m1.m20*ww;
return;
}
} else {
this.x = 0;
this.y = 0;
this.z = 1;
return;
}
this.x = 0;
ww = 0.5f*(1.0f - m1.m22);
if (ww >= EPS2) {
this.y = Math.sqrt(ww);
this.z = m1.m21/(2.0f*this.y);
return;
}
this.y = 0;
this.z = 1;
} | [
"public",
"final",
"void",
"setFromMatrix",
"(",
"Matrix4f",
"m1",
")",
"{",
"double",
"ww",
"=",
"0.25f",
"*",
"(",
"m1",
".",
"m00",
"+",
"m1",
".",
"m11",
"+",
"m1",
".",
"m22",
"+",
"m1",
".",
"m33",
")",
";",
"if",
"(",
"ww",
">=",
"0",
")",
"{",
"if",
"(",
"ww",
">=",
"EPS2",
")",
"{",
"this",
".",
"w",
"=",
"Math",
".",
"sqrt",
"(",
"ww",
")",
";",
"ww",
"=",
"0.25f",
"/",
"this",
".",
"w",
";",
"this",
".",
"x",
"=",
"(",
"m1",
".",
"m21",
"-",
"m1",
".",
"m12",
")",
"*",
"ww",
";",
"this",
".",
"y",
"=",
"(",
"m1",
".",
"m02",
"-",
"m1",
".",
"m20",
")",
"*",
"ww",
";",
"this",
".",
"z",
"=",
"(",
"m1",
".",
"m10",
"-",
"m1",
".",
"m01",
")",
"*",
"ww",
";",
"return",
";",
"}",
"}",
"else",
"{",
"this",
".",
"w",
"=",
"0",
";",
"this",
".",
"x",
"=",
"0",
";",
"this",
".",
"y",
"=",
"0",
";",
"this",
".",
"z",
"=",
"1",
";",
"return",
";",
"}",
"this",
".",
"w",
"=",
"0",
";",
"ww",
"=",
"-",
"0.5f",
"*",
"(",
"m1",
".",
"m11",
"+",
"m1",
".",
"m22",
")",
";",
"if",
"(",
"ww",
">=",
"0",
")",
"{",
"if",
"(",
"ww",
">=",
"EPS2",
")",
"{",
"this",
".",
"x",
"=",
"Math",
".",
"sqrt",
"(",
"ww",
")",
";",
"ww",
"=",
"1.0f",
"/",
"(",
"2.0f",
"*",
"this",
".",
"x",
")",
";",
"this",
".",
"y",
"=",
"m1",
".",
"m10",
"*",
"ww",
";",
"this",
".",
"z",
"=",
"m1",
".",
"m20",
"*",
"ww",
";",
"return",
";",
"}",
"}",
"else",
"{",
"this",
".",
"x",
"=",
"0",
";",
"this",
".",
"y",
"=",
"0",
";",
"this",
".",
"z",
"=",
"1",
";",
"return",
";",
"}",
"this",
".",
"x",
"=",
"0",
";",
"ww",
"=",
"0.5f",
"*",
"(",
"1.0f",
"-",
"m1",
".",
"m22",
")",
";",
"if",
"(",
"ww",
">=",
"EPS2",
")",
"{",
"this",
".",
"y",
"=",
"Math",
".",
"sqrt",
"(",
"ww",
")",
";",
"this",
".",
"z",
"=",
"m1",
".",
"m21",
"/",
"(",
"2.0f",
"*",
"this",
".",
"y",
")",
";",
"return",
";",
"}",
"this",
".",
"y",
"=",
"0",
";",
"this",
".",
"z",
"=",
"1",
";",
"}"
] | Sets the value of this quaternion to the rotational component of
the passed matrix.
@param m1 the Matrix4f | [
"Sets",
"the",
"value",
"of",
"this",
"quaternion",
"to",
"the",
"rotational",
"component",
"of",
"the",
"passed",
"matrix",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java#L498-L548 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java | Quaternion.getAxis | @Pure
public final Vector3f getAxis() {
double mag = this.x*this.x + this.y*this.y + this.z*this.z;
if ( mag > EPS ) {
mag = Math.sqrt(mag);
double invMag = 1f/mag;
return new Vector3f(
this.x*invMag,
this.y*invMag,
this.z*invMag);
}
return new Vector3f(0f, 0f, 1f);
} | java | @Pure
public final Vector3f getAxis() {
double mag = this.x*this.x + this.y*this.y + this.z*this.z;
if ( mag > EPS ) {
mag = Math.sqrt(mag);
double invMag = 1f/mag;
return new Vector3f(
this.x*invMag,
this.y*invMag,
this.z*invMag);
}
return new Vector3f(0f, 0f, 1f);
} | [
"@",
"Pure",
"public",
"final",
"Vector3f",
"getAxis",
"(",
")",
"{",
"double",
"mag",
"=",
"this",
".",
"x",
"*",
"this",
".",
"x",
"+",
"this",
".",
"y",
"*",
"this",
".",
"y",
"+",
"this",
".",
"z",
"*",
"this",
".",
"z",
";",
"if",
"(",
"mag",
">",
"EPS",
")",
"{",
"mag",
"=",
"Math",
".",
"sqrt",
"(",
"mag",
")",
";",
"double",
"invMag",
"=",
"1f",
"/",
"mag",
";",
"return",
"new",
"Vector3f",
"(",
"this",
".",
"x",
"*",
"invMag",
",",
"this",
".",
"y",
"*",
"invMag",
",",
"this",
".",
"z",
"*",
"invMag",
")",
";",
"}",
"return",
"new",
"Vector3f",
"(",
"0f",
",",
"0f",
",",
"1f",
")",
";",
"}"
] | Replies the rotation axis-angle represented by this quaternion.
@return the rotation axis-angle. | [
"Replies",
"the",
"rotation",
"axis",
"-",
"angle",
"represented",
"by",
"this",
"quaternion",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java#L672-L686 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java | Quaternion.getAngle | @Pure
public final double getAngle() {
double mag = this.x*this.x + this.y*this.y + this.z*this.z;
if ( mag > EPS ) {
mag = Math.sqrt(mag);
return (2.f*Math.atan2(mag, this.w));
}
return 0f;
} | java | @Pure
public final double getAngle() {
double mag = this.x*this.x + this.y*this.y + this.z*this.z;
if ( mag > EPS ) {
mag = Math.sqrt(mag);
return (2.f*Math.atan2(mag, this.w));
}
return 0f;
} | [
"@",
"Pure",
"public",
"final",
"double",
"getAngle",
"(",
")",
"{",
"double",
"mag",
"=",
"this",
".",
"x",
"*",
"this",
".",
"x",
"+",
"this",
".",
"y",
"*",
"this",
".",
"y",
"+",
"this",
".",
"z",
"*",
"this",
".",
"z",
";",
"if",
"(",
"mag",
">",
"EPS",
")",
"{",
"mag",
"=",
"Math",
".",
"sqrt",
"(",
"mag",
")",
";",
"return",
"(",
"2.f",
"*",
"Math",
".",
"atan2",
"(",
"mag",
",",
"this",
".",
"w",
")",
")",
";",
"}",
"return",
"0f",
";",
"}"
] | Replies the rotation angle represented by this quaternion.
@return the rotation axis
@see #setAxisAngle(Vector3D, double)
@see #setAxisAngle(double, double, double, double)
@see #getAxis() | [
"Replies",
"the",
"rotation",
"angle",
"represented",
"by",
"this",
"quaternion",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java#L695-L704 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java | Quaternion.getAxisAngle | @SuppressWarnings("synthetic-access")
@Pure
public final AxisAngle getAxisAngle() {
double mag = this.x*this.x + this.y*this.y + this.z*this.z;
if ( mag > EPS ) {
mag = Math.sqrt(mag);
double invMag = 1f/mag;
return new AxisAngle(
this.x*invMag,
this.y*invMag,
this.z*invMag,
(2.*Math.atan2(mag, this.w)));
}
return new AxisAngle(0, 0, 1, 0);
} | java | @SuppressWarnings("synthetic-access")
@Pure
public final AxisAngle getAxisAngle() {
double mag = this.x*this.x + this.y*this.y + this.z*this.z;
if ( mag > EPS ) {
mag = Math.sqrt(mag);
double invMag = 1f/mag;
return new AxisAngle(
this.x*invMag,
this.y*invMag,
this.z*invMag,
(2.*Math.atan2(mag, this.w)));
}
return new AxisAngle(0, 0, 1, 0);
} | [
"@",
"SuppressWarnings",
"(",
"\"synthetic-access\"",
")",
"@",
"Pure",
"public",
"final",
"AxisAngle",
"getAxisAngle",
"(",
")",
"{",
"double",
"mag",
"=",
"this",
".",
"x",
"*",
"this",
".",
"x",
"+",
"this",
".",
"y",
"*",
"this",
".",
"y",
"+",
"this",
".",
"z",
"*",
"this",
".",
"z",
";",
"if",
"(",
"mag",
">",
"EPS",
")",
"{",
"mag",
"=",
"Math",
".",
"sqrt",
"(",
"mag",
")",
";",
"double",
"invMag",
"=",
"1f",
"/",
"mag",
";",
"return",
"new",
"AxisAngle",
"(",
"this",
".",
"x",
"*",
"invMag",
",",
"this",
".",
"y",
"*",
"invMag",
",",
"this",
".",
"z",
"*",
"invMag",
",",
"(",
"2.",
"*",
"Math",
".",
"atan2",
"(",
"mag",
",",
"this",
".",
"w",
")",
")",
")",
";",
"}",
"return",
"new",
"AxisAngle",
"(",
"0",
",",
"0",
",",
"1",
",",
"0",
")",
";",
"}"
] | Replies the rotation axis represented by this quaternion.
@return the rotation axis
@see #setAxisAngle(Vector3D, double)
@see #setAxisAngle(double, double, double, double)
@see #getAngle() | [
"Replies",
"the",
"rotation",
"axis",
"represented",
"by",
"this",
"quaternion",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java#L713-L729 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java | Quaternion.interpolate | public final void interpolate(Quaternion q1, double alpha) {
// From "Advanced Animation and Rendering Techniques"
// by Watt and Watt pg. 364, function as implemented appeared to be
// incorrect. Fails to choose the same quaternion for the double
// covering. Resulting in change of direction for rotations.
// Fixed function to negate the first quaternion in the case that the
// dot product of q1 and this is negative. Second case was not needed.
double dot,s1,s2,om,sinom;
dot = this.x*q1.x + this.y*q1.y + this.z*q1.z + this.w*q1.w;
if ( dot < 0 ) {
// negate quaternion
q1.x = -q1.x; q1.y = -q1.y; q1.z = -q1.z; q1.w = -q1.w;
dot = -dot;
}
if ( (1.0 - dot) > EPS ) {
om = Math.acos(dot);
sinom = Math.sin(om);
s1 = Math.sin((1.0-alpha)*om)/sinom;
s2 = Math.sin( alpha*om)/sinom;
} else{
s1 = 1.0 - alpha;
s2 = alpha;
}
this.w = (s1*this.w + s2*q1.w);
this.x = (s1*this.x + s2*q1.x);
this.y = (s1*this.y + s2*q1.y);
this.z = (s1*this.z + s2*q1.z);
} | java | public final void interpolate(Quaternion q1, double alpha) {
// From "Advanced Animation and Rendering Techniques"
// by Watt and Watt pg. 364, function as implemented appeared to be
// incorrect. Fails to choose the same quaternion for the double
// covering. Resulting in change of direction for rotations.
// Fixed function to negate the first quaternion in the case that the
// dot product of q1 and this is negative. Second case was not needed.
double dot,s1,s2,om,sinom;
dot = this.x*q1.x + this.y*q1.y + this.z*q1.z + this.w*q1.w;
if ( dot < 0 ) {
// negate quaternion
q1.x = -q1.x; q1.y = -q1.y; q1.z = -q1.z; q1.w = -q1.w;
dot = -dot;
}
if ( (1.0 - dot) > EPS ) {
om = Math.acos(dot);
sinom = Math.sin(om);
s1 = Math.sin((1.0-alpha)*om)/sinom;
s2 = Math.sin( alpha*om)/sinom;
} else{
s1 = 1.0 - alpha;
s2 = alpha;
}
this.w = (s1*this.w + s2*q1.w);
this.x = (s1*this.x + s2*q1.x);
this.y = (s1*this.y + s2*q1.y);
this.z = (s1*this.z + s2*q1.z);
} | [
"public",
"final",
"void",
"interpolate",
"(",
"Quaternion",
"q1",
",",
"double",
"alpha",
")",
"{",
"// From \"Advanced Animation and Rendering Techniques\"",
"// by Watt and Watt pg. 364, function as implemented appeared to be ",
"// incorrect. Fails to choose the same quaternion for the double",
"// covering. Resulting in change of direction for rotations.",
"// Fixed function to negate the first quaternion in the case that the",
"// dot product of q1 and this is negative. Second case was not needed. ",
"double",
"dot",
",",
"s1",
",",
"s2",
",",
"om",
",",
"sinom",
";",
"dot",
"=",
"this",
".",
"x",
"*",
"q1",
".",
"x",
"+",
"this",
".",
"y",
"*",
"q1",
".",
"y",
"+",
"this",
".",
"z",
"*",
"q1",
".",
"z",
"+",
"this",
".",
"w",
"*",
"q1",
".",
"w",
";",
"if",
"(",
"dot",
"<",
"0",
")",
"{",
"// negate quaternion",
"q1",
".",
"x",
"=",
"-",
"q1",
".",
"x",
";",
"q1",
".",
"y",
"=",
"-",
"q1",
".",
"y",
";",
"q1",
".",
"z",
"=",
"-",
"q1",
".",
"z",
";",
"q1",
".",
"w",
"=",
"-",
"q1",
".",
"w",
";",
"dot",
"=",
"-",
"dot",
";",
"}",
"if",
"(",
"(",
"1.0",
"-",
"dot",
")",
">",
"EPS",
")",
"{",
"om",
"=",
"Math",
".",
"acos",
"(",
"dot",
")",
";",
"sinom",
"=",
"Math",
".",
"sin",
"(",
"om",
")",
";",
"s1",
"=",
"Math",
".",
"sin",
"(",
"(",
"1.0",
"-",
"alpha",
")",
"*",
"om",
")",
"/",
"sinom",
";",
"s2",
"=",
"Math",
".",
"sin",
"(",
"alpha",
"*",
"om",
")",
"/",
"sinom",
";",
"}",
"else",
"{",
"s1",
"=",
"1.0",
"-",
"alpha",
";",
"s2",
"=",
"alpha",
";",
"}",
"this",
".",
"w",
"=",
"(",
"s1",
"*",
"this",
".",
"w",
"+",
"s2",
"*",
"q1",
".",
"w",
")",
";",
"this",
".",
"x",
"=",
"(",
"s1",
"*",
"this",
".",
"x",
"+",
"s2",
"*",
"q1",
".",
"x",
")",
";",
"this",
".",
"y",
"=",
"(",
"s1",
"*",
"this",
".",
"y",
"+",
"s2",
"*",
"q1",
".",
"y",
")",
";",
"this",
".",
"z",
"=",
"(",
"s1",
"*",
"this",
".",
"z",
"+",
"s2",
"*",
"q1",
".",
"z",
")",
";",
"}"
] | Performs a great circle interpolation between this quaternion
and the quaternion parameter and places the result into this
quaternion.
@param q1 the other quaternion
@param alpha the alpha interpolation parameter | [
"Performs",
"a",
"great",
"circle",
"interpolation",
"between",
"this",
"quaternion",
"and",
"the",
"quaternion",
"parameter",
"and",
"places",
"the",
"result",
"into",
"this",
"quaternion",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java#L738-L770 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java | Quaternion.getEulerAngles | @SuppressWarnings("synthetic-access")
@Pure
public EulerAngles getEulerAngles(CoordinateSystem3D system) {
// See http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/index.htm
// Standard used: XZY_RIGHT_HAND
Quaternion q = new Quaternion(this);
system.toSystem(q, CoordinateSystem3D.XZY_RIGHT_HAND);
double sqw = q.w * q.w;
double sqx = q.x * q.x;
double sqy = q.y * q.y;
double sqz = q.z * q.z;
double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor
double test = q.x * q.y + q.z * q.w;
if (MathUtil.compareEpsilon(test, .5 * unit) >= 0) { // singularity at north pole
return new EulerAngles(
2. * Math.atan2(q.x, q.w), // heading
MathConstants.DEMI_PI, // attitude
0.,
system);
}
if (MathUtil.compareEpsilon(test, -.5 * unit) <= 0) { // singularity at south pole
return new EulerAngles(
-2. * Math.atan2(q.x, q.w), // heading
-MathConstants.DEMI_PI, // attitude
0.,
system);
}
return new EulerAngles(
Math.atan2(2. * q.y * q.w - 2. * q.x * q.z, sqx - sqy - sqz + sqw),
Math.asin(2. * test / unit),
Math.atan2(2. * q.x * q.w - 2. * q.y * q.z, -sqx + sqy - sqz + sqw),
system);
} | java | @SuppressWarnings("synthetic-access")
@Pure
public EulerAngles getEulerAngles(CoordinateSystem3D system) {
// See http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/index.htm
// Standard used: XZY_RIGHT_HAND
Quaternion q = new Quaternion(this);
system.toSystem(q, CoordinateSystem3D.XZY_RIGHT_HAND);
double sqw = q.w * q.w;
double sqx = q.x * q.x;
double sqy = q.y * q.y;
double sqz = q.z * q.z;
double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor
double test = q.x * q.y + q.z * q.w;
if (MathUtil.compareEpsilon(test, .5 * unit) >= 0) { // singularity at north pole
return new EulerAngles(
2. * Math.atan2(q.x, q.w), // heading
MathConstants.DEMI_PI, // attitude
0.,
system);
}
if (MathUtil.compareEpsilon(test, -.5 * unit) <= 0) { // singularity at south pole
return new EulerAngles(
-2. * Math.atan2(q.x, q.w), // heading
-MathConstants.DEMI_PI, // attitude
0.,
system);
}
return new EulerAngles(
Math.atan2(2. * q.y * q.w - 2. * q.x * q.z, sqx - sqy - sqz + sqw),
Math.asin(2. * test / unit),
Math.atan2(2. * q.x * q.w - 2. * q.y * q.z, -sqx + sqy - sqz + sqw),
system);
} | [
"@",
"SuppressWarnings",
"(",
"\"synthetic-access\"",
")",
"@",
"Pure",
"public",
"EulerAngles",
"getEulerAngles",
"(",
"CoordinateSystem3D",
"system",
")",
"{",
"// See http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/index.htm",
"// Standard used: XZY_RIGHT_HAND",
"Quaternion",
"q",
"=",
"new",
"Quaternion",
"(",
"this",
")",
";",
"system",
".",
"toSystem",
"(",
"q",
",",
"CoordinateSystem3D",
".",
"XZY_RIGHT_HAND",
")",
";",
"double",
"sqw",
"=",
"q",
".",
"w",
"*",
"q",
".",
"w",
";",
"double",
"sqx",
"=",
"q",
".",
"x",
"*",
"q",
".",
"x",
";",
"double",
"sqy",
"=",
"q",
".",
"y",
"*",
"q",
".",
"y",
";",
"double",
"sqz",
"=",
"q",
".",
"z",
"*",
"q",
".",
"z",
";",
"double",
"unit",
"=",
"sqx",
"+",
"sqy",
"+",
"sqz",
"+",
"sqw",
";",
"// if normalised is one, otherwise is correction factor",
"double",
"test",
"=",
"q",
".",
"x",
"*",
"q",
".",
"y",
"+",
"q",
".",
"z",
"*",
"q",
".",
"w",
";",
"if",
"(",
"MathUtil",
".",
"compareEpsilon",
"(",
"test",
",",
".5",
"*",
"unit",
")",
">=",
"0",
")",
"{",
"// singularity at north pole",
"return",
"new",
"EulerAngles",
"(",
"2.",
"*",
"Math",
".",
"atan2",
"(",
"q",
".",
"x",
",",
"q",
".",
"w",
")",
",",
"// heading",
"MathConstants",
".",
"DEMI_PI",
",",
"// attitude",
"0.",
",",
"system",
")",
";",
"}",
"if",
"(",
"MathUtil",
".",
"compareEpsilon",
"(",
"test",
",",
"-",
".5",
"*",
"unit",
")",
"<=",
"0",
")",
"{",
"// singularity at south pole",
"return",
"new",
"EulerAngles",
"(",
"-",
"2.",
"*",
"Math",
".",
"atan2",
"(",
"q",
".",
"x",
",",
"q",
".",
"w",
")",
",",
"// heading",
"-",
"MathConstants",
".",
"DEMI_PI",
",",
"// attitude",
"0.",
",",
"system",
")",
";",
"}",
"return",
"new",
"EulerAngles",
"(",
"Math",
".",
"atan2",
"(",
"2.",
"*",
"q",
".",
"y",
"*",
"q",
".",
"w",
"-",
"2.",
"*",
"q",
".",
"x",
"*",
"q",
".",
"z",
",",
"sqx",
"-",
"sqy",
"-",
"sqz",
"+",
"sqw",
")",
",",
"Math",
".",
"asin",
"(",
"2.",
"*",
"test",
"/",
"unit",
")",
",",
"Math",
".",
"atan2",
"(",
"2.",
"*",
"q",
".",
"x",
"*",
"q",
".",
"w",
"-",
"2.",
"*",
"q",
".",
"y",
"*",
"q",
".",
"z",
",",
"-",
"sqx",
"+",
"sqy",
"-",
"sqz",
"+",
"sqw",
")",
",",
"system",
")",
";",
"}"
] | Replies the Euler's angles that corresponds to the quaternion.
@param system is the coordinate system used to define the up,left and front vectors.
@return the heading, attitude and bank angles.
@see <a href="http://en.wikipedia.org/wiki/Euler_angles">Euler Angles</a>
@see <a href="http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/index.htm">Quaternion to Euler</a> | [
"Replies",
"the",
"Euler",
"s",
"angles",
"that",
"corresponds",
"to",
"the",
"quaternion",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Quaternion.java#L901-L935 | train |
gallandarakhneorg/afc | advanced/gis/gisroadinputoutput/src/main/java/org/arakhne/afc/gis/road/io/XMLRoadUtil.java | XMLRoadUtil.writeRoadNetwork | public static void writeRoadNetwork(Element xmlNode, RoadNetwork primitive, URL geometryURL,
MapMetricProjection mapProjection, URL attributeURL, XMLBuilder builder,
PathBuilder pathBuilder, XMLResources resources) throws IOException {
final ContainerWrapper w = new ContainerWrapper(primitive);
w.setElementGeometrySource(geometryURL, mapProjection);
w.setElementAttributeSourceURL(attributeURL);
writeGISElementContainer(xmlNode,
w, NODE_ROAD, builder, pathBuilder, resources);
final Rectangle2d bounds = primitive.getBoundingBox();
if (bounds != null) {
xmlNode.setAttribute(ATTR_X, Double.toString(bounds.getMinX()));
xmlNode.setAttribute(ATTR_Y, Double.toString(bounds.getMinY()));
xmlNode.setAttribute(ATTR_WIDTH, Double.toString(bounds.getWidth()));
xmlNode.setAttribute(ATTR_HEIGHT, Double.toString(bounds.getHeight()));
}
} | java | public static void writeRoadNetwork(Element xmlNode, RoadNetwork primitive, URL geometryURL,
MapMetricProjection mapProjection, URL attributeURL, XMLBuilder builder,
PathBuilder pathBuilder, XMLResources resources) throws IOException {
final ContainerWrapper w = new ContainerWrapper(primitive);
w.setElementGeometrySource(geometryURL, mapProjection);
w.setElementAttributeSourceURL(attributeURL);
writeGISElementContainer(xmlNode,
w, NODE_ROAD, builder, pathBuilder, resources);
final Rectangle2d bounds = primitive.getBoundingBox();
if (bounds != null) {
xmlNode.setAttribute(ATTR_X, Double.toString(bounds.getMinX()));
xmlNode.setAttribute(ATTR_Y, Double.toString(bounds.getMinY()));
xmlNode.setAttribute(ATTR_WIDTH, Double.toString(bounds.getWidth()));
xmlNode.setAttribute(ATTR_HEIGHT, Double.toString(bounds.getHeight()));
}
} | [
"public",
"static",
"void",
"writeRoadNetwork",
"(",
"Element",
"xmlNode",
",",
"RoadNetwork",
"primitive",
",",
"URL",
"geometryURL",
",",
"MapMetricProjection",
"mapProjection",
",",
"URL",
"attributeURL",
",",
"XMLBuilder",
"builder",
",",
"PathBuilder",
"pathBuilder",
",",
"XMLResources",
"resources",
")",
"throws",
"IOException",
"{",
"final",
"ContainerWrapper",
"w",
"=",
"new",
"ContainerWrapper",
"(",
"primitive",
")",
";",
"w",
".",
"setElementGeometrySource",
"(",
"geometryURL",
",",
"mapProjection",
")",
";",
"w",
".",
"setElementAttributeSourceURL",
"(",
"attributeURL",
")",
";",
"writeGISElementContainer",
"(",
"xmlNode",
",",
"w",
",",
"NODE_ROAD",
",",
"builder",
",",
"pathBuilder",
",",
"resources",
")",
";",
"final",
"Rectangle2d",
"bounds",
"=",
"primitive",
".",
"getBoundingBox",
"(",
")",
";",
"if",
"(",
"bounds",
"!=",
"null",
")",
"{",
"xmlNode",
".",
"setAttribute",
"(",
"ATTR_X",
",",
"Double",
".",
"toString",
"(",
"bounds",
".",
"getMinX",
"(",
")",
")",
")",
";",
"xmlNode",
".",
"setAttribute",
"(",
"ATTR_Y",
",",
"Double",
".",
"toString",
"(",
"bounds",
".",
"getMinY",
"(",
")",
")",
")",
";",
"xmlNode",
".",
"setAttribute",
"(",
"ATTR_WIDTH",
",",
"Double",
".",
"toString",
"(",
"bounds",
".",
"getWidth",
"(",
")",
")",
")",
";",
"xmlNode",
".",
"setAttribute",
"(",
"ATTR_HEIGHT",
",",
"Double",
".",
"toString",
"(",
"bounds",
".",
"getHeight",
"(",
")",
")",
")",
";",
"}",
"}"
] | Write the XML description for the given container of roads.
@param xmlNode is the XML node to fill with the container data.
@param primitive is the container of roads to output.
@param geometryURL is the URL of the file that contains the geometry of the roads.
If <code>null</code>, the road will be directly written in the XML document.
@param mapProjection is the map projection to use to write the geometry shapes.
@param attributeURL is the URL of the file that contains the attributes of the roads.
This parameter is used only if <var>geometryURL</var> is not <code>null</code>.
@param builder is the tool to create XML nodes.
@param pathBuilder is the tool to make paths relative.
@param resources is the tool that permits to gather the resources.
@throws IOException in case of error. | [
"Write",
"the",
"XML",
"description",
"for",
"the",
"given",
"container",
"of",
"roads",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisroadinputoutput/src/main/java/org/arakhne/afc/gis/road/io/XMLRoadUtil.java#L148-L163 | train |
gallandarakhneorg/afc | advanced/bootique/bootique-synopsishelp/src/main/java/org/arakhne/afc/bootique/synopsishelp/help/SynopsisHelpGenerator.java | SynopsisHelpGenerator.printSynopsis | @SuppressWarnings("static-method")
protected void printSynopsis(HelpAppender out, String name, String argumentSynopsis) {
out.printSectionName(SYNOPSIS);
assert name != null;
if (Strings.isNullOrEmpty(argumentSynopsis)) {
out.printText(name, OPTION_SYNOPSIS);
} else {
out.printText(name, OPTION_SYNOPSIS, argumentSynopsis);
}
} | java | @SuppressWarnings("static-method")
protected void printSynopsis(HelpAppender out, String name, String argumentSynopsis) {
out.printSectionName(SYNOPSIS);
assert name != null;
if (Strings.isNullOrEmpty(argumentSynopsis)) {
out.printText(name, OPTION_SYNOPSIS);
} else {
out.printText(name, OPTION_SYNOPSIS, argumentSynopsis);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"void",
"printSynopsis",
"(",
"HelpAppender",
"out",
",",
"String",
"name",
",",
"String",
"argumentSynopsis",
")",
"{",
"out",
".",
"printSectionName",
"(",
"SYNOPSIS",
")",
";",
"assert",
"name",
"!=",
"null",
";",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"argumentSynopsis",
")",
")",
"{",
"out",
".",
"printText",
"(",
"name",
",",
"OPTION_SYNOPSIS",
")",
";",
"}",
"else",
"{",
"out",
".",
"printText",
"(",
"name",
",",
"OPTION_SYNOPSIS",
",",
"argumentSynopsis",
")",
";",
"}",
"}"
] | Print the synopsis of the command.
@param out the output receiver.
@param name the name of the command.
@param argumentSynopsis the synopsis of the arguments. | [
"Print",
"the",
"synopsis",
"of",
"the",
"command",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/bootique/bootique-synopsishelp/src/main/java/org/arakhne/afc/bootique/synopsishelp/help/SynopsisHelpGenerator.java#L107-L118 | train |
gallandarakhneorg/afc | advanced/bootique/bootique-synopsishelp/src/main/java/org/arakhne/afc/bootique/synopsishelp/help/SynopsisHelpGenerator.java | SynopsisHelpGenerator.printDetailedDescription | @SuppressWarnings("static-method")
protected void printDetailedDescription(SynopsisHelpAppender out, String detailedDescription) {
if (!Strings.isNullOrEmpty(detailedDescription)) {
out.printSectionName(DETAILED_DESCRIPTION);
out.printLongDescription(detailedDescription.split("[\r\n\f]+")); //$NON-NLS-1$
}
} | java | @SuppressWarnings("static-method")
protected void printDetailedDescription(SynopsisHelpAppender out, String detailedDescription) {
if (!Strings.isNullOrEmpty(detailedDescription)) {
out.printSectionName(DETAILED_DESCRIPTION);
out.printLongDescription(detailedDescription.split("[\r\n\f]+")); //$NON-NLS-1$
}
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"void",
"printDetailedDescription",
"(",
"SynopsisHelpAppender",
"out",
",",
"String",
"detailedDescription",
")",
"{",
"if",
"(",
"!",
"Strings",
".",
"isNullOrEmpty",
"(",
"detailedDescription",
")",
")",
"{",
"out",
".",
"printSectionName",
"(",
"DETAILED_DESCRIPTION",
")",
";",
"out",
".",
"printLongDescription",
"(",
"detailedDescription",
".",
"split",
"(",
"\"[\\r\\n\\f]+\"",
")",
")",
";",
"//$NON-NLS-1$",
"}",
"}"
] | Print the detailed description of the command.
@param out the output receiver.
@param detailedDescription the detailed description of the application. | [
"Print",
"the",
"detailed",
"description",
"of",
"the",
"command",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/bootique/bootique-synopsishelp/src/main/java/org/arakhne/afc/bootique/synopsishelp/help/SynopsisHelpGenerator.java#L125-L131 | train |
gallandarakhneorg/afc | advanced/gis/giscorefx/src/main/java/org/arakhne/afc/gis/ui/drawers/GisElementContainerDrawer.java | GisElementContainerDrawer.draw | protected Drawer<? super T> draw(ZoomableGraphicsContext gc, GISElementContainer<T> primitive, Drawer<? super T> drawer) {
Drawer<? super T> drw = drawer;
final Iterator<T> iterator = primitive.iterator(gc.getVisibleArea());
while (iterator.hasNext()) {
final T mapelement = iterator.next();
if (drw == null) {
drw = Drawers.getDrawerFor(mapelement.getClass());
if (drw != null) {
gc.save();
drw.draw(gc, mapelement);
gc.restore();
}
} else {
gc.save();
drw.draw(gc, mapelement);
gc.restore();
}
}
return drw;
} | java | protected Drawer<? super T> draw(ZoomableGraphicsContext gc, GISElementContainer<T> primitive, Drawer<? super T> drawer) {
Drawer<? super T> drw = drawer;
final Iterator<T> iterator = primitive.iterator(gc.getVisibleArea());
while (iterator.hasNext()) {
final T mapelement = iterator.next();
if (drw == null) {
drw = Drawers.getDrawerFor(mapelement.getClass());
if (drw != null) {
gc.save();
drw.draw(gc, mapelement);
gc.restore();
}
} else {
gc.save();
drw.draw(gc, mapelement);
gc.restore();
}
}
return drw;
} | [
"protected",
"Drawer",
"<",
"?",
"super",
"T",
">",
"draw",
"(",
"ZoomableGraphicsContext",
"gc",
",",
"GISElementContainer",
"<",
"T",
">",
"primitive",
",",
"Drawer",
"<",
"?",
"super",
"T",
">",
"drawer",
")",
"{",
"Drawer",
"<",
"?",
"super",
"T",
">",
"drw",
"=",
"drawer",
";",
"final",
"Iterator",
"<",
"T",
">",
"iterator",
"=",
"primitive",
".",
"iterator",
"(",
"gc",
".",
"getVisibleArea",
"(",
")",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"final",
"T",
"mapelement",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"drw",
"==",
"null",
")",
"{",
"drw",
"=",
"Drawers",
".",
"getDrawerFor",
"(",
"mapelement",
".",
"getClass",
"(",
")",
")",
";",
"if",
"(",
"drw",
"!=",
"null",
")",
"{",
"gc",
".",
"save",
"(",
")",
";",
"drw",
".",
"draw",
"(",
"gc",
",",
"mapelement",
")",
";",
"gc",
".",
"restore",
"(",
")",
";",
"}",
"}",
"else",
"{",
"gc",
".",
"save",
"(",
")",
";",
"drw",
".",
"draw",
"(",
"gc",
",",
"mapelement",
")",
";",
"gc",
".",
"restore",
"(",
")",
";",
"}",
"}",
"return",
"drw",
";",
"}"
] | Draw the primitive with the given drawer.
@param gc the graphics context to draw with.
@param primitive the primitive to draw.
@param drawer the drawer, or {@code null} to use the default.
@return the drawer to use. | [
"Draw",
"the",
"primitive",
"with",
"the",
"given",
"drawer",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscorefx/src/main/java/org/arakhne/afc/gis/ui/drawers/GisElementContainerDrawer.java#L72-L91 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractSphere3F.java | AbstractSphere3F.intersectsSolidSphereOrientedBox | @Pure
public static boolean intersectsSolidSphereOrientedBox(
double sphereCenterx, double sphereCentery, double sphereCenterz, double sphereRadius,
double boxCenterx, double boxCentery, double boxCenterz,
double boxAxis1x, double boxAxis1y, double boxAxis1z,
double boxAxis2x, double boxAxis2y, double boxAxis2z,
double boxAxis3x, double boxAxis3y, double boxAxis3z,
double boxExtentAxis1, double boxExtentAxis2, double boxExtentAxis3) {
// Find points on OBB closest and farest to sphere center
Point3f closest = new Point3f();
Point3f farest = new Point3f();
AbstractOrientedBox3F.computeClosestFarestOBBPoints(
sphereCenterx, sphereCentery, sphereCenterz,
boxCenterx, boxCentery, boxCenterz,
boxAxis1x, boxAxis1y, boxAxis1z,
boxAxis2x, boxAxis2y, boxAxis2z,
boxAxis3x, boxAxis3y, boxAxis3z,
boxExtentAxis1, boxExtentAxis2, boxExtentAxis3,
closest,
farest);
// Sphere and OBB intersect if the (squared) distance from sphere
// center to point p is less than the (squared) sphere radius
double squaredRadius = sphereRadius * sphereRadius;
return (FunctionalPoint3D.distanceSquaredPointPoint(
sphereCenterx, sphereCentery, sphereCenterz,
closest.getX(), closest.getY(), closest.getZ()) < squaredRadius);
} | java | @Pure
public static boolean intersectsSolidSphereOrientedBox(
double sphereCenterx, double sphereCentery, double sphereCenterz, double sphereRadius,
double boxCenterx, double boxCentery, double boxCenterz,
double boxAxis1x, double boxAxis1y, double boxAxis1z,
double boxAxis2x, double boxAxis2y, double boxAxis2z,
double boxAxis3x, double boxAxis3y, double boxAxis3z,
double boxExtentAxis1, double boxExtentAxis2, double boxExtentAxis3) {
// Find points on OBB closest and farest to sphere center
Point3f closest = new Point3f();
Point3f farest = new Point3f();
AbstractOrientedBox3F.computeClosestFarestOBBPoints(
sphereCenterx, sphereCentery, sphereCenterz,
boxCenterx, boxCentery, boxCenterz,
boxAxis1x, boxAxis1y, boxAxis1z,
boxAxis2x, boxAxis2y, boxAxis2z,
boxAxis3x, boxAxis3y, boxAxis3z,
boxExtentAxis1, boxExtentAxis2, boxExtentAxis3,
closest,
farest);
// Sphere and OBB intersect if the (squared) distance from sphere
// center to point p is less than the (squared) sphere radius
double squaredRadius = sphereRadius * sphereRadius;
return (FunctionalPoint3D.distanceSquaredPointPoint(
sphereCenterx, sphereCentery, sphereCenterz,
closest.getX(), closest.getY(), closest.getZ()) < squaredRadius);
} | [
"@",
"Pure",
"public",
"static",
"boolean",
"intersectsSolidSphereOrientedBox",
"(",
"double",
"sphereCenterx",
",",
"double",
"sphereCentery",
",",
"double",
"sphereCenterz",
",",
"double",
"sphereRadius",
",",
"double",
"boxCenterx",
",",
"double",
"boxCentery",
",",
"double",
"boxCenterz",
",",
"double",
"boxAxis1x",
",",
"double",
"boxAxis1y",
",",
"double",
"boxAxis1z",
",",
"double",
"boxAxis2x",
",",
"double",
"boxAxis2y",
",",
"double",
"boxAxis2z",
",",
"double",
"boxAxis3x",
",",
"double",
"boxAxis3y",
",",
"double",
"boxAxis3z",
",",
"double",
"boxExtentAxis1",
",",
"double",
"boxExtentAxis2",
",",
"double",
"boxExtentAxis3",
")",
"{",
"// Find points on OBB closest and farest to sphere center",
"Point3f",
"closest",
"=",
"new",
"Point3f",
"(",
")",
";",
"Point3f",
"farest",
"=",
"new",
"Point3f",
"(",
")",
";",
"AbstractOrientedBox3F",
".",
"computeClosestFarestOBBPoints",
"(",
"sphereCenterx",
",",
"sphereCentery",
",",
"sphereCenterz",
",",
"boxCenterx",
",",
"boxCentery",
",",
"boxCenterz",
",",
"boxAxis1x",
",",
"boxAxis1y",
",",
"boxAxis1z",
",",
"boxAxis2x",
",",
"boxAxis2y",
",",
"boxAxis2z",
",",
"boxAxis3x",
",",
"boxAxis3y",
",",
"boxAxis3z",
",",
"boxExtentAxis1",
",",
"boxExtentAxis2",
",",
"boxExtentAxis3",
",",
"closest",
",",
"farest",
")",
";",
"// Sphere and OBB intersect if the (squared) distance from sphere",
"// center to point p is less than the (squared) sphere radius",
"double",
"squaredRadius",
"=",
"sphereRadius",
"*",
"sphereRadius",
";",
"return",
"(",
"FunctionalPoint3D",
".",
"distanceSquaredPointPoint",
"(",
"sphereCenterx",
",",
"sphereCentery",
",",
"sphereCenterz",
",",
"closest",
".",
"getX",
"(",
")",
",",
"closest",
".",
"getY",
"(",
")",
",",
"closest",
".",
"getZ",
"(",
")",
")",
"<",
"squaredRadius",
")",
";",
"}"
] | Replies if the specified box intersects the specified sphere.
@param sphereCenterx x coordinate of the sphere center.
@param sphereCentery y coordinate of the sphere center.
@param sphereCenterz z coordinate of the sphere center.
@param sphereRadius is the radius of the sphere.
@param boxCenterx x coordinate of the center point of the oriented box.
@param boxCentery y coordinate of the center point of the oriented box.
@param boxCenterz z coordinate of the center point of the oriented box.
@param boxAxis1x x coordinate of the first axis of the oriented box axis.
@param boxAxis1y y coordinate of the first axis of the oriented box axis.
@param boxAxis1z z coordinate of the first axis of the oriented box axis.
@param boxAxis2x x coordinate of the second axis of the oriented box axis.
@param boxAxis2y y coordinate of the second axis of the oriented box axis.
@param boxAxis2z z coordinate of the second axis of the oriented box axis.
@param boxAxis3x x coordinate of the third axis of the oriented box axis.
@param boxAxis3y y coordinate of the third axis of the oriented box axis.
@param boxAxis3z z coordinate of the third axis of the oriented box axis.
@param boxExtentAxis1 extent of the first axis of the oriented box.
@param boxExtentAxis2 extent of the second axis of the oriented box.
@param boxExtentAxis3 extent of the third axis of the oriented box.
@return <code>true</code> if intersecting, otherwise <code>false</code> | [
"Replies",
"if",
"the",
"specified",
"box",
"intersects",
"the",
"specified",
"sphere",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractSphere3F.java#L65-L94 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractSphere3F.java | AbstractSphere3F.intersectsSphereCapsule | @Pure
public static boolean intersectsSphereCapsule(
double sphereCenterx, double sphereCentery, double sphereCenterz, double sphereRadius,
double capsuleAx, double capsuleAy, double capsuleAz,
double capsuleBx, double capsuleBy, double capsuleBz,
double capsuleRadius) {
// Compute (squared) distance between sphere center and capsule line segment
double dist2 = AbstractSegment3F.distanceSquaredSegmentPoint(
capsuleAx, capsuleAy, capsuleAz, capsuleBx, capsuleBy, capsuleBz,
sphereCenterx, sphereCentery, sphereCenterz);
// If (squared) distance smaller than (squared) sum of radii, they collide
double radius = sphereRadius + capsuleRadius;
return dist2 < radius * radius;
} | java | @Pure
public static boolean intersectsSphereCapsule(
double sphereCenterx, double sphereCentery, double sphereCenterz, double sphereRadius,
double capsuleAx, double capsuleAy, double capsuleAz,
double capsuleBx, double capsuleBy, double capsuleBz,
double capsuleRadius) {
// Compute (squared) distance between sphere center and capsule line segment
double dist2 = AbstractSegment3F.distanceSquaredSegmentPoint(
capsuleAx, capsuleAy, capsuleAz, capsuleBx, capsuleBy, capsuleBz,
sphereCenterx, sphereCentery, sphereCenterz);
// If (squared) distance smaller than (squared) sum of radii, they collide
double radius = sphereRadius + capsuleRadius;
return dist2 < radius * radius;
} | [
"@",
"Pure",
"public",
"static",
"boolean",
"intersectsSphereCapsule",
"(",
"double",
"sphereCenterx",
",",
"double",
"sphereCentery",
",",
"double",
"sphereCenterz",
",",
"double",
"sphereRadius",
",",
"double",
"capsuleAx",
",",
"double",
"capsuleAy",
",",
"double",
"capsuleAz",
",",
"double",
"capsuleBx",
",",
"double",
"capsuleBy",
",",
"double",
"capsuleBz",
",",
"double",
"capsuleRadius",
")",
"{",
"// Compute (squared) distance between sphere center and capsule line segment",
"double",
"dist2",
"=",
"AbstractSegment3F",
".",
"distanceSquaredSegmentPoint",
"(",
"capsuleAx",
",",
"capsuleAy",
",",
"capsuleAz",
",",
"capsuleBx",
",",
"capsuleBy",
",",
"capsuleBz",
",",
"sphereCenterx",
",",
"sphereCentery",
",",
"sphereCenterz",
")",
";",
"// If (squared) distance smaller than (squared) sum of radii, they collide",
"double",
"radius",
"=",
"sphereRadius",
"+",
"capsuleRadius",
";",
"return",
"dist2",
"<",
"radius",
"*",
"radius",
";",
"}"
] | Replies if the specified sphere intersects the specified capsule.
@param sphereCenterx - center of the sphere
@param sphereCentery - center of the sphere
@param sphereCenterz - center of the sphere
@param sphereRadius - radius of the sphere
@param capsuleAx - Medial line segment start point of the capsule
@param capsuleAy - Medial line segment start point of the capsule
@param capsuleAz - Medial line segment start point of the capsule
@param capsuleBx - Medial line segment end point of the capsule
@param capsuleBy - Medial line segment end point of the capsule
@param capsuleBz - Medial line segment end point of the capsule
@param capsuleRadius - radius of the capsule
@return <code>true</code> if intersecting, otherwise <code>false</code> | [
"Replies",
"if",
"the",
"specified",
"sphere",
"intersects",
"the",
"specified",
"capsule",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractSphere3F.java#L111-L124 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractSphere3F.java | AbstractSphere3F.containsSpherePoint | @Pure
public static boolean containsSpherePoint(double cx, double cy, double cz, double radius,
double px, double py, double pz) {
return FunctionalPoint3D.distanceSquaredPointPoint(
px, py, pz,
cx, cy, cz) <= (radius * radius);
} | java | @Pure
public static boolean containsSpherePoint(double cx, double cy, double cz, double radius,
double px, double py, double pz) {
return FunctionalPoint3D.distanceSquaredPointPoint(
px, py, pz,
cx, cy, cz) <= (radius * radius);
} | [
"@",
"Pure",
"public",
"static",
"boolean",
"containsSpherePoint",
"(",
"double",
"cx",
",",
"double",
"cy",
",",
"double",
"cz",
",",
"double",
"radius",
",",
"double",
"px",
",",
"double",
"py",
",",
"double",
"pz",
")",
"{",
"return",
"FunctionalPoint3D",
".",
"distanceSquaredPointPoint",
"(",
"px",
",",
"py",
",",
"pz",
",",
"cx",
",",
"cy",
",",
"cz",
")",
"<=",
"(",
"radius",
"*",
"radius",
")",
";",
"}"
] | Replies if the given point is inside the given sphere.
@param cx is the center of the sphere.
@param cy is the center of the sphere.
@param cz is the center of the sphere.
@param radius is the radius of the sphere.
@param px is the point to test.
@param py is the point to test.
@param pz is the point to test.
@return <code>true</code> if the point is inside the circle;
<code>false</code> if not. | [
"Replies",
"if",
"the",
"given",
"point",
"is",
"inside",
"the",
"given",
"sphere",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractSphere3F.java#L391-L397 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractSphere3F.java | AbstractSphere3F.containsSphereAlignedBox | @Pure
public static boolean containsSphereAlignedBox(
double cx, double cy, double cz, double radius,
double bx, double by, double bz, double bsx, double bsy, double bsz) {
double rcx = (bx + bsx/2f);
double rcy = (by + bsy/2f);
double rcz = (bz + bsz/2f);
double farX;
if (cx<=rcx) farX = bx + bsx;
else farX = bx;
double farY;
if (cy<=rcy) farY = by + bsy;
else farY = by;
double farZ;
if (cz<=rcz) farZ = bz + bsz;
else farZ = bz;
return containsSpherePoint(cx, cy, cz, radius, farX, farY, farZ);
} | java | @Pure
public static boolean containsSphereAlignedBox(
double cx, double cy, double cz, double radius,
double bx, double by, double bz, double bsx, double bsy, double bsz) {
double rcx = (bx + bsx/2f);
double rcy = (by + bsy/2f);
double rcz = (bz + bsz/2f);
double farX;
if (cx<=rcx) farX = bx + bsx;
else farX = bx;
double farY;
if (cy<=rcy) farY = by + bsy;
else farY = by;
double farZ;
if (cz<=rcz) farZ = bz + bsz;
else farZ = bz;
return containsSpherePoint(cx, cy, cz, radius, farX, farY, farZ);
} | [
"@",
"Pure",
"public",
"static",
"boolean",
"containsSphereAlignedBox",
"(",
"double",
"cx",
",",
"double",
"cy",
",",
"double",
"cz",
",",
"double",
"radius",
",",
"double",
"bx",
",",
"double",
"by",
",",
"double",
"bz",
",",
"double",
"bsx",
",",
"double",
"bsy",
",",
"double",
"bsz",
")",
"{",
"double",
"rcx",
"=",
"(",
"bx",
"+",
"bsx",
"/",
"2f",
")",
";",
"double",
"rcy",
"=",
"(",
"by",
"+",
"bsy",
"/",
"2f",
")",
";",
"double",
"rcz",
"=",
"(",
"bz",
"+",
"bsz",
"/",
"2f",
")",
";",
"double",
"farX",
";",
"if",
"(",
"cx",
"<=",
"rcx",
")",
"farX",
"=",
"bx",
"+",
"bsx",
";",
"else",
"farX",
"=",
"bx",
";",
"double",
"farY",
";",
"if",
"(",
"cy",
"<=",
"rcy",
")",
"farY",
"=",
"by",
"+",
"bsy",
";",
"else",
"farY",
"=",
"by",
";",
"double",
"farZ",
";",
"if",
"(",
"cz",
"<=",
"rcz",
")",
"farZ",
"=",
"bz",
"+",
"bsz",
";",
"else",
"farZ",
"=",
"bz",
";",
"return",
"containsSpherePoint",
"(",
"cx",
",",
"cy",
",",
"cz",
",",
"radius",
",",
"farX",
",",
"farY",
",",
"farZ",
")",
";",
"}"
] | Replies if an aligned box is inside in the sphere.
@param cx is the center of the sphere.
@param cy is the center of the sphere.
@param cz is the center of the sphere.
@param radius is the radius of the sphere.
@param bx is the lowest corner of the box.
@param by is the lowest corner of the box.
@param bz is the lowest corner of the box.
@param bsx is the X size of the box.
@param bsy is the Y size of the box.
@param bsz is the Z size of the box.
@return <code>true</code> if the given box is inside the sphere;
otherwise <code>false</code>. | [
"Replies",
"if",
"an",
"aligned",
"box",
"is",
"inside",
"in",
"the",
"sphere",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractSphere3F.java#L414-L431 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractSphere3F.java | AbstractSphere3F.intersectsSphereSphere | @Pure
public static boolean intersectsSphereSphere(
double x1, double y1, double z1, double radius1,
double x2, double y2, double z2, double radius2) {
double r = radius1+radius2;
return FunctionalPoint3D.distanceSquaredPointPoint(x1, y1, z1, x2, y2, z2) < (r*r);
} | java | @Pure
public static boolean intersectsSphereSphere(
double x1, double y1, double z1, double radius1,
double x2, double y2, double z2, double radius2) {
double r = radius1+radius2;
return FunctionalPoint3D.distanceSquaredPointPoint(x1, y1, z1, x2, y2, z2) < (r*r);
} | [
"@",
"Pure",
"public",
"static",
"boolean",
"intersectsSphereSphere",
"(",
"double",
"x1",
",",
"double",
"y1",
",",
"double",
"z1",
",",
"double",
"radius1",
",",
"double",
"x2",
",",
"double",
"y2",
",",
"double",
"z2",
",",
"double",
"radius2",
")",
"{",
"double",
"r",
"=",
"radius1",
"+",
"radius2",
";",
"return",
"FunctionalPoint3D",
".",
"distanceSquaredPointPoint",
"(",
"x1",
",",
"y1",
",",
"z1",
",",
"x2",
",",
"y2",
",",
"z2",
")",
"<",
"(",
"r",
"*",
"r",
")",
";",
"}"
] | Replies if two spheres are intersecting.
@param x1 is the center of the first sphere
@param y1 is the center of the first sphere
@param z1 is the center of the first sphere
@param radius1 is the radius of the first sphere
@param x2 is the center of the second sphere
@param y2 is the center of the second sphere
@param z2 is the center of the second sphere
@param radius2 is the radius of the second sphere
@return <code>true</code> if the two shapes are intersecting; otherwise
<code>false</code> | [
"Replies",
"if",
"two",
"spheres",
"are",
"intersecting",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractSphere3F.java#L446-L452 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractSphere3F.java | AbstractSphere3F.intersectsSphereLine | @Pure
public static boolean intersectsSphereLine(
double x1, double y1, double z1, double radius,
double x2, double y2, double z2,
double x3, double y3, double z3) {
double d = AbstractSegment3F.distanceSquaredLinePoint(x2, y2, z2, x3, y3, z3, x1, y1, z1);
return d<(radius*radius);
} | java | @Pure
public static boolean intersectsSphereLine(
double x1, double y1, double z1, double radius,
double x2, double y2, double z2,
double x3, double y3, double z3) {
double d = AbstractSegment3F.distanceSquaredLinePoint(x2, y2, z2, x3, y3, z3, x1, y1, z1);
return d<(radius*radius);
} | [
"@",
"Pure",
"public",
"static",
"boolean",
"intersectsSphereLine",
"(",
"double",
"x1",
",",
"double",
"y1",
",",
"double",
"z1",
",",
"double",
"radius",
",",
"double",
"x2",
",",
"double",
"y2",
",",
"double",
"z2",
",",
"double",
"x3",
",",
"double",
"y3",
",",
"double",
"z3",
")",
"{",
"double",
"d",
"=",
"AbstractSegment3F",
".",
"distanceSquaredLinePoint",
"(",
"x2",
",",
"y2",
",",
"z2",
",",
"x3",
",",
"y3",
",",
"z3",
",",
"x1",
",",
"y1",
",",
"z1",
")",
";",
"return",
"d",
"<",
"(",
"radius",
"*",
"radius",
")",
";",
"}"
] | Replies if a sphere and a line are intersecting.
@param x1 is the center of the sphere
@param y1 is the center of the sphere
@param z1 is the center of the sphere
@param radius is the radius of the sphere
@param x2 is the first point of the line.
@param y2 is the first point of the line.
@param z2 is the first point of the line.
@param x3 is the second point of the line.
@param y3 is the second point of the line.
@param z3 is the second point of the line.
@return <code>true</code> if the two shapes are intersecting; otherwise
<code>false</code> | [
"Replies",
"if",
"a",
"sphere",
"and",
"a",
"line",
"are",
"intersecting",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractSphere3F.java#L529-L536 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractSphere3F.java | AbstractSphere3F.intersectsSphereSegment | @Pure
public static boolean intersectsSphereSegment(
double x1, double y1, double z1, double radius,
double x2, double y2, double z2,
double x3, double y3, double z3) {
double d = AbstractSegment3F.distanceSquaredSegmentPoint(x2, y2, z2, x3, y3, z3, x1, y1, z1);
return d<(radius*radius);
} | java | @Pure
public static boolean intersectsSphereSegment(
double x1, double y1, double z1, double radius,
double x2, double y2, double z2,
double x3, double y3, double z3) {
double d = AbstractSegment3F.distanceSquaredSegmentPoint(x2, y2, z2, x3, y3, z3, x1, y1, z1);
return d<(radius*radius);
} | [
"@",
"Pure",
"public",
"static",
"boolean",
"intersectsSphereSegment",
"(",
"double",
"x1",
",",
"double",
"y1",
",",
"double",
"z1",
",",
"double",
"radius",
",",
"double",
"x2",
",",
"double",
"y2",
",",
"double",
"z2",
",",
"double",
"x3",
",",
"double",
"y3",
",",
"double",
"z3",
")",
"{",
"double",
"d",
"=",
"AbstractSegment3F",
".",
"distanceSquaredSegmentPoint",
"(",
"x2",
",",
"y2",
",",
"z2",
",",
"x3",
",",
"y3",
",",
"z3",
",",
"x1",
",",
"y1",
",",
"z1",
")",
";",
"return",
"d",
"<",
"(",
"radius",
"*",
"radius",
")",
";",
"}"
] | Replies if a sphere and a segment are intersecting.
@param x1 is the center of the sphere
@param y1 is the center of the sphere
@param z1 is the center of the sphere
@param radius is the radius of the sphere
@param x2 is the first point of the line.
@param y2 is the first point of the line.
@param z2 is the first point of the line.
@param x3 is the second point of the line.
@param y3 is the second point of the line.
@param z3 is the second point of the line.
@return <code>true</code> if the two shapes are intersecting; otherwise
<code>false</code> | [
"Replies",
"if",
"a",
"sphere",
"and",
"a",
"segment",
"are",
"intersecting",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractSphere3F.java#L553-L560 | train |
qiujuer/OkHttpPacker | okhttp/src/main/java/net/qiujuer/common/okhttp/cookie/PersistentCookieStore.java | PersistentCookieStore.encodeCookie | protected String encodeCookie(SerializableHttpCookie cookie) {
if (cookie == null)
return null;
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
ObjectOutputStream outputStream = new ObjectOutputStream(os);
outputStream.writeObject(cookie);
} catch (IOException e) {
Util.log("IOException in encodeCookie", e);
return null;
}
return byteArrayToHexString(os.toByteArray());
} | java | protected String encodeCookie(SerializableHttpCookie cookie) {
if (cookie == null)
return null;
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
ObjectOutputStream outputStream = new ObjectOutputStream(os);
outputStream.writeObject(cookie);
} catch (IOException e) {
Util.log("IOException in encodeCookie", e);
return null;
}
return byteArrayToHexString(os.toByteArray());
} | [
"protected",
"String",
"encodeCookie",
"(",
"SerializableHttpCookie",
"cookie",
")",
"{",
"if",
"(",
"cookie",
"==",
"null",
")",
"return",
"null",
";",
"ByteArrayOutputStream",
"os",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"try",
"{",
"ObjectOutputStream",
"outputStream",
"=",
"new",
"ObjectOutputStream",
"(",
"os",
")",
";",
"outputStream",
".",
"writeObject",
"(",
"cookie",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"Util",
".",
"log",
"(",
"\"IOException in encodeCookie\"",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"return",
"byteArrayToHexString",
"(",
"os",
".",
"toByteArray",
"(",
")",
")",
";",
"}"
] | Serializes Cookie object into String
@param cookie cookie to be encoded, can be null
@return cookie encoded as String | [
"Serializes",
"Cookie",
"object",
"into",
"String"
] | d2d484facb66b7e11e6cbbfeb78025f76ce25ebd | https://github.com/qiujuer/OkHttpPacker/blob/d2d484facb66b7e11e6cbbfeb78025f76ce25ebd/okhttp/src/main/java/net/qiujuer/common/okhttp/cookie/PersistentCookieStore.java#L177-L190 | train |
qiujuer/OkHttpPacker | okhttp/src/main/java/net/qiujuer/common/okhttp/cookie/PersistentCookieStore.java | PersistentCookieStore.decodeCookie | protected Cookie decodeCookie(String cookieString) {
byte[] bytes = hexStringToByteArray(cookieString);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
Cookie cookie = null;
try {
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
cookie = ((SerializableHttpCookie) objectInputStream.readObject()).getCookie();
} catch (IOException e) {
Util.log("IOException in decodeCookie", e);
} catch (ClassNotFoundException e) {
Util.log("ClassNotFoundException in decodeCookie", e);
}
return cookie;
} | java | protected Cookie decodeCookie(String cookieString) {
byte[] bytes = hexStringToByteArray(cookieString);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
Cookie cookie = null;
try {
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
cookie = ((SerializableHttpCookie) objectInputStream.readObject()).getCookie();
} catch (IOException e) {
Util.log("IOException in decodeCookie", e);
} catch (ClassNotFoundException e) {
Util.log("ClassNotFoundException in decodeCookie", e);
}
return cookie;
} | [
"protected",
"Cookie",
"decodeCookie",
"(",
"String",
"cookieString",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"hexStringToByteArray",
"(",
"cookieString",
")",
";",
"ByteArrayInputStream",
"byteArrayInputStream",
"=",
"new",
"ByteArrayInputStream",
"(",
"bytes",
")",
";",
"Cookie",
"cookie",
"=",
"null",
";",
"try",
"{",
"ObjectInputStream",
"objectInputStream",
"=",
"new",
"ObjectInputStream",
"(",
"byteArrayInputStream",
")",
";",
"cookie",
"=",
"(",
"(",
"SerializableHttpCookie",
")",
"objectInputStream",
".",
"readObject",
"(",
")",
")",
".",
"getCookie",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"Util",
".",
"log",
"(",
"\"IOException in decodeCookie\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"Util",
".",
"log",
"(",
"\"ClassNotFoundException in decodeCookie\"",
",",
"e",
")",
";",
"}",
"return",
"cookie",
";",
"}"
] | Returns cookie decoded from cookie string
@param cookieString string of cookie as returned from http request
@return decoded cookie or null if exception occured | [
"Returns",
"cookie",
"decoded",
"from",
"cookie",
"string"
] | d2d484facb66b7e11e6cbbfeb78025f76ce25ebd | https://github.com/qiujuer/OkHttpPacker/blob/d2d484facb66b7e11e6cbbfeb78025f76ce25ebd/okhttp/src/main/java/net/qiujuer/common/okhttp/cookie/PersistentCookieStore.java#L198-L212 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/ReflectionUtil.java | ReflectionUtil.getSuperClasses | @Pure
public static <T> Collection<Class<? super T>> getSuperClasses(Class<T> className) {
assert className != null;
final Collection<Class<? super T>> list = new ArrayList<>();
Class<? super T> type = className.getSuperclass();
while (type != null && !Object.class.equals(type)) {
list.add(type);
type = type.getSuperclass();
}
return list;
} | java | @Pure
public static <T> Collection<Class<? super T>> getSuperClasses(Class<T> className) {
assert className != null;
final Collection<Class<? super T>> list = new ArrayList<>();
Class<? super T> type = className.getSuperclass();
while (type != null && !Object.class.equals(type)) {
list.add(type);
type = type.getSuperclass();
}
return list;
} | [
"@",
"Pure",
"public",
"static",
"<",
"T",
">",
"Collection",
"<",
"Class",
"<",
"?",
"super",
"T",
">",
">",
"getSuperClasses",
"(",
"Class",
"<",
"T",
">",
"className",
")",
"{",
"assert",
"className",
"!=",
"null",
";",
"final",
"Collection",
"<",
"Class",
"<",
"?",
"super",
"T",
">",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Class",
"<",
"?",
"super",
"T",
">",
"type",
"=",
"className",
".",
"getSuperclass",
"(",
")",
";",
"while",
"(",
"type",
"!=",
"null",
"&&",
"!",
"Object",
".",
"class",
".",
"equals",
"(",
"type",
")",
")",
"{",
"list",
".",
"add",
"(",
"type",
")",
";",
"type",
"=",
"type",
".",
"getSuperclass",
"(",
")",
";",
"}",
"return",
"list",
";",
"}"
] | Replies the list of all the superclasses of the given class.
<p>This function does not replies <code>Object.class</code>.
@param <T> is the type of the lowest class.
@param className is the type of the lowest class.
@return the list of superclasses.
@since 5.0 | [
"Replies",
"the",
"list",
"of",
"all",
"the",
"superclasses",
"of",
"the",
"given",
"class",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/ReflectionUtil.java#L662-L672 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/ReflectionUtil.java | ReflectionUtil.getCommonType | public static Class<?> getCommonType(Class<?> type1, Class<?> type2) {
if (type1 == null) {
return type2;
}
if (type2 == null) {
return type1;
}
Class<?> top = type1;
while (!top.isAssignableFrom(type2)) {
top = top.getSuperclass();
assert top != null;
}
return top;
} | java | public static Class<?> getCommonType(Class<?> type1, Class<?> type2) {
if (type1 == null) {
return type2;
}
if (type2 == null) {
return type1;
}
Class<?> top = type1;
while (!top.isAssignableFrom(type2)) {
top = top.getSuperclass();
assert top != null;
}
return top;
} | [
"public",
"static",
"Class",
"<",
"?",
">",
"getCommonType",
"(",
"Class",
"<",
"?",
">",
"type1",
",",
"Class",
"<",
"?",
">",
"type2",
")",
"{",
"if",
"(",
"type1",
"==",
"null",
")",
"{",
"return",
"type2",
";",
"}",
"if",
"(",
"type2",
"==",
"null",
")",
"{",
"return",
"type1",
";",
"}",
"Class",
"<",
"?",
">",
"top",
"=",
"type1",
";",
"while",
"(",
"!",
"top",
".",
"isAssignableFrom",
"(",
"type2",
")",
")",
"{",
"top",
"=",
"top",
".",
"getSuperclass",
"(",
")",
";",
"assert",
"top",
"!=",
"null",
";",
"}",
"return",
"top",
";",
"}"
] | Replies the top-most type which is common to both given types.
@param type1 first type.
@param type2 second type.
@return the top-most type which is common to both given types.
@since 6.0 | [
"Replies",
"the",
"top",
"-",
"most",
"type",
"which",
"is",
"common",
"to",
"both",
"given",
"types",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/ReflectionUtil.java#L681-L694 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/ReflectionUtil.java | ReflectionUtil.getCommonType | @Pure
public static Class<?> getCommonType(Object instance1, Object instance2) {
if (instance1 == null) {
return instance2 == null ? null : instance2.getClass();
}
if (instance2 == null) {
return instance1.getClass();
}
Class<?> top = instance1.getClass();
while (!top.isInstance(instance2)) {
top = top.getSuperclass();
assert top != null;
}
return top;
} | java | @Pure
public static Class<?> getCommonType(Object instance1, Object instance2) {
if (instance1 == null) {
return instance2 == null ? null : instance2.getClass();
}
if (instance2 == null) {
return instance1.getClass();
}
Class<?> top = instance1.getClass();
while (!top.isInstance(instance2)) {
top = top.getSuperclass();
assert top != null;
}
return top;
} | [
"@",
"Pure",
"public",
"static",
"Class",
"<",
"?",
">",
"getCommonType",
"(",
"Object",
"instance1",
",",
"Object",
"instance2",
")",
"{",
"if",
"(",
"instance1",
"==",
"null",
")",
"{",
"return",
"instance2",
"==",
"null",
"?",
"null",
":",
"instance2",
".",
"getClass",
"(",
")",
";",
"}",
"if",
"(",
"instance2",
"==",
"null",
")",
"{",
"return",
"instance1",
".",
"getClass",
"(",
")",
";",
"}",
"Class",
"<",
"?",
">",
"top",
"=",
"instance1",
".",
"getClass",
"(",
")",
";",
"while",
"(",
"!",
"top",
".",
"isInstance",
"(",
"instance2",
")",
")",
"{",
"top",
"=",
"top",
".",
"getSuperclass",
"(",
")",
";",
"assert",
"top",
"!=",
"null",
";",
"}",
"return",
"top",
";",
"}"
] | Replies the top-most type which is common to both given objects.
@param instance1 first object.
@param instance2 second object.
@return the top-most type which is common to both given objects.
@since 6.0 | [
"Replies",
"the",
"top",
"-",
"most",
"type",
"which",
"is",
"common",
"to",
"both",
"given",
"objects",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/ReflectionUtil.java#L703-L717 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/ReflectionUtil.java | ReflectionUtil.getOutboxingType | @Pure
@SuppressWarnings({"checkstyle:returncount", "npathcomplexity"})
public static Class<?> getOutboxingType(Class<?> type) {
if (void.class.equals(type)) {
return Void.class;
}
if (boolean.class.equals(type)) {
return Boolean.class;
}
if (byte.class.equals(type)) {
return Byte.class;
}
if (char.class.equals(type)) {
return Character.class;
}
if (double.class.equals(type)) {
return Double.class;
}
if (float.class.equals(type)) {
return Float.class;
}
if (int.class.equals(type)) {
return Integer.class;
}
if (long.class.equals(type)) {
return Long.class;
}
if (short.class.equals(type)) {
return Short.class;
}
return type;
} | java | @Pure
@SuppressWarnings({"checkstyle:returncount", "npathcomplexity"})
public static Class<?> getOutboxingType(Class<?> type) {
if (void.class.equals(type)) {
return Void.class;
}
if (boolean.class.equals(type)) {
return Boolean.class;
}
if (byte.class.equals(type)) {
return Byte.class;
}
if (char.class.equals(type)) {
return Character.class;
}
if (double.class.equals(type)) {
return Double.class;
}
if (float.class.equals(type)) {
return Float.class;
}
if (int.class.equals(type)) {
return Integer.class;
}
if (long.class.equals(type)) {
return Long.class;
}
if (short.class.equals(type)) {
return Short.class;
}
return type;
} | [
"@",
"Pure",
"@",
"SuppressWarnings",
"(",
"{",
"\"checkstyle:returncount\"",
",",
"\"npathcomplexity\"",
"}",
")",
"public",
"static",
"Class",
"<",
"?",
">",
"getOutboxingType",
"(",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"if",
"(",
"void",
".",
"class",
".",
"equals",
"(",
"type",
")",
")",
"{",
"return",
"Void",
".",
"class",
";",
"}",
"if",
"(",
"boolean",
".",
"class",
".",
"equals",
"(",
"type",
")",
")",
"{",
"return",
"Boolean",
".",
"class",
";",
"}",
"if",
"(",
"byte",
".",
"class",
".",
"equals",
"(",
"type",
")",
")",
"{",
"return",
"Byte",
".",
"class",
";",
"}",
"if",
"(",
"char",
".",
"class",
".",
"equals",
"(",
"type",
")",
")",
"{",
"return",
"Character",
".",
"class",
";",
"}",
"if",
"(",
"double",
".",
"class",
".",
"equals",
"(",
"type",
")",
")",
"{",
"return",
"Double",
".",
"class",
";",
"}",
"if",
"(",
"float",
".",
"class",
".",
"equals",
"(",
"type",
")",
")",
"{",
"return",
"Float",
".",
"class",
";",
"}",
"if",
"(",
"int",
".",
"class",
".",
"equals",
"(",
"type",
")",
")",
"{",
"return",
"Integer",
".",
"class",
";",
"}",
"if",
"(",
"long",
".",
"class",
".",
"equals",
"(",
"type",
")",
")",
"{",
"return",
"Long",
".",
"class",
";",
"}",
"if",
"(",
"short",
".",
"class",
".",
"equals",
"(",
"type",
")",
")",
"{",
"return",
"Short",
".",
"class",
";",
"}",
"return",
"type",
";",
"}"
] | Replies the outboxing type for the given type.
@param type the type.
@return the outboxing of the given type.
@since 7.1 | [
"Replies",
"the",
"outboxing",
"type",
"for",
"the",
"given",
"type",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/ReflectionUtil.java#L725-L756 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/ReflectionUtil.java | ReflectionUtil.matchesParameters | @Pure
public static boolean matchesParameters(Class<?>[] formalParameters, Object... parameterValues) {
if (formalParameters == null) {
return parameterValues == null;
}
if (parameterValues != null && formalParameters.length == parameterValues.length) {
for (int i = 0; i < formalParameters.length; ++i) {
if (!isInstance(formalParameters[i], parameterValues[i])) {
return false;
}
}
return true;
}
return false;
} | java | @Pure
public static boolean matchesParameters(Class<?>[] formalParameters, Object... parameterValues) {
if (formalParameters == null) {
return parameterValues == null;
}
if (parameterValues != null && formalParameters.length == parameterValues.length) {
for (int i = 0; i < formalParameters.length; ++i) {
if (!isInstance(formalParameters[i], parameterValues[i])) {
return false;
}
}
return true;
}
return false;
} | [
"@",
"Pure",
"public",
"static",
"boolean",
"matchesParameters",
"(",
"Class",
"<",
"?",
">",
"[",
"]",
"formalParameters",
",",
"Object",
"...",
"parameterValues",
")",
"{",
"if",
"(",
"formalParameters",
"==",
"null",
")",
"{",
"return",
"parameterValues",
"==",
"null",
";",
"}",
"if",
"(",
"parameterValues",
"!=",
"null",
"&&",
"formalParameters",
".",
"length",
"==",
"parameterValues",
".",
"length",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"formalParameters",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"!",
"isInstance",
"(",
"formalParameters",
"[",
"i",
"]",
",",
"parameterValues",
"[",
"i",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Replies if the formal parameters are matching the given values.
@param formalParameters the types of the formal parameters.
@param parameterValues the values associated to the paramters.
@return <code>true</code> if the values could be passed to the method.
@since 7.1 | [
"Replies",
"if",
"the",
"formal",
"parameters",
"are",
"matching",
"the",
"given",
"values",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/ReflectionUtil.java#L804-L818 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/ReflectionUtil.java | ReflectionUtil.matchesParameters | @Pure
@Inline(value = "ReflectionUtil.matchesParameters(($1).getParameterTypes(), ($2))", imported = {ReflectionUtil.class})
public static boolean matchesParameters(Method method, Object... parameters) {
return matchesParameters(method.getParameterTypes(), parameters);
} | java | @Pure
@Inline(value = "ReflectionUtil.matchesParameters(($1).getParameterTypes(), ($2))", imported = {ReflectionUtil.class})
public static boolean matchesParameters(Method method, Object... parameters) {
return matchesParameters(method.getParameterTypes(), parameters);
} | [
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"ReflectionUtil.matchesParameters(($1).getParameterTypes(), ($2))\"",
",",
"imported",
"=",
"{",
"ReflectionUtil",
".",
"class",
"}",
")",
"public",
"static",
"boolean",
"matchesParameters",
"(",
"Method",
"method",
",",
"Object",
"...",
"parameters",
")",
"{",
"return",
"matchesParameters",
"(",
"method",
".",
"getParameterTypes",
"(",
")",
",",
"parameters",
")",
";",
"}"
] | Replies if the parameters of the given method are matching the given values.
@param method the method that contains the types.
@param parameters the objects associated to the paramters.
@return <code>true</code> if the values could be passed to the method.
@since 7.1 | [
"Replies",
"if",
"the",
"parameters",
"of",
"the",
"given",
"method",
"are",
"matching",
"the",
"given",
"values",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/ReflectionUtil.java#L827-L831 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/ReflectionUtil.java | ReflectionUtil.toJson | public static void toJson(Object object, JsonBuffer output) {
if (object == null) {
return;
}
for (final Method method : object.getClass().getMethods()) {
try {
if (!method.isSynthetic() && !Modifier.isStatic(method.getModifiers()) && method.getParameterCount() == 0
&& (method.getReturnType().isPrimitive() || String.class.equals(method.getReturnType())
|| method.getReturnType().isEnum())) {
final String name = method.getName();
if (name.startsWith("get") && name.length() > 3) { //$NON-NLS-1$
output.add(makeName(name, 3), method.invoke(object));
} else if (name.startsWith("is") && name.length() > 2) { //$NON-NLS-1$
output.add(makeName(name, 2), method.invoke(object));
}
}
} catch (Exception e) {
//
}
}
} | java | public static void toJson(Object object, JsonBuffer output) {
if (object == null) {
return;
}
for (final Method method : object.getClass().getMethods()) {
try {
if (!method.isSynthetic() && !Modifier.isStatic(method.getModifiers()) && method.getParameterCount() == 0
&& (method.getReturnType().isPrimitive() || String.class.equals(method.getReturnType())
|| method.getReturnType().isEnum())) {
final String name = method.getName();
if (name.startsWith("get") && name.length() > 3) { //$NON-NLS-1$
output.add(makeName(name, 3), method.invoke(object));
} else if (name.startsWith("is") && name.length() > 2) { //$NON-NLS-1$
output.add(makeName(name, 2), method.invoke(object));
}
}
} catch (Exception e) {
//
}
}
} | [
"public",
"static",
"void",
"toJson",
"(",
"Object",
"object",
",",
"JsonBuffer",
"output",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"return",
";",
"}",
"for",
"(",
"final",
"Method",
"method",
":",
"object",
".",
"getClass",
"(",
")",
".",
"getMethods",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"method",
".",
"isSynthetic",
"(",
")",
"&&",
"!",
"Modifier",
".",
"isStatic",
"(",
"method",
".",
"getModifiers",
"(",
")",
")",
"&&",
"method",
".",
"getParameterCount",
"(",
")",
"==",
"0",
"&&",
"(",
"method",
".",
"getReturnType",
"(",
")",
".",
"isPrimitive",
"(",
")",
"||",
"String",
".",
"class",
".",
"equals",
"(",
"method",
".",
"getReturnType",
"(",
")",
")",
"||",
"method",
".",
"getReturnType",
"(",
")",
".",
"isEnum",
"(",
")",
")",
")",
"{",
"final",
"String",
"name",
"=",
"method",
".",
"getName",
"(",
")",
";",
"if",
"(",
"name",
".",
"startsWith",
"(",
"\"get\"",
")",
"&&",
"name",
".",
"length",
"(",
")",
">",
"3",
")",
"{",
"//$NON-NLS-1$",
"output",
".",
"add",
"(",
"makeName",
"(",
"name",
",",
"3",
")",
",",
"method",
".",
"invoke",
"(",
"object",
")",
")",
";",
"}",
"else",
"if",
"(",
"name",
".",
"startsWith",
"(",
"\"is\"",
")",
"&&",
"name",
".",
"length",
"(",
")",
">",
"2",
")",
"{",
"//$NON-NLS-1$",
"output",
".",
"add",
"(",
"makeName",
"(",
"name",
",",
"2",
")",
",",
"method",
".",
"invoke",
"(",
"object",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"//",
"}",
"}",
"}"
] | Replies the string representation of the given object.
<p>The string representation is based on the values replied by the getters (functions
that are starting by "get" or "is" or "has").
@param object the object to analyze.
@param output the Json string representation.
@since 15.0 | [
"Replies",
"the",
"string",
"representation",
"of",
"the",
"given",
"object",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/ReflectionUtil.java#L856-L876 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Capsule3d.java | Capsule3d.getCenter | @Pure
@Override
public Point3d getCenter() {
return new Point3d(
(this.medial1.getX() + this.medial2.getX()) / 2.,
(this.medial1.getY() + this.medial2.getY()) / 2.,
(this.medial1.getZ() + this.medial2.getZ()) / 2.);
} | java | @Pure
@Override
public Point3d getCenter() {
return new Point3d(
(this.medial1.getX() + this.medial2.getX()) / 2.,
(this.medial1.getY() + this.medial2.getY()) / 2.,
(this.medial1.getZ() + this.medial2.getZ()) / 2.);
} | [
"@",
"Pure",
"@",
"Override",
"public",
"Point3d",
"getCenter",
"(",
")",
"{",
"return",
"new",
"Point3d",
"(",
"(",
"this",
".",
"medial1",
".",
"getX",
"(",
")",
"+",
"this",
".",
"medial2",
".",
"getX",
"(",
")",
")",
"/",
"2.",
",",
"(",
"this",
".",
"medial1",
".",
"getY",
"(",
")",
"+",
"this",
".",
"medial2",
".",
"getY",
"(",
")",
")",
"/",
"2.",
",",
"(",
"this",
".",
"medial1",
".",
"getZ",
"(",
")",
"+",
"this",
".",
"medial2",
".",
"getZ",
"(",
")",
")",
"/",
"2.",
")",
";",
"}"
] | Replies the center point of the capsule.
@return the center point. | [
"Replies",
"the",
"center",
"point",
"of",
"the",
"capsule",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Capsule3d.java#L366-L373 | train |
lightblueseas/swing-components | src/main/java/de/alpharogroup/swing/table/model/GenericTableColumnsModel.java | GenericTableColumnsModel.onSetColumnNames | protected void onSetColumnNames()
{
columnNames = ReflectionExtensions.getDeclaredFieldNames(getType(), "serialVersionUID");
for(int i = 0; i < columnNames.length; i++){
columnNames[i] = StringUtils.capitalize(columnNames[i]);
}
} | java | protected void onSetColumnNames()
{
columnNames = ReflectionExtensions.getDeclaredFieldNames(getType(), "serialVersionUID");
for(int i = 0; i < columnNames.length; i++){
columnNames[i] = StringUtils.capitalize(columnNames[i]);
}
} | [
"protected",
"void",
"onSetColumnNames",
"(",
")",
"{",
"columnNames",
"=",
"ReflectionExtensions",
".",
"getDeclaredFieldNames",
"(",
"getType",
"(",
")",
",",
"\"serialVersionUID\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"columnNames",
".",
"length",
";",
"i",
"++",
")",
"{",
"columnNames",
"[",
"i",
"]",
"=",
"StringUtils",
".",
"capitalize",
"(",
"columnNames",
"[",
"i",
"]",
")",
";",
"}",
"}"
] | Callback method for set the column names array from the generic given type. This method is
invoked in the constructor from the derived classes and can be overridden so users can
provide their own version of a column names | [
"Callback",
"method",
"for",
"set",
"the",
"column",
"names",
"array",
"from",
"the",
"generic",
"given",
"type",
".",
"This",
"method",
"is",
"invoked",
"in",
"the",
"constructor",
"from",
"the",
"derived",
"classes",
"and",
"can",
"be",
"overridden",
"so",
"users",
"can",
"provide",
"their",
"own",
"version",
"of",
"a",
"column",
"names"
] | 4045e85cabd8f0ce985cbfff134c3c9873930c79 | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/table/model/GenericTableColumnsModel.java#L75-L81 | train |
lightblueseas/swing-components | src/main/java/de/alpharogroup/swing/table/model/GenericTableColumnsModel.java | GenericTableColumnsModel.onSetCanEdit | protected void onSetCanEdit()
{
Field[] fields = ReflectionExtensions.getDeclaredFields(getType(), "serialVersionUID");
canEdit = new boolean[fields.length];
for (int i = 0; i < fields.length; i++)
{
canEdit[i] = false;
}
} | java | protected void onSetCanEdit()
{
Field[] fields = ReflectionExtensions.getDeclaredFields(getType(), "serialVersionUID");
canEdit = new boolean[fields.length];
for (int i = 0; i < fields.length; i++)
{
canEdit[i] = false;
}
} | [
"protected",
"void",
"onSetCanEdit",
"(",
")",
"{",
"Field",
"[",
"]",
"fields",
"=",
"ReflectionExtensions",
".",
"getDeclaredFields",
"(",
"getType",
"(",
")",
",",
"\"serialVersionUID\"",
")",
";",
"canEdit",
"=",
"new",
"boolean",
"[",
"fields",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fields",
".",
"length",
";",
"i",
"++",
")",
"{",
"canEdit",
"[",
"i",
"]",
"=",
"false",
";",
"}",
"}"
] | Callback method for set the canEdit array from the generic given type. This method is invoked
in the constructor from the derived classes and can be overridden so users can provide their
own version of a column classes | [
"Callback",
"method",
"for",
"set",
"the",
"canEdit",
"array",
"from",
"the",
"generic",
"given",
"type",
".",
"This",
"method",
"is",
"invoked",
"in",
"the",
"constructor",
"from",
"the",
"derived",
"classes",
"and",
"can",
"be",
"overridden",
"so",
"users",
"can",
"provide",
"their",
"own",
"version",
"of",
"a",
"column",
"classes"
] | 4045e85cabd8f0ce985cbfff134c3c9873930c79 | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/table/model/GenericTableColumnsModel.java#L108-L116 | train |
gallandarakhneorg/afc | core/maths/mathtree/src/main/java/org/arakhne/afc/math/tree/node/ConstantNaryTreeNode.java | ConstantNaryTreeNode.setChildAt | @Override
public boolean setChildAt(int index, N newChild) throws IndexOutOfBoundsException {
final N oldChild = (index < this.children.length) ? this.children[index] : null;
if (oldChild == newChild) {
return false;
}
if (oldChild != null) {
oldChild.setParentNodeReference(null, true);
--this.notNullChildCount;
firePropertyChildRemoved(index, oldChild);
}
if (newChild != null) {
final N oldParent = newChild.getParentNode();
if (oldParent != this) {
newChild.removeFromParent();
}
}
// set the element
this.children[index] = newChild;
if (newChild != null) {
newChild.setParentNodeReference(toN(), true);
++this.notNullChildCount;
firePropertyChildAdded(index, newChild);
}
return true;
} | java | @Override
public boolean setChildAt(int index, N newChild) throws IndexOutOfBoundsException {
final N oldChild = (index < this.children.length) ? this.children[index] : null;
if (oldChild == newChild) {
return false;
}
if (oldChild != null) {
oldChild.setParentNodeReference(null, true);
--this.notNullChildCount;
firePropertyChildRemoved(index, oldChild);
}
if (newChild != null) {
final N oldParent = newChild.getParentNode();
if (oldParent != this) {
newChild.removeFromParent();
}
}
// set the element
this.children[index] = newChild;
if (newChild != null) {
newChild.setParentNodeReference(toN(), true);
++this.notNullChildCount;
firePropertyChildAdded(index, newChild);
}
return true;
} | [
"@",
"Override",
"public",
"boolean",
"setChildAt",
"(",
"int",
"index",
",",
"N",
"newChild",
")",
"throws",
"IndexOutOfBoundsException",
"{",
"final",
"N",
"oldChild",
"=",
"(",
"index",
"<",
"this",
".",
"children",
".",
"length",
")",
"?",
"this",
".",
"children",
"[",
"index",
"]",
":",
"null",
";",
"if",
"(",
"oldChild",
"==",
"newChild",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"oldChild",
"!=",
"null",
")",
"{",
"oldChild",
".",
"setParentNodeReference",
"(",
"null",
",",
"true",
")",
";",
"--",
"this",
".",
"notNullChildCount",
";",
"firePropertyChildRemoved",
"(",
"index",
",",
"oldChild",
")",
";",
"}",
"if",
"(",
"newChild",
"!=",
"null",
")",
"{",
"final",
"N",
"oldParent",
"=",
"newChild",
".",
"getParentNode",
"(",
")",
";",
"if",
"(",
"oldParent",
"!=",
"this",
")",
"{",
"newChild",
".",
"removeFromParent",
"(",
")",
";",
"}",
"}",
"// set the element",
"this",
".",
"children",
"[",
"index",
"]",
"=",
"newChild",
";",
"if",
"(",
"newChild",
"!=",
"null",
")",
"{",
"newChild",
".",
"setParentNodeReference",
"(",
"toN",
"(",
")",
",",
"true",
")",
";",
"++",
"this",
".",
"notNullChildCount",
";",
"firePropertyChildAdded",
"(",
"index",
",",
"newChild",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Set the child at the given index in this node.
@param index is the index of the new child between <code>0</code>
and <code>getChildCount()</code> (inclusive).
@param newChild is the child to insert. | [
"Set",
"the",
"child",
"at",
"the",
"given",
"index",
"in",
"this",
"node",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathtree/src/main/java/org/arakhne/afc/math/tree/node/ConstantNaryTreeNode.java#L219-L249 | train |
gallandarakhneorg/afc | core/util/src/main/java/org/arakhne/afc/sizediterator/MultiSizedIterator.java | MultiSizedIterator.addIterator | public void addIterator(SizedIterator<? extends M> iterator) {
if (this.iterators.add(iterator)) {
this.total += iterator.totalSize();
this.update = true;
}
} | java | public void addIterator(SizedIterator<? extends M> iterator) {
if (this.iterators.add(iterator)) {
this.total += iterator.totalSize();
this.update = true;
}
} | [
"public",
"void",
"addIterator",
"(",
"SizedIterator",
"<",
"?",
"extends",
"M",
">",
"iterator",
")",
"{",
"if",
"(",
"this",
".",
"iterators",
".",
"add",
"(",
"iterator",
")",
")",
"{",
"this",
".",
"total",
"+=",
"iterator",
".",
"totalSize",
"(",
")",
";",
"this",
".",
"update",
"=",
"true",
";",
"}",
"}"
] | Add an iterator in the list of iterators.
@param iterator the iterator. | [
"Add",
"an",
"iterator",
"in",
"the",
"list",
"of",
"iterators",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/util/src/main/java/org/arakhne/afc/sizediterator/MultiSizedIterator.java#L62-L67 | train |
gallandarakhneorg/afc | advanced/gis/gisinputoutput/src/main/java/org/arakhne/afc/gis/io/binary/GISLayerWriter.java | GISLayerWriter.write | public void write(Collection<? extends MapLayer> layers) throws IOException {
if (this.progression != null) {
this.progression.setProperties(0, 0, layers.size() + 1, false);
}
// Write the header
if (!this.isHeaderWritten) {
this.isHeaderWritten = true;
writeHeader();
}
if (this.progression != null) {
this.progression.increment();
}
final ObjectOutputStream oos = new ObjectOutputStream(this.tmpOutput);
for (final MapLayer layer : layers) {
oos.writeObject(layer);
++this.length;
if (this.progression != null) {
this.progression.increment();
}
}
if (this.progression != null) {
this.progression.end();
}
} | java | public void write(Collection<? extends MapLayer> layers) throws IOException {
if (this.progression != null) {
this.progression.setProperties(0, 0, layers.size() + 1, false);
}
// Write the header
if (!this.isHeaderWritten) {
this.isHeaderWritten = true;
writeHeader();
}
if (this.progression != null) {
this.progression.increment();
}
final ObjectOutputStream oos = new ObjectOutputStream(this.tmpOutput);
for (final MapLayer layer : layers) {
oos.writeObject(layer);
++this.length;
if (this.progression != null) {
this.progression.increment();
}
}
if (this.progression != null) {
this.progression.end();
}
} | [
"public",
"void",
"write",
"(",
"Collection",
"<",
"?",
"extends",
"MapLayer",
">",
"layers",
")",
"throws",
"IOException",
"{",
"if",
"(",
"this",
".",
"progression",
"!=",
"null",
")",
"{",
"this",
".",
"progression",
".",
"setProperties",
"(",
"0",
",",
"0",
",",
"layers",
".",
"size",
"(",
")",
"+",
"1",
",",
"false",
")",
";",
"}",
"// Write the header",
"if",
"(",
"!",
"this",
".",
"isHeaderWritten",
")",
"{",
"this",
".",
"isHeaderWritten",
"=",
"true",
";",
"writeHeader",
"(",
")",
";",
"}",
"if",
"(",
"this",
".",
"progression",
"!=",
"null",
")",
"{",
"this",
".",
"progression",
".",
"increment",
"(",
")",
";",
"}",
"final",
"ObjectOutputStream",
"oos",
"=",
"new",
"ObjectOutputStream",
"(",
"this",
".",
"tmpOutput",
")",
";",
"for",
"(",
"final",
"MapLayer",
"layer",
":",
"layers",
")",
"{",
"oos",
".",
"writeObject",
"(",
"layer",
")",
";",
"++",
"this",
".",
"length",
";",
"if",
"(",
"this",
".",
"progression",
"!=",
"null",
")",
"{",
"this",
".",
"progression",
".",
"increment",
"(",
")",
";",
"}",
"}",
"if",
"(",
"this",
".",
"progression",
"!=",
"null",
")",
"{",
"this",
".",
"progression",
".",
"end",
"(",
")",
";",
"}",
"}"
] | Write the given layers into the output.
@param layers are the layers to write.
@throws IOException in case of error. | [
"Write",
"the",
"given",
"layers",
"into",
"the",
"output",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisinputoutput/src/main/java/org/arakhne/afc/gis/io/binary/GISLayerWriter.java#L186-L212 | train |
gallandarakhneorg/afc | advanced/gis/gisinputoutput/src/main/java/org/arakhne/afc/gis/io/binary/GISLayerWriter.java | GISLayerWriter.writeHeader | protected void writeHeader() throws IOException {
this.tmpOutput.write(HEADER_KEY.getBytes());
this.tmpOutput.write(new byte[]{MAJOR_SPEC_NUMBER, MINOR_SPEC_NUMBER});
this.tmpOutput.write(new byte[] {0, 0, 0, 0});
} | java | protected void writeHeader() throws IOException {
this.tmpOutput.write(HEADER_KEY.getBytes());
this.tmpOutput.write(new byte[]{MAJOR_SPEC_NUMBER, MINOR_SPEC_NUMBER});
this.tmpOutput.write(new byte[] {0, 0, 0, 0});
} | [
"protected",
"void",
"writeHeader",
"(",
")",
"throws",
"IOException",
"{",
"this",
".",
"tmpOutput",
".",
"write",
"(",
"HEADER_KEY",
".",
"getBytes",
"(",
")",
")",
";",
"this",
".",
"tmpOutput",
".",
"write",
"(",
"new",
"byte",
"[",
"]",
"{",
"MAJOR_SPEC_NUMBER",
",",
"MINOR_SPEC_NUMBER",
"}",
")",
";",
"this",
".",
"tmpOutput",
".",
"write",
"(",
"new",
"byte",
"[",
"]",
"{",
"0",
",",
"0",
",",
"0",
",",
"0",
"}",
")",
";",
"}"
] | Write the header of the file.
@throws IOException in case of error. | [
"Write",
"the",
"header",
"of",
"the",
"file",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisinputoutput/src/main/java/org/arakhne/afc/gis/io/binary/GISLayerWriter.java#L218-L222 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/AbstractOperatingSystemWrapper.java | AbstractOperatingSystemWrapper.runCommand | protected static String runCommand(String... command) {
try {
final Process p = Runtime.getRuntime().exec(command);
if (p == null) {
return null;
}
final StringBuilder bStr = new StringBuilder();
try (InputStream standardOutput = p.getInputStream()) {
final byte[] buffer = new byte[BUFFER_SIZE];
int len;
while ((len = standardOutput.read(buffer)) > 0) {
bStr.append(new String(buffer, 0, len));
}
p.waitFor();
return bStr.toString();
}
} catch (Exception e) {
return null;
}
} | java | protected static String runCommand(String... command) {
try {
final Process p = Runtime.getRuntime().exec(command);
if (p == null) {
return null;
}
final StringBuilder bStr = new StringBuilder();
try (InputStream standardOutput = p.getInputStream()) {
final byte[] buffer = new byte[BUFFER_SIZE];
int len;
while ((len = standardOutput.read(buffer)) > 0) {
bStr.append(new String(buffer, 0, len));
}
p.waitFor();
return bStr.toString();
}
} catch (Exception e) {
return null;
}
} | [
"protected",
"static",
"String",
"runCommand",
"(",
"String",
"...",
"command",
")",
"{",
"try",
"{",
"final",
"Process",
"p",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"exec",
"(",
"command",
")",
";",
"if",
"(",
"p",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"StringBuilder",
"bStr",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"try",
"(",
"InputStream",
"standardOutput",
"=",
"p",
".",
"getInputStream",
"(",
")",
")",
"{",
"final",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"BUFFER_SIZE",
"]",
";",
"int",
"len",
";",
"while",
"(",
"(",
"len",
"=",
"standardOutput",
".",
"read",
"(",
"buffer",
")",
")",
">",
"0",
")",
"{",
"bStr",
".",
"append",
"(",
"new",
"String",
"(",
"buffer",
",",
"0",
",",
"len",
")",
")",
";",
"}",
"p",
".",
"waitFor",
"(",
")",
";",
"return",
"bStr",
".",
"toString",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Run a shell command.
@param command is the shell command to run.
@return the standard output | [
"Run",
"a",
"shell",
"command",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/AbstractOperatingSystemWrapper.java#L54-L73 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/AbstractOperatingSystemWrapper.java | AbstractOperatingSystemWrapper.grep | protected static String grep(String selector, String text) {
if (text == null || text.isEmpty()) {
return null;
}
final StringBuilder line = new StringBuilder();
final int textLength = text.length();
char c;
String string;
for (int i = 0; i < textLength; ++i) {
c = text.charAt(i);
if (c == '\n' || c == '\r') {
string = line.toString();
if (string.contains(selector)) {
return string;
}
line.setLength(0);
} else {
line.append(c);
}
}
if (line.length() > 0) {
string = line.toString();
if (string.contains(selector)) {
return string;
}
}
return null;
} | java | protected static String grep(String selector, String text) {
if (text == null || text.isEmpty()) {
return null;
}
final StringBuilder line = new StringBuilder();
final int textLength = text.length();
char c;
String string;
for (int i = 0; i < textLength; ++i) {
c = text.charAt(i);
if (c == '\n' || c == '\r') {
string = line.toString();
if (string.contains(selector)) {
return string;
}
line.setLength(0);
} else {
line.append(c);
}
}
if (line.length() > 0) {
string = line.toString();
if (string.contains(selector)) {
return string;
}
}
return null;
} | [
"protected",
"static",
"String",
"grep",
"(",
"String",
"selector",
",",
"String",
"text",
")",
"{",
"if",
"(",
"text",
"==",
"null",
"||",
"text",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"final",
"StringBuilder",
"line",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"int",
"textLength",
"=",
"text",
".",
"length",
"(",
")",
";",
"char",
"c",
";",
"String",
"string",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"textLength",
";",
"++",
"i",
")",
"{",
"c",
"=",
"text",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
")",
"{",
"string",
"=",
"line",
".",
"toString",
"(",
")",
";",
"if",
"(",
"string",
".",
"contains",
"(",
"selector",
")",
")",
"{",
"return",
"string",
";",
"}",
"line",
".",
"setLength",
"(",
"0",
")",
";",
"}",
"else",
"{",
"line",
".",
"append",
"(",
"c",
")",
";",
"}",
"}",
"if",
"(",
"line",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"string",
"=",
"line",
".",
"toString",
"(",
")",
";",
"if",
"(",
"string",
".",
"contains",
"(",
"selector",
")",
")",
"{",
"return",
"string",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Replies the first line that contains the given selector.
@param selector is the string to search for.
@param text is the text to search in.
@return the found line or <code>null</code>. | [
"Replies",
"the",
"first",
"line",
"that",
"contains",
"the",
"given",
"selector",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/AbstractOperatingSystemWrapper.java#L81-L108 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/AbstractOperatingSystemWrapper.java | AbstractOperatingSystemWrapper.cut | protected static String cut(String delimiter, int column, String lineText) {
if (lineText == null || lineText.isEmpty()) {
return null;
}
final String[] columns = lineText.split(Pattern.quote(delimiter));
if (columns != null && column >= 0 && column < columns.length) {
return columns[column].trim();
}
return null;
} | java | protected static String cut(String delimiter, int column, String lineText) {
if (lineText == null || lineText.isEmpty()) {
return null;
}
final String[] columns = lineText.split(Pattern.quote(delimiter));
if (columns != null && column >= 0 && column < columns.length) {
return columns[column].trim();
}
return null;
} | [
"protected",
"static",
"String",
"cut",
"(",
"String",
"delimiter",
",",
"int",
"column",
",",
"String",
"lineText",
")",
"{",
"if",
"(",
"lineText",
"==",
"null",
"||",
"lineText",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"final",
"String",
"[",
"]",
"columns",
"=",
"lineText",
".",
"split",
"(",
"Pattern",
".",
"quote",
"(",
"delimiter",
")",
")",
";",
"if",
"(",
"columns",
"!=",
"null",
"&&",
"column",
">=",
"0",
"&&",
"column",
"<",
"columns",
".",
"length",
")",
"{",
"return",
"columns",
"[",
"column",
"]",
".",
"trim",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Cut the line in columns and replies the given column.
@param delimiter is the delmiter to use to cut.
@param column is the number of the column to reply.
@param lineText is the line to cut.
@return the column or {@code null}. | [
"Cut",
"the",
"line",
"in",
"columns",
"and",
"replies",
"the",
"given",
"column",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/AbstractOperatingSystemWrapper.java#L117-L126 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java | AbstractTriangle3F.toPlane | @Pure
protected static Plane3D<?> toPlane(
double tx1, double ty1, double tz1,
double tx2, double ty2, double tz2,
double tx3, double ty3, double tz3) {
Vector3f norm = new Vector3f();
FunctionalVector3D.crossProduct(
tx2 - tx1,
ty2 - ty1,
tz2 - tz1,
tx3 - tx1,
ty3 - ty1,
tz3 - tz1,
norm);
assert(norm!=null);
if (norm.getY()==0. && norm.getZ()==0.)
return new PlaneYZ4f(tx1);
if (norm.getX()==0. && norm.getZ()==0.)
return new PlaneXZ4f(ty1);
if (norm.getX()==0. && norm.getY()==0.)
return new PlaneXY4f(tz1);
return new Plane4f(tx1, ty1, tz1, tx2, ty2, tz2, tx3, ty3, tz3);
} | java | @Pure
protected static Plane3D<?> toPlane(
double tx1, double ty1, double tz1,
double tx2, double ty2, double tz2,
double tx3, double ty3, double tz3) {
Vector3f norm = new Vector3f();
FunctionalVector3D.crossProduct(
tx2 - tx1,
ty2 - ty1,
tz2 - tz1,
tx3 - tx1,
ty3 - ty1,
tz3 - tz1,
norm);
assert(norm!=null);
if (norm.getY()==0. && norm.getZ()==0.)
return new PlaneYZ4f(tx1);
if (norm.getX()==0. && norm.getZ()==0.)
return new PlaneXZ4f(ty1);
if (norm.getX()==0. && norm.getY()==0.)
return new PlaneXY4f(tz1);
return new Plane4f(tx1, ty1, tz1, tx2, ty2, tz2, tx3, ty3, tz3);
} | [
"@",
"Pure",
"protected",
"static",
"Plane3D",
"<",
"?",
">",
"toPlane",
"(",
"double",
"tx1",
",",
"double",
"ty1",
",",
"double",
"tz1",
",",
"double",
"tx2",
",",
"double",
"ty2",
",",
"double",
"tz2",
",",
"double",
"tx3",
",",
"double",
"ty3",
",",
"double",
"tz3",
")",
"{",
"Vector3f",
"norm",
"=",
"new",
"Vector3f",
"(",
")",
";",
"FunctionalVector3D",
".",
"crossProduct",
"(",
"tx2",
"-",
"tx1",
",",
"ty2",
"-",
"ty1",
",",
"tz2",
"-",
"tz1",
",",
"tx3",
"-",
"tx1",
",",
"ty3",
"-",
"ty1",
",",
"tz3",
"-",
"tz1",
",",
"norm",
")",
";",
"assert",
"(",
"norm",
"!=",
"null",
")",
";",
"if",
"(",
"norm",
".",
"getY",
"(",
")",
"==",
"0.",
"&&",
"norm",
".",
"getZ",
"(",
")",
"==",
"0.",
")",
"return",
"new",
"PlaneYZ4f",
"(",
"tx1",
")",
";",
"if",
"(",
"norm",
".",
"getX",
"(",
")",
"==",
"0.",
"&&",
"norm",
".",
"getZ",
"(",
")",
"==",
"0.",
")",
"return",
"new",
"PlaneXZ4f",
"(",
"ty1",
")",
";",
"if",
"(",
"norm",
".",
"getX",
"(",
")",
"==",
"0.",
"&&",
"norm",
".",
"getY",
"(",
")",
"==",
"0.",
")",
"return",
"new",
"PlaneXY4f",
"(",
"tz1",
")",
";",
"return",
"new",
"Plane4f",
"(",
"tx1",
",",
"ty1",
",",
"tz1",
",",
"tx2",
",",
"ty2",
",",
"tz2",
",",
"tx3",
",",
"ty3",
",",
"tz3",
")",
";",
"}"
] | Compute the plane of the given triangle.
@param tx1 x coordinate of the first point of the triangle.
@param ty1 y coordinate of the first point of the triangle.
@param tz1 z coordinate of the first point of the triangle.
@param tx2 x coordinate of the second point of the triangle.
@param ty2 y coordinate of the second point of the triangle.
@param tz2 z coordinate of the second point of the triangle.
@param tx3 x coordinate of the third point of the triangle.
@param ty3 y coordinate of the third point of the triangle.
@param tz3 z coordinate of the third point of the triangle.
@return the plane. | [
"Compute",
"the",
"plane",
"of",
"the",
"given",
"triangle",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java#L407-L429 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java | AbstractTriangle3F.computeClosestPointTrianglePoint | @Unefficient
public static void computeClosestPointTrianglePoint(
double tx1, double ty1, double tz1,
double tx2, double ty2, double tz2,
double tx3, double ty3, double tz3,
double px, double py, double pz,
Point3D closestPoint) {
if (containsTrianglePoint(
tx1, ty1, tz1,
tx2, ty2, tz2,
tx3, ty3, tz3,
px, py, pz,
false, MathConstants.EPSILON)) {
closestPoint.set(toPlane(
tx1, ty1, tz1,
tx2, ty2, tz2,
tx3, ty3, tz3).getProjection(px, py, pz));
return;
}
double f;
f = AbstractSegment3F.getPointProjectionFactorOnSegmentLine(
px, py, pz,
tx1, ty1, tz1,
tx2, ty2, tz2);
double p1x = tx1 + f * (tx2 - tx1);
double p1y = ty1 + f * (ty2 - ty1);
double p1z = tz1 + f * (tz2 - tz1);
f = AbstractSegment3F.getPointProjectionFactorOnSegmentLine(
px, py, pz,
tx2, ty2, tz2,
tx3, ty3, tz3);
double p2x = tx2 + f * (tx3 - tx2);
double p2y = ty2 + f * (ty3 - ty2);
double p2z = tz2 + f * (tz3 - tz2);
f = AbstractSegment3F.getPointProjectionFactorOnSegmentLine(
px, py, pz,
tx3, ty3, tz3,
tx1, ty1, tz1);
double p3x = tx3 + f * (tx1 - tx3);
double p3y = ty3 + f * (ty1 - ty3);
double p3z = tz3 + f * (tz1 - tz3);
double d1 = FunctionalPoint3D.distanceSquaredPointPoint(px, py, pz, p1x, p1y, p1z);
double d2 = FunctionalPoint3D.distanceSquaredPointPoint(px, py, pz, p2x, p2y, p3z);
double d3 = FunctionalPoint3D.distanceSquaredPointPoint(px, py, pz, p3x, p3y, p3z);
if (d1 <= d2) {
if (d1 <= d3) {
closestPoint.set(p1x, p1y, p1z);
} else {
closestPoint.set(p3x, p3y, p3z);
}
} if (d2 <= d3) {
closestPoint.set(p2x, p2y, p2z);
} else {
closestPoint.set(p3x, p3y, p3z);
}
} | java | @Unefficient
public static void computeClosestPointTrianglePoint(
double tx1, double ty1, double tz1,
double tx2, double ty2, double tz2,
double tx3, double ty3, double tz3,
double px, double py, double pz,
Point3D closestPoint) {
if (containsTrianglePoint(
tx1, ty1, tz1,
tx2, ty2, tz2,
tx3, ty3, tz3,
px, py, pz,
false, MathConstants.EPSILON)) {
closestPoint.set(toPlane(
tx1, ty1, tz1,
tx2, ty2, tz2,
tx3, ty3, tz3).getProjection(px, py, pz));
return;
}
double f;
f = AbstractSegment3F.getPointProjectionFactorOnSegmentLine(
px, py, pz,
tx1, ty1, tz1,
tx2, ty2, tz2);
double p1x = tx1 + f * (tx2 - tx1);
double p1y = ty1 + f * (ty2 - ty1);
double p1z = tz1 + f * (tz2 - tz1);
f = AbstractSegment3F.getPointProjectionFactorOnSegmentLine(
px, py, pz,
tx2, ty2, tz2,
tx3, ty3, tz3);
double p2x = tx2 + f * (tx3 - tx2);
double p2y = ty2 + f * (ty3 - ty2);
double p2z = tz2 + f * (tz3 - tz2);
f = AbstractSegment3F.getPointProjectionFactorOnSegmentLine(
px, py, pz,
tx3, ty3, tz3,
tx1, ty1, tz1);
double p3x = tx3 + f * (tx1 - tx3);
double p3y = ty3 + f * (ty1 - ty3);
double p3z = tz3 + f * (tz1 - tz3);
double d1 = FunctionalPoint3D.distanceSquaredPointPoint(px, py, pz, p1x, p1y, p1z);
double d2 = FunctionalPoint3D.distanceSquaredPointPoint(px, py, pz, p2x, p2y, p3z);
double d3 = FunctionalPoint3D.distanceSquaredPointPoint(px, py, pz, p3x, p3y, p3z);
if (d1 <= d2) {
if (d1 <= d3) {
closestPoint.set(p1x, p1y, p1z);
} else {
closestPoint.set(p3x, p3y, p3z);
}
} if (d2 <= d3) {
closestPoint.set(p2x, p2y, p2z);
} else {
closestPoint.set(p3x, p3y, p3z);
}
} | [
"@",
"Unefficient",
"public",
"static",
"void",
"computeClosestPointTrianglePoint",
"(",
"double",
"tx1",
",",
"double",
"ty1",
",",
"double",
"tz1",
",",
"double",
"tx2",
",",
"double",
"ty2",
",",
"double",
"tz2",
",",
"double",
"tx3",
",",
"double",
"ty3",
",",
"double",
"tz3",
",",
"double",
"px",
",",
"double",
"py",
",",
"double",
"pz",
",",
"Point3D",
"closestPoint",
")",
"{",
"if",
"(",
"containsTrianglePoint",
"(",
"tx1",
",",
"ty1",
",",
"tz1",
",",
"tx2",
",",
"ty2",
",",
"tz2",
",",
"tx3",
",",
"ty3",
",",
"tz3",
",",
"px",
",",
"py",
",",
"pz",
",",
"false",
",",
"MathConstants",
".",
"EPSILON",
")",
")",
"{",
"closestPoint",
".",
"set",
"(",
"toPlane",
"(",
"tx1",
",",
"ty1",
",",
"tz1",
",",
"tx2",
",",
"ty2",
",",
"tz2",
",",
"tx3",
",",
"ty3",
",",
"tz3",
")",
".",
"getProjection",
"(",
"px",
",",
"py",
",",
"pz",
")",
")",
";",
"return",
";",
"}",
"double",
"f",
";",
"f",
"=",
"AbstractSegment3F",
".",
"getPointProjectionFactorOnSegmentLine",
"(",
"px",
",",
"py",
",",
"pz",
",",
"tx1",
",",
"ty1",
",",
"tz1",
",",
"tx2",
",",
"ty2",
",",
"tz2",
")",
";",
"double",
"p1x",
"=",
"tx1",
"+",
"f",
"*",
"(",
"tx2",
"-",
"tx1",
")",
";",
"double",
"p1y",
"=",
"ty1",
"+",
"f",
"*",
"(",
"ty2",
"-",
"ty1",
")",
";",
"double",
"p1z",
"=",
"tz1",
"+",
"f",
"*",
"(",
"tz2",
"-",
"tz1",
")",
";",
"f",
"=",
"AbstractSegment3F",
".",
"getPointProjectionFactorOnSegmentLine",
"(",
"px",
",",
"py",
",",
"pz",
",",
"tx2",
",",
"ty2",
",",
"tz2",
",",
"tx3",
",",
"ty3",
",",
"tz3",
")",
";",
"double",
"p2x",
"=",
"tx2",
"+",
"f",
"*",
"(",
"tx3",
"-",
"tx2",
")",
";",
"double",
"p2y",
"=",
"ty2",
"+",
"f",
"*",
"(",
"ty3",
"-",
"ty2",
")",
";",
"double",
"p2z",
"=",
"tz2",
"+",
"f",
"*",
"(",
"tz3",
"-",
"tz2",
")",
";",
"f",
"=",
"AbstractSegment3F",
".",
"getPointProjectionFactorOnSegmentLine",
"(",
"px",
",",
"py",
",",
"pz",
",",
"tx3",
",",
"ty3",
",",
"tz3",
",",
"tx1",
",",
"ty1",
",",
"tz1",
")",
";",
"double",
"p3x",
"=",
"tx3",
"+",
"f",
"*",
"(",
"tx1",
"-",
"tx3",
")",
";",
"double",
"p3y",
"=",
"ty3",
"+",
"f",
"*",
"(",
"ty1",
"-",
"ty3",
")",
";",
"double",
"p3z",
"=",
"tz3",
"+",
"f",
"*",
"(",
"tz1",
"-",
"tz3",
")",
";",
"double",
"d1",
"=",
"FunctionalPoint3D",
".",
"distanceSquaredPointPoint",
"(",
"px",
",",
"py",
",",
"pz",
",",
"p1x",
",",
"p1y",
",",
"p1z",
")",
";",
"double",
"d2",
"=",
"FunctionalPoint3D",
".",
"distanceSquaredPointPoint",
"(",
"px",
",",
"py",
",",
"pz",
",",
"p2x",
",",
"p2y",
",",
"p3z",
")",
";",
"double",
"d3",
"=",
"FunctionalPoint3D",
".",
"distanceSquaredPointPoint",
"(",
"px",
",",
"py",
",",
"pz",
",",
"p3x",
",",
"p3y",
",",
"p3z",
")",
";",
"if",
"(",
"d1",
"<=",
"d2",
")",
"{",
"if",
"(",
"d1",
"<=",
"d3",
")",
"{",
"closestPoint",
".",
"set",
"(",
"p1x",
",",
"p1y",
",",
"p1z",
")",
";",
"}",
"else",
"{",
"closestPoint",
".",
"set",
"(",
"p3x",
",",
"p3y",
",",
"p3z",
")",
";",
"}",
"}",
"if",
"(",
"d2",
"<=",
"d3",
")",
"{",
"closestPoint",
".",
"set",
"(",
"p2x",
",",
"p2y",
",",
"p2z",
")",
";",
"}",
"else",
"{",
"closestPoint",
".",
"set",
"(",
"p3x",
",",
"p3y",
",",
"p3z",
")",
";",
"}",
"}"
] | Replies the closest point from the triangle to the point.
@param tx1 x coordinate of the first point of the triangle.
@param ty1 y coordinate of the first point of the triangle.
@param tz1 z coordinate of the first point of the triangle.
@param tx2 x coordinate of the second point of the triangle.
@param ty2 y coordinate of the second point of the triangle.
@param tz2 z coordinate of the second point of the triangle.
@param tx3 x coordinate of the third point of the triangle.
@param ty3 y coordinate of the third point of the triangle.
@param tz3 z coordinate of the third point of the triangle.
@param px x coordinate of the point.
@param py y coordinate of the point.
@param pz z coordinate of the point.
@param closestPoint the point set with the closest coordinates.
@see "https://github.com/juj/MathGeoLib" | [
"Replies",
"the",
"closest",
"point",
"from",
"the",
"triangle",
"to",
"the",
"point",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java#L448-L509 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java | AbstractTriangle3F.distanceSquaredTriangleSegment | @Pure
@Unefficient
public static double distanceSquaredTriangleSegment(
double tx1, double ty1, double tz1,
double tx2, double ty2, double tz2,
double tx3, double ty3, double tz3,
double sx1, double sy1, double sz1,
double sx2, double sy2, double sz2) {
double t = getTriangleSegmentIntersectionFactorWithJimenezAlgorithm(
tx1, ty1, tz1, tx2, ty2, tz2, tx3, ty3, tz3, sx1, sy1, sz1, sx2, sy2, sz2);
if (Double.isInfinite(t) || (!Double.isNaN(t) && t >= 0. && t <= 1.)) {
return 0.;
}
double d1 = AbstractSegment3F.distanceSquaredSegmentSegment(
tx1, ty1, tz1, tx2, ty2, tz2,
sx1, sy1, sz1, sx2, sy2, sz2);
double d2 = AbstractSegment3F.distanceSquaredSegmentSegment(
tx1, ty1, tz1, tx3, ty3, tz3,
sx1, sy1, sz1, sx2, sy2, sz2);
double d3 = AbstractSegment3F.distanceSquaredSegmentSegment(
tx2, ty2, tz2, tx3, ty3, tz3,
sx1, sy1, sz1, sx2, sy2, sz2);
return MathUtil.min(d1, d2, d3);
} | java | @Pure
@Unefficient
public static double distanceSquaredTriangleSegment(
double tx1, double ty1, double tz1,
double tx2, double ty2, double tz2,
double tx3, double ty3, double tz3,
double sx1, double sy1, double sz1,
double sx2, double sy2, double sz2) {
double t = getTriangleSegmentIntersectionFactorWithJimenezAlgorithm(
tx1, ty1, tz1, tx2, ty2, tz2, tx3, ty3, tz3, sx1, sy1, sz1, sx2, sy2, sz2);
if (Double.isInfinite(t) || (!Double.isNaN(t) && t >= 0. && t <= 1.)) {
return 0.;
}
double d1 = AbstractSegment3F.distanceSquaredSegmentSegment(
tx1, ty1, tz1, tx2, ty2, tz2,
sx1, sy1, sz1, sx2, sy2, sz2);
double d2 = AbstractSegment3F.distanceSquaredSegmentSegment(
tx1, ty1, tz1, tx3, ty3, tz3,
sx1, sy1, sz1, sx2, sy2, sz2);
double d3 = AbstractSegment3F.distanceSquaredSegmentSegment(
tx2, ty2, tz2, tx3, ty3, tz3,
sx1, sy1, sz1, sx2, sy2, sz2);
return MathUtil.min(d1, d2, d3);
} | [
"@",
"Pure",
"@",
"Unefficient",
"public",
"static",
"double",
"distanceSquaredTriangleSegment",
"(",
"double",
"tx1",
",",
"double",
"ty1",
",",
"double",
"tz1",
",",
"double",
"tx2",
",",
"double",
"ty2",
",",
"double",
"tz2",
",",
"double",
"tx3",
",",
"double",
"ty3",
",",
"double",
"tz3",
",",
"double",
"sx1",
",",
"double",
"sy1",
",",
"double",
"sz1",
",",
"double",
"sx2",
",",
"double",
"sy2",
",",
"double",
"sz2",
")",
"{",
"double",
"t",
"=",
"getTriangleSegmentIntersectionFactorWithJimenezAlgorithm",
"(",
"tx1",
",",
"ty1",
",",
"tz1",
",",
"tx2",
",",
"ty2",
",",
"tz2",
",",
"tx3",
",",
"ty3",
",",
"tz3",
",",
"sx1",
",",
"sy1",
",",
"sz1",
",",
"sx2",
",",
"sy2",
",",
"sz2",
")",
";",
"if",
"(",
"Double",
".",
"isInfinite",
"(",
"t",
")",
"||",
"(",
"!",
"Double",
".",
"isNaN",
"(",
"t",
")",
"&&",
"t",
">=",
"0.",
"&&",
"t",
"<=",
"1.",
")",
")",
"{",
"return",
"0.",
";",
"}",
"double",
"d1",
"=",
"AbstractSegment3F",
".",
"distanceSquaredSegmentSegment",
"(",
"tx1",
",",
"ty1",
",",
"tz1",
",",
"tx2",
",",
"ty2",
",",
"tz2",
",",
"sx1",
",",
"sy1",
",",
"sz1",
",",
"sx2",
",",
"sy2",
",",
"sz2",
")",
";",
"double",
"d2",
"=",
"AbstractSegment3F",
".",
"distanceSquaredSegmentSegment",
"(",
"tx1",
",",
"ty1",
",",
"tz1",
",",
"tx3",
",",
"ty3",
",",
"tz3",
",",
"sx1",
",",
"sy1",
",",
"sz1",
",",
"sx2",
",",
"sy2",
",",
"sz2",
")",
";",
"double",
"d3",
"=",
"AbstractSegment3F",
".",
"distanceSquaredSegmentSegment",
"(",
"tx2",
",",
"ty2",
",",
"tz2",
",",
"tx3",
",",
"ty3",
",",
"tz3",
",",
"sx1",
",",
"sy1",
",",
"sz1",
",",
"sx2",
",",
"sy2",
",",
"sz2",
")",
";",
"return",
"MathUtil",
".",
"min",
"(",
"d1",
",",
"d2",
",",
"d3",
")",
";",
"}"
] | Replies the squared distance from the triangle to the segment.
@param tx1 x coordinate of the first point of the triangle.
@param ty1 y coordinate of the first point of the triangle.
@param tz1 z coordinate of the first point of the triangle.
@param tx2 x coordinate of the second point of the triangle.
@param ty2 y coordinate of the second point of the triangle.
@param tz2 z coordinate of the second point of the triangle.
@param tx3 x coordinate of the third point of the triangle.
@param ty3 y coordinate of the third point of the triangle.
@param tz3 z coordinate of the third point of the triangle.
@param sx1 x coordinate of the first point of the segment.
@param sy1 y coordinate of the first point of the segment.
@param sz1 z coordinate of the first axis of the oriented box.
@param sx2 x coordinate of the second point of the segment.
@param sy2 y coordinate of the second point of the segment.
@param sz2 z coordinate of the second axis of the oriented box.
@return the squared distance.
@see "https://github.com/juj/MathGeoLib" | [
"Replies",
"the",
"squared",
"distance",
"from",
"the",
"triangle",
"to",
"the",
"segment",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java#L531-L556 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java | AbstractTriangle3F.intersectsTriangleCapsule | @Pure
@Unefficient
public static boolean intersectsTriangleCapsule(
double tx1, double ty1, double tz1,
double tx2, double ty2, double tz2,
double tx3, double ty3, double tz3,
double cx1, double cy1, double cz1,
double cx2, double cy2, double cz2,
double radius) {
double d = distanceSquaredTriangleSegment(
tx1, ty1, tz1, tx2, ty2, tz2, tx3, ty3, tz3,
cx1, cy1, cz1, cx2, cy2, cz2);
return d < (radius * radius);
} | java | @Pure
@Unefficient
public static boolean intersectsTriangleCapsule(
double tx1, double ty1, double tz1,
double tx2, double ty2, double tz2,
double tx3, double ty3, double tz3,
double cx1, double cy1, double cz1,
double cx2, double cy2, double cz2,
double radius) {
double d = distanceSquaredTriangleSegment(
tx1, ty1, tz1, tx2, ty2, tz2, tx3, ty3, tz3,
cx1, cy1, cz1, cx2, cy2, cz2);
return d < (radius * radius);
} | [
"@",
"Pure",
"@",
"Unefficient",
"public",
"static",
"boolean",
"intersectsTriangleCapsule",
"(",
"double",
"tx1",
",",
"double",
"ty1",
",",
"double",
"tz1",
",",
"double",
"tx2",
",",
"double",
"ty2",
",",
"double",
"tz2",
",",
"double",
"tx3",
",",
"double",
"ty3",
",",
"double",
"tz3",
",",
"double",
"cx1",
",",
"double",
"cy1",
",",
"double",
"cz1",
",",
"double",
"cx2",
",",
"double",
"cy2",
",",
"double",
"cz2",
",",
"double",
"radius",
")",
"{",
"double",
"d",
"=",
"distanceSquaredTriangleSegment",
"(",
"tx1",
",",
"ty1",
",",
"tz1",
",",
"tx2",
",",
"ty2",
",",
"tz2",
",",
"tx3",
",",
"ty3",
",",
"tz3",
",",
"cx1",
",",
"cy1",
",",
"cz1",
",",
"cx2",
",",
"cy2",
",",
"cz2",
")",
";",
"return",
"d",
"<",
"(",
"radius",
"*",
"radius",
")",
";",
"}"
] | Replies if the triangle intersects the capsule.
@param tx1 x coordinate of the first point of the triangle.
@param ty1 y coordinate of the first point of the triangle.
@param tz1 z coordinate of the first point of the triangle.
@param tx2 x coordinate of the second point of the triangle.
@param ty2 y coordinate of the second point of the triangle.
@param tz2 z coordinate of the second point of the triangle.
@param tx3 x coordinate of the third point of the triangle.
@param ty3 y coordinate of the third point of the triangle.
@param tz3 z coordinate of the third point of the triangle.
@param cx1 x coordinate of the first point of the capsule medial.
@param cy1 y coordinate of the first point of the capsule medial.
@param cz1 z coordinate of the first point of the capsule medial.
@param cx2 x coordinate of the second point of the capsule medial.
@param cy2 y coordinate of the second point of the capsule medial.
@param cz2 z coordinate of the second point of the capsule medial.
@param radius radius of the capsule.
@return <code>true</code> if the triangle and capsule are intersecting.
@see "https://github.com/juj/MathGeoLib" | [
"Replies",
"if",
"the",
"triangle",
"intersects",
"the",
"capsule",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java#L579-L592 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java | AbstractTriangle3F.intersectsTriangleOrientedBox | @Pure
public static boolean intersectsTriangleOrientedBox(
double tx1, double ty1, double tz1,
double tx2, double ty2, double tz2,
double tx3, double ty3, double tz3,
double cx, double cy, double cz,
double ax1, double ay1, double az1,
double ax2, double ay2, double az2,
double ax3, double ay3, double az3,
double ae1, double ae2, double ae3) {
double nx, ny, nz;
// Translate the triangle into the oriented box frame.
nx = tx1 - cx;
ny = ty1 - cy;
nz = tz1 - cz;
double ntx1 = FunctionalVector3D.dotProduct(nx, ny, nz, ax1, ay1, az1);
double nty1 = FunctionalVector3D.dotProduct(nx, ny, nz, ax2, ay2, az2);
double ntz1 = FunctionalVector3D.dotProduct(nx, ny, nz, ax3, ay3, az3);
nx = tx2 - cx;
ny = ty2 - cy;
nz = tz2 - cz;
double ntx2 = FunctionalVector3D.dotProduct(nx, ny, nz, ax1, ay1, az1);
double nty2 = FunctionalVector3D.dotProduct(nx, ny, nz, ax2, ay2, az2);
double ntz2 = FunctionalVector3D.dotProduct(nx, ny, nz, ax3, ay3, az3);
nx = tx3 - cx;
ny = ty3 - cy;
nz = tz3 - cz;
double ntx3 = FunctionalVector3D.dotProduct(nx, ny, nz, ax1, ay1, az1);
double nty3 = FunctionalVector3D.dotProduct(nx, ny, nz, ax2, ay2, az2);
double ntz3 = FunctionalVector3D.dotProduct(nx, ny, nz, ax3, ay3, az3);
// Test intersection
return intersectsTriangleAlignedBox(
ntx1, nty1, ntz1, ntx2, nty2, ntz2, ntx3, nty3, ntz3,
-ae1, -ae2, -ae3, ae1, ae2, ae3);
} | java | @Pure
public static boolean intersectsTriangleOrientedBox(
double tx1, double ty1, double tz1,
double tx2, double ty2, double tz2,
double tx3, double ty3, double tz3,
double cx, double cy, double cz,
double ax1, double ay1, double az1,
double ax2, double ay2, double az2,
double ax3, double ay3, double az3,
double ae1, double ae2, double ae3) {
double nx, ny, nz;
// Translate the triangle into the oriented box frame.
nx = tx1 - cx;
ny = ty1 - cy;
nz = tz1 - cz;
double ntx1 = FunctionalVector3D.dotProduct(nx, ny, nz, ax1, ay1, az1);
double nty1 = FunctionalVector3D.dotProduct(nx, ny, nz, ax2, ay2, az2);
double ntz1 = FunctionalVector3D.dotProduct(nx, ny, nz, ax3, ay3, az3);
nx = tx2 - cx;
ny = ty2 - cy;
nz = tz2 - cz;
double ntx2 = FunctionalVector3D.dotProduct(nx, ny, nz, ax1, ay1, az1);
double nty2 = FunctionalVector3D.dotProduct(nx, ny, nz, ax2, ay2, az2);
double ntz2 = FunctionalVector3D.dotProduct(nx, ny, nz, ax3, ay3, az3);
nx = tx3 - cx;
ny = ty3 - cy;
nz = tz3 - cz;
double ntx3 = FunctionalVector3D.dotProduct(nx, ny, nz, ax1, ay1, az1);
double nty3 = FunctionalVector3D.dotProduct(nx, ny, nz, ax2, ay2, az2);
double ntz3 = FunctionalVector3D.dotProduct(nx, ny, nz, ax3, ay3, az3);
// Test intersection
return intersectsTriangleAlignedBox(
ntx1, nty1, ntz1, ntx2, nty2, ntz2, ntx3, nty3, ntz3,
-ae1, -ae2, -ae3, ae1, ae2, ae3);
} | [
"@",
"Pure",
"public",
"static",
"boolean",
"intersectsTriangleOrientedBox",
"(",
"double",
"tx1",
",",
"double",
"ty1",
",",
"double",
"tz1",
",",
"double",
"tx2",
",",
"double",
"ty2",
",",
"double",
"tz2",
",",
"double",
"tx3",
",",
"double",
"ty3",
",",
"double",
"tz3",
",",
"double",
"cx",
",",
"double",
"cy",
",",
"double",
"cz",
",",
"double",
"ax1",
",",
"double",
"ay1",
",",
"double",
"az1",
",",
"double",
"ax2",
",",
"double",
"ay2",
",",
"double",
"az2",
",",
"double",
"ax3",
",",
"double",
"ay3",
",",
"double",
"az3",
",",
"double",
"ae1",
",",
"double",
"ae2",
",",
"double",
"ae3",
")",
"{",
"double",
"nx",
",",
"ny",
",",
"nz",
";",
"// Translate the triangle into the oriented box frame.",
"nx",
"=",
"tx1",
"-",
"cx",
";",
"ny",
"=",
"ty1",
"-",
"cy",
";",
"nz",
"=",
"tz1",
"-",
"cz",
";",
"double",
"ntx1",
"=",
"FunctionalVector3D",
".",
"dotProduct",
"(",
"nx",
",",
"ny",
",",
"nz",
",",
"ax1",
",",
"ay1",
",",
"az1",
")",
";",
"double",
"nty1",
"=",
"FunctionalVector3D",
".",
"dotProduct",
"(",
"nx",
",",
"ny",
",",
"nz",
",",
"ax2",
",",
"ay2",
",",
"az2",
")",
";",
"double",
"ntz1",
"=",
"FunctionalVector3D",
".",
"dotProduct",
"(",
"nx",
",",
"ny",
",",
"nz",
",",
"ax3",
",",
"ay3",
",",
"az3",
")",
";",
"nx",
"=",
"tx2",
"-",
"cx",
";",
"ny",
"=",
"ty2",
"-",
"cy",
";",
"nz",
"=",
"tz2",
"-",
"cz",
";",
"double",
"ntx2",
"=",
"FunctionalVector3D",
".",
"dotProduct",
"(",
"nx",
",",
"ny",
",",
"nz",
",",
"ax1",
",",
"ay1",
",",
"az1",
")",
";",
"double",
"nty2",
"=",
"FunctionalVector3D",
".",
"dotProduct",
"(",
"nx",
",",
"ny",
",",
"nz",
",",
"ax2",
",",
"ay2",
",",
"az2",
")",
";",
"double",
"ntz2",
"=",
"FunctionalVector3D",
".",
"dotProduct",
"(",
"nx",
",",
"ny",
",",
"nz",
",",
"ax3",
",",
"ay3",
",",
"az3",
")",
";",
"nx",
"=",
"tx3",
"-",
"cx",
";",
"ny",
"=",
"ty3",
"-",
"cy",
";",
"nz",
"=",
"tz3",
"-",
"cz",
";",
"double",
"ntx3",
"=",
"FunctionalVector3D",
".",
"dotProduct",
"(",
"nx",
",",
"ny",
",",
"nz",
",",
"ax1",
",",
"ay1",
",",
"az1",
")",
";",
"double",
"nty3",
"=",
"FunctionalVector3D",
".",
"dotProduct",
"(",
"nx",
",",
"ny",
",",
"nz",
",",
"ax2",
",",
"ay2",
",",
"az2",
")",
";",
"double",
"ntz3",
"=",
"FunctionalVector3D",
".",
"dotProduct",
"(",
"nx",
",",
"ny",
",",
"nz",
",",
"ax3",
",",
"ay3",
",",
"az3",
")",
";",
"// Test intersection",
"return",
"intersectsTriangleAlignedBox",
"(",
"ntx1",
",",
"nty1",
",",
"ntz1",
",",
"ntx2",
",",
"nty2",
",",
"ntz2",
",",
"ntx3",
",",
"nty3",
",",
"ntz3",
",",
"-",
"ae1",
",",
"-",
"ae2",
",",
"-",
"ae3",
",",
"ae1",
",",
"ae2",
",",
"ae3",
")",
";",
"}"
] | Replies if the triangle intersects the oriented box.
@param tx1 x coordinate of the first point of the triangle.
@param ty1 y coordinate of the first point of the triangle.
@param tz1 z coordinate of the first point of the triangle.
@param tx2 x coordinate of the second point of the triangle.
@param ty2 y coordinate of the second point of the triangle.
@param tz2 z coordinate of the second point of the triangle.
@param tx3 x coordinate of the third point of the triangle.
@param ty3 y coordinate of the third point of the triangle.
@param tz3 z coordinate of the third point of the triangle.
@param cx x coordinate of the center of the oriented box.
@param cy y coordinate of the center of the oriented box.
@param cz z coordinate of the center of the oriented box.
@param ax1 x coordinate of the first axis of the oriented box.
@param ay1 y coordinate of the first axis of the oriented box.
@param az1 z coordinate of the first axis of the oriented box.
@param ax2 x coordinate of the second axis of the oriented box.
@param ay2 y coordinate of the second axis of the oriented box.
@param az2 z coordinate of the second axis of the oriented box.
@param ax3 x coordinate of the third axis of the oriented box.
@param ay3 y coordinate of the third axis of the oriented box.
@param az3 z coordinate of the third axis of the oriented box.
@param ae1 the extent of the first axis.
@param ae2 the extent of the second axis.
@param ae3 the extent of the third axis.
@return <code>true</code> if the triangle and oriented box are intersecting. | [
"Replies",
"if",
"the",
"triangle",
"intersects",
"the",
"oriented",
"box",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java#L866-L903 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java | AbstractTriangle3F.intersectsTriangleSegment | @Pure
public static boolean intersectsTriangleSegment(
double tx1, double ty1, double tz1,
double tx2, double ty2, double tz2,
double tx3, double ty3, double tz3,
double sx1, double sy1, double sz1,
double sx2, double sy2, double sz2) {
double factor = getTriangleSegmentIntersectionFactorWithJimenezAlgorithm(
tx1, ty1, tz1,
tx2, ty2, tz2,
tx3, ty3, tz3,
sx1, sy1, sz1,
sx2, sy2, sz2);
return !Double.isNaN(factor);
} | java | @Pure
public static boolean intersectsTriangleSegment(
double tx1, double ty1, double tz1,
double tx2, double ty2, double tz2,
double tx3, double ty3, double tz3,
double sx1, double sy1, double sz1,
double sx2, double sy2, double sz2) {
double factor = getTriangleSegmentIntersectionFactorWithJimenezAlgorithm(
tx1, ty1, tz1,
tx2, ty2, tz2,
tx3, ty3, tz3,
sx1, sy1, sz1,
sx2, sy2, sz2);
return !Double.isNaN(factor);
} | [
"@",
"Pure",
"public",
"static",
"boolean",
"intersectsTriangleSegment",
"(",
"double",
"tx1",
",",
"double",
"ty1",
",",
"double",
"tz1",
",",
"double",
"tx2",
",",
"double",
"ty2",
",",
"double",
"tz2",
",",
"double",
"tx3",
",",
"double",
"ty3",
",",
"double",
"tz3",
",",
"double",
"sx1",
",",
"double",
"sy1",
",",
"double",
"sz1",
",",
"double",
"sx2",
",",
"double",
"sy2",
",",
"double",
"sz2",
")",
"{",
"double",
"factor",
"=",
"getTriangleSegmentIntersectionFactorWithJimenezAlgorithm",
"(",
"tx1",
",",
"ty1",
",",
"tz1",
",",
"tx2",
",",
"ty2",
",",
"tz2",
",",
"tx3",
",",
"ty3",
",",
"tz3",
",",
"sx1",
",",
"sy1",
",",
"sz1",
",",
"sx2",
",",
"sy2",
",",
"sz2",
")",
";",
"return",
"!",
"Double",
".",
"isNaN",
"(",
"factor",
")",
";",
"}"
] | Replies if the triangle intersects the segment.
Source: <a href="./doc-files/segment_triangle_intersection.pdf">
Juan J. Jimenez, Rafael J. Segura, Francisco R. Feito.
"A robust segment/triangle intersection algorithm for interference tests. Efficiency study".
Computational Geometry 43 (2010) pp 474-492. 2010.</a>
@param tx1 x coordinate of the first point of the triangle.
@param ty1 y coordinate of the first point of the triangle.
@param tz1 z coordinate of the first point of the triangle.
@param tx2 x coordinate of the second point of the triangle.
@param ty2 y coordinate of the second point of the triangle.
@param tz2 z coordinate of the second point of the triangle.
@param tx3 x coordinate of the third point of the triangle.
@param ty3 y coordinate of the third point of the triangle.
@param tz3 z coordinate of the third point of the triangle.
@param sx1 x coordinate of the first point of the segment.
@param sy1 y coordinate of the first point of the segment.
@param sz1 z coordinate of the first axis of the oriented box.
@param sx2 x coordinate of the second point of the segment.
@param sy2 y coordinate of the second point of the segment.
@param sz2 z coordinate of the second axis of the oriented box.
@return <code>true</code> if the triangle and segment are intersecting. | [
"Replies",
"if",
"the",
"triangle",
"intersects",
"the",
"segment",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java#L929-L943 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java | AbstractTriangle3F.containsTrianglePoint | @Pure
private static boolean containsTrianglePoint(
int i0, int i1, double[] v, double[] u1, double[] u2, double[] u3) {
// is T1 completly inside T2?
// check if V0 is inside tri(U0,U1,U2)
double a = u2[i1] - u1[i1];
double b = -(u2[i0] - u1[i0]);
double c = -a * u1[i0] - b * u1[i1];
double d0 = a * v[i0] + b * v[i1] + c;
a = u3[i1] - u2[i1];
b = -(u3[i0] - u2[i0]);
c = -a * u2[i0] - b * u2[i1];
double d1 = a * v[i0] + b * v[i1] + c;
a = u1[i1] - u2[i1];
b = -(u1[i0] - u3[i0]);
c = -a * u3[i0] - b * u3[i1];
double d2 = a * v[i0] + b * v[i1] + c;
return ((d0*d1>0.)&&(d0*d2>0.0));
} | java | @Pure
private static boolean containsTrianglePoint(
int i0, int i1, double[] v, double[] u1, double[] u2, double[] u3) {
// is T1 completly inside T2?
// check if V0 is inside tri(U0,U1,U2)
double a = u2[i1] - u1[i1];
double b = -(u2[i0] - u1[i0]);
double c = -a * u1[i0] - b * u1[i1];
double d0 = a * v[i0] + b * v[i1] + c;
a = u3[i1] - u2[i1];
b = -(u3[i0] - u2[i0]);
c = -a * u2[i0] - b * u2[i1];
double d1 = a * v[i0] + b * v[i1] + c;
a = u1[i1] - u2[i1];
b = -(u1[i0] - u3[i0]);
c = -a * u3[i0] - b * u3[i1];
double d2 = a * v[i0] + b * v[i1] + c;
return ((d0*d1>0.)&&(d0*d2>0.0));
} | [
"@",
"Pure",
"private",
"static",
"boolean",
"containsTrianglePoint",
"(",
"int",
"i0",
",",
"int",
"i1",
",",
"double",
"[",
"]",
"v",
",",
"double",
"[",
"]",
"u1",
",",
"double",
"[",
"]",
"u2",
",",
"double",
"[",
"]",
"u3",
")",
"{",
"// is T1 completly inside T2?",
"// check if V0 is inside tri(U0,U1,U2)",
"double",
"a",
"=",
"u2",
"[",
"i1",
"]",
"-",
"u1",
"[",
"i1",
"]",
";",
"double",
"b",
"=",
"-",
"(",
"u2",
"[",
"i0",
"]",
"-",
"u1",
"[",
"i0",
"]",
")",
";",
"double",
"c",
"=",
"-",
"a",
"*",
"u1",
"[",
"i0",
"]",
"-",
"b",
"*",
"u1",
"[",
"i1",
"]",
";",
"double",
"d0",
"=",
"a",
"*",
"v",
"[",
"i0",
"]",
"+",
"b",
"*",
"v",
"[",
"i1",
"]",
"+",
"c",
";",
"a",
"=",
"u3",
"[",
"i1",
"]",
"-",
"u2",
"[",
"i1",
"]",
";",
"b",
"=",
"-",
"(",
"u3",
"[",
"i0",
"]",
"-",
"u2",
"[",
"i0",
"]",
")",
";",
"c",
"=",
"-",
"a",
"*",
"u2",
"[",
"i0",
"]",
"-",
"b",
"*",
"u2",
"[",
"i1",
"]",
";",
"double",
"d1",
"=",
"a",
"*",
"v",
"[",
"i0",
"]",
"+",
"b",
"*",
"v",
"[",
"i1",
"]",
"+",
"c",
";",
"a",
"=",
"u1",
"[",
"i1",
"]",
"-",
"u2",
"[",
"i1",
"]",
";",
"b",
"=",
"-",
"(",
"u1",
"[",
"i0",
"]",
"-",
"u3",
"[",
"i0",
"]",
")",
";",
"c",
"=",
"-",
"a",
"*",
"u3",
"[",
"i0",
"]",
"-",
"b",
"*",
"u3",
"[",
"i1",
"]",
";",
"double",
"d2",
"=",
"a",
"*",
"v",
"[",
"i0",
"]",
"+",
"b",
"*",
"v",
"[",
"i1",
"]",
"+",
"c",
";",
"return",
"(",
"(",
"d0",
"*",
"d1",
">",
"0.",
")",
"&&",
"(",
"d0",
"*",
"d2",
">",
"0.0",
")",
")",
";",
"}"
] | Replies if a point is inside a triangle. | [
"Replies",
"if",
"a",
"point",
"is",
"inside",
"a",
"triangle",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java#L1226-L1247 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java | AbstractTriangle3F.intersectsCoplanarTriangle | @Pure
private static boolean intersectsCoplanarTriangle(
int i0, int i1, int con, double[] s1, double[] s2, double[] u1, double[] u2, double[] u3) {
double Ax,Ay;
Ax = s2[i0] - s1[i0];
Ay = s2[i1] - s1[i1];
// test edge U0,U1 against V0,V1
if (intersectEdgeEdge(i0, i1, con, Ax, Ay, s1, u1, u2)) return true;
// test edge U1,U2 against V0,V1
if (intersectEdgeEdge(i0, i1, con, Ax, Ay, s1, u2, u3)) return true;
// test edge U2,U1 against V0,V1
if (intersectEdgeEdge(i0, i1, con, Ax, Ay, s1, u3, u1)) return true;
return false;
} | java | @Pure
private static boolean intersectsCoplanarTriangle(
int i0, int i1, int con, double[] s1, double[] s2, double[] u1, double[] u2, double[] u3) {
double Ax,Ay;
Ax = s2[i0] - s1[i0];
Ay = s2[i1] - s1[i1];
// test edge U0,U1 against V0,V1
if (intersectEdgeEdge(i0, i1, con, Ax, Ay, s1, u1, u2)) return true;
// test edge U1,U2 against V0,V1
if (intersectEdgeEdge(i0, i1, con, Ax, Ay, s1, u2, u3)) return true;
// test edge U2,U1 against V0,V1
if (intersectEdgeEdge(i0, i1, con, Ax, Ay, s1, u3, u1)) return true;
return false;
} | [
"@",
"Pure",
"private",
"static",
"boolean",
"intersectsCoplanarTriangle",
"(",
"int",
"i0",
",",
"int",
"i1",
",",
"int",
"con",
",",
"double",
"[",
"]",
"s1",
",",
"double",
"[",
"]",
"s2",
",",
"double",
"[",
"]",
"u1",
",",
"double",
"[",
"]",
"u2",
",",
"double",
"[",
"]",
"u3",
")",
"{",
"double",
"Ax",
",",
"Ay",
";",
"Ax",
"=",
"s2",
"[",
"i0",
"]",
"-",
"s1",
"[",
"i0",
"]",
";",
"Ay",
"=",
"s2",
"[",
"i1",
"]",
"-",
"s1",
"[",
"i1",
"]",
";",
"// test edge U0,U1 against V0,V1",
"if",
"(",
"intersectEdgeEdge",
"(",
"i0",
",",
"i1",
",",
"con",
",",
"Ax",
",",
"Ay",
",",
"s1",
",",
"u1",
",",
"u2",
")",
")",
"return",
"true",
";",
"// test edge U1,U2 against V0,V1",
"if",
"(",
"intersectEdgeEdge",
"(",
"i0",
",",
"i1",
",",
"con",
",",
"Ax",
",",
"Ay",
",",
"s1",
",",
"u2",
",",
"u3",
")",
")",
"return",
"true",
";",
"// test edge U2,U1 against V0,V1",
"if",
"(",
"intersectEdgeEdge",
"(",
"i0",
",",
"i1",
",",
"con",
",",
"Ax",
",",
"Ay",
",",
"s1",
",",
"u3",
",",
"u1",
")",
")",
"return",
"true",
";",
"return",
"false",
";",
"}"
] | Replies if coplanar segment-triangle intersect. | [
"Replies",
"if",
"coplanar",
"segment",
"-",
"triangle",
"intersect",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java#L1251-L1267 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.