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 | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java | AbstractTriangle3F.contains | @Pure
public boolean contains(FunctionalPoint3D point) {
return containsTrianglePoint(
this.getP1().getX(), this.getP1().getY(), this.getP1().getZ(),
this.getP2().getX(), this.getP2().getY(), this.getP2().getZ(),
this.getP3().getX(), this.getP3().getY(), this.getP3().getZ(),
point.getX(), point.getY(), point.getZ(),
true, 0.);
} | java | @Pure
public boolean contains(FunctionalPoint3D point) {
return containsTrianglePoint(
this.getP1().getX(), this.getP1().getY(), this.getP1().getZ(),
this.getP2().getX(), this.getP2().getY(), this.getP2().getZ(),
this.getP3().getX(), this.getP3().getY(), this.getP3().getZ(),
point.getX(), point.getY(), point.getZ(),
true, 0.);
} | [
"@",
"Pure",
"public",
"boolean",
"contains",
"(",
"FunctionalPoint3D",
"point",
")",
"{",
"return",
"containsTrianglePoint",
"(",
"this",
".",
"getP1",
"(",
")",
".",
"getX",
"(",
")",
",",
"this",
".",
"getP1",
"(",
")",
".",
"getY",
"(",
")",
",",
"this",
".",
"getP1",
"(",
")",
".",
"getZ",
"(",
")",
",",
"this",
".",
"getP2",
"(",
")",
".",
"getX",
"(",
")",
",",
"this",
".",
"getP2",
"(",
")",
".",
"getY",
"(",
")",
",",
"this",
".",
"getP2",
"(",
")",
".",
"getZ",
"(",
")",
",",
"this",
".",
"getP3",
"(",
")",
".",
"getX",
"(",
")",
",",
"this",
".",
"getP3",
"(",
")",
".",
"getY",
"(",
")",
",",
"this",
".",
"getP3",
"(",
")",
".",
"getZ",
"(",
")",
",",
"point",
".",
"getX",
"(",
")",
",",
"point",
".",
"getY",
"(",
")",
",",
"point",
".",
"getZ",
"(",
")",
",",
"true",
",",
"0.",
")",
";",
"}"
] | Checks if a point is inside this triangle.
@param point is the the point
@return <code>true</code> if the point is in the triangle , otherwise <code>false</code>. | [
"Checks",
"if",
"a",
"point",
"is",
"inside",
"this",
"triangle",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java#L1580-L1588 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java | AbstractTriangle3F.getPlane | @Pure
public Plane3D<?> getPlane() {
return toPlane(
getX1(), getY1(), getZ1(),
getX1(), getY1(), getZ1(),
getX1(), getY1(), getZ1());
} | java | @Pure
public Plane3D<?> getPlane() {
return toPlane(
getX1(), getY1(), getZ1(),
getX1(), getY1(), getZ1(),
getX1(), getY1(), getZ1());
} | [
"@",
"Pure",
"public",
"Plane3D",
"<",
"?",
">",
"getPlane",
"(",
")",
"{",
"return",
"toPlane",
"(",
"getX1",
"(",
")",
",",
"getY1",
"(",
")",
",",
"getZ1",
"(",
")",
",",
"getX1",
"(",
")",
",",
"getY1",
"(",
")",
",",
"getZ1",
"(",
")",
",",
"getX1",
"(",
")",
",",
"getY1",
"(",
")",
",",
"getZ1",
"(",
")",
")",
";",
"}"
] | Replies the plane on which this triangle is coplanar.
@return the coplanar plane to this triangle | [
"Replies",
"the",
"plane",
"on",
"which",
"this",
"triangle",
"is",
"coplanar",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/AbstractTriangle3F.java#L1599-L1605 | train |
gallandarakhneorg/afc | core/inputoutput/src/main/java/org/arakhne/afc/inputoutput/stream/WriterOutputStream.java | WriterOutputStream.writeln | public void writeln(String text) throws IOException {
this.writer.write(text);
if (text != null && text.length() > 0) {
this.writer.write("\n"); //$NON-NLS-1$
}
} | java | public void writeln(String text) throws IOException {
this.writer.write(text);
if (text != null && text.length() > 0) {
this.writer.write("\n"); //$NON-NLS-1$
}
} | [
"public",
"void",
"writeln",
"(",
"String",
"text",
")",
"throws",
"IOException",
"{",
"this",
".",
"writer",
".",
"write",
"(",
"text",
")",
";",
"if",
"(",
"text",
"!=",
"null",
"&&",
"text",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"this",
".",
"writer",
".",
"write",
"(",
"\"\\n\"",
")",
";",
"//$NON-NLS-1$",
"}",
"}"
] | Write a sequence of characters followed by a carriage return.
@param text text.
@throws IOException on error. | [
"Write",
"a",
"sequence",
"of",
"characters",
"followed",
"by",
"a",
"carriage",
"return",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/inputoutput/src/main/java/org/arakhne/afc/inputoutput/stream/WriterOutputStream.java#L67-L72 | train |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/collections/IterableUtils.java | IterableUtils.zip | public static <X, Y> Iterable<ZipPair<X, Y>> zip(final Iterable<X> iter1,
final Iterable<Y> iter2) {
return new ZipIterable<X, Y>(iter1, iter2);
} | java | public static <X, Y> Iterable<ZipPair<X, Y>> zip(final Iterable<X> iter1,
final Iterable<Y> iter2) {
return new ZipIterable<X, Y>(iter1, iter2);
} | [
"public",
"static",
"<",
"X",
",",
"Y",
">",
"Iterable",
"<",
"ZipPair",
"<",
"X",
",",
"Y",
">",
">",
"zip",
"(",
"final",
"Iterable",
"<",
"X",
">",
"iter1",
",",
"final",
"Iterable",
"<",
"Y",
">",
"iter2",
")",
"{",
"return",
"new",
"ZipIterable",
"<",
"X",
",",
"Y",
">",
"(",
"iter1",
",",
"iter2",
")",
";",
"}"
] | An implementation of Python's zip. | [
"An",
"implementation",
"of",
"Python",
"s",
"zip",
"."
] | d618652674d647867306e2e4b987a21b7c29c015 | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/collections/IterableUtils.java#L75-L78 | train |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/collections/IterableUtils.java | IterableUtils.reduce | public static <A, B> B reduce(final Iterable<A> iterable,
final B initial, final Function2<A, B> func) {
B b = initial;
for (final A item : iterable) {
b = func.apply(b, item);
}
return b;
} | java | public static <A, B> B reduce(final Iterable<A> iterable,
final B initial, final Function2<A, B> func) {
B b = initial;
for (final A item : iterable) {
b = func.apply(b, item);
}
return b;
} | [
"public",
"static",
"<",
"A",
",",
"B",
">",
"B",
"reduce",
"(",
"final",
"Iterable",
"<",
"A",
">",
"iterable",
",",
"final",
"B",
"initial",
",",
"final",
"Function2",
"<",
"A",
",",
"B",
">",
"func",
")",
"{",
"B",
"b",
"=",
"initial",
";",
"for",
"(",
"final",
"A",
"item",
":",
"iterable",
")",
"{",
"b",
"=",
"func",
".",
"apply",
"(",
"b",
",",
"item",
")",
";",
"}",
"return",
"b",
";",
"}"
] | reduces an iterable to a single value starting from an initial value and applying down the
iterable. | [
"reduces",
"an",
"iterable",
"to",
"a",
"single",
"value",
"starting",
"from",
"an",
"initial",
"value",
"and",
"applying",
"down",
"the",
"iterable",
"."
] | d618652674d647867306e2e4b987a21b7c29c015 | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/collections/IterableUtils.java#L251-L258 | train |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/collections/IterableUtils.java | IterableUtils.mapFromPairedKeyValueSequences | public static <K, V> ImmutableMap<K, V> mapFromPairedKeyValueSequences(
final Iterable<K> keys, final Iterable<V> values) {
final ImmutableMap.Builder<K, V> builder = ImmutableMap.builder();
for (final ZipPair<K, V> pair : zip(keys, values)) {
builder.put(pair.first(), pair.second());
}
return builder.build();
} | java | public static <K, V> ImmutableMap<K, V> mapFromPairedKeyValueSequences(
final Iterable<K> keys, final Iterable<V> values) {
final ImmutableMap.Builder<K, V> builder = ImmutableMap.builder();
for (final ZipPair<K, V> pair : zip(keys, values)) {
builder.put(pair.first(), pair.second());
}
return builder.build();
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"ImmutableMap",
"<",
"K",
",",
"V",
">",
"mapFromPairedKeyValueSequences",
"(",
"final",
"Iterable",
"<",
"K",
">",
"keys",
",",
"final",
"Iterable",
"<",
"V",
">",
"values",
")",
"{",
"final",
"ImmutableMap",
".",
"Builder",
"<",
"K",
",",
"V",
">",
"builder",
"=",
"ImmutableMap",
".",
"builder",
"(",
")",
";",
"for",
"(",
"final",
"ZipPair",
"<",
"K",
",",
"V",
">",
"pair",
":",
"zip",
"(",
"keys",
",",
"values",
")",
")",
"{",
"builder",
".",
"put",
"(",
"pair",
".",
"first",
"(",
")",
",",
"pair",
".",
"second",
"(",
")",
")",
";",
"}",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}"
] | Given a paired sequence of Iterables, produce a map with keys from the first and values from
the second. An exception will be raised if the Iterables have different numbers of elements, or
if there are multiple mappings for the same key. | [
"Given",
"a",
"paired",
"sequence",
"of",
"Iterables",
"produce",
"a",
"map",
"with",
"keys",
"from",
"the",
"first",
"and",
"values",
"from",
"the",
"second",
".",
"An",
"exception",
"will",
"be",
"raised",
"if",
"the",
"Iterables",
"have",
"different",
"numbers",
"of",
"elements",
"or",
"if",
"there",
"are",
"multiple",
"mappings",
"for",
"the",
"same",
"key",
"."
] | d618652674d647867306e2e4b987a21b7c29c015 | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/collections/IterableUtils.java#L338-L345 | train |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/collections/IterableUtils.java | IterableUtils.allTheSame | @Deprecated
public static <T> boolean allTheSame(final Iterable<T> iterable) {
if (Iterables.isEmpty(iterable)) {
return true;
}
final T reference = Iterables.getFirst(iterable, null);
for (final T x : iterable) {
if (!x.equals(reference)) {
return false;
}
}
return true;
} | java | @Deprecated
public static <T> boolean allTheSame(final Iterable<T> iterable) {
if (Iterables.isEmpty(iterable)) {
return true;
}
final T reference = Iterables.getFirst(iterable, null);
for (final T x : iterable) {
if (!x.equals(reference)) {
return false;
}
}
return true;
} | [
"@",
"Deprecated",
"public",
"static",
"<",
"T",
">",
"boolean",
"allTheSame",
"(",
"final",
"Iterable",
"<",
"T",
">",
"iterable",
")",
"{",
"if",
"(",
"Iterables",
".",
"isEmpty",
"(",
"iterable",
")",
")",
"{",
"return",
"true",
";",
"}",
"final",
"T",
"reference",
"=",
"Iterables",
".",
"getFirst",
"(",
"iterable",
",",
"null",
")",
";",
"for",
"(",
"final",
"T",
"x",
":",
"iterable",
")",
"{",
"if",
"(",
"!",
"x",
".",
"equals",
"(",
"reference",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Prefer allEqual, whose name is less ambiguous between equality and identity
@deprecated | [
"Prefer",
"allEqual",
"whose",
"name",
"is",
"less",
"ambiguous",
"between",
"equality",
"and",
"identity"
] | d618652674d647867306e2e4b987a21b7c29c015 | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/collections/IterableUtils.java#L360-L374 | train |
gallandarakhneorg/afc | advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d1/dfx/Vector1dfx.java | Vector1dfx.convert | public static Vector1dfx convert(Tuple1dfx<?> tuple) {
if (tuple instanceof Vector1dfx) {
return (Vector1dfx) tuple;
}
return new Vector1dfx(tuple.getSegment(), tuple.getX(), tuple.getY());
} | java | public static Vector1dfx convert(Tuple1dfx<?> tuple) {
if (tuple instanceof Vector1dfx) {
return (Vector1dfx) tuple;
}
return new Vector1dfx(tuple.getSegment(), tuple.getX(), tuple.getY());
} | [
"public",
"static",
"Vector1dfx",
"convert",
"(",
"Tuple1dfx",
"<",
"?",
">",
"tuple",
")",
"{",
"if",
"(",
"tuple",
"instanceof",
"Vector1dfx",
")",
"{",
"return",
"(",
"Vector1dfx",
")",
"tuple",
";",
"}",
"return",
"new",
"Vector1dfx",
"(",
"tuple",
".",
"getSegment",
"(",
")",
",",
"tuple",
".",
"getX",
"(",
")",
",",
"tuple",
".",
"getY",
"(",
")",
")",
";",
"}"
] | Convert the given tuple to a real Vector1dfx.
<p>If the given tuple is already a Vector1dfx, it is replied.
@param tuple the tuple.
@return the Vector1dfx.
@since 14.0 | [
"Convert",
"the",
"given",
"tuple",
"to",
"a",
"real",
"Vector1dfx",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d1/dfx/Vector1dfx.java#L157-L162 | train |
qiujuer/OkHttpPacker | okhttp/src/main/java/net/qiujuer/common/okhttp/impl/RequestCallBuilder.java | RequestCallBuilder.buildGetParams | protected boolean buildGetParams(StringBuilder sb, boolean isFirst) {
BuilderListener listener = mListener;
if (listener != null) {
return listener.onBuildGetParams(sb, isFirst);
} else {
return isFirst;
}
} | java | protected boolean buildGetParams(StringBuilder sb, boolean isFirst) {
BuilderListener listener = mListener;
if (listener != null) {
return listener.onBuildGetParams(sb, isFirst);
} else {
return isFirst;
}
} | [
"protected",
"boolean",
"buildGetParams",
"(",
"StringBuilder",
"sb",
",",
"boolean",
"isFirst",
")",
"{",
"BuilderListener",
"listener",
"=",
"mListener",
";",
"if",
"(",
"listener",
"!=",
"null",
")",
"{",
"return",
"listener",
".",
"onBuildGetParams",
"(",
"sb",
",",
"isFirst",
")",
";",
"}",
"else",
"{",
"return",
"isFirst",
";",
"}",
"}"
] | In this we should add same default params to the get builder
@param sb Get Values
@param isFirst The Url and values is have "?" char
@return values is have "?" char | [
"In",
"this",
"we",
"should",
"add",
"same",
"default",
"params",
"to",
"the",
"get",
"builder"
] | d2d484facb66b7e11e6cbbfeb78025f76ce25ebd | https://github.com/qiujuer/OkHttpPacker/blob/d2d484facb66b7e11e6cbbfeb78025f76ce25ebd/okhttp/src/main/java/net/qiujuer/common/okhttp/impl/RequestCallBuilder.java#L59-L66 | train |
italiangrid/voms-clients | src/main/java/org/italiangrid/voms/clients/impl/DefaultVOMSProxyInitBehaviour.java | DefaultVOMSProxyInitBehaviour.extendedProxyTypeAsProxyType | private ProxyType extendedProxyTypeAsProxyType(ExtendedProxyType pt) {
switch (pt) {
case DRAFT_RFC:
return ProxyType.DRAFT_RFC;
case LEGACY:
return ProxyType.LEGACY;
case RFC3820:
return ProxyType.RFC3820;
default:
return null;
}
} | java | private ProxyType extendedProxyTypeAsProxyType(ExtendedProxyType pt) {
switch (pt) {
case DRAFT_RFC:
return ProxyType.DRAFT_RFC;
case LEGACY:
return ProxyType.LEGACY;
case RFC3820:
return ProxyType.RFC3820;
default:
return null;
}
} | [
"private",
"ProxyType",
"extendedProxyTypeAsProxyType",
"(",
"ExtendedProxyType",
"pt",
")",
"{",
"switch",
"(",
"pt",
")",
"{",
"case",
"DRAFT_RFC",
":",
"return",
"ProxyType",
".",
"DRAFT_RFC",
";",
"case",
"LEGACY",
":",
"return",
"ProxyType",
".",
"LEGACY",
";",
"case",
"RFC3820",
":",
"return",
"ProxyType",
".",
"RFC3820",
";",
"default",
":",
"return",
"null",
";",
"}",
"}"
] | Why we have to do this nonsense? | [
"Why",
"we",
"have",
"to",
"do",
"this",
"nonsense?"
] | 069cbe324c85286fa454bd78c3f76c23e97e5768 | https://github.com/italiangrid/voms-clients/blob/069cbe324c85286fa454bd78c3f76c23e97e5768/src/main/java/org/italiangrid/voms/clients/impl/DefaultVOMSProxyInitBehaviour.java#L317-L333 | train |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.encodeBase26 | @Pure
@SuppressWarnings("checkstyle:magicnumber")
public static String encodeBase26(int number) {
final StringBuilder value = new StringBuilder();
int code = number;
do {
final int rest = code % 26;
value.insert(0, (char) ('A' + rest));
code = code / 26 - 1;
}
while (code >= 0);
return value.toString();
} | java | @Pure
@SuppressWarnings("checkstyle:magicnumber")
public static String encodeBase26(int number) {
final StringBuilder value = new StringBuilder();
int code = number;
do {
final int rest = code % 26;
value.insert(0, (char) ('A' + rest));
code = code / 26 - 1;
}
while (code >= 0);
return value.toString();
} | [
"@",
"Pure",
"@",
"SuppressWarnings",
"(",
"\"checkstyle:magicnumber\"",
")",
"public",
"static",
"String",
"encodeBase26",
"(",
"int",
"number",
")",
"{",
"final",
"StringBuilder",
"value",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"int",
"code",
"=",
"number",
";",
"do",
"{",
"final",
"int",
"rest",
"=",
"code",
"%",
"26",
";",
"value",
".",
"insert",
"(",
"0",
",",
"(",
"char",
")",
"(",
"'",
"'",
"+",
"rest",
")",
")",
";",
"code",
"=",
"code",
"/",
"26",
"-",
"1",
";",
"}",
"while",
"(",
"code",
">=",
"0",
")",
";",
"return",
"value",
".",
"toString",
"(",
")",
";",
"}"
] | Replies a base 26 encoding string for the given
number.
@param number the number to encode.
@return the base 26 encoding.
@since 4.0 | [
"Replies",
"a",
"base",
"26",
"encoding",
"string",
"for",
"the",
"given",
"number",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L98-L110 | train |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.getJavaToHTMLTranslationTable | @Pure
@SuppressWarnings("checkstyle:npathcomplexity")
public static Map<Character, String> getJavaToHTMLTranslationTable() {
Map<Character, String> map = null;
try {
LOCK.lock();
if (javaToHtmlTransTbl != null) {
map = javaToHtmlTransTbl.get();
}
} finally {
LOCK.unlock();
}
if (map != null) {
return map;
}
// Get the resource file
ResourceBundle resource = null;
try {
resource = ResourceBundle.getBundle(
TextUtil.class.getCanonicalName(),
java.util.Locale.getDefault());
} catch (MissingResourceException exep) {
return null;
}
// get the resource string
final String result;
try {
result = resource.getString("HTML_TRANS_TBL"); //$NON-NLS-1$
} catch (Exception e) {
return null;
}
map = new TreeMap<>();
final String[] pairs = result.split("(\\}\\{)|\\{|\\}"); //$NON-NLS-1$
Integer isoCode;
String entity;
String code;
for (int i = 1; (i + 1) < pairs.length; i += 2) {
try {
entity = pairs[i];
code = pairs[i + 1];
isoCode = Integer.valueOf(code);
if (isoCode != null) {
map.put((char) isoCode.intValue(), entity);
}
} catch (Throwable exception) {
//
}
}
try {
LOCK.lock();
javaToHtmlTransTbl = new SoftReference<>(map);
} finally {
LOCK.unlock();
}
return map;
} | java | @Pure
@SuppressWarnings("checkstyle:npathcomplexity")
public static Map<Character, String> getJavaToHTMLTranslationTable() {
Map<Character, String> map = null;
try {
LOCK.lock();
if (javaToHtmlTransTbl != null) {
map = javaToHtmlTransTbl.get();
}
} finally {
LOCK.unlock();
}
if (map != null) {
return map;
}
// Get the resource file
ResourceBundle resource = null;
try {
resource = ResourceBundle.getBundle(
TextUtil.class.getCanonicalName(),
java.util.Locale.getDefault());
} catch (MissingResourceException exep) {
return null;
}
// get the resource string
final String result;
try {
result = resource.getString("HTML_TRANS_TBL"); //$NON-NLS-1$
} catch (Exception e) {
return null;
}
map = new TreeMap<>();
final String[] pairs = result.split("(\\}\\{)|\\{|\\}"); //$NON-NLS-1$
Integer isoCode;
String entity;
String code;
for (int i = 1; (i + 1) < pairs.length; i += 2) {
try {
entity = pairs[i];
code = pairs[i + 1];
isoCode = Integer.valueOf(code);
if (isoCode != null) {
map.put((char) isoCode.intValue(), entity);
}
} catch (Throwable exception) {
//
}
}
try {
LOCK.lock();
javaToHtmlTransTbl = new SoftReference<>(map);
} finally {
LOCK.unlock();
}
return map;
} | [
"@",
"Pure",
"@",
"SuppressWarnings",
"(",
"\"checkstyle:npathcomplexity\"",
")",
"public",
"static",
"Map",
"<",
"Character",
",",
"String",
">",
"getJavaToHTMLTranslationTable",
"(",
")",
"{",
"Map",
"<",
"Character",
",",
"String",
">",
"map",
"=",
"null",
";",
"try",
"{",
"LOCK",
".",
"lock",
"(",
")",
";",
"if",
"(",
"javaToHtmlTransTbl",
"!=",
"null",
")",
"{",
"map",
"=",
"javaToHtmlTransTbl",
".",
"get",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"LOCK",
".",
"unlock",
"(",
")",
";",
"}",
"if",
"(",
"map",
"!=",
"null",
")",
"{",
"return",
"map",
";",
"}",
"// Get the resource file",
"ResourceBundle",
"resource",
"=",
"null",
";",
"try",
"{",
"resource",
"=",
"ResourceBundle",
".",
"getBundle",
"(",
"TextUtil",
".",
"class",
".",
"getCanonicalName",
"(",
")",
",",
"java",
".",
"util",
".",
"Locale",
".",
"getDefault",
"(",
")",
")",
";",
"}",
"catch",
"(",
"MissingResourceException",
"exep",
")",
"{",
"return",
"null",
";",
"}",
"// get the resource string",
"final",
"String",
"result",
";",
"try",
"{",
"result",
"=",
"resource",
".",
"getString",
"(",
"\"HTML_TRANS_TBL\"",
")",
";",
"//$NON-NLS-1$",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"null",
";",
"}",
"map",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"final",
"String",
"[",
"]",
"pairs",
"=",
"result",
".",
"split",
"(",
"\"(\\\\}\\\\{)|\\\\{|\\\\}\"",
")",
";",
"//$NON-NLS-1$",
"Integer",
"isoCode",
";",
"String",
"entity",
";",
"String",
"code",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"(",
"i",
"+",
"1",
")",
"<",
"pairs",
".",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"try",
"{",
"entity",
"=",
"pairs",
"[",
"i",
"]",
";",
"code",
"=",
"pairs",
"[",
"i",
"+",
"1",
"]",
";",
"isoCode",
"=",
"Integer",
".",
"valueOf",
"(",
"code",
")",
";",
"if",
"(",
"isoCode",
"!=",
"null",
")",
"{",
"map",
".",
"put",
"(",
"(",
"char",
")",
"isoCode",
".",
"intValue",
"(",
")",
",",
"entity",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"exception",
")",
"{",
"//",
"}",
"}",
"try",
"{",
"LOCK",
".",
"lock",
"(",
")",
";",
"javaToHtmlTransTbl",
"=",
"new",
"SoftReference",
"<>",
"(",
"map",
")",
";",
"}",
"finally",
"{",
"LOCK",
".",
"unlock",
"(",
")",
";",
"}",
"return",
"map",
";",
"}"
] | Replies the java-to-html's translation table.
<p>This method read the translations from the
resource file <code>HTML_TRANS_TBL</code>.
@return the translation table or <code>null</code> if none was found.
The translation table maps an ISO character code to its corresponding HTML entity.
@since 4.0 | [
"Replies",
"the",
"java",
"-",
"to",
"-",
"html",
"s",
"translation",
"table",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L195-L258 | train |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.parseHTML | @Pure
@SuppressWarnings("checkstyle:magicnumber")
public static String parseHTML(String html) {
if (html == null) {
return null;
}
final Map<String, Integer> transTbl = getHtmlToJavaTranslationTable();
assert transTbl != null;
if (transTbl.isEmpty()) {
return html;
}
final Pattern pattern = Pattern.compile("[&](([a-zA-Z]+)|(#x?[0-9]+))[;]"); //$NON-NLS-1$
final Matcher matcher = pattern.matcher(html);
final StringBuilder result = new StringBuilder();
String entity;
Integer isoCode;
int lastIndex = 0;
while (matcher.find()) {
final int idx = matcher.start();
result.append(html.substring(lastIndex, idx));
lastIndex = matcher.end();
entity = matcher.group(1);
if (entity.startsWith("#x")) { //$NON-NLS-1$
try {
isoCode = Integer.valueOf(entity.substring(2), 16);
} catch (Throwable exception) {
isoCode = null;
}
} else if (entity.startsWith("#")) { //$NON-NLS-1$
try {
isoCode = Integer.valueOf(entity.substring(1));
} catch (Throwable exception) {
isoCode = null;
}
} else {
isoCode = transTbl.get(entity);
}
if (isoCode == null) {
result.append(matcher.group());
} else {
result.append((char) isoCode.intValue());
}
}
if (lastIndex < html.length()) {
result.append(html.substring(lastIndex));
}
return result.toString();
} | java | @Pure
@SuppressWarnings("checkstyle:magicnumber")
public static String parseHTML(String html) {
if (html == null) {
return null;
}
final Map<String, Integer> transTbl = getHtmlToJavaTranslationTable();
assert transTbl != null;
if (transTbl.isEmpty()) {
return html;
}
final Pattern pattern = Pattern.compile("[&](([a-zA-Z]+)|(#x?[0-9]+))[;]"); //$NON-NLS-1$
final Matcher matcher = pattern.matcher(html);
final StringBuilder result = new StringBuilder();
String entity;
Integer isoCode;
int lastIndex = 0;
while (matcher.find()) {
final int idx = matcher.start();
result.append(html.substring(lastIndex, idx));
lastIndex = matcher.end();
entity = matcher.group(1);
if (entity.startsWith("#x")) { //$NON-NLS-1$
try {
isoCode = Integer.valueOf(entity.substring(2), 16);
} catch (Throwable exception) {
isoCode = null;
}
} else if (entity.startsWith("#")) { //$NON-NLS-1$
try {
isoCode = Integer.valueOf(entity.substring(1));
} catch (Throwable exception) {
isoCode = null;
}
} else {
isoCode = transTbl.get(entity);
}
if (isoCode == null) {
result.append(matcher.group());
} else {
result.append((char) isoCode.intValue());
}
}
if (lastIndex < html.length()) {
result.append(html.substring(lastIndex));
}
return result.toString();
} | [
"@",
"Pure",
"@",
"SuppressWarnings",
"(",
"\"checkstyle:magicnumber\"",
")",
"public",
"static",
"String",
"parseHTML",
"(",
"String",
"html",
")",
"{",
"if",
"(",
"html",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"Map",
"<",
"String",
",",
"Integer",
">",
"transTbl",
"=",
"getHtmlToJavaTranslationTable",
"(",
")",
";",
"assert",
"transTbl",
"!=",
"null",
";",
"if",
"(",
"transTbl",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"html",
";",
"}",
"final",
"Pattern",
"pattern",
"=",
"Pattern",
".",
"compile",
"(",
"\"[&](([a-zA-Z]+)|(#x?[0-9]+))[;]\"",
")",
";",
"//$NON-NLS-1$",
"final",
"Matcher",
"matcher",
"=",
"pattern",
".",
"matcher",
"(",
"html",
")",
";",
"final",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"entity",
";",
"Integer",
"isoCode",
";",
"int",
"lastIndex",
"=",
"0",
";",
"while",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"final",
"int",
"idx",
"=",
"matcher",
".",
"start",
"(",
")",
";",
"result",
".",
"append",
"(",
"html",
".",
"substring",
"(",
"lastIndex",
",",
"idx",
")",
")",
";",
"lastIndex",
"=",
"matcher",
".",
"end",
"(",
")",
";",
"entity",
"=",
"matcher",
".",
"group",
"(",
"1",
")",
";",
"if",
"(",
"entity",
".",
"startsWith",
"(",
"\"#x\"",
")",
")",
"{",
"//$NON-NLS-1$",
"try",
"{",
"isoCode",
"=",
"Integer",
".",
"valueOf",
"(",
"entity",
".",
"substring",
"(",
"2",
")",
",",
"16",
")",
";",
"}",
"catch",
"(",
"Throwable",
"exception",
")",
"{",
"isoCode",
"=",
"null",
";",
"}",
"}",
"else",
"if",
"(",
"entity",
".",
"startsWith",
"(",
"\"#\"",
")",
")",
"{",
"//$NON-NLS-1$",
"try",
"{",
"isoCode",
"=",
"Integer",
".",
"valueOf",
"(",
"entity",
".",
"substring",
"(",
"1",
")",
")",
";",
"}",
"catch",
"(",
"Throwable",
"exception",
")",
"{",
"isoCode",
"=",
"null",
";",
"}",
"}",
"else",
"{",
"isoCode",
"=",
"transTbl",
".",
"get",
"(",
"entity",
")",
";",
"}",
"if",
"(",
"isoCode",
"==",
"null",
")",
"{",
"result",
".",
"append",
"(",
"matcher",
".",
"group",
"(",
")",
")",
";",
"}",
"else",
"{",
"result",
".",
"append",
"(",
"(",
"char",
")",
"isoCode",
".",
"intValue",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"lastIndex",
"<",
"html",
".",
"length",
"(",
")",
")",
"{",
"result",
".",
"append",
"(",
"html",
".",
"substring",
"(",
"lastIndex",
")",
")",
";",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] | Parse the given HTML text and replace all
the HTML entities by the corresponding unicode
character.
@param html is the HTML to convert.
@return the unicode representation of the given html text.
@since 4.0
@see #toHTML(String) | [
"Parse",
"the",
"given",
"HTML",
"text",
"and",
"replace",
"all",
"the",
"HTML",
"entities",
"by",
"the",
"corresponding",
"unicode",
"character",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L269-L317 | train |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.toHTML | @Pure
public static String toHTML(String text) {
if (text == null) {
return null;
}
final Map<Character, String> transTbl = getJavaToHTMLTranslationTable();
assert transTbl != null;
if (transTbl.isEmpty()) {
return text;
}
final StringBuilder patternStr = new StringBuilder();
for (final Character c : transTbl.keySet()) {
if (patternStr.length() > 0) {
patternStr.append("|"); //$NON-NLS-1$
}
patternStr.append(Pattern.quote(c.toString()));
}
final Pattern pattern = Pattern.compile(patternStr.toString());
final Matcher matcher = pattern.matcher(text);
final StringBuilder result = new StringBuilder();
String character;
String entity;
int lastIndex = 0;
while (matcher.find()) {
final int idx = matcher.start();
result.append(text.substring(lastIndex, idx));
lastIndex = matcher.end();
character = matcher.group();
if (character.length() == 1) {
entity = transTbl.get(Character.valueOf(character.charAt(0)));
if (entity != null) {
entity = "&" + entity + ";"; //$NON-NLS-1$ //$NON-NLS-2$
} else {
entity = character;
}
} else {
entity = character;
}
result.append(entity);
}
if (lastIndex < text.length()) {
result.append(text.substring(lastIndex));
}
return result.toString();
} | java | @Pure
public static String toHTML(String text) {
if (text == null) {
return null;
}
final Map<Character, String> transTbl = getJavaToHTMLTranslationTable();
assert transTbl != null;
if (transTbl.isEmpty()) {
return text;
}
final StringBuilder patternStr = new StringBuilder();
for (final Character c : transTbl.keySet()) {
if (patternStr.length() > 0) {
patternStr.append("|"); //$NON-NLS-1$
}
patternStr.append(Pattern.quote(c.toString()));
}
final Pattern pattern = Pattern.compile(patternStr.toString());
final Matcher matcher = pattern.matcher(text);
final StringBuilder result = new StringBuilder();
String character;
String entity;
int lastIndex = 0;
while (matcher.find()) {
final int idx = matcher.start();
result.append(text.substring(lastIndex, idx));
lastIndex = matcher.end();
character = matcher.group();
if (character.length() == 1) {
entity = transTbl.get(Character.valueOf(character.charAt(0)));
if (entity != null) {
entity = "&" + entity + ";"; //$NON-NLS-1$ //$NON-NLS-2$
} else {
entity = character;
}
} else {
entity = character;
}
result.append(entity);
}
if (lastIndex < text.length()) {
result.append(text.substring(lastIndex));
}
return result.toString();
} | [
"@",
"Pure",
"public",
"static",
"String",
"toHTML",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"Map",
"<",
"Character",
",",
"String",
">",
"transTbl",
"=",
"getJavaToHTMLTranslationTable",
"(",
")",
";",
"assert",
"transTbl",
"!=",
"null",
";",
"if",
"(",
"transTbl",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"text",
";",
"}",
"final",
"StringBuilder",
"patternStr",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"final",
"Character",
"c",
":",
"transTbl",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"patternStr",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"patternStr",
".",
"append",
"(",
"\"|\"",
")",
";",
"//$NON-NLS-1$",
"}",
"patternStr",
".",
"append",
"(",
"Pattern",
".",
"quote",
"(",
"c",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"final",
"Pattern",
"pattern",
"=",
"Pattern",
".",
"compile",
"(",
"patternStr",
".",
"toString",
"(",
")",
")",
";",
"final",
"Matcher",
"matcher",
"=",
"pattern",
".",
"matcher",
"(",
"text",
")",
";",
"final",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"character",
";",
"String",
"entity",
";",
"int",
"lastIndex",
"=",
"0",
";",
"while",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"final",
"int",
"idx",
"=",
"matcher",
".",
"start",
"(",
")",
";",
"result",
".",
"append",
"(",
"text",
".",
"substring",
"(",
"lastIndex",
",",
"idx",
")",
")",
";",
"lastIndex",
"=",
"matcher",
".",
"end",
"(",
")",
";",
"character",
"=",
"matcher",
".",
"group",
"(",
")",
";",
"if",
"(",
"character",
".",
"length",
"(",
")",
"==",
"1",
")",
"{",
"entity",
"=",
"transTbl",
".",
"get",
"(",
"Character",
".",
"valueOf",
"(",
"character",
".",
"charAt",
"(",
"0",
")",
")",
")",
";",
"if",
"(",
"entity",
"!=",
"null",
")",
"{",
"entity",
"=",
"\"&\"",
"+",
"entity",
"+",
"\";\"",
";",
"//$NON-NLS-1$ //$NON-NLS-2$",
"}",
"else",
"{",
"entity",
"=",
"character",
";",
"}",
"}",
"else",
"{",
"entity",
"=",
"character",
";",
"}",
"result",
".",
"append",
"(",
"entity",
")",
";",
"}",
"if",
"(",
"lastIndex",
"<",
"text",
".",
"length",
"(",
")",
")",
"{",
"result",
".",
"append",
"(",
"text",
".",
"substring",
"(",
"lastIndex",
")",
")",
";",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] | Translate all the special character from the given
text to their equivalent HTML entities.
@param text is the text to convert.
@return the HTML text which is corresponding to the given text.
@since 4.0
@see #parseHTML(String) | [
"Translate",
"all",
"the",
"special",
"character",
"from",
"the",
"given",
"text",
"to",
"their",
"equivalent",
"HTML",
"entities",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L327-L371 | train |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.cutStringAsArray | public static void cutStringAsArray(String text, CutStringCritera critera, List<String> output) {
cutStringAlgo(text, critera, new CutStringToArray(output));
} | java | public static void cutStringAsArray(String text, CutStringCritera critera, List<String> output) {
cutStringAlgo(text, critera, new CutStringToArray(output));
} | [
"public",
"static",
"void",
"cutStringAsArray",
"(",
"String",
"text",
",",
"CutStringCritera",
"critera",
",",
"List",
"<",
"String",
">",
"output",
")",
"{",
"cutStringAlgo",
"(",
"text",
",",
"critera",
",",
"new",
"CutStringToArray",
"(",
"output",
")",
")",
";",
"}"
] | Format the text to be sure that each line is not
more longer than the specified critera.
@param text is the string to cut
@param critera is the critera to respect.
@param output is the given {@code text} splitted in lines separated by <code>\n</code>.
@since 4.0 | [
"Format",
"the",
"text",
"to",
"be",
"sure",
"that",
"each",
"line",
"is",
"not",
"more",
"longer",
"than",
"the",
"specified",
"critera",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L412-L414 | train |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.getMnemonicChar | @Pure
public static char getMnemonicChar(String text) {
if (text != null) {
final int pos = text.indexOf('&');
if ((pos != -1) && (pos < text.length() - 1)) {
return text.charAt(pos + 1);
}
}
return '\0';
} | java | @Pure
public static char getMnemonicChar(String text) {
if (text != null) {
final int pos = text.indexOf('&');
if ((pos != -1) && (pos < text.length() - 1)) {
return text.charAt(pos + 1);
}
}
return '\0';
} | [
"@",
"Pure",
"public",
"static",
"char",
"getMnemonicChar",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"text",
"!=",
"null",
")",
"{",
"final",
"int",
"pos",
"=",
"text",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"(",
"pos",
"!=",
"-",
"1",
")",
"&&",
"(",
"pos",
"<",
"text",
".",
"length",
"(",
")",
"-",
"1",
")",
")",
"{",
"return",
"text",
".",
"charAt",
"(",
"pos",
"+",
"1",
")",
";",
"}",
"}",
"return",
"'",
"'",
";",
"}"
] | Replies the character which follow the first '&'.
@param text is the text to scan.
@return the character that is following the first '&' or '<code>\0</code>' | [
"Replies",
"the",
"character",
"which",
"follow",
"the",
"first",
"&",
";",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L472-L481 | train |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.removeMnemonicChar | @Pure
public static String removeMnemonicChar(String text) {
if (text == null) {
return text;
}
return text.replaceFirst("&", ""); //$NON-NLS-1$ //$NON-NLS-2$
} | java | @Pure
public static String removeMnemonicChar(String text) {
if (text == null) {
return text;
}
return text.replaceFirst("&", ""); //$NON-NLS-1$ //$NON-NLS-2$
} | [
"@",
"Pure",
"public",
"static",
"String",
"removeMnemonicChar",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"return",
"text",
";",
"}",
"return",
"text",
".",
"replaceFirst",
"(",
"\"&\"",
",",
"\"\"",
")",
";",
"//$NON-NLS-1$ //$NON-NLS-2$",
"}"
] | Remove the mnemonic char from the specified string.
@param text is the text to scan.
@return the given text without the mnemonic character. | [
"Remove",
"the",
"mnemonic",
"char",
"from",
"the",
"specified",
"string",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L488-L494 | train |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.getAccentTranslationTable | @Pure
@SuppressWarnings("checkstyle:npathcomplexity")
public static Map<Character, String> getAccentTranslationTable() {
Map<Character, String> map = null;
try {
LOCK.lock();
if (accentTransTbl != null) {
map = accentTransTbl.get();
}
} finally {
LOCK.unlock();
}
if (map != null) {
return map;
}
// Get the resource file
ResourceBundle resource = null;
try {
resource = ResourceBundle.getBundle(
TextUtil.class.getCanonicalName(),
java.util.Locale.getDefault());
} catch (MissingResourceException exep) {
return null;
}
// get the resource string
final String result;
try {
result = resource.getString("ACCENT_TRANS_TBL"); //$NON-NLS-1$
} catch (Exception e) {
return null;
}
map = new TreeMap<>();
final String[] pairs = result.split("(\\}\\{)|\\{|\\}"); //$NON-NLS-1$
for (final String pair : pairs) {
if (pair.length() > 1) {
map.put(pair.charAt(0), pair.substring(1));
}
}
try {
LOCK.lock();
accentTransTbl = new SoftReference<>(map);
} finally {
LOCK.unlock();
}
return map;
} | java | @Pure
@SuppressWarnings("checkstyle:npathcomplexity")
public static Map<Character, String> getAccentTranslationTable() {
Map<Character, String> map = null;
try {
LOCK.lock();
if (accentTransTbl != null) {
map = accentTransTbl.get();
}
} finally {
LOCK.unlock();
}
if (map != null) {
return map;
}
// Get the resource file
ResourceBundle resource = null;
try {
resource = ResourceBundle.getBundle(
TextUtil.class.getCanonicalName(),
java.util.Locale.getDefault());
} catch (MissingResourceException exep) {
return null;
}
// get the resource string
final String result;
try {
result = resource.getString("ACCENT_TRANS_TBL"); //$NON-NLS-1$
} catch (Exception e) {
return null;
}
map = new TreeMap<>();
final String[] pairs = result.split("(\\}\\{)|\\{|\\}"); //$NON-NLS-1$
for (final String pair : pairs) {
if (pair.length() > 1) {
map.put(pair.charAt(0), pair.substring(1));
}
}
try {
LOCK.lock();
accentTransTbl = new SoftReference<>(map);
} finally {
LOCK.unlock();
}
return map;
} | [
"@",
"Pure",
"@",
"SuppressWarnings",
"(",
"\"checkstyle:npathcomplexity\"",
")",
"public",
"static",
"Map",
"<",
"Character",
",",
"String",
">",
"getAccentTranslationTable",
"(",
")",
"{",
"Map",
"<",
"Character",
",",
"String",
">",
"map",
"=",
"null",
";",
"try",
"{",
"LOCK",
".",
"lock",
"(",
")",
";",
"if",
"(",
"accentTransTbl",
"!=",
"null",
")",
"{",
"map",
"=",
"accentTransTbl",
".",
"get",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"LOCK",
".",
"unlock",
"(",
")",
";",
"}",
"if",
"(",
"map",
"!=",
"null",
")",
"{",
"return",
"map",
";",
"}",
"// Get the resource file",
"ResourceBundle",
"resource",
"=",
"null",
";",
"try",
"{",
"resource",
"=",
"ResourceBundle",
".",
"getBundle",
"(",
"TextUtil",
".",
"class",
".",
"getCanonicalName",
"(",
")",
",",
"java",
".",
"util",
".",
"Locale",
".",
"getDefault",
"(",
")",
")",
";",
"}",
"catch",
"(",
"MissingResourceException",
"exep",
")",
"{",
"return",
"null",
";",
"}",
"// get the resource string",
"final",
"String",
"result",
";",
"try",
"{",
"result",
"=",
"resource",
".",
"getString",
"(",
"\"ACCENT_TRANS_TBL\"",
")",
";",
"//$NON-NLS-1$",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"null",
";",
"}",
"map",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"final",
"String",
"[",
"]",
"pairs",
"=",
"result",
".",
"split",
"(",
"\"(\\\\}\\\\{)|\\\\{|\\\\}\"",
")",
";",
"//$NON-NLS-1$",
"for",
"(",
"final",
"String",
"pair",
":",
"pairs",
")",
"{",
"if",
"(",
"pair",
".",
"length",
"(",
")",
">",
"1",
")",
"{",
"map",
".",
"put",
"(",
"pair",
".",
"charAt",
"(",
"0",
")",
",",
"pair",
".",
"substring",
"(",
"1",
")",
")",
";",
"}",
"}",
"try",
"{",
"LOCK",
".",
"lock",
"(",
")",
";",
"accentTransTbl",
"=",
"new",
"SoftReference",
"<>",
"(",
"map",
")",
";",
"}",
"finally",
"{",
"LOCK",
".",
"unlock",
"(",
")",
";",
"}",
"return",
"map",
";",
"}"
] | Replies the accent's translation table.
<p>This method read the translations from the
resource file <code>ACCENT_TRANS_TBL</code>.
@return the translation table or <code>null</code> if none was found. | [
"Replies",
"the",
"accent",
"s",
"translation",
"table",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L503-L556 | train |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.removeAccents | @Pure
public static String removeAccents(String text) {
final Map<Character, String> map = getAccentTranslationTable();
if ((map == null) || (map.isEmpty())) {
return text;
}
return removeAccents(text, map);
} | java | @Pure
public static String removeAccents(String text) {
final Map<Character, String> map = getAccentTranslationTable();
if ((map == null) || (map.isEmpty())) {
return text;
}
return removeAccents(text, map);
} | [
"@",
"Pure",
"public",
"static",
"String",
"removeAccents",
"(",
"String",
"text",
")",
"{",
"final",
"Map",
"<",
"Character",
",",
"String",
">",
"map",
"=",
"getAccentTranslationTable",
"(",
")",
";",
"if",
"(",
"(",
"map",
"==",
"null",
")",
"||",
"(",
"map",
".",
"isEmpty",
"(",
")",
")",
")",
"{",
"return",
"text",
";",
"}",
"return",
"removeAccents",
"(",
"text",
",",
"map",
")",
";",
"}"
] | Remove the accents inside the specified string.
@param text is the string into which the accents must be removed.
@return the given string without the accents | [
"Remove",
"the",
"accents",
"inside",
"the",
"specified",
"string",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L563-L570 | train |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.split | @Pure
public static String[] split(char leftSeparator, char rightSeparator, String str) {
final SplitSeparatorToArrayAlgorithm algo = new SplitSeparatorToArrayAlgorithm();
splitSeparatorAlgorithm(leftSeparator, rightSeparator, str, algo);
return algo.toArray();
} | java | @Pure
public static String[] split(char leftSeparator, char rightSeparator, String str) {
final SplitSeparatorToArrayAlgorithm algo = new SplitSeparatorToArrayAlgorithm();
splitSeparatorAlgorithm(leftSeparator, rightSeparator, str, algo);
return algo.toArray();
} | [
"@",
"Pure",
"public",
"static",
"String",
"[",
"]",
"split",
"(",
"char",
"leftSeparator",
",",
"char",
"rightSeparator",
",",
"String",
"str",
")",
"{",
"final",
"SplitSeparatorToArrayAlgorithm",
"algo",
"=",
"new",
"SplitSeparatorToArrayAlgorithm",
"(",
")",
";",
"splitSeparatorAlgorithm",
"(",
"leftSeparator",
",",
"rightSeparator",
",",
"str",
",",
"algo",
")",
";",
"return",
"algo",
".",
"toArray",
"(",
")",
";",
"}"
] | Split the given string according to the separators.
The separators are used to delimit the groups
of characters.
<p>Examples:
<ul>
<li><code>split('{','}',"{a}{b}{cd}")</code> returns the array
<code>["a","b","cd"]</code></li>
<li><code>split('{','}',"abcd")</code> returns the array
<code>["abcd"]</code></li>
<li><code>split('{','}',"a{bcd")</code> returns the array
<code>["a","bcd"]</code></li>
</ul>
@param leftSeparator is the left separator.
@param rightSeparator is the right separator.
@param str is the strig with brackets.
@return the groups of strings
@since 4.0 | [
"Split",
"the",
"given",
"string",
"according",
"to",
"the",
"separators",
".",
"The",
"separators",
"are",
"used",
"to",
"delimit",
"the",
"groups",
"of",
"characters",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L639-L644 | train |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.join | @Pure
public static <T> String join(char leftSeparator, char rightSeparator, @SuppressWarnings("unchecked") T... strs) {
final StringBuilder buffer = new StringBuilder();
for (final Object s : strs) {
buffer.append(leftSeparator);
if (s != null) {
buffer.append(s.toString());
}
buffer.append(rightSeparator);
}
return buffer.toString();
} | java | @Pure
public static <T> String join(char leftSeparator, char rightSeparator, @SuppressWarnings("unchecked") T... strs) {
final StringBuilder buffer = new StringBuilder();
for (final Object s : strs) {
buffer.append(leftSeparator);
if (s != null) {
buffer.append(s.toString());
}
buffer.append(rightSeparator);
}
return buffer.toString();
} | [
"@",
"Pure",
"public",
"static",
"<",
"T",
">",
"String",
"join",
"(",
"char",
"leftSeparator",
",",
"char",
"rightSeparator",
",",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"T",
"...",
"strs",
")",
"{",
"final",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"final",
"Object",
"s",
":",
"strs",
")",
"{",
"buffer",
".",
"append",
"(",
"leftSeparator",
")",
";",
"if",
"(",
"s",
"!=",
"null",
")",
"{",
"buffer",
".",
"append",
"(",
"s",
".",
"toString",
"(",
")",
")",
";",
"}",
"buffer",
".",
"append",
"(",
"rightSeparator",
")",
";",
"}",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] | Merge the given strings with to separators.
The separators are used to delimit the groups
of characters.
<p>Examples:
<ul>
<li><code>merge('{','}',"a","b","cd")</code> returns the string
<code>"{a}{b}{cd}"</code></li>
<li><code>merge('{','}',"a{bcd")</code> returns the string
<code>"{a{bcd}"</code></li>
</ul>
@param <T> is the type of the parameters.
@param leftSeparator is the left separator to use.
@param rightSeparator is the right separator to use.
@param strs is the array of strings.
@return the string with merged strings.
@since 4.0 | [
"Merge",
"the",
"given",
"strings",
"with",
"to",
"separators",
".",
"The",
"separators",
"are",
"used",
"to",
"delimit",
"the",
"groups",
"of",
"characters",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L889-L900 | train |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.toUpperCaseWithoutAccent | @Pure
public static String toUpperCaseWithoutAccent(String text, Map<Character, String> map) {
final StringBuilder buffer = new StringBuilder();
for (final char c : text.toCharArray()) {
final String trans = map.get(c);
if (trans != null) {
buffer.append(trans.toUpperCase());
} else {
buffer.append(Character.toUpperCase(c));
}
}
return buffer.toString();
} | java | @Pure
public static String toUpperCaseWithoutAccent(String text, Map<Character, String> map) {
final StringBuilder buffer = new StringBuilder();
for (final char c : text.toCharArray()) {
final String trans = map.get(c);
if (trans != null) {
buffer.append(trans.toUpperCase());
} else {
buffer.append(Character.toUpperCase(c));
}
}
return buffer.toString();
} | [
"@",
"Pure",
"public",
"static",
"String",
"toUpperCaseWithoutAccent",
"(",
"String",
"text",
",",
"Map",
"<",
"Character",
",",
"String",
">",
"map",
")",
"{",
"final",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"final",
"char",
"c",
":",
"text",
".",
"toCharArray",
"(",
")",
")",
"{",
"final",
"String",
"trans",
"=",
"map",
".",
"get",
"(",
"c",
")",
";",
"if",
"(",
"trans",
"!=",
"null",
")",
"{",
"buffer",
".",
"append",
"(",
"trans",
".",
"toUpperCase",
"(",
")",
")",
";",
"}",
"else",
"{",
"buffer",
".",
"append",
"(",
"Character",
".",
"toUpperCase",
"(",
"c",
")",
")",
";",
"}",
"}",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] | Translate the specified string to upper case and remove the accents.
@param text is the text to scan.
@param map is the translation table from an accentuated character to an
unaccentuated character.
@return the given string without the accents and upper cased | [
"Translate",
"the",
"specified",
"string",
"to",
"upper",
"case",
"and",
"remove",
"the",
"accents",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L1439-L1451 | train |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.formatDouble | @Pure
public static String formatDouble(double amount, int decimalCount) {
final int dc = (decimalCount < 0) ? 0 : decimalCount;
final StringBuilder str = new StringBuilder("#0"); //$NON-NLS-1$
if (dc > 0) {
str.append('.');
for (int i = 0; i < dc; ++i) {
str.append('0');
}
}
final DecimalFormat fmt = new DecimalFormat(str.toString());
return fmt.format(amount);
} | java | @Pure
public static String formatDouble(double amount, int decimalCount) {
final int dc = (decimalCount < 0) ? 0 : decimalCount;
final StringBuilder str = new StringBuilder("#0"); //$NON-NLS-1$
if (dc > 0) {
str.append('.');
for (int i = 0; i < dc; ++i) {
str.append('0');
}
}
final DecimalFormat fmt = new DecimalFormat(str.toString());
return fmt.format(amount);
} | [
"@",
"Pure",
"public",
"static",
"String",
"formatDouble",
"(",
"double",
"amount",
",",
"int",
"decimalCount",
")",
"{",
"final",
"int",
"dc",
"=",
"(",
"decimalCount",
"<",
"0",
")",
"?",
"0",
":",
"decimalCount",
";",
"final",
"StringBuilder",
"str",
"=",
"new",
"StringBuilder",
"(",
"\"#0\"",
")",
";",
"//$NON-NLS-1$",
"if",
"(",
"dc",
">",
"0",
")",
"{",
"str",
".",
"append",
"(",
"'",
"'",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"dc",
";",
"++",
"i",
")",
"{",
"str",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"final",
"DecimalFormat",
"fmt",
"=",
"new",
"DecimalFormat",
"(",
"str",
".",
"toString",
"(",
")",
")",
";",
"return",
"fmt",
".",
"format",
"(",
"amount",
")",
";",
"}"
] | Format the given double value.
@param amount the value to convert.
@param decimalCount is the maximal count of decimal to put in the string.
@return a string representation of the given value. | [
"Format",
"the",
"given",
"double",
"value",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L1639-L1654 | train |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.getLevenshteinDistance | public static int getLevenshteinDistance(String firstString, String secondString) {
final String s0 = firstString == null ? "" : firstString; //$NON-NLS-1$
final String s1 = secondString == null ? "" : secondString; //$NON-NLS-1$
final int len0 = s0.length() + 1;
final int len1 = s1.length() + 1;
// the array of distances
int[] cost = new int[len0];
int[] newcost = new int[len0];
// initial cost of skipping prefix in String s0
for (int i = 0; i < len0; ++i) {
cost[i] = i;
}
// dynamically computing the array of distances
// transformation cost for each letter in s1
for (int j = 1; j < len1; ++j) {
// initial cost of skipping prefix in String s1
newcost[0] = j;
// transformation cost for each letter in s0
for (int i = 1; i < len0; ++i) {
// matching current letters in both strings
final int match = (s0.charAt(i - 1) == s1.charAt(j - 1)) ? 0 : 1;
// computing cost for each transformation
final int costReplace = cost[i - 1] + match;
final int costInsert = cost[i] + 1;
final int costDelete = newcost[i - 1] + 1;
// keep minimum cost
newcost[i] = Math.min(Math.min(costInsert, costDelete), costReplace);
}
// swap cost/newcost arrays
final int[] swap = cost;
cost = newcost;
newcost = swap;
}
// the distance is the cost for transforming all letters in both strings
return cost[len0 - 1];
} | java | public static int getLevenshteinDistance(String firstString, String secondString) {
final String s0 = firstString == null ? "" : firstString; //$NON-NLS-1$
final String s1 = secondString == null ? "" : secondString; //$NON-NLS-1$
final int len0 = s0.length() + 1;
final int len1 = s1.length() + 1;
// the array of distances
int[] cost = new int[len0];
int[] newcost = new int[len0];
// initial cost of skipping prefix in String s0
for (int i = 0; i < len0; ++i) {
cost[i] = i;
}
// dynamically computing the array of distances
// transformation cost for each letter in s1
for (int j = 1; j < len1; ++j) {
// initial cost of skipping prefix in String s1
newcost[0] = j;
// transformation cost for each letter in s0
for (int i = 1; i < len0; ++i) {
// matching current letters in both strings
final int match = (s0.charAt(i - 1) == s1.charAt(j - 1)) ? 0 : 1;
// computing cost for each transformation
final int costReplace = cost[i - 1] + match;
final int costInsert = cost[i] + 1;
final int costDelete = newcost[i - 1] + 1;
// keep minimum cost
newcost[i] = Math.min(Math.min(costInsert, costDelete), costReplace);
}
// swap cost/newcost arrays
final int[] swap = cost;
cost = newcost;
newcost = swap;
}
// the distance is the cost for transforming all letters in both strings
return cost[len0 - 1];
} | [
"public",
"static",
"int",
"getLevenshteinDistance",
"(",
"String",
"firstString",
",",
"String",
"secondString",
")",
"{",
"final",
"String",
"s0",
"=",
"firstString",
"==",
"null",
"?",
"\"\"",
":",
"firstString",
";",
"//$NON-NLS-1$",
"final",
"String",
"s1",
"=",
"secondString",
"==",
"null",
"?",
"\"\"",
":",
"secondString",
";",
"//$NON-NLS-1$",
"final",
"int",
"len0",
"=",
"s0",
".",
"length",
"(",
")",
"+",
"1",
";",
"final",
"int",
"len1",
"=",
"s1",
".",
"length",
"(",
")",
"+",
"1",
";",
"// the array of distances",
"int",
"[",
"]",
"cost",
"=",
"new",
"int",
"[",
"len0",
"]",
";",
"int",
"[",
"]",
"newcost",
"=",
"new",
"int",
"[",
"len0",
"]",
";",
"// initial cost of skipping prefix in String s0",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"len0",
";",
"++",
"i",
")",
"{",
"cost",
"[",
"i",
"]",
"=",
"i",
";",
"}",
"// dynamically computing the array of distances",
"// transformation cost for each letter in s1",
"for",
"(",
"int",
"j",
"=",
"1",
";",
"j",
"<",
"len1",
";",
"++",
"j",
")",
"{",
"// initial cost of skipping prefix in String s1",
"newcost",
"[",
"0",
"]",
"=",
"j",
";",
"// transformation cost for each letter in s0",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"len0",
";",
"++",
"i",
")",
"{",
"// matching current letters in both strings",
"final",
"int",
"match",
"=",
"(",
"s0",
".",
"charAt",
"(",
"i",
"-",
"1",
")",
"==",
"s1",
".",
"charAt",
"(",
"j",
"-",
"1",
")",
")",
"?",
"0",
":",
"1",
";",
"// computing cost for each transformation",
"final",
"int",
"costReplace",
"=",
"cost",
"[",
"i",
"-",
"1",
"]",
"+",
"match",
";",
"final",
"int",
"costInsert",
"=",
"cost",
"[",
"i",
"]",
"+",
"1",
";",
"final",
"int",
"costDelete",
"=",
"newcost",
"[",
"i",
"-",
"1",
"]",
"+",
"1",
";",
"// keep minimum cost",
"newcost",
"[",
"i",
"]",
"=",
"Math",
".",
"min",
"(",
"Math",
".",
"min",
"(",
"costInsert",
",",
"costDelete",
")",
",",
"costReplace",
")",
";",
"}",
"// swap cost/newcost arrays",
"final",
"int",
"[",
"]",
"swap",
"=",
"cost",
";",
"cost",
"=",
"newcost",
";",
"newcost",
"=",
"swap",
";",
"}",
"// the distance is the cost for transforming all letters in both strings",
"return",
"cost",
"[",
"len0",
"-",
"1",
"]",
";",
"}"
] | Compute the Levenshstein distance between two strings.
<p>Null string is assimilated to the empty string.
@param firstString first string.
@param secondString second string.
@return the Levenshstein distance.
@see "https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance" | [
"Compute",
"the",
"Levenshstein",
"distance",
"between",
"two",
"strings",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L1688-L1733 | train |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.toJavaString | @Pure
public static String toJavaString(String text) {
final StringEscaper escaper = new StringEscaper();
return escaper.escape(text);
} | java | @Pure
public static String toJavaString(String text) {
final StringEscaper escaper = new StringEscaper();
return escaper.escape(text);
} | [
"@",
"Pure",
"public",
"static",
"String",
"toJavaString",
"(",
"String",
"text",
")",
"{",
"final",
"StringEscaper",
"escaper",
"=",
"new",
"StringEscaper",
"(",
")",
";",
"return",
"escaper",
".",
"escape",
"(",
"text",
")",
";",
"}"
] | Translate the given string to its Java string equivalent.
All the special characters will be escaped. The enclosing double quote
characters are not added.
<p>The Java special characters are listed within {@link StringEscaper#JAVA_SPECIAL_CHARS}.
Any character outside the range [{@link StringEscaper#JAVA_MIN_CHAR}, {@link StringEscaper#JAVA_MAX_CHAR}]
is automatically escaped.
@param text is the text to convert.
@return the Java string for the text.
@since 15.0 | [
"Translate",
"the",
"given",
"string",
"to",
"its",
"Java",
"string",
"equivalent",
".",
"All",
"the",
"special",
"characters",
"will",
"be",
"escaped",
".",
"The",
"enclosing",
"double",
"quote",
"characters",
"are",
"not",
"added",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L1747-L1751 | train |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.toJsonString | @Pure
public static String toJsonString(String text) {
final StringEscaper escaper = new StringEscaper(
StringEscaper.JAVA_ESCAPE_CHAR,
StringEscaper.JAVA_STRING_CHAR, StringEscaper.JAVA_ESCAPE_CHAR, StringEscaper.JSON_SPECIAL_ESCAPED_CHAR);
return escaper.escape(text);
} | java | @Pure
public static String toJsonString(String text) {
final StringEscaper escaper = new StringEscaper(
StringEscaper.JAVA_ESCAPE_CHAR,
StringEscaper.JAVA_STRING_CHAR, StringEscaper.JAVA_ESCAPE_CHAR, StringEscaper.JSON_SPECIAL_ESCAPED_CHAR);
return escaper.escape(text);
} | [
"@",
"Pure",
"public",
"static",
"String",
"toJsonString",
"(",
"String",
"text",
")",
"{",
"final",
"StringEscaper",
"escaper",
"=",
"new",
"StringEscaper",
"(",
"StringEscaper",
".",
"JAVA_ESCAPE_CHAR",
",",
"StringEscaper",
".",
"JAVA_STRING_CHAR",
",",
"StringEscaper",
".",
"JAVA_ESCAPE_CHAR",
",",
"StringEscaper",
".",
"JSON_SPECIAL_ESCAPED_CHAR",
")",
";",
"return",
"escaper",
".",
"escape",
"(",
"text",
")",
";",
"}"
] | Translate the given string to its Json string equivalent.
All the special characters will be escaped. The enclosing double quote
characters are not added.
<p>The Json escaping extends the {@link #toJavaString(String) Java escaping} by
protecting the {@code /} character.
@param text is the text to convert.
@return the Json string for the text.
@since 15.0 | [
"Translate",
"the",
"given",
"string",
"to",
"its",
"Json",
"string",
"equivalent",
".",
"All",
"the",
"special",
"characters",
"will",
"be",
"escaped",
".",
"The",
"enclosing",
"double",
"quote",
"characters",
"are",
"not",
"added",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L1764-L1770 | train |
gallandarakhneorg/afc | advanced/bootique/bootique-variables/src/main/java/org/arakhne/afc/bootique/variables/VariableDecls.java | VariableDecls.extend | public static VariableDecls extend(Binder binder) {
return new VariableDecls(io.bootique.BQCoreModule.extend(binder));
} | java | public static VariableDecls extend(Binder binder) {
return new VariableDecls(io.bootique.BQCoreModule.extend(binder));
} | [
"public",
"static",
"VariableDecls",
"extend",
"(",
"Binder",
"binder",
")",
"{",
"return",
"new",
"VariableDecls",
"(",
"io",
".",
"bootique",
".",
"BQCoreModule",
".",
"extend",
"(",
"binder",
")",
")",
";",
"}"
] | Create an extended from the given binder.
@param binder the injection binder.
@return the variable declarator. | [
"Create",
"an",
"extended",
"from",
"the",
"given",
"binder",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/bootique/bootique-variables/src/main/java/org/arakhne/afc/bootique/variables/VariableDecls.java#L52-L54 | train |
gallandarakhneorg/afc | advanced/bootique/bootique-variables/src/main/java/org/arakhne/afc/bootique/variables/VariableDecls.java | VariableDecls.declareVar | public VariableDecls declareVar(String bootiqueVariable) {
this.extender.declareVar(bootiqueVariable, VariableNames.toEnvironmentVariableName(bootiqueVariable));
return this;
} | java | public VariableDecls declareVar(String bootiqueVariable) {
this.extender.declareVar(bootiqueVariable, VariableNames.toEnvironmentVariableName(bootiqueVariable));
return this;
} | [
"public",
"VariableDecls",
"declareVar",
"(",
"String",
"bootiqueVariable",
")",
"{",
"this",
".",
"extender",
".",
"declareVar",
"(",
"bootiqueVariable",
",",
"VariableNames",
".",
"toEnvironmentVariableName",
"(",
"bootiqueVariable",
")",
")",
";",
"return",
"this",
";",
"}"
] | Declare an environment variable which is linked to the given Bootique variable, and has its name defined
from the name of the Bootique variable.
@param bootiqueVariable the name of the bootique variable.
@return the Bootique extender. | [
"Declare",
"an",
"environment",
"variable",
"which",
"is",
"linked",
"to",
"the",
"given",
"Bootique",
"variable",
"and",
"has",
"its",
"name",
"defined",
"from",
"the",
"name",
"of",
"the",
"Bootique",
"variable",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/bootique/bootique-variables/src/main/java/org/arakhne/afc/bootique/variables/VariableDecls.java#L62-L65 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/layer/BusItineraryLayer.java | BusItineraryLayer.initializeElements | protected void initializeElements() {
final BusItinerary itinerary = getBusItinerary();
if (itinerary != null) {
int i = 0;
for (final BusItineraryHalt halt : itinerary.busHalts()) {
onBusItineraryHaltAdded(halt, i, null);
++i;
}
}
} | java | protected void initializeElements() {
final BusItinerary itinerary = getBusItinerary();
if (itinerary != null) {
int i = 0;
for (final BusItineraryHalt halt : itinerary.busHalts()) {
onBusItineraryHaltAdded(halt, i, null);
++i;
}
}
} | [
"protected",
"void",
"initializeElements",
"(",
")",
"{",
"final",
"BusItinerary",
"itinerary",
"=",
"getBusItinerary",
"(",
")",
";",
"if",
"(",
"itinerary",
"!=",
"null",
")",
"{",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"final",
"BusItineraryHalt",
"halt",
":",
"itinerary",
".",
"busHalts",
"(",
")",
")",
"{",
"onBusItineraryHaltAdded",
"(",
"halt",
",",
"i",
",",
"null",
")",
";",
"++",
"i",
";",
"}",
"}",
"}"
] | Run the initialization of the elements from the current bus itinerary.
<p>This function is invoked by the constructor of BusItineraryLayer
if its parameter <var>autoUpdate</var> is <code>true</code>, and
not invoked if this parameter is <code>false</code>. | [
"Run",
"the",
"initialization",
"of",
"the",
"elements",
"from",
"the",
"current",
"bus",
"itinerary",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/layer/BusItineraryLayer.java#L254-L263 | train |
gallandarakhneorg/afc | core/references/src/main/java/org/arakhne/afc/references/AbstractReferencedValueMap.java | AbstractReferencedValueMap.maskNull | @Pure
@SuppressWarnings("unchecked")
protected static <VALUET> VALUET maskNull(VALUET value) {
return (value == null) ? (VALUET) NULL_VALUE : value;
} | java | @Pure
@SuppressWarnings("unchecked")
protected static <VALUET> VALUET maskNull(VALUET value) {
return (value == null) ? (VALUET) NULL_VALUE : value;
} | [
"@",
"Pure",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"static",
"<",
"VALUET",
">",
"VALUET",
"maskNull",
"(",
"VALUET",
"value",
")",
"{",
"return",
"(",
"value",
"==",
"null",
")",
"?",
"(",
"VALUET",
")",
"NULL_VALUE",
":",
"value",
";",
"}"
] | Mask the null values given by the used of this map.
<p>This method replaces the <code>null</code> value by
the internal representation {@link #NULL_VALUE}.
@param <VALUET> is the type of the value.
@param value is the value given by the user of this map.
@return the internal representation of the value.
@see #unmaskNull(Object) | [
"Mask",
"the",
"null",
"values",
"given",
"by",
"the",
"used",
"of",
"this",
"map",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/references/src/main/java/org/arakhne/afc/references/AbstractReferencedValueMap.java#L94-L98 | train |
gallandarakhneorg/afc | core/references/src/main/java/org/arakhne/afc/references/AbstractReferencedValueMap.java | AbstractReferencedValueMap.unmaskNull | @Pure
protected static <VALUET> VALUET unmaskNull(VALUET value) {
return (value == NULL_VALUE) ? null : value;
} | java | @Pure
protected static <VALUET> VALUET unmaskNull(VALUET value) {
return (value == NULL_VALUE) ? null : value;
} | [
"@",
"Pure",
"protected",
"static",
"<",
"VALUET",
">",
"VALUET",
"unmaskNull",
"(",
"VALUET",
"value",
")",
"{",
"return",
"(",
"value",
"==",
"NULL_VALUE",
")",
"?",
"null",
":",
"value",
";",
"}"
] | Unmask the null values given by the used of this map.
<p>This method replaces the internal representation
{@link #NULL_VALUE} of null values by its user representation
<code>null</code>.
@param <VALUET> is the type of the value.
@param value is the value given by the user of this map.
@return the internal representation of the value.
@see #maskNull(Object) | [
"Unmask",
"the",
"null",
"values",
"given",
"by",
"the",
"used",
"of",
"this",
"map",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/references/src/main/java/org/arakhne/afc/references/AbstractReferencedValueMap.java#L111-L114 | train |
gallandarakhneorg/afc | core/references/src/main/java/org/arakhne/afc/references/AbstractReferencedValueMap.java | AbstractReferencedValueMap.finishToArray | @SuppressWarnings("unchecked")
static <T> T[] finishToArray(T[] array, Iterator<?> it) {
T[] rp = array;
int i = rp.length;
while (it.hasNext()) {
final int cap = rp.length;
if (i == cap) {
int newCap = ((cap / 2) + 1) * 3;
if (newCap <= cap) {
// integer overflow
if (cap == Integer.MAX_VALUE) {
throw new OutOfMemoryError();
}
newCap = Integer.MAX_VALUE;
}
rp = Arrays.copyOf(rp, newCap);
}
rp[++i] = (T) it.next();
}
// trim if overallocated
return (i == rp.length) ? rp : Arrays.copyOf(rp, i);
} | java | @SuppressWarnings("unchecked")
static <T> T[] finishToArray(T[] array, Iterator<?> it) {
T[] rp = array;
int i = rp.length;
while (it.hasNext()) {
final int cap = rp.length;
if (i == cap) {
int newCap = ((cap / 2) + 1) * 3;
if (newCap <= cap) {
// integer overflow
if (cap == Integer.MAX_VALUE) {
throw new OutOfMemoryError();
}
newCap = Integer.MAX_VALUE;
}
rp = Arrays.copyOf(rp, newCap);
}
rp[++i] = (T) it.next();
}
// trim if overallocated
return (i == rp.length) ? rp : Arrays.copyOf(rp, i);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"static",
"<",
"T",
">",
"T",
"[",
"]",
"finishToArray",
"(",
"T",
"[",
"]",
"array",
",",
"Iterator",
"<",
"?",
">",
"it",
")",
"{",
"T",
"[",
"]",
"rp",
"=",
"array",
";",
"int",
"i",
"=",
"rp",
".",
"length",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"final",
"int",
"cap",
"=",
"rp",
".",
"length",
";",
"if",
"(",
"i",
"==",
"cap",
")",
"{",
"int",
"newCap",
"=",
"(",
"(",
"cap",
"/",
"2",
")",
"+",
"1",
")",
"*",
"3",
";",
"if",
"(",
"newCap",
"<=",
"cap",
")",
"{",
"// integer overflow",
"if",
"(",
"cap",
"==",
"Integer",
".",
"MAX_VALUE",
")",
"{",
"throw",
"new",
"OutOfMemoryError",
"(",
")",
";",
"}",
"newCap",
"=",
"Integer",
".",
"MAX_VALUE",
";",
"}",
"rp",
"=",
"Arrays",
".",
"copyOf",
"(",
"rp",
",",
"newCap",
")",
";",
"}",
"rp",
"[",
"++",
"i",
"]",
"=",
"(",
"T",
")",
"it",
".",
"next",
"(",
")",
";",
"}",
"// trim if overallocated",
"return",
"(",
"i",
"==",
"rp",
".",
"length",
")",
"?",
"rp",
":",
"Arrays",
".",
"copyOf",
"(",
"rp",
",",
"i",
")",
";",
"}"
] | Reallocates the array being used within toArray when the iterator
returned more elements than expected, and finishes filling it from
the iterator.
@param <T> the type of the elements in the array.
@param array the array, replete with previously stored elements
@param it the in-progress iterator over this collection
@return array containing the elements in the given array, plus any
further elements returned by the iterator, trimmed to size | [
"Reallocates",
"the",
"array",
"being",
"used",
"within",
"toArray",
"when",
"the",
"iterator",
"returned",
"more",
"elements",
"than",
"expected",
"and",
"finishes",
"filling",
"it",
"from",
"the",
"iterator",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/references/src/main/java/org/arakhne/afc/references/AbstractReferencedValueMap.java#L127-L148 | train |
gallandarakhneorg/afc | core/references/src/main/java/org/arakhne/afc/references/AbstractReferencedValueMap.java | AbstractReferencedValueMap.makeValue | protected final ReferencableValue<K, V> makeValue(K key, V value) {
return makeValue(key, value, this.queue);
} | java | protected final ReferencableValue<K, V> makeValue(K key, V value) {
return makeValue(key, value, this.queue);
} | [
"protected",
"final",
"ReferencableValue",
"<",
"K",
",",
"V",
">",
"makeValue",
"(",
"K",
"key",
",",
"V",
"value",
")",
"{",
"return",
"makeValue",
"(",
"key",
",",
"value",
",",
"this",
".",
"queue",
")",
";",
"}"
] | Create a storage object that permits to put the specified
elements inside this map.
@param key is the key associated to the value
@param value is the value
@return the new storage object | [
"Create",
"a",
"storage",
"object",
"that",
"permits",
"to",
"put",
"the",
"specified",
"elements",
"inside",
"this",
"map",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/references/src/main/java/org/arakhne/afc/references/AbstractReferencedValueMap.java#L242-L244 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.getFirstFreeBusItineraryName | @Pure
public static String getFirstFreeBusItineraryName(BusLine busline) {
if (busline == null) {
return null;
}
int nb = busline.getBusItineraryCount();
String name;
do {
++nb;
name = Locale.getString("NAME_TEMPLATE", Integer.toString(nb)); //$NON-NLS-1$
}
while (busline.getBusItinerary(name) != null);
return name;
} | java | @Pure
public static String getFirstFreeBusItineraryName(BusLine busline) {
if (busline == null) {
return null;
}
int nb = busline.getBusItineraryCount();
String name;
do {
++nb;
name = Locale.getString("NAME_TEMPLATE", Integer.toString(nb)); //$NON-NLS-1$
}
while (busline.getBusItinerary(name) != null);
return name;
} | [
"@",
"Pure",
"public",
"static",
"String",
"getFirstFreeBusItineraryName",
"(",
"BusLine",
"busline",
")",
"{",
"if",
"(",
"busline",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"int",
"nb",
"=",
"busline",
".",
"getBusItineraryCount",
"(",
")",
";",
"String",
"name",
";",
"do",
"{",
"++",
"nb",
";",
"name",
"=",
"Locale",
".",
"getString",
"(",
"\"NAME_TEMPLATE\"",
",",
"Integer",
".",
"toString",
"(",
"nb",
")",
")",
";",
"//$NON-NLS-1$",
"}",
"while",
"(",
"busline",
".",
"getBusItinerary",
"(",
"name",
")",
"!=",
"null",
")",
";",
"return",
"name",
";",
"}"
] | Replies a bus itinerary name that was not exist in the specified
bus line.
@param busline the line.
@return a free name | [
"Replies",
"a",
"bus",
"itinerary",
"name",
"that",
"was",
"not",
"exist",
"in",
"the",
"specified",
"bus",
"line",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L286-L299 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.invert | public void invert() {
final boolean isEventFirable = isEventFirable();
setEventFirable(false);
try {
final int count = this.roadSegments.getRoadSegmentCount();
// Invert the segments
this.roadSegments.invert();
// Invert the bus halts and their indexes.
final int middle = this.validHalts.size() / 2;
for (int i = 0, j = this.validHalts.size() - 1; i < middle; ++i, --j) {
final BusItineraryHalt h1 = this.validHalts.get(i);
final BusItineraryHalt h2 = this.validHalts.get(j);
this.validHalts.set(i, h2);
this.validHalts.set(j, h1);
int idx = h1.getRoadSegmentIndex();
idx = count - idx - 1;
h1.setRoadSegmentIndex(idx);
idx = h2.getRoadSegmentIndex();
idx = count - idx - 1;
h2.setRoadSegmentIndex(idx);
}
if (middle * 2 != this.validHalts.size()) {
final BusItineraryHalt h1 = this.validHalts.get(middle);
int idx = h1.getRoadSegmentIndex();
idx = count - idx - 1;
h1.setRoadSegmentIndex(idx);
}
} finally {
setEventFirable(isEventFirable);
}
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ITINERARY_INVERTED,
this,
indexInParent(),
"busHalts", //$NON-NLS-1$
null, null));
} | java | public void invert() {
final boolean isEventFirable = isEventFirable();
setEventFirable(false);
try {
final int count = this.roadSegments.getRoadSegmentCount();
// Invert the segments
this.roadSegments.invert();
// Invert the bus halts and their indexes.
final int middle = this.validHalts.size() / 2;
for (int i = 0, j = this.validHalts.size() - 1; i < middle; ++i, --j) {
final BusItineraryHalt h1 = this.validHalts.get(i);
final BusItineraryHalt h2 = this.validHalts.get(j);
this.validHalts.set(i, h2);
this.validHalts.set(j, h1);
int idx = h1.getRoadSegmentIndex();
idx = count - idx - 1;
h1.setRoadSegmentIndex(idx);
idx = h2.getRoadSegmentIndex();
idx = count - idx - 1;
h2.setRoadSegmentIndex(idx);
}
if (middle * 2 != this.validHalts.size()) {
final BusItineraryHalt h1 = this.validHalts.get(middle);
int idx = h1.getRoadSegmentIndex();
idx = count - idx - 1;
h1.setRoadSegmentIndex(idx);
}
} finally {
setEventFirable(isEventFirable);
}
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ITINERARY_INVERTED,
this,
indexInParent(),
"busHalts", //$NON-NLS-1$
null, null));
} | [
"public",
"void",
"invert",
"(",
")",
"{",
"final",
"boolean",
"isEventFirable",
"=",
"isEventFirable",
"(",
")",
";",
"setEventFirable",
"(",
"false",
")",
";",
"try",
"{",
"final",
"int",
"count",
"=",
"this",
".",
"roadSegments",
".",
"getRoadSegmentCount",
"(",
")",
";",
"// Invert the segments",
"this",
".",
"roadSegments",
".",
"invert",
"(",
")",
";",
"// Invert the bus halts and their indexes.",
"final",
"int",
"middle",
"=",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
"/",
"2",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"j",
"=",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
"<",
"middle",
";",
"++",
"i",
",",
"--",
"j",
")",
"{",
"final",
"BusItineraryHalt",
"h1",
"=",
"this",
".",
"validHalts",
".",
"get",
"(",
"i",
")",
";",
"final",
"BusItineraryHalt",
"h2",
"=",
"this",
".",
"validHalts",
".",
"get",
"(",
"j",
")",
";",
"this",
".",
"validHalts",
".",
"set",
"(",
"i",
",",
"h2",
")",
";",
"this",
".",
"validHalts",
".",
"set",
"(",
"j",
",",
"h1",
")",
";",
"int",
"idx",
"=",
"h1",
".",
"getRoadSegmentIndex",
"(",
")",
";",
"idx",
"=",
"count",
"-",
"idx",
"-",
"1",
";",
"h1",
".",
"setRoadSegmentIndex",
"(",
"idx",
")",
";",
"idx",
"=",
"h2",
".",
"getRoadSegmentIndex",
"(",
")",
";",
"idx",
"=",
"count",
"-",
"idx",
"-",
"1",
";",
"h2",
".",
"setRoadSegmentIndex",
"(",
"idx",
")",
";",
"}",
"if",
"(",
"middle",
"*",
"2",
"!=",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
")",
"{",
"final",
"BusItineraryHalt",
"h1",
"=",
"this",
".",
"validHalts",
".",
"get",
"(",
"middle",
")",
";",
"int",
"idx",
"=",
"h1",
".",
"getRoadSegmentIndex",
"(",
")",
";",
"idx",
"=",
"count",
"-",
"idx",
"-",
"1",
";",
"h1",
".",
"setRoadSegmentIndex",
"(",
"idx",
")",
";",
"}",
"}",
"finally",
"{",
"setEventFirable",
"(",
"isEventFirable",
")",
";",
"}",
"fireShapeChanged",
"(",
"new",
"BusChangeEvent",
"(",
"this",
",",
"BusChangeEventType",
".",
"ITINERARY_INVERTED",
",",
"this",
",",
"indexInParent",
"(",
")",
",",
"\"busHalts\"",
",",
"//$NON-NLS-1$",
"null",
",",
"null",
")",
")",
";",
"}"
] | Invert the order of this itinerary.
<p>This function reverses the direction of the itinerary, ie. the order
of the road segments of the itinerary.
<p>This function does not reverse the location of the bus halts on the itinerary.
Their locations will be unchanged. | [
"Invert",
"the",
"order",
"of",
"this",
"itinerary",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L711-L753 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.hasBusHaltOnSegment | @Pure
public boolean hasBusHaltOnSegment(RoadSegment segment) {
if (this.roadSegments.isEmpty() || this.validHalts.isEmpty()) {
return false;
}
int cIdxSegment;
int lIdxSegment = -1;
RoadSegment cSegment;
for (final BusItineraryHalt bushalt : this.validHalts) {
cIdxSegment = bushalt.getRoadSegmentIndex();
if (cIdxSegment >= 0 && cIdxSegment < this.roadSegments.getRoadSegmentCount()
&& cIdxSegment != lIdxSegment) {
cSegment = this.roadSegments.getRoadSegmentAt(cIdxSegment);
lIdxSegment = cIdxSegment;
if (segment == cSegment) {
return true;
}
}
}
return false;
} | java | @Pure
public boolean hasBusHaltOnSegment(RoadSegment segment) {
if (this.roadSegments.isEmpty() || this.validHalts.isEmpty()) {
return false;
}
int cIdxSegment;
int lIdxSegment = -1;
RoadSegment cSegment;
for (final BusItineraryHalt bushalt : this.validHalts) {
cIdxSegment = bushalt.getRoadSegmentIndex();
if (cIdxSegment >= 0 && cIdxSegment < this.roadSegments.getRoadSegmentCount()
&& cIdxSegment != lIdxSegment) {
cSegment = this.roadSegments.getRoadSegmentAt(cIdxSegment);
lIdxSegment = cIdxSegment;
if (segment == cSegment) {
return true;
}
}
}
return false;
} | [
"@",
"Pure",
"public",
"boolean",
"hasBusHaltOnSegment",
"(",
"RoadSegment",
"segment",
")",
"{",
"if",
"(",
"this",
".",
"roadSegments",
".",
"isEmpty",
"(",
")",
"||",
"this",
".",
"validHalts",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"int",
"cIdxSegment",
";",
"int",
"lIdxSegment",
"=",
"-",
"1",
";",
"RoadSegment",
"cSegment",
";",
"for",
"(",
"final",
"BusItineraryHalt",
"bushalt",
":",
"this",
".",
"validHalts",
")",
"{",
"cIdxSegment",
"=",
"bushalt",
".",
"getRoadSegmentIndex",
"(",
")",
";",
"if",
"(",
"cIdxSegment",
">=",
"0",
"&&",
"cIdxSegment",
"<",
"this",
".",
"roadSegments",
".",
"getRoadSegmentCount",
"(",
")",
"&&",
"cIdxSegment",
"!=",
"lIdxSegment",
")",
"{",
"cSegment",
"=",
"this",
".",
"roadSegments",
".",
"getRoadSegmentAt",
"(",
"cIdxSegment",
")",
";",
"lIdxSegment",
"=",
"cIdxSegment",
";",
"if",
"(",
"segment",
"==",
"cSegment",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Replies if the given segment has a bus halt on it.
@param segment is the segment to search on.
@return <code>true</code> if a bus halt was located on the segment,
otherwhise <code>false</code> | [
"Replies",
"if",
"the",
"given",
"segment",
"has",
"a",
"bus",
"halt",
"on",
"it",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L761-L784 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.getBusHaltsOnSegment | @Pure
public List<BusItineraryHalt> getBusHaltsOnSegment(RoadSegment segment) {
if (this.roadSegments.isEmpty() || this.validHalts.isEmpty()) {
return Collections.emptyList();
}
int cIdxSegment;
int lIdxSegment = -1;
int sIdxSegment = -1;
RoadSegment cSegment;
final List<BusItineraryHalt> halts = new ArrayList<>();
for (final BusItineraryHalt bushalt : this.validHalts) {
cIdxSegment = bushalt.getRoadSegmentIndex();
if (cIdxSegment >= 0 && cIdxSegment < this.roadSegments.getRoadSegmentCount()
&& cIdxSegment != lIdxSegment) {
cSegment = this.roadSegments.getRoadSegmentAt(cIdxSegment);
lIdxSegment = cIdxSegment;
if (segment == cSegment) {
sIdxSegment = cIdxSegment;
} else if (sIdxSegment != -1) {
// halt loop now because I'm sure there has no more bus halt
break;
}
}
if (sIdxSegment != -1) {
halts.add(bushalt);
}
}
return halts;
} | java | @Pure
public List<BusItineraryHalt> getBusHaltsOnSegment(RoadSegment segment) {
if (this.roadSegments.isEmpty() || this.validHalts.isEmpty()) {
return Collections.emptyList();
}
int cIdxSegment;
int lIdxSegment = -1;
int sIdxSegment = -1;
RoadSegment cSegment;
final List<BusItineraryHalt> halts = new ArrayList<>();
for (final BusItineraryHalt bushalt : this.validHalts) {
cIdxSegment = bushalt.getRoadSegmentIndex();
if (cIdxSegment >= 0 && cIdxSegment < this.roadSegments.getRoadSegmentCount()
&& cIdxSegment != lIdxSegment) {
cSegment = this.roadSegments.getRoadSegmentAt(cIdxSegment);
lIdxSegment = cIdxSegment;
if (segment == cSegment) {
sIdxSegment = cIdxSegment;
} else if (sIdxSegment != -1) {
// halt loop now because I'm sure there has no more bus halt
break;
}
}
if (sIdxSegment != -1) {
halts.add(bushalt);
}
}
return halts;
} | [
"@",
"Pure",
"public",
"List",
"<",
"BusItineraryHalt",
">",
"getBusHaltsOnSegment",
"(",
"RoadSegment",
"segment",
")",
"{",
"if",
"(",
"this",
".",
"roadSegments",
".",
"isEmpty",
"(",
")",
"||",
"this",
".",
"validHalts",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"int",
"cIdxSegment",
";",
"int",
"lIdxSegment",
"=",
"-",
"1",
";",
"int",
"sIdxSegment",
"=",
"-",
"1",
";",
"RoadSegment",
"cSegment",
";",
"final",
"List",
"<",
"BusItineraryHalt",
">",
"halts",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"BusItineraryHalt",
"bushalt",
":",
"this",
".",
"validHalts",
")",
"{",
"cIdxSegment",
"=",
"bushalt",
".",
"getRoadSegmentIndex",
"(",
")",
";",
"if",
"(",
"cIdxSegment",
">=",
"0",
"&&",
"cIdxSegment",
"<",
"this",
".",
"roadSegments",
".",
"getRoadSegmentCount",
"(",
")",
"&&",
"cIdxSegment",
"!=",
"lIdxSegment",
")",
"{",
"cSegment",
"=",
"this",
".",
"roadSegments",
".",
"getRoadSegmentAt",
"(",
"cIdxSegment",
")",
";",
"lIdxSegment",
"=",
"cIdxSegment",
";",
"if",
"(",
"segment",
"==",
"cSegment",
")",
"{",
"sIdxSegment",
"=",
"cIdxSegment",
";",
"}",
"else",
"if",
"(",
"sIdxSegment",
"!=",
"-",
"1",
")",
"{",
"// halt loop now because I'm sure there has no more bus halt",
"break",
";",
"}",
"}",
"if",
"(",
"sIdxSegment",
"!=",
"-",
"1",
")",
"{",
"halts",
".",
"add",
"(",
"bushalt",
")",
";",
"}",
"}",
"return",
"halts",
";",
"}"
] | Replies the bus halts on the given segment.
@param segment is the segment to search on.
@return the list of bus halts. | [
"Replies",
"the",
"bus",
"halts",
"on",
"the",
"given",
"segment",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L791-L823 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.getBusHaltBinding | @Pure
public Map<BusItineraryHalt, Pair<Integer, Double>> getBusHaltBinding() {
final Comparator<BusItineraryHalt> comp = (elt1, elt2) -> {
if (elt1 == elt2) {
return 0;
}
if (elt1 == null) {
return -1;
}
if (elt2 == null) {
return 1;
}
return elt1.getName().compareTo(elt2.getName());
};
final Map<BusItineraryHalt, Pair<Integer, Double>> haltBinding = new TreeMap<>(comp);
for (final BusItineraryHalt halt : busHalts()) {
haltBinding.put(halt, new Pair<>(
halt.getRoadSegmentIndex(),
halt.getPositionOnSegment()));
}
return haltBinding;
} | java | @Pure
public Map<BusItineraryHalt, Pair<Integer, Double>> getBusHaltBinding() {
final Comparator<BusItineraryHalt> comp = (elt1, elt2) -> {
if (elt1 == elt2) {
return 0;
}
if (elt1 == null) {
return -1;
}
if (elt2 == null) {
return 1;
}
return elt1.getName().compareTo(elt2.getName());
};
final Map<BusItineraryHalt, Pair<Integer, Double>> haltBinding = new TreeMap<>(comp);
for (final BusItineraryHalt halt : busHalts()) {
haltBinding.put(halt, new Pair<>(
halt.getRoadSegmentIndex(),
halt.getPositionOnSegment()));
}
return haltBinding;
} | [
"@",
"Pure",
"public",
"Map",
"<",
"BusItineraryHalt",
",",
"Pair",
"<",
"Integer",
",",
"Double",
">",
">",
"getBusHaltBinding",
"(",
")",
"{",
"final",
"Comparator",
"<",
"BusItineraryHalt",
">",
"comp",
"=",
"(",
"elt1",
",",
"elt2",
")",
"->",
"{",
"if",
"(",
"elt1",
"==",
"elt2",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"elt1",
"==",
"null",
")",
"{",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"elt2",
"==",
"null",
")",
"{",
"return",
"1",
";",
"}",
"return",
"elt1",
".",
"getName",
"(",
")",
".",
"compareTo",
"(",
"elt2",
".",
"getName",
"(",
")",
")",
";",
"}",
";",
"final",
"Map",
"<",
"BusItineraryHalt",
",",
"Pair",
"<",
"Integer",
",",
"Double",
">",
">",
"haltBinding",
"=",
"new",
"TreeMap",
"<>",
"(",
"comp",
")",
";",
"for",
"(",
"final",
"BusItineraryHalt",
"halt",
":",
"busHalts",
"(",
")",
")",
"{",
"haltBinding",
".",
"put",
"(",
"halt",
",",
"new",
"Pair",
"<>",
"(",
"halt",
".",
"getRoadSegmentIndex",
"(",
")",
",",
"halt",
".",
"getPositionOnSegment",
"(",
")",
")",
")",
";",
"}",
"return",
"haltBinding",
";",
"}"
] | Replies the binding informations for all the bus halts of this itinerary.
@return the pairs containing the index of the road segment and the
curviline position of each bus itinerary halt. | [
"Replies",
"the",
"binding",
"informations",
"for",
"all",
"the",
"bus",
"halts",
"of",
"this",
"itinerary",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L830-L851 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.setBusHaltBinding | public void setBusHaltBinding(Map<BusItineraryHalt, Pair<Integer, Float>> binding) {
if (binding != null) {
BusItineraryHalt halt;
boolean shapeChanged = false;
for (final Entry<BusItineraryHalt, Pair<Integer, Float>> entry : binding.entrySet()) {
halt = entry.getKey();
halt.setRoadSegmentIndex(entry.getValue().getKey());
halt.setPositionOnSegment(entry.getValue().getValue());
halt.checkPrimitiveValidity();
shapeChanged = true;
}
if (shapeChanged) {
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ITINERARY_CHANGED,
null,
-1,
"shape", //$NON-NLS-1$
null,
null));
}
checkPrimitiveValidity();
}
} | java | public void setBusHaltBinding(Map<BusItineraryHalt, Pair<Integer, Float>> binding) {
if (binding != null) {
BusItineraryHalt halt;
boolean shapeChanged = false;
for (final Entry<BusItineraryHalt, Pair<Integer, Float>> entry : binding.entrySet()) {
halt = entry.getKey();
halt.setRoadSegmentIndex(entry.getValue().getKey());
halt.setPositionOnSegment(entry.getValue().getValue());
halt.checkPrimitiveValidity();
shapeChanged = true;
}
if (shapeChanged) {
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ITINERARY_CHANGED,
null,
-1,
"shape", //$NON-NLS-1$
null,
null));
}
checkPrimitiveValidity();
}
} | [
"public",
"void",
"setBusHaltBinding",
"(",
"Map",
"<",
"BusItineraryHalt",
",",
"Pair",
"<",
"Integer",
",",
"Float",
">",
">",
"binding",
")",
"{",
"if",
"(",
"binding",
"!=",
"null",
")",
"{",
"BusItineraryHalt",
"halt",
";",
"boolean",
"shapeChanged",
"=",
"false",
";",
"for",
"(",
"final",
"Entry",
"<",
"BusItineraryHalt",
",",
"Pair",
"<",
"Integer",
",",
"Float",
">",
">",
"entry",
":",
"binding",
".",
"entrySet",
"(",
")",
")",
"{",
"halt",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"halt",
".",
"setRoadSegmentIndex",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"getKey",
"(",
")",
")",
";",
"halt",
".",
"setPositionOnSegment",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"getValue",
"(",
")",
")",
";",
"halt",
".",
"checkPrimitiveValidity",
"(",
")",
";",
"shapeChanged",
"=",
"true",
";",
"}",
"if",
"(",
"shapeChanged",
")",
"{",
"fireShapeChanged",
"(",
"new",
"BusChangeEvent",
"(",
"this",
",",
"BusChangeEventType",
".",
"ITINERARY_CHANGED",
",",
"null",
",",
"-",
"1",
",",
"\"shape\"",
",",
"//$NON-NLS-1$",
"null",
",",
"null",
")",
")",
";",
"}",
"checkPrimitiveValidity",
"(",
")",
";",
"}",
"}"
] | Set the binding informations for all the bus halts of this itinerary.
@param binding are the pairs containing the index of the road segment and the
curviline position of each bus itinerary halt. | [
"Set",
"the",
"binding",
"informations",
"for",
"all",
"the",
"bus",
"halts",
"of",
"this",
"itinerary",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L858-L880 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.getLength | @Pure
public double getLength() {
double length = this.roadSegments.getLength();
if (isValidPrimitive()) {
BusItineraryHalt halt = this.validHalts.get(0);
assert halt != null;
RoadSegment sgmt = halt.getRoadSegment();
assert sgmt != null;
Direction1D dir = this.roadSegments.getRoadSegmentDirectionAt(halt.getRoadSegmentIndex());
assert dir != null;
if (dir == Direction1D.SEGMENT_DIRECTION) {
length -= halt.getPositionOnSegment();
} else {
length -= sgmt.getLength() - halt.getPositionOnSegment();
}
halt = this.validHalts.get(this.validHalts.size() - 1);
assert halt != null;
sgmt = halt.getRoadSegment();
assert sgmt != null;
dir = this.roadSegments.getRoadSegmentDirectionAt(halt.getRoadSegmentIndex());
assert dir != null;
if (dir == Direction1D.SEGMENT_DIRECTION) {
length -= sgmt.getLength() - halt.getPositionOnSegment();
} else {
length -= halt.getPositionOnSegment();
}
if (length < 0.) {
length = 0.;
}
}
return length;
} | java | @Pure
public double getLength() {
double length = this.roadSegments.getLength();
if (isValidPrimitive()) {
BusItineraryHalt halt = this.validHalts.get(0);
assert halt != null;
RoadSegment sgmt = halt.getRoadSegment();
assert sgmt != null;
Direction1D dir = this.roadSegments.getRoadSegmentDirectionAt(halt.getRoadSegmentIndex());
assert dir != null;
if (dir == Direction1D.SEGMENT_DIRECTION) {
length -= halt.getPositionOnSegment();
} else {
length -= sgmt.getLength() - halt.getPositionOnSegment();
}
halt = this.validHalts.get(this.validHalts.size() - 1);
assert halt != null;
sgmt = halt.getRoadSegment();
assert sgmt != null;
dir = this.roadSegments.getRoadSegmentDirectionAt(halt.getRoadSegmentIndex());
assert dir != null;
if (dir == Direction1D.SEGMENT_DIRECTION) {
length -= sgmt.getLength() - halt.getPositionOnSegment();
} else {
length -= halt.getPositionOnSegment();
}
if (length < 0.) {
length = 0.;
}
}
return length;
} | [
"@",
"Pure",
"public",
"double",
"getLength",
"(",
")",
"{",
"double",
"length",
"=",
"this",
".",
"roadSegments",
".",
"getLength",
"(",
")",
";",
"if",
"(",
"isValidPrimitive",
"(",
")",
")",
"{",
"BusItineraryHalt",
"halt",
"=",
"this",
".",
"validHalts",
".",
"get",
"(",
"0",
")",
";",
"assert",
"halt",
"!=",
"null",
";",
"RoadSegment",
"sgmt",
"=",
"halt",
".",
"getRoadSegment",
"(",
")",
";",
"assert",
"sgmt",
"!=",
"null",
";",
"Direction1D",
"dir",
"=",
"this",
".",
"roadSegments",
".",
"getRoadSegmentDirectionAt",
"(",
"halt",
".",
"getRoadSegmentIndex",
"(",
")",
")",
";",
"assert",
"dir",
"!=",
"null",
";",
"if",
"(",
"dir",
"==",
"Direction1D",
".",
"SEGMENT_DIRECTION",
")",
"{",
"length",
"-=",
"halt",
".",
"getPositionOnSegment",
"(",
")",
";",
"}",
"else",
"{",
"length",
"-=",
"sgmt",
".",
"getLength",
"(",
")",
"-",
"halt",
".",
"getPositionOnSegment",
"(",
")",
";",
"}",
"halt",
"=",
"this",
".",
"validHalts",
".",
"get",
"(",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"assert",
"halt",
"!=",
"null",
";",
"sgmt",
"=",
"halt",
".",
"getRoadSegment",
"(",
")",
";",
"assert",
"sgmt",
"!=",
"null",
";",
"dir",
"=",
"this",
".",
"roadSegments",
".",
"getRoadSegmentDirectionAt",
"(",
"halt",
".",
"getRoadSegmentIndex",
"(",
")",
")",
";",
"assert",
"dir",
"!=",
"null",
";",
"if",
"(",
"dir",
"==",
"Direction1D",
".",
"SEGMENT_DIRECTION",
")",
"{",
"length",
"-=",
"sgmt",
".",
"getLength",
"(",
")",
"-",
"halt",
".",
"getPositionOnSegment",
"(",
")",
";",
"}",
"else",
"{",
"length",
"-=",
"halt",
".",
"getPositionOnSegment",
"(",
")",
";",
"}",
"if",
"(",
"length",
"<",
"0.",
")",
"{",
"length",
"=",
"0.",
";",
"}",
"}",
"return",
"length",
";",
"}"
] | Replies the length of this itinerary.
<p>If the itinerary is valid, replies the distance
between the start bus halt and the terminus.
If the itinerary is not valid, replies the sum
of the road segment lengths.
@return the length of the itinerary. | [
"Replies",
"the",
"length",
"of",
"this",
"itinerary",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L892-L925 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.getDistanceBetweenBusHalts | @Pure
public double getDistanceBetweenBusHalts(int firsthaltIndex, int lasthaltIndex) {
if (firsthaltIndex < 0 || firsthaltIndex >= this.validHalts.size() - 1) {
throw new ArrayIndexOutOfBoundsException(firsthaltIndex);
}
if (lasthaltIndex <= firsthaltIndex || lasthaltIndex >= this.validHalts.size()) {
throw new ArrayIndexOutOfBoundsException(lasthaltIndex);
}
double length = 0;
final BusItineraryHalt b1 = this.validHalts.get(firsthaltIndex);
final BusItineraryHalt b2 = this.validHalts.get(lasthaltIndex);
final int firstSegment = b1.getRoadSegmentIndex();
final int lastSegment = b2.getRoadSegmentIndex();
for (int i = firstSegment + 1; i < lastSegment; ++i) {
final RoadSegment segment = this.roadSegments.getRoadSegmentAt(i);
length += segment.getLength();
}
Direction1D direction = getRoadSegmentDirection(firstSegment);
if (direction.isRevertedSegmentDirection()) {
length += b1.getPositionOnSegment();
} else {
length += this.roadSegments.getRoadSegmentAt(firstSegment).getLength() - b1.getPositionOnSegment();
}
direction = getRoadSegmentDirection(lastSegment);
if (direction.isSegmentDirection()) {
length += b2.getPositionOnSegment();
} else {
length += this.roadSegments.getRoadSegmentAt(firstSegment).getLength() - b2.getPositionOnSegment();
}
return length;
} | java | @Pure
public double getDistanceBetweenBusHalts(int firsthaltIndex, int lasthaltIndex) {
if (firsthaltIndex < 0 || firsthaltIndex >= this.validHalts.size() - 1) {
throw new ArrayIndexOutOfBoundsException(firsthaltIndex);
}
if (lasthaltIndex <= firsthaltIndex || lasthaltIndex >= this.validHalts.size()) {
throw new ArrayIndexOutOfBoundsException(lasthaltIndex);
}
double length = 0;
final BusItineraryHalt b1 = this.validHalts.get(firsthaltIndex);
final BusItineraryHalt b2 = this.validHalts.get(lasthaltIndex);
final int firstSegment = b1.getRoadSegmentIndex();
final int lastSegment = b2.getRoadSegmentIndex();
for (int i = firstSegment + 1; i < lastSegment; ++i) {
final RoadSegment segment = this.roadSegments.getRoadSegmentAt(i);
length += segment.getLength();
}
Direction1D direction = getRoadSegmentDirection(firstSegment);
if (direction.isRevertedSegmentDirection()) {
length += b1.getPositionOnSegment();
} else {
length += this.roadSegments.getRoadSegmentAt(firstSegment).getLength() - b1.getPositionOnSegment();
}
direction = getRoadSegmentDirection(lastSegment);
if (direction.isSegmentDirection()) {
length += b2.getPositionOnSegment();
} else {
length += this.roadSegments.getRoadSegmentAt(firstSegment).getLength() - b2.getPositionOnSegment();
}
return length;
} | [
"@",
"Pure",
"public",
"double",
"getDistanceBetweenBusHalts",
"(",
"int",
"firsthaltIndex",
",",
"int",
"lasthaltIndex",
")",
"{",
"if",
"(",
"firsthaltIndex",
"<",
"0",
"||",
"firsthaltIndex",
">=",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
"-",
"1",
")",
"{",
"throw",
"new",
"ArrayIndexOutOfBoundsException",
"(",
"firsthaltIndex",
")",
";",
"}",
"if",
"(",
"lasthaltIndex",
"<=",
"firsthaltIndex",
"||",
"lasthaltIndex",
">=",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"ArrayIndexOutOfBoundsException",
"(",
"lasthaltIndex",
")",
";",
"}",
"double",
"length",
"=",
"0",
";",
"final",
"BusItineraryHalt",
"b1",
"=",
"this",
".",
"validHalts",
".",
"get",
"(",
"firsthaltIndex",
")",
";",
"final",
"BusItineraryHalt",
"b2",
"=",
"this",
".",
"validHalts",
".",
"get",
"(",
"lasthaltIndex",
")",
";",
"final",
"int",
"firstSegment",
"=",
"b1",
".",
"getRoadSegmentIndex",
"(",
")",
";",
"final",
"int",
"lastSegment",
"=",
"b2",
".",
"getRoadSegmentIndex",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"firstSegment",
"+",
"1",
";",
"i",
"<",
"lastSegment",
";",
"++",
"i",
")",
"{",
"final",
"RoadSegment",
"segment",
"=",
"this",
".",
"roadSegments",
".",
"getRoadSegmentAt",
"(",
"i",
")",
";",
"length",
"+=",
"segment",
".",
"getLength",
"(",
")",
";",
"}",
"Direction1D",
"direction",
"=",
"getRoadSegmentDirection",
"(",
"firstSegment",
")",
";",
"if",
"(",
"direction",
".",
"isRevertedSegmentDirection",
"(",
")",
")",
"{",
"length",
"+=",
"b1",
".",
"getPositionOnSegment",
"(",
")",
";",
"}",
"else",
"{",
"length",
"+=",
"this",
".",
"roadSegments",
".",
"getRoadSegmentAt",
"(",
"firstSegment",
")",
".",
"getLength",
"(",
")",
"-",
"b1",
".",
"getPositionOnSegment",
"(",
")",
";",
"}",
"direction",
"=",
"getRoadSegmentDirection",
"(",
"lastSegment",
")",
";",
"if",
"(",
"direction",
".",
"isSegmentDirection",
"(",
")",
")",
"{",
"length",
"+=",
"b2",
".",
"getPositionOnSegment",
"(",
")",
";",
"}",
"else",
"{",
"length",
"+=",
"this",
".",
"roadSegments",
".",
"getRoadSegmentAt",
"(",
"firstSegment",
")",
".",
"getLength",
"(",
")",
"-",
"b2",
".",
"getPositionOnSegment",
"(",
")",
";",
"}",
"return",
"length",
";",
"}"
] | Replies the distance between two bus halt.
@param firsthaltIndex is the index of the first bus halt.
@param lasthaltIndex is the index of the last bus halt.
@return the distance in meters between the given bus halts. | [
"Replies",
"the",
"distance",
"between",
"two",
"bus",
"halt",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L934-L970 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.addBusHalt | boolean addBusHalt(BusItineraryHalt halt, int insertToIndex) {
//set index for right ordering when add to invalid list !
if (insertToIndex < 0) {
halt.setInvalidListIndex(this.insertionIndex);
} else {
halt.setInvalidListIndex(insertToIndex);
}
if (halt.isValidPrimitive()) {
ListUtil.addIfAbsent(this.validHalts, VALID_HALT_COMPARATOR, halt);
} else {
ListUtil.addIfAbsent(this.invalidHalts, INVALID_HALT_COMPARATOR, halt);
}
halt.setEventFirable(isEventFirable());
++this.insertionIndex;
if (isEventFirable()) {
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ITINERARY_HALT_ADDED,
halt,
halt.indexInParent(),
"shape", null, null)); //$NON-NLS-1$
checkPrimitiveValidity();
}
return true;
} | java | boolean addBusHalt(BusItineraryHalt halt, int insertToIndex) {
//set index for right ordering when add to invalid list !
if (insertToIndex < 0) {
halt.setInvalidListIndex(this.insertionIndex);
} else {
halt.setInvalidListIndex(insertToIndex);
}
if (halt.isValidPrimitive()) {
ListUtil.addIfAbsent(this.validHalts, VALID_HALT_COMPARATOR, halt);
} else {
ListUtil.addIfAbsent(this.invalidHalts, INVALID_HALT_COMPARATOR, halt);
}
halt.setEventFirable(isEventFirable());
++this.insertionIndex;
if (isEventFirable()) {
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ITINERARY_HALT_ADDED,
halt,
halt.indexInParent(),
"shape", null, null)); //$NON-NLS-1$
checkPrimitiveValidity();
}
return true;
} | [
"boolean",
"addBusHalt",
"(",
"BusItineraryHalt",
"halt",
",",
"int",
"insertToIndex",
")",
"{",
"//set index for right ordering when add to invalid list !",
"if",
"(",
"insertToIndex",
"<",
"0",
")",
"{",
"halt",
".",
"setInvalidListIndex",
"(",
"this",
".",
"insertionIndex",
")",
";",
"}",
"else",
"{",
"halt",
".",
"setInvalidListIndex",
"(",
"insertToIndex",
")",
";",
"}",
"if",
"(",
"halt",
".",
"isValidPrimitive",
"(",
")",
")",
"{",
"ListUtil",
".",
"addIfAbsent",
"(",
"this",
".",
"validHalts",
",",
"VALID_HALT_COMPARATOR",
",",
"halt",
")",
";",
"}",
"else",
"{",
"ListUtil",
".",
"addIfAbsent",
"(",
"this",
".",
"invalidHalts",
",",
"INVALID_HALT_COMPARATOR",
",",
"halt",
")",
";",
"}",
"halt",
".",
"setEventFirable",
"(",
"isEventFirable",
"(",
")",
")",
";",
"++",
"this",
".",
"insertionIndex",
";",
"if",
"(",
"isEventFirable",
"(",
")",
")",
"{",
"fireShapeChanged",
"(",
"new",
"BusChangeEvent",
"(",
"this",
",",
"BusChangeEventType",
".",
"ITINERARY_HALT_ADDED",
",",
"halt",
",",
"halt",
".",
"indexInParent",
"(",
")",
",",
"\"shape\"",
",",
"null",
",",
"null",
")",
")",
";",
"//$NON-NLS-1$",
"checkPrimitiveValidity",
"(",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Add the given bus halt in this itinerary.
@param halt the halt.
@param insertToIndex the insertion index.
@return <code>true</code> if the addition was successful, <code>false</code>
otherwise. | [
"Add",
"the",
"given",
"bus",
"halt",
"in",
"this",
"itinerary",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L1127-L1151 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.removeAllBusHalts | public void removeAllBusHalts() {
for (final BusItineraryHalt bushalt : this.invalidHalts) {
bushalt.setContainer(null);
bushalt.setRoadSegmentIndex(-1);
bushalt.setPositionOnSegment(Float.NaN);
bushalt.checkPrimitiveValidity();
}
final BusItineraryHalt[] halts = new BusItineraryHalt[this.validHalts.size()];
this.validHalts.toArray(halts);
this.validHalts.clear();
this.invalidHalts.clear();
for (final BusItineraryHalt bushalt : halts) {
bushalt.setContainer(null);
bushalt.setRoadSegmentIndex(-1);
bushalt.setPositionOnSegment(Float.NaN);
bushalt.checkPrimitiveValidity();
}
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ALL_ITINERARY_HALTS_REMOVED,
null,
-1,
"shape", //$NON-NLS-1$
null,
null));
checkPrimitiveValidity();
} | java | public void removeAllBusHalts() {
for (final BusItineraryHalt bushalt : this.invalidHalts) {
bushalt.setContainer(null);
bushalt.setRoadSegmentIndex(-1);
bushalt.setPositionOnSegment(Float.NaN);
bushalt.checkPrimitiveValidity();
}
final BusItineraryHalt[] halts = new BusItineraryHalt[this.validHalts.size()];
this.validHalts.toArray(halts);
this.validHalts.clear();
this.invalidHalts.clear();
for (final BusItineraryHalt bushalt : halts) {
bushalt.setContainer(null);
bushalt.setRoadSegmentIndex(-1);
bushalt.setPositionOnSegment(Float.NaN);
bushalt.checkPrimitiveValidity();
}
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ALL_ITINERARY_HALTS_REMOVED,
null,
-1,
"shape", //$NON-NLS-1$
null,
null));
checkPrimitiveValidity();
} | [
"public",
"void",
"removeAllBusHalts",
"(",
")",
"{",
"for",
"(",
"final",
"BusItineraryHalt",
"bushalt",
":",
"this",
".",
"invalidHalts",
")",
"{",
"bushalt",
".",
"setContainer",
"(",
"null",
")",
";",
"bushalt",
".",
"setRoadSegmentIndex",
"(",
"-",
"1",
")",
";",
"bushalt",
".",
"setPositionOnSegment",
"(",
"Float",
".",
"NaN",
")",
";",
"bushalt",
".",
"checkPrimitiveValidity",
"(",
")",
";",
"}",
"final",
"BusItineraryHalt",
"[",
"]",
"halts",
"=",
"new",
"BusItineraryHalt",
"[",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
"]",
";",
"this",
".",
"validHalts",
".",
"toArray",
"(",
"halts",
")",
";",
"this",
".",
"validHalts",
".",
"clear",
"(",
")",
";",
"this",
".",
"invalidHalts",
".",
"clear",
"(",
")",
";",
"for",
"(",
"final",
"BusItineraryHalt",
"bushalt",
":",
"halts",
")",
"{",
"bushalt",
".",
"setContainer",
"(",
"null",
")",
";",
"bushalt",
".",
"setRoadSegmentIndex",
"(",
"-",
"1",
")",
";",
"bushalt",
".",
"setPositionOnSegment",
"(",
"Float",
".",
"NaN",
")",
";",
"bushalt",
".",
"checkPrimitiveValidity",
"(",
")",
";",
"}",
"fireShapeChanged",
"(",
"new",
"BusChangeEvent",
"(",
"this",
",",
"BusChangeEventType",
".",
"ALL_ITINERARY_HALTS_REMOVED",
",",
"null",
",",
"-",
"1",
",",
"\"shape\"",
",",
"//$NON-NLS-1$",
"null",
",",
"null",
")",
")",
";",
"checkPrimitiveValidity",
"(",
")",
";",
"}"
] | Remove all the bus halts from the current itinerary. | [
"Remove",
"all",
"the",
"bus",
"halts",
"from",
"the",
"current",
"itinerary",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L1299-L1328 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.removeBusHalt | public boolean removeBusHalt(BusItineraryHalt bushalt) {
try {
int index = ListUtil.indexOf(this.validHalts, VALID_HALT_COMPARATOR, bushalt);
if (index >= 0) {
return removeBusHalt(index);
}
index = ListUtil.indexOf(this.invalidHalts, INVALID_HALT_COMPARATOR, bushalt);
if (index >= 0) {
index += this.validHalts.size();
return removeBusHalt(index);
}
} catch (Throwable exception) {
//
}
return false;
} | java | public boolean removeBusHalt(BusItineraryHalt bushalt) {
try {
int index = ListUtil.indexOf(this.validHalts, VALID_HALT_COMPARATOR, bushalt);
if (index >= 0) {
return removeBusHalt(index);
}
index = ListUtil.indexOf(this.invalidHalts, INVALID_HALT_COMPARATOR, bushalt);
if (index >= 0) {
index += this.validHalts.size();
return removeBusHalt(index);
}
} catch (Throwable exception) {
//
}
return false;
} | [
"public",
"boolean",
"removeBusHalt",
"(",
"BusItineraryHalt",
"bushalt",
")",
"{",
"try",
"{",
"int",
"index",
"=",
"ListUtil",
".",
"indexOf",
"(",
"this",
".",
"validHalts",
",",
"VALID_HALT_COMPARATOR",
",",
"bushalt",
")",
";",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"return",
"removeBusHalt",
"(",
"index",
")",
";",
"}",
"index",
"=",
"ListUtil",
".",
"indexOf",
"(",
"this",
".",
"invalidHalts",
",",
"INVALID_HALT_COMPARATOR",
",",
"bushalt",
")",
";",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"index",
"+=",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
";",
"return",
"removeBusHalt",
"(",
"index",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"exception",
")",
"{",
"//",
"}",
"return",
"false",
";",
"}"
] | Remove a bus bus from this itinerary.
@param bushalt is the bus halt to remove.
@return <code>true</code> if the bus halt was successfully removed, otherwise <code>false</code> | [
"Remove",
"a",
"bus",
"bus",
"from",
"this",
"itinerary",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L1336-L1351 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.removeBusHalt | public boolean removeBusHalt(String name) {
Iterator<BusItineraryHalt> iterator = this.validHalts.iterator();
BusItineraryHalt bushalt;
int i = 0;
while (iterator.hasNext()) {
bushalt = iterator.next();
if (name.equals(bushalt.getName())) {
return removeBusHalt(i);
}
++i;
}
iterator = this.invalidHalts.iterator();
i = 0;
while (iterator.hasNext()) {
bushalt = iterator.next();
if (name.equals(bushalt.getName())) {
return removeBusHalt(i);
}
++i;
}
return false;
} | java | public boolean removeBusHalt(String name) {
Iterator<BusItineraryHalt> iterator = this.validHalts.iterator();
BusItineraryHalt bushalt;
int i = 0;
while (iterator.hasNext()) {
bushalt = iterator.next();
if (name.equals(bushalt.getName())) {
return removeBusHalt(i);
}
++i;
}
iterator = this.invalidHalts.iterator();
i = 0;
while (iterator.hasNext()) {
bushalt = iterator.next();
if (name.equals(bushalt.getName())) {
return removeBusHalt(i);
}
++i;
}
return false;
} | [
"public",
"boolean",
"removeBusHalt",
"(",
"String",
"name",
")",
"{",
"Iterator",
"<",
"BusItineraryHalt",
">",
"iterator",
"=",
"this",
".",
"validHalts",
".",
"iterator",
"(",
")",
";",
"BusItineraryHalt",
"bushalt",
";",
"int",
"i",
"=",
"0",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"bushalt",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"name",
".",
"equals",
"(",
"bushalt",
".",
"getName",
"(",
")",
")",
")",
"{",
"return",
"removeBusHalt",
"(",
"i",
")",
";",
"}",
"++",
"i",
";",
"}",
"iterator",
"=",
"this",
".",
"invalidHalts",
".",
"iterator",
"(",
")",
";",
"i",
"=",
"0",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"bushalt",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"name",
".",
"equals",
"(",
"bushalt",
".",
"getName",
"(",
")",
")",
")",
"{",
"return",
"removeBusHalt",
"(",
"i",
")",
";",
"}",
"++",
"i",
";",
"}",
"return",
"false",
";",
"}"
] | Remove the bus halt with the given name.
@param name is the name of the bus halt to remove.
@return <code>true</code> if the bus halt was successfully removed, otherwise <code>false</code> | [
"Remove",
"the",
"bus",
"halt",
"with",
"the",
"given",
"name",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L1359-L1382 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.removeBusHalt | public boolean removeBusHalt(int index) {
try {
final BusItineraryHalt removedBushalt;
if (index < this.validHalts.size()) {
removedBushalt = this.validHalts.remove(index);
} else {
final int idx = index - this.validHalts.size();
removedBushalt = this.invalidHalts.remove(idx);
}
removedBushalt.setContainer(null);
removedBushalt.setRoadSegmentIndex(-1);
removedBushalt.setPositionOnSegment(Float.NaN);
removedBushalt.setEventFirable(true);
removedBushalt.checkPrimitiveValidity();
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ITINERARY_HALT_REMOVED,
removedBushalt,
removedBushalt.indexInParent(),
"shape", //$NON-NLS-1$
null,
null));
checkPrimitiveValidity();
return true;
} catch (Throwable exception) {
//
}
return false;
} | java | public boolean removeBusHalt(int index) {
try {
final BusItineraryHalt removedBushalt;
if (index < this.validHalts.size()) {
removedBushalt = this.validHalts.remove(index);
} else {
final int idx = index - this.validHalts.size();
removedBushalt = this.invalidHalts.remove(idx);
}
removedBushalt.setContainer(null);
removedBushalt.setRoadSegmentIndex(-1);
removedBushalt.setPositionOnSegment(Float.NaN);
removedBushalt.setEventFirable(true);
removedBushalt.checkPrimitiveValidity();
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ITINERARY_HALT_REMOVED,
removedBushalt,
removedBushalt.indexInParent(),
"shape", //$NON-NLS-1$
null,
null));
checkPrimitiveValidity();
return true;
} catch (Throwable exception) {
//
}
return false;
} | [
"public",
"boolean",
"removeBusHalt",
"(",
"int",
"index",
")",
"{",
"try",
"{",
"final",
"BusItineraryHalt",
"removedBushalt",
";",
"if",
"(",
"index",
"<",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
")",
"{",
"removedBushalt",
"=",
"this",
".",
"validHalts",
".",
"remove",
"(",
"index",
")",
";",
"}",
"else",
"{",
"final",
"int",
"idx",
"=",
"index",
"-",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
";",
"removedBushalt",
"=",
"this",
".",
"invalidHalts",
".",
"remove",
"(",
"idx",
")",
";",
"}",
"removedBushalt",
".",
"setContainer",
"(",
"null",
")",
";",
"removedBushalt",
".",
"setRoadSegmentIndex",
"(",
"-",
"1",
")",
";",
"removedBushalt",
".",
"setPositionOnSegment",
"(",
"Float",
".",
"NaN",
")",
";",
"removedBushalt",
".",
"setEventFirable",
"(",
"true",
")",
";",
"removedBushalt",
".",
"checkPrimitiveValidity",
"(",
")",
";",
"fireShapeChanged",
"(",
"new",
"BusChangeEvent",
"(",
"this",
",",
"BusChangeEventType",
".",
"ITINERARY_HALT_REMOVED",
",",
"removedBushalt",
",",
"removedBushalt",
".",
"indexInParent",
"(",
")",
",",
"\"shape\"",
",",
"//$NON-NLS-1$",
"null",
",",
"null",
")",
")",
";",
"checkPrimitiveValidity",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Throwable",
"exception",
")",
"{",
"//",
"}",
"return",
"false",
";",
"}"
] | Remove the bus halt at the specified index.
@param index is the index of the bus halt to remove.
@return <code>true</code> if the bus halt was successfully removed, otherwise <code>false</code> | [
"Remove",
"the",
"bus",
"halt",
"at",
"the",
"specified",
"index",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L1390-L1417 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.indexOf | @Pure
public int indexOf(BusItineraryHalt bushalt) {
if (bushalt == null) {
return -1;
}
if (bushalt.isValidPrimitive()) {
return ListUtil.indexOf(this.validHalts, VALID_HALT_COMPARATOR, bushalt);
}
int idx = ListUtil.indexOf(this.invalidHalts, INVALID_HALT_COMPARATOR, bushalt);
if (idx >= 0) {
idx += this.validHalts.size();
}
return idx;
} | java | @Pure
public int indexOf(BusItineraryHalt bushalt) {
if (bushalt == null) {
return -1;
}
if (bushalt.isValidPrimitive()) {
return ListUtil.indexOf(this.validHalts, VALID_HALT_COMPARATOR, bushalt);
}
int idx = ListUtil.indexOf(this.invalidHalts, INVALID_HALT_COMPARATOR, bushalt);
if (idx >= 0) {
idx += this.validHalts.size();
}
return idx;
} | [
"@",
"Pure",
"public",
"int",
"indexOf",
"(",
"BusItineraryHalt",
"bushalt",
")",
"{",
"if",
"(",
"bushalt",
"==",
"null",
")",
"{",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"bushalt",
".",
"isValidPrimitive",
"(",
")",
")",
"{",
"return",
"ListUtil",
".",
"indexOf",
"(",
"this",
".",
"validHalts",
",",
"VALID_HALT_COMPARATOR",
",",
"bushalt",
")",
";",
"}",
"int",
"idx",
"=",
"ListUtil",
".",
"indexOf",
"(",
"this",
".",
"invalidHalts",
",",
"INVALID_HALT_COMPARATOR",
",",
"bushalt",
")",
";",
"if",
"(",
"idx",
">=",
"0",
")",
"{",
"idx",
"+=",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
";",
"}",
"return",
"idx",
";",
"}"
] | Replies the index of the specified bus halt.
@param bushalt is the bus halt to search for.
@return the index or <code>-1</code> if it was not found. | [
"Replies",
"the",
"index",
"of",
"the",
"specified",
"bus",
"halt",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L1449-L1462 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.contains | @Pure
public boolean contains(BusItineraryHalt bushalt) {
if (bushalt == null) {
return false;
}
if (bushalt.isValidPrimitive()) {
return ListUtil.contains(this.validHalts, VALID_HALT_COMPARATOR, bushalt);
}
return ListUtil.contains(this.invalidHalts, INVALID_HALT_COMPARATOR, bushalt);
} | java | @Pure
public boolean contains(BusItineraryHalt bushalt) {
if (bushalt == null) {
return false;
}
if (bushalt.isValidPrimitive()) {
return ListUtil.contains(this.validHalts, VALID_HALT_COMPARATOR, bushalt);
}
return ListUtil.contains(this.invalidHalts, INVALID_HALT_COMPARATOR, bushalt);
} | [
"@",
"Pure",
"public",
"boolean",
"contains",
"(",
"BusItineraryHalt",
"bushalt",
")",
"{",
"if",
"(",
"bushalt",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"bushalt",
".",
"isValidPrimitive",
"(",
")",
")",
"{",
"return",
"ListUtil",
".",
"contains",
"(",
"this",
".",
"validHalts",
",",
"VALID_HALT_COMPARATOR",
",",
"bushalt",
")",
";",
"}",
"return",
"ListUtil",
".",
"contains",
"(",
"this",
".",
"invalidHalts",
",",
"INVALID_HALT_COMPARATOR",
",",
"bushalt",
")",
";",
"}"
] | Replies if the given bus halt is inside this bus itinerary.
@param bushalt is the bus halt to search for.
@return <code>true</code> if the bus halt is inside the itinerary,
otherwise <code>false</code> | [
"Replies",
"if",
"the",
"given",
"bus",
"halt",
"is",
"inside",
"this",
"bus",
"itinerary",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L1503-L1512 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.getBusHaltAt | @Pure
public BusItineraryHalt getBusHaltAt(int index) {
if (index < this.validHalts.size()) {
return this.validHalts.get(index);
}
return this.invalidHalts.get(index - this.validHalts.size());
} | java | @Pure
public BusItineraryHalt getBusHaltAt(int index) {
if (index < this.validHalts.size()) {
return this.validHalts.get(index);
}
return this.invalidHalts.get(index - this.validHalts.size());
} | [
"@",
"Pure",
"public",
"BusItineraryHalt",
"getBusHaltAt",
"(",
"int",
"index",
")",
"{",
"if",
"(",
"index",
"<",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
")",
"{",
"return",
"this",
".",
"validHalts",
".",
"get",
"(",
"index",
")",
";",
"}",
"return",
"this",
".",
"invalidHalts",
".",
"get",
"(",
"index",
"-",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
")",
";",
"}"
] | Replies the halt at the specified index.
@param index the index.
@return a bus halt | [
"Replies",
"the",
"halt",
"at",
"the",
"specified",
"index",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L1533-L1539 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.getBusHalt | @Pure
public BusItineraryHalt getBusHalt(UUID uuid) {
if (uuid == null) {
return null;
}
for (final BusItineraryHalt busHalt : this.validHalts) {
if (uuid.equals(busHalt.getUUID())) {
return busHalt;
}
}
for (final BusItineraryHalt busHalt : this.invalidHalts) {
if (uuid.equals(busHalt.getUUID())) {
return busHalt;
}
}
return null;
} | java | @Pure
public BusItineraryHalt getBusHalt(UUID uuid) {
if (uuid == null) {
return null;
}
for (final BusItineraryHalt busHalt : this.validHalts) {
if (uuid.equals(busHalt.getUUID())) {
return busHalt;
}
}
for (final BusItineraryHalt busHalt : this.invalidHalts) {
if (uuid.equals(busHalt.getUUID())) {
return busHalt;
}
}
return null;
} | [
"@",
"Pure",
"public",
"BusItineraryHalt",
"getBusHalt",
"(",
"UUID",
"uuid",
")",
"{",
"if",
"(",
"uuid",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"for",
"(",
"final",
"BusItineraryHalt",
"busHalt",
":",
"this",
".",
"validHalts",
")",
"{",
"if",
"(",
"uuid",
".",
"equals",
"(",
"busHalt",
".",
"getUUID",
"(",
")",
")",
")",
"{",
"return",
"busHalt",
";",
"}",
"}",
"for",
"(",
"final",
"BusItineraryHalt",
"busHalt",
":",
"this",
".",
"invalidHalts",
")",
"{",
"if",
"(",
"uuid",
".",
"equals",
"(",
"busHalt",
".",
"getUUID",
"(",
")",
")",
")",
"{",
"return",
"busHalt",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Replies the bus halt with the specified uuid.
@param uuid the identifier.
@return BusItineraryHalt or <code>null</code> | [
"Replies",
"the",
"bus",
"halt",
"with",
"the",
"specified",
"uuid",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L1558-L1574 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.getBusHalt | @Pure
public BusItineraryHalt getBusHalt(String name, Comparator<String> nameComparator) {
if (name == null) {
return null;
}
final Comparator<String> cmp = nameComparator == null ? BusNetworkUtilities.NAME_COMPARATOR : nameComparator;
for (final BusItineraryHalt bushalt : this.validHalts) {
if (cmp.compare(name, bushalt.getName()) == 0) {
return bushalt;
}
}
for (final BusItineraryHalt bushalt : this.invalidHalts) {
if (cmp.compare(name, bushalt.getName()) == 0) {
return bushalt;
}
}
return null;
} | java | @Pure
public BusItineraryHalt getBusHalt(String name, Comparator<String> nameComparator) {
if (name == null) {
return null;
}
final Comparator<String> cmp = nameComparator == null ? BusNetworkUtilities.NAME_COMPARATOR : nameComparator;
for (final BusItineraryHalt bushalt : this.validHalts) {
if (cmp.compare(name, bushalt.getName()) == 0) {
return bushalt;
}
}
for (final BusItineraryHalt bushalt : this.invalidHalts) {
if (cmp.compare(name, bushalt.getName()) == 0) {
return bushalt;
}
}
return null;
} | [
"@",
"Pure",
"public",
"BusItineraryHalt",
"getBusHalt",
"(",
"String",
"name",
",",
"Comparator",
"<",
"String",
">",
"nameComparator",
")",
"{",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"Comparator",
"<",
"String",
">",
"cmp",
"=",
"nameComparator",
"==",
"null",
"?",
"BusNetworkUtilities",
".",
"NAME_COMPARATOR",
":",
"nameComparator",
";",
"for",
"(",
"final",
"BusItineraryHalt",
"bushalt",
":",
"this",
".",
"validHalts",
")",
"{",
"if",
"(",
"cmp",
".",
"compare",
"(",
"name",
",",
"bushalt",
".",
"getName",
"(",
")",
")",
"==",
"0",
")",
"{",
"return",
"bushalt",
";",
"}",
"}",
"for",
"(",
"final",
"BusItineraryHalt",
"bushalt",
":",
"this",
".",
"invalidHalts",
")",
"{",
"if",
"(",
"cmp",
".",
"compare",
"(",
"name",
",",
"bushalt",
".",
"getName",
"(",
")",
")",
"==",
"0",
")",
"{",
"return",
"bushalt",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Replies the bus halt with the specified name.
@param name is the desired name
@param nameComparator is used to compare the names.
@return a bus halt or <code>null</code> | [
"Replies",
"the",
"bus",
"halt",
"with",
"the",
"specified",
"name",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L1583-L1600 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.toBusHaltArray | @Pure
public BusItineraryHalt[] toBusHaltArray() {
final BusItineraryHalt[] tab = new BusItineraryHalt[this.validHalts.size() + this.invalidHalts.size()];
int i = 0;
for (final BusItineraryHalt h : this.validHalts) {
tab[i] = h;
++i;
}
for (final BusItineraryHalt h : this.invalidHalts) {
tab[i] = h;
++i;
}
return tab;
} | java | @Pure
public BusItineraryHalt[] toBusHaltArray() {
final BusItineraryHalt[] tab = new BusItineraryHalt[this.validHalts.size() + this.invalidHalts.size()];
int i = 0;
for (final BusItineraryHalt h : this.validHalts) {
tab[i] = h;
++i;
}
for (final BusItineraryHalt h : this.invalidHalts) {
tab[i] = h;
++i;
}
return tab;
} | [
"@",
"Pure",
"public",
"BusItineraryHalt",
"[",
"]",
"toBusHaltArray",
"(",
")",
"{",
"final",
"BusItineraryHalt",
"[",
"]",
"tab",
"=",
"new",
"BusItineraryHalt",
"[",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
"+",
"this",
".",
"invalidHalts",
".",
"size",
"(",
")",
"]",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"final",
"BusItineraryHalt",
"h",
":",
"this",
".",
"validHalts",
")",
"{",
"tab",
"[",
"i",
"]",
"=",
"h",
";",
"++",
"i",
";",
"}",
"for",
"(",
"final",
"BusItineraryHalt",
"h",
":",
"this",
".",
"invalidHalts",
")",
"{",
"tab",
"[",
"i",
"]",
"=",
"h",
";",
"++",
"i",
";",
"}",
"return",
"tab",
";",
"}"
] | Replies an array of the bus halts inside this itinerary.
This function copy the internal data structures into the array.
@return an array of the bus halts inside this itinerary. | [
"Replies",
"an",
"array",
"of",
"the",
"bus",
"halts",
"inside",
"this",
"itinerary",
".",
"This",
"function",
"copy",
"the",
"internal",
"data",
"structures",
"into",
"the",
"array",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L1628-L1641 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.toInvalidBusHaltArray | @Pure
public BusItineraryHalt[] toInvalidBusHaltArray() {
final BusItineraryHalt[] tab = new BusItineraryHalt[this.invalidHalts.size()];
return this.invalidHalts.toArray(tab);
} | java | @Pure
public BusItineraryHalt[] toInvalidBusHaltArray() {
final BusItineraryHalt[] tab = new BusItineraryHalt[this.invalidHalts.size()];
return this.invalidHalts.toArray(tab);
} | [
"@",
"Pure",
"public",
"BusItineraryHalt",
"[",
"]",
"toInvalidBusHaltArray",
"(",
")",
"{",
"final",
"BusItineraryHalt",
"[",
"]",
"tab",
"=",
"new",
"BusItineraryHalt",
"[",
"this",
".",
"invalidHalts",
".",
"size",
"(",
")",
"]",
";",
"return",
"this",
".",
"invalidHalts",
".",
"toArray",
"(",
"tab",
")",
";",
"}"
] | Replies an array of the invalid bus halts inside this itinerary.
This function copy the internal data structures into the array.
@return an array of the invalid bus halts inside this itinerary. | [
"Replies",
"an",
"array",
"of",
"the",
"invalid",
"bus",
"halts",
"inside",
"this",
"itinerary",
".",
"This",
"function",
"copy",
"the",
"internal",
"data",
"structures",
"into",
"the",
"array",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L1648-L1652 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.toValidBusHaltArray | @Pure
public BusItineraryHalt[] toValidBusHaltArray() {
final BusItineraryHalt[] tab = new BusItineraryHalt[this.validHalts.size()];
return this.validHalts.toArray(tab);
} | java | @Pure
public BusItineraryHalt[] toValidBusHaltArray() {
final BusItineraryHalt[] tab = new BusItineraryHalt[this.validHalts.size()];
return this.validHalts.toArray(tab);
} | [
"@",
"Pure",
"public",
"BusItineraryHalt",
"[",
"]",
"toValidBusHaltArray",
"(",
")",
"{",
"final",
"BusItineraryHalt",
"[",
"]",
"tab",
"=",
"new",
"BusItineraryHalt",
"[",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
"]",
";",
"return",
"this",
".",
"validHalts",
".",
"toArray",
"(",
"tab",
")",
";",
"}"
] | Replies an array of the valid bus halts inside this itinerary.
This function copy the internal data structures into the array.
@return an array of the invalid bus halts inside this itinerary. | [
"Replies",
"an",
"array",
"of",
"the",
"valid",
"bus",
"halts",
"inside",
"this",
"itinerary",
".",
"This",
"function",
"copy",
"the",
"internal",
"data",
"structures",
"into",
"the",
"array",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L1659-L1663 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.getNearestRoadSegment | @Pure
public RoadSegment getNearestRoadSegment(Point2D<?, ?> point) {
assert point != null;
double distance = Double.MAX_VALUE;
RoadSegment nearestSegment = null;
final Iterator<RoadSegment> iterator = this.roadSegments.roadSegments();
RoadSegment segment;
while (iterator.hasNext()) {
segment = iterator.next();
final double d = segment.distance(point);
if (d < distance) {
distance = d;
nearestSegment = segment;
}
}
return nearestSegment;
} | java | @Pure
public RoadSegment getNearestRoadSegment(Point2D<?, ?> point) {
assert point != null;
double distance = Double.MAX_VALUE;
RoadSegment nearestSegment = null;
final Iterator<RoadSegment> iterator = this.roadSegments.roadSegments();
RoadSegment segment;
while (iterator.hasNext()) {
segment = iterator.next();
final double d = segment.distance(point);
if (d < distance) {
distance = d;
nearestSegment = segment;
}
}
return nearestSegment;
} | [
"@",
"Pure",
"public",
"RoadSegment",
"getNearestRoadSegment",
"(",
"Point2D",
"<",
"?",
",",
"?",
">",
"point",
")",
"{",
"assert",
"point",
"!=",
"null",
";",
"double",
"distance",
"=",
"Double",
".",
"MAX_VALUE",
";",
"RoadSegment",
"nearestSegment",
"=",
"null",
";",
"final",
"Iterator",
"<",
"RoadSegment",
">",
"iterator",
"=",
"this",
".",
"roadSegments",
".",
"roadSegments",
"(",
")",
";",
"RoadSegment",
"segment",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"segment",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"final",
"double",
"d",
"=",
"segment",
".",
"distance",
"(",
"point",
")",
";",
"if",
"(",
"d",
"<",
"distance",
")",
"{",
"distance",
"=",
"d",
";",
"nearestSegment",
"=",
"segment",
";",
"}",
"}",
"return",
"nearestSegment",
";",
"}"
] | Replies the nearest road segment from this itinerary to the given point.
@param point the point.
@return the nearest road segment or <code>null</code> if none was found. | [
"Replies",
"the",
"nearest",
"road",
"segment",
"from",
"this",
"itinerary",
"to",
"the",
"given",
"point",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L1698-L1714 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.addRoadSegments | public boolean addRoadSegments(RoadPath segments, boolean autoConnectHalts, boolean enableLoopAutoBuild) {
if (segments == null || segments.isEmpty()) {
return false;
}
BusItineraryHalt halt;
RoadSegment sgmt;
final Map<BusItineraryHalt, RoadSegment> haltMapping = new TreeMap<>(
(obj1, obj2) -> Integer.compare(System.identityHashCode(obj1), System.identityHashCode(obj2)));
final Iterator<BusItineraryHalt> haltIterator = this.validHalts.iterator();
while (haltIterator.hasNext()) {
halt = haltIterator.next();
sgmt = this.roadSegments.getRoadSegmentAt(halt.getRoadSegmentIndex());
haltMapping.put(halt, sgmt);
}
final boolean isValidBefore = isValidPrimitive();
final RoadPath changedPath = this.roadSegments.addAndGetPath(segments);
if (changedPath != null) {
if (enableLoopAutoBuild) {
autoLoop(isValidBefore, changedPath, segments);
}
int nIdx;
for (final Entry<BusItineraryHalt, RoadSegment> entry : haltMapping.entrySet()) {
halt = entry.getKey();
sgmt = entry.getValue();
nIdx = this.roadSegments.indexOf(sgmt);
halt.setRoadSegmentIndex(nIdx);
halt.checkPrimitiveValidity();
}
final BusItineraryHalt[] tabV = new BusItineraryHalt[this.validHalts.size()];
this.validHalts.toArray(tabV);
this.validHalts.clear();
for (final BusItineraryHalt busHalt : tabV) {
assert busHalt != null && busHalt.isValidPrimitive();
ListUtil.addIfAbsent(this.validHalts, VALID_HALT_COMPARATOR, busHalt);
}
if (this.roadNetwork == null) {
final RoadNetwork network = segments.getFirstSegment().getRoadNetwork();
this.roadNetwork = new WeakReference<>(network);
network.addRoadNetworkListener(this);
}
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.SEGMENT_ADDED,
segments.getLastSegment(),
this.roadSegments.indexOf(segments.getLastSegment()),
"shape", //$NON-NLS-1$
null,
null));
// Try to connect the itinerary halts to
// the road segments
if (autoConnectHalts) {
putInvalidHaltsOnRoads();
} else {
checkPrimitiveValidity();
}
return true;
}
return false;
} | java | public boolean addRoadSegments(RoadPath segments, boolean autoConnectHalts, boolean enableLoopAutoBuild) {
if (segments == null || segments.isEmpty()) {
return false;
}
BusItineraryHalt halt;
RoadSegment sgmt;
final Map<BusItineraryHalt, RoadSegment> haltMapping = new TreeMap<>(
(obj1, obj2) -> Integer.compare(System.identityHashCode(obj1), System.identityHashCode(obj2)));
final Iterator<BusItineraryHalt> haltIterator = this.validHalts.iterator();
while (haltIterator.hasNext()) {
halt = haltIterator.next();
sgmt = this.roadSegments.getRoadSegmentAt(halt.getRoadSegmentIndex());
haltMapping.put(halt, sgmt);
}
final boolean isValidBefore = isValidPrimitive();
final RoadPath changedPath = this.roadSegments.addAndGetPath(segments);
if (changedPath != null) {
if (enableLoopAutoBuild) {
autoLoop(isValidBefore, changedPath, segments);
}
int nIdx;
for (final Entry<BusItineraryHalt, RoadSegment> entry : haltMapping.entrySet()) {
halt = entry.getKey();
sgmt = entry.getValue();
nIdx = this.roadSegments.indexOf(sgmt);
halt.setRoadSegmentIndex(nIdx);
halt.checkPrimitiveValidity();
}
final BusItineraryHalt[] tabV = new BusItineraryHalt[this.validHalts.size()];
this.validHalts.toArray(tabV);
this.validHalts.clear();
for (final BusItineraryHalt busHalt : tabV) {
assert busHalt != null && busHalt.isValidPrimitive();
ListUtil.addIfAbsent(this.validHalts, VALID_HALT_COMPARATOR, busHalt);
}
if (this.roadNetwork == null) {
final RoadNetwork network = segments.getFirstSegment().getRoadNetwork();
this.roadNetwork = new WeakReference<>(network);
network.addRoadNetworkListener(this);
}
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.SEGMENT_ADDED,
segments.getLastSegment(),
this.roadSegments.indexOf(segments.getLastSegment()),
"shape", //$NON-NLS-1$
null,
null));
// Try to connect the itinerary halts to
// the road segments
if (autoConnectHalts) {
putInvalidHaltsOnRoads();
} else {
checkPrimitiveValidity();
}
return true;
}
return false;
} | [
"public",
"boolean",
"addRoadSegments",
"(",
"RoadPath",
"segments",
",",
"boolean",
"autoConnectHalts",
",",
"boolean",
"enableLoopAutoBuild",
")",
"{",
"if",
"(",
"segments",
"==",
"null",
"||",
"segments",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"BusItineraryHalt",
"halt",
";",
"RoadSegment",
"sgmt",
";",
"final",
"Map",
"<",
"BusItineraryHalt",
",",
"RoadSegment",
">",
"haltMapping",
"=",
"new",
"TreeMap",
"<>",
"(",
"(",
"obj1",
",",
"obj2",
")",
"->",
"Integer",
".",
"compare",
"(",
"System",
".",
"identityHashCode",
"(",
"obj1",
")",
",",
"System",
".",
"identityHashCode",
"(",
"obj2",
")",
")",
")",
";",
"final",
"Iterator",
"<",
"BusItineraryHalt",
">",
"haltIterator",
"=",
"this",
".",
"validHalts",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"haltIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"halt",
"=",
"haltIterator",
".",
"next",
"(",
")",
";",
"sgmt",
"=",
"this",
".",
"roadSegments",
".",
"getRoadSegmentAt",
"(",
"halt",
".",
"getRoadSegmentIndex",
"(",
")",
")",
";",
"haltMapping",
".",
"put",
"(",
"halt",
",",
"sgmt",
")",
";",
"}",
"final",
"boolean",
"isValidBefore",
"=",
"isValidPrimitive",
"(",
")",
";",
"final",
"RoadPath",
"changedPath",
"=",
"this",
".",
"roadSegments",
".",
"addAndGetPath",
"(",
"segments",
")",
";",
"if",
"(",
"changedPath",
"!=",
"null",
")",
"{",
"if",
"(",
"enableLoopAutoBuild",
")",
"{",
"autoLoop",
"(",
"isValidBefore",
",",
"changedPath",
",",
"segments",
")",
";",
"}",
"int",
"nIdx",
";",
"for",
"(",
"final",
"Entry",
"<",
"BusItineraryHalt",
",",
"RoadSegment",
">",
"entry",
":",
"haltMapping",
".",
"entrySet",
"(",
")",
")",
"{",
"halt",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"sgmt",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"nIdx",
"=",
"this",
".",
"roadSegments",
".",
"indexOf",
"(",
"sgmt",
")",
";",
"halt",
".",
"setRoadSegmentIndex",
"(",
"nIdx",
")",
";",
"halt",
".",
"checkPrimitiveValidity",
"(",
")",
";",
"}",
"final",
"BusItineraryHalt",
"[",
"]",
"tabV",
"=",
"new",
"BusItineraryHalt",
"[",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
"]",
";",
"this",
".",
"validHalts",
".",
"toArray",
"(",
"tabV",
")",
";",
"this",
".",
"validHalts",
".",
"clear",
"(",
")",
";",
"for",
"(",
"final",
"BusItineraryHalt",
"busHalt",
":",
"tabV",
")",
"{",
"assert",
"busHalt",
"!=",
"null",
"&&",
"busHalt",
".",
"isValidPrimitive",
"(",
")",
";",
"ListUtil",
".",
"addIfAbsent",
"(",
"this",
".",
"validHalts",
",",
"VALID_HALT_COMPARATOR",
",",
"busHalt",
")",
";",
"}",
"if",
"(",
"this",
".",
"roadNetwork",
"==",
"null",
")",
"{",
"final",
"RoadNetwork",
"network",
"=",
"segments",
".",
"getFirstSegment",
"(",
")",
".",
"getRoadNetwork",
"(",
")",
";",
"this",
".",
"roadNetwork",
"=",
"new",
"WeakReference",
"<>",
"(",
"network",
")",
";",
"network",
".",
"addRoadNetworkListener",
"(",
"this",
")",
";",
"}",
"fireShapeChanged",
"(",
"new",
"BusChangeEvent",
"(",
"this",
",",
"BusChangeEventType",
".",
"SEGMENT_ADDED",
",",
"segments",
".",
"getLastSegment",
"(",
")",
",",
"this",
".",
"roadSegments",
".",
"indexOf",
"(",
"segments",
".",
"getLastSegment",
"(",
")",
")",
",",
"\"shape\"",
",",
"//$NON-NLS-1$",
"null",
",",
"null",
")",
")",
";",
"// Try to connect the itinerary halts to",
"// the road segments",
"if",
"(",
"autoConnectHalts",
")",
"{",
"putInvalidHaltsOnRoads",
"(",
")",
";",
"}",
"else",
"{",
"checkPrimitiveValidity",
"(",
")",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Add road segments inside the bus itinerary.
@param segments is the segment to add.
@param autoConnectHalts indicates if the invalid itinery halts are trying to
be connected to the added segments. If <code>true</code> {@link #putInvalidHaltsOnRoads(BusItineraryHalt...)}
is invoked.
@param enableLoopAutoBuild indicates if the automatic building of loop is enabled.
@return <code>true</code> if the segment was added, otherwise <code>false</code>.
@since 4.0
@see #addRoadSegment(RoadSegment)
@see #addRoadSegments(RoadPath)
@see #addRoadSegment(RoadSegment, boolean)
@see #putInvalidHaltsOnRoads(BusItineraryHalt...) | [
"Add",
"road",
"segments",
"inside",
"the",
"bus",
"itinerary",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L1813-L1883 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.putHaltOnRoad | @SuppressWarnings("checkstyle:nestedifdepth")
public boolean putHaltOnRoad(BusItineraryHalt halt, RoadSegment road) {
if (contains(halt)) {
final BusStop stop = halt.getBusStop();
if (stop != null) {
final Point2d stopPosition = stop.getPosition2D();
if (stopPosition != null) {
final int idx = indexOf(road);
if (idx >= 0) {
final Point1d pos = road.getNearestPosition(stopPosition);
if (pos != null) {
halt.setRoadSegmentIndex(idx);
halt.setPositionOnSegment(pos.getCurvilineCoordinate());
halt.checkPrimitiveValidity();
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ITINERARY_CHANGED,
null,
-1,
"shape", //$NON-NLS-1$
null,
null));
checkPrimitiveValidity();
return true;
}
}
return false;
}
}
}
return true;
} | java | @SuppressWarnings("checkstyle:nestedifdepth")
public boolean putHaltOnRoad(BusItineraryHalt halt, RoadSegment road) {
if (contains(halt)) {
final BusStop stop = halt.getBusStop();
if (stop != null) {
final Point2d stopPosition = stop.getPosition2D();
if (stopPosition != null) {
final int idx = indexOf(road);
if (idx >= 0) {
final Point1d pos = road.getNearestPosition(stopPosition);
if (pos != null) {
halt.setRoadSegmentIndex(idx);
halt.setPositionOnSegment(pos.getCurvilineCoordinate());
halt.checkPrimitiveValidity();
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ITINERARY_CHANGED,
null,
-1,
"shape", //$NON-NLS-1$
null,
null));
checkPrimitiveValidity();
return true;
}
}
return false;
}
}
}
return true;
} | [
"@",
"SuppressWarnings",
"(",
"\"checkstyle:nestedifdepth\"",
")",
"public",
"boolean",
"putHaltOnRoad",
"(",
"BusItineraryHalt",
"halt",
",",
"RoadSegment",
"road",
")",
"{",
"if",
"(",
"contains",
"(",
"halt",
")",
")",
"{",
"final",
"BusStop",
"stop",
"=",
"halt",
".",
"getBusStop",
"(",
")",
";",
"if",
"(",
"stop",
"!=",
"null",
")",
"{",
"final",
"Point2d",
"stopPosition",
"=",
"stop",
".",
"getPosition2D",
"(",
")",
";",
"if",
"(",
"stopPosition",
"!=",
"null",
")",
"{",
"final",
"int",
"idx",
"=",
"indexOf",
"(",
"road",
")",
";",
"if",
"(",
"idx",
">=",
"0",
")",
"{",
"final",
"Point1d",
"pos",
"=",
"road",
".",
"getNearestPosition",
"(",
"stopPosition",
")",
";",
"if",
"(",
"pos",
"!=",
"null",
")",
"{",
"halt",
".",
"setRoadSegmentIndex",
"(",
"idx",
")",
";",
"halt",
".",
"setPositionOnSegment",
"(",
"pos",
".",
"getCurvilineCoordinate",
"(",
")",
")",
";",
"halt",
".",
"checkPrimitiveValidity",
"(",
")",
";",
"fireShapeChanged",
"(",
"new",
"BusChangeEvent",
"(",
"this",
",",
"BusChangeEventType",
".",
"ITINERARY_CHANGED",
",",
"null",
",",
"-",
"1",
",",
"\"shape\"",
",",
"//$NON-NLS-1$",
"null",
",",
"null",
")",
")",
";",
"checkPrimitiveValidity",
"(",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | Put the given bus itinerary halt on the nearest
point on road.
@param halt is the halt to put on the road.
@param road is the road.
@return <code>false</code> if the road was not found;
otherwise <code>true</code>. If the bus halt is not binded
to a valid bus stop, replies <code>true</code> also. | [
"Put",
"the",
"given",
"bus",
"itinerary",
"halt",
"on",
"the",
"nearest",
"point",
"on",
"road",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L2068-L2098 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.removeAllRoadSegments | public void removeAllRoadSegments() {
for (final BusItineraryHalt halt : this.invalidHalts) {
halt.setRoadSegmentIndex(-1);
halt.setPositionOnSegment(Float.NaN);
halt.checkPrimitiveValidity();
}
final BusItineraryHalt[] halts = new BusItineraryHalt[this.validHalts.size()];
this.validHalts.toArray(halts);
for (final BusItineraryHalt halt : halts) {
halt.setRoadSegmentIndex(-1);
halt.setPositionOnSegment(Float.NaN);
halt.checkPrimitiveValidity();
}
if (this.roadNetwork != null) {
final RoadNetwork network = this.roadNetwork.get();
if (network != null) {
network.removeRoadNetworkListener(this);
}
this.roadNetwork = null;
}
this.roadSegments.clear();
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ALL_SEGMENTS_REMOVED,
null,
-1,
"shape", //$NON-NLS-1$
null,
null));
checkPrimitiveValidity();
} | java | public void removeAllRoadSegments() {
for (final BusItineraryHalt halt : this.invalidHalts) {
halt.setRoadSegmentIndex(-1);
halt.setPositionOnSegment(Float.NaN);
halt.checkPrimitiveValidity();
}
final BusItineraryHalt[] halts = new BusItineraryHalt[this.validHalts.size()];
this.validHalts.toArray(halts);
for (final BusItineraryHalt halt : halts) {
halt.setRoadSegmentIndex(-1);
halt.setPositionOnSegment(Float.NaN);
halt.checkPrimitiveValidity();
}
if (this.roadNetwork != null) {
final RoadNetwork network = this.roadNetwork.get();
if (network != null) {
network.removeRoadNetworkListener(this);
}
this.roadNetwork = null;
}
this.roadSegments.clear();
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ALL_SEGMENTS_REMOVED,
null,
-1,
"shape", //$NON-NLS-1$
null,
null));
checkPrimitiveValidity();
} | [
"public",
"void",
"removeAllRoadSegments",
"(",
")",
"{",
"for",
"(",
"final",
"BusItineraryHalt",
"halt",
":",
"this",
".",
"invalidHalts",
")",
"{",
"halt",
".",
"setRoadSegmentIndex",
"(",
"-",
"1",
")",
";",
"halt",
".",
"setPositionOnSegment",
"(",
"Float",
".",
"NaN",
")",
";",
"halt",
".",
"checkPrimitiveValidity",
"(",
")",
";",
"}",
"final",
"BusItineraryHalt",
"[",
"]",
"halts",
"=",
"new",
"BusItineraryHalt",
"[",
"this",
".",
"validHalts",
".",
"size",
"(",
")",
"]",
";",
"this",
".",
"validHalts",
".",
"toArray",
"(",
"halts",
")",
";",
"for",
"(",
"final",
"BusItineraryHalt",
"halt",
":",
"halts",
")",
"{",
"halt",
".",
"setRoadSegmentIndex",
"(",
"-",
"1",
")",
";",
"halt",
".",
"setPositionOnSegment",
"(",
"Float",
".",
"NaN",
")",
";",
"halt",
".",
"checkPrimitiveValidity",
"(",
")",
";",
"}",
"if",
"(",
"this",
".",
"roadNetwork",
"!=",
"null",
")",
"{",
"final",
"RoadNetwork",
"network",
"=",
"this",
".",
"roadNetwork",
".",
"get",
"(",
")",
";",
"if",
"(",
"network",
"!=",
"null",
")",
"{",
"network",
".",
"removeRoadNetworkListener",
"(",
"this",
")",
";",
"}",
"this",
".",
"roadNetwork",
"=",
"null",
";",
"}",
"this",
".",
"roadSegments",
".",
"clear",
"(",
")",
";",
"fireShapeChanged",
"(",
"new",
"BusChangeEvent",
"(",
"this",
",",
"BusChangeEventType",
".",
"ALL_SEGMENTS_REMOVED",
",",
"null",
",",
"-",
"1",
",",
"\"shape\"",
",",
"//$NON-NLS-1$",
"null",
",",
"null",
")",
")",
";",
"checkPrimitiveValidity",
"(",
")",
";",
"}"
] | Remove all the road segments from the current itinerary.
<p>All the bus halts will also be removed. | [
"Remove",
"all",
"the",
"road",
"segments",
"from",
"the",
"current",
"itinerary",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L2147-L2178 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.removeRoadSegment | public boolean removeRoadSegment(int segmentIndex) {
if (segmentIndex >= 0 && segmentIndex < this.roadSegments.getRoadSegmentCount()) {
final RoadSegment segment = this.roadSegments.getRoadSegmentAt(segmentIndex);
if (segment != null) {
//
// Invalidate the bus halts on the segment
//
final Map<BusItineraryHalt, RoadSegment> segmentMap = new TreeMap<>(
(obj1, obj2) -> Integer.compare(System.identityHashCode(obj1), System.identityHashCode(obj2)));
final Iterator<BusItineraryHalt> haltIterator = this.validHalts.iterator();
while (haltIterator.hasNext()) {
final BusItineraryHalt halt = haltIterator.next();
final int sgmtIndex = halt.getRoadSegmentIndex();
if (sgmtIndex == segmentIndex) {
segmentMap.put(halt, null);
} else {
final RoadSegment sgmt = this.roadSegments.getRoadSegmentAt(sgmtIndex);
segmentMap.put(halt, sgmt);
}
}
//
// Remove the road segment itself on the segment
//
this.roadSegments.removeRoadSegmentAt(segmentIndex);
//
// Force the road segment indexes
//
for (final Entry<BusItineraryHalt, RoadSegment> entry : segmentMap.entrySet()) {
final BusItineraryHalt halt = entry.getKey();
final RoadSegment sgmt = entry.getValue();
if (sgmt == null) {
halt.setRoadSegmentIndex(-1);
halt.setPositionOnSegment(Float.NaN);
halt.checkPrimitiveValidity();
} else {
final int sgmtIndex = halt.getRoadSegmentIndex();
final int idx = this.roadSegments.indexOf(sgmt);
if (idx != sgmtIndex) {
halt.setRoadSegmentIndex(idx);
halt.checkPrimitiveValidity();
}
}
}
//
// Change the road network reference
//
if (this.roadSegments.isEmpty() && this.roadNetwork != null) {
final RoadNetwork network = this.roadNetwork.get();
if (network != null) {
network.removeRoadNetworkListener(this);
}
this.roadNetwork = null;
}
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.SEGMENT_REMOVED,
segment,
segmentIndex,
"shape", //$NON-NLS-1$
null,
null));
checkPrimitiveValidity();
return true;
}
}
return false;
} | java | public boolean removeRoadSegment(int segmentIndex) {
if (segmentIndex >= 0 && segmentIndex < this.roadSegments.getRoadSegmentCount()) {
final RoadSegment segment = this.roadSegments.getRoadSegmentAt(segmentIndex);
if (segment != null) {
//
// Invalidate the bus halts on the segment
//
final Map<BusItineraryHalt, RoadSegment> segmentMap = new TreeMap<>(
(obj1, obj2) -> Integer.compare(System.identityHashCode(obj1), System.identityHashCode(obj2)));
final Iterator<BusItineraryHalt> haltIterator = this.validHalts.iterator();
while (haltIterator.hasNext()) {
final BusItineraryHalt halt = haltIterator.next();
final int sgmtIndex = halt.getRoadSegmentIndex();
if (sgmtIndex == segmentIndex) {
segmentMap.put(halt, null);
} else {
final RoadSegment sgmt = this.roadSegments.getRoadSegmentAt(sgmtIndex);
segmentMap.put(halt, sgmt);
}
}
//
// Remove the road segment itself on the segment
//
this.roadSegments.removeRoadSegmentAt(segmentIndex);
//
// Force the road segment indexes
//
for (final Entry<BusItineraryHalt, RoadSegment> entry : segmentMap.entrySet()) {
final BusItineraryHalt halt = entry.getKey();
final RoadSegment sgmt = entry.getValue();
if (sgmt == null) {
halt.setRoadSegmentIndex(-1);
halt.setPositionOnSegment(Float.NaN);
halt.checkPrimitiveValidity();
} else {
final int sgmtIndex = halt.getRoadSegmentIndex();
final int idx = this.roadSegments.indexOf(sgmt);
if (idx != sgmtIndex) {
halt.setRoadSegmentIndex(idx);
halt.checkPrimitiveValidity();
}
}
}
//
// Change the road network reference
//
if (this.roadSegments.isEmpty() && this.roadNetwork != null) {
final RoadNetwork network = this.roadNetwork.get();
if (network != null) {
network.removeRoadNetworkListener(this);
}
this.roadNetwork = null;
}
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.SEGMENT_REMOVED,
segment,
segmentIndex,
"shape", //$NON-NLS-1$
null,
null));
checkPrimitiveValidity();
return true;
}
}
return false;
} | [
"public",
"boolean",
"removeRoadSegment",
"(",
"int",
"segmentIndex",
")",
"{",
"if",
"(",
"segmentIndex",
">=",
"0",
"&&",
"segmentIndex",
"<",
"this",
".",
"roadSegments",
".",
"getRoadSegmentCount",
"(",
")",
")",
"{",
"final",
"RoadSegment",
"segment",
"=",
"this",
".",
"roadSegments",
".",
"getRoadSegmentAt",
"(",
"segmentIndex",
")",
";",
"if",
"(",
"segment",
"!=",
"null",
")",
"{",
"//",
"// Invalidate the bus halts on the segment",
"//",
"final",
"Map",
"<",
"BusItineraryHalt",
",",
"RoadSegment",
">",
"segmentMap",
"=",
"new",
"TreeMap",
"<>",
"(",
"(",
"obj1",
",",
"obj2",
")",
"->",
"Integer",
".",
"compare",
"(",
"System",
".",
"identityHashCode",
"(",
"obj1",
")",
",",
"System",
".",
"identityHashCode",
"(",
"obj2",
")",
")",
")",
";",
"final",
"Iterator",
"<",
"BusItineraryHalt",
">",
"haltIterator",
"=",
"this",
".",
"validHalts",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"haltIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"final",
"BusItineraryHalt",
"halt",
"=",
"haltIterator",
".",
"next",
"(",
")",
";",
"final",
"int",
"sgmtIndex",
"=",
"halt",
".",
"getRoadSegmentIndex",
"(",
")",
";",
"if",
"(",
"sgmtIndex",
"==",
"segmentIndex",
")",
"{",
"segmentMap",
".",
"put",
"(",
"halt",
",",
"null",
")",
";",
"}",
"else",
"{",
"final",
"RoadSegment",
"sgmt",
"=",
"this",
".",
"roadSegments",
".",
"getRoadSegmentAt",
"(",
"sgmtIndex",
")",
";",
"segmentMap",
".",
"put",
"(",
"halt",
",",
"sgmt",
")",
";",
"}",
"}",
"//",
"// Remove the road segment itself on the segment",
"//",
"this",
".",
"roadSegments",
".",
"removeRoadSegmentAt",
"(",
"segmentIndex",
")",
";",
"//",
"// Force the road segment indexes",
"//",
"for",
"(",
"final",
"Entry",
"<",
"BusItineraryHalt",
",",
"RoadSegment",
">",
"entry",
":",
"segmentMap",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"BusItineraryHalt",
"halt",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"final",
"RoadSegment",
"sgmt",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"sgmt",
"==",
"null",
")",
"{",
"halt",
".",
"setRoadSegmentIndex",
"(",
"-",
"1",
")",
";",
"halt",
".",
"setPositionOnSegment",
"(",
"Float",
".",
"NaN",
")",
";",
"halt",
".",
"checkPrimitiveValidity",
"(",
")",
";",
"}",
"else",
"{",
"final",
"int",
"sgmtIndex",
"=",
"halt",
".",
"getRoadSegmentIndex",
"(",
")",
";",
"final",
"int",
"idx",
"=",
"this",
".",
"roadSegments",
".",
"indexOf",
"(",
"sgmt",
")",
";",
"if",
"(",
"idx",
"!=",
"sgmtIndex",
")",
"{",
"halt",
".",
"setRoadSegmentIndex",
"(",
"idx",
")",
";",
"halt",
".",
"checkPrimitiveValidity",
"(",
")",
";",
"}",
"}",
"}",
"//",
"// Change the road network reference",
"//",
"if",
"(",
"this",
".",
"roadSegments",
".",
"isEmpty",
"(",
")",
"&&",
"this",
".",
"roadNetwork",
"!=",
"null",
")",
"{",
"final",
"RoadNetwork",
"network",
"=",
"this",
".",
"roadNetwork",
".",
"get",
"(",
")",
";",
"if",
"(",
"network",
"!=",
"null",
")",
"{",
"network",
".",
"removeRoadNetworkListener",
"(",
"this",
")",
";",
"}",
"this",
".",
"roadNetwork",
"=",
"null",
";",
"}",
"fireShapeChanged",
"(",
"new",
"BusChangeEvent",
"(",
"this",
",",
"BusChangeEventType",
".",
"SEGMENT_REMOVED",
",",
"segment",
",",
"segmentIndex",
",",
"\"shape\"",
",",
"//$NON-NLS-1$",
"null",
",",
"null",
")",
")",
";",
"checkPrimitiveValidity",
"(",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Remove a road segment from this itinerary.
<p>The bus halts on the segment will also be removed.
@param segmentIndex is the index of the segment to remove.
@return <code>true</code> if the segment was successfully removed, otherwise <code>false</code> | [
"Remove",
"a",
"road",
"segment",
"from",
"this",
"itinerary",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L2188-L2257 | train |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.roadSegments | @Pure
public Iterable<RoadSegment> roadSegments() {
return new Iterable<RoadSegment>() {
@Override
public Iterator<RoadSegment> iterator() {
return roadSegmentsIterator();
}
};
} | java | @Pure
public Iterable<RoadSegment> roadSegments() {
return new Iterable<RoadSegment>() {
@Override
public Iterator<RoadSegment> iterator() {
return roadSegmentsIterator();
}
};
} | [
"@",
"Pure",
"public",
"Iterable",
"<",
"RoadSegment",
">",
"roadSegments",
"(",
")",
"{",
"return",
"new",
"Iterable",
"<",
"RoadSegment",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Iterator",
"<",
"RoadSegment",
">",
"iterator",
"(",
")",
"{",
"return",
"roadSegmentsIterator",
"(",
")",
";",
"}",
"}",
";",
"}"
] | Replies the list of the road segments of the bus itinerary.
@return a list of road segments | [
"Replies",
"the",
"list",
"of",
"the",
"road",
"segments",
"of",
"the",
"bus",
"itinerary",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L2453-L2461 | train |
BBN-E/bue-common-open | scoring-open/src/main/java/com/bbn/bue/common/evaluation/EquivalenceBasedProvenancedAligner.java | EquivalenceBasedProvenancedAligner.forEquivalenceFunction | @SuppressWarnings("unchecked")
/**
* Creates an aligner given a single function from items to equivalence classes (requires left
* and right items to both be of types compatible with this function).
*/
public static <InT, EqClass> EquivalenceBasedProvenancedAligner<InT, InT, EqClass> forEquivalenceFunction(
Function<? super InT, ? extends EqClass> equivalenceFunction) {
return new EquivalenceBasedProvenancedAligner<InT, InT, EqClass>(
(Function<InT, EqClass>) equivalenceFunction,
(Function<InT, EqClass>) equivalenceFunction);
} | java | @SuppressWarnings("unchecked")
/**
* Creates an aligner given a single function from items to equivalence classes (requires left
* and right items to both be of types compatible with this function).
*/
public static <InT, EqClass> EquivalenceBasedProvenancedAligner<InT, InT, EqClass> forEquivalenceFunction(
Function<? super InT, ? extends EqClass> equivalenceFunction) {
return new EquivalenceBasedProvenancedAligner<InT, InT, EqClass>(
(Function<InT, EqClass>) equivalenceFunction,
(Function<InT, EqClass>) equivalenceFunction);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"/**\n * Creates an aligner given a single function from items to equivalence classes (requires left\n * and right items to both be of types compatible with this function).\n */",
"public",
"static",
"<",
"InT",
",",
"EqClass",
">",
"EquivalenceBasedProvenancedAligner",
"<",
"InT",
",",
"InT",
",",
"EqClass",
">",
"forEquivalenceFunction",
"(",
"Function",
"<",
"?",
"super",
"InT",
",",
"?",
"extends",
"EqClass",
">",
"equivalenceFunction",
")",
"{",
"return",
"new",
"EquivalenceBasedProvenancedAligner",
"<",
"InT",
",",
"InT",
",",
"EqClass",
">",
"(",
"(",
"Function",
"<",
"InT",
",",
"EqClass",
">",
")",
"equivalenceFunction",
",",
"(",
"Function",
"<",
"InT",
",",
"EqClass",
">",
")",
"equivalenceFunction",
")",
";",
"}"
] | we don't need | [
"we",
"don",
"t",
"need"
] | d618652674d647867306e2e4b987a21b7c29c015 | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/scoring-open/src/main/java/com/bbn/bue/common/evaluation/EquivalenceBasedProvenancedAligner.java#L30-L40 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java | VMCommandLine.getExecutableFilename | @Pure
public static String getExecutableFilename(String name) {
if (OperatingSystem.WIN.isCurrentOS()) {
return name + ".exe"; //$NON-NLS-1$
}
return name;
} | java | @Pure
public static String getExecutableFilename(String name) {
if (OperatingSystem.WIN.isCurrentOS()) {
return name + ".exe"; //$NON-NLS-1$
}
return name;
} | [
"@",
"Pure",
"public",
"static",
"String",
"getExecutableFilename",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"OperatingSystem",
".",
"WIN",
".",
"isCurrentOS",
"(",
")",
")",
"{",
"return",
"name",
"+",
"\".exe\"",
";",
"//$NON-NLS-1$",
"}",
"return",
"name",
";",
"}"
] | Replies a binary executable filename depending of the current platform.
@param name is the name which must be converted into a binary executable filename.
@return the binary executable filename. | [
"Replies",
"a",
"binary",
"executable",
"filename",
"depending",
"of",
"the",
"current",
"platform",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java#L126-L132 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java | VMCommandLine.getVMBinary | @Pure
public static String getVMBinary() {
final String javaHome = System.getProperty("java.home"); //$NON-NLS-1$
final File binDir = new File(new File(javaHome), "bin"); //$NON-NLS-1$
if (binDir.isDirectory()) {
File exec = new File(binDir, getExecutableFilename("javaw")); //$NON-NLS-1$
if (exec.isFile()) {
return exec.getAbsolutePath();
}
exec = new File(binDir, getExecutableFilename("java")); //$NON-NLS-1$
if (exec.isFile()) {
return exec.getAbsolutePath();
}
}
return null;
} | java | @Pure
public static String getVMBinary() {
final String javaHome = System.getProperty("java.home"); //$NON-NLS-1$
final File binDir = new File(new File(javaHome), "bin"); //$NON-NLS-1$
if (binDir.isDirectory()) {
File exec = new File(binDir, getExecutableFilename("javaw")); //$NON-NLS-1$
if (exec.isFile()) {
return exec.getAbsolutePath();
}
exec = new File(binDir, getExecutableFilename("java")); //$NON-NLS-1$
if (exec.isFile()) {
return exec.getAbsolutePath();
}
}
return null;
} | [
"@",
"Pure",
"public",
"static",
"String",
"getVMBinary",
"(",
")",
"{",
"final",
"String",
"javaHome",
"=",
"System",
".",
"getProperty",
"(",
"\"java.home\"",
")",
";",
"//$NON-NLS-1$",
"final",
"File",
"binDir",
"=",
"new",
"File",
"(",
"new",
"File",
"(",
"javaHome",
")",
",",
"\"bin\"",
")",
";",
"//$NON-NLS-1$",
"if",
"(",
"binDir",
".",
"isDirectory",
"(",
")",
")",
"{",
"File",
"exec",
"=",
"new",
"File",
"(",
"binDir",
",",
"getExecutableFilename",
"(",
"\"javaw\"",
")",
")",
";",
"//$NON-NLS-1$",
"if",
"(",
"exec",
".",
"isFile",
"(",
")",
")",
"{",
"return",
"exec",
".",
"getAbsolutePath",
"(",
")",
";",
"}",
"exec",
"=",
"new",
"File",
"(",
"binDir",
",",
"getExecutableFilename",
"(",
"\"java\"",
")",
")",
";",
"//$NON-NLS-1$",
"if",
"(",
"exec",
".",
"isFile",
"(",
")",
")",
"{",
"return",
"exec",
".",
"getAbsolutePath",
"(",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Replies the current java VM binary.
@return the binary executable filename that was used to launch the virtual machine. | [
"Replies",
"the",
"current",
"java",
"VM",
"binary",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java#L138-L153 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java | VMCommandLine.launchVMWithJar | @SuppressWarnings("checkstyle:magicnumber")
public static Process launchVMWithJar(File jarFile, String... additionalParams) throws IOException {
final String javaBin = getVMBinary();
if (javaBin == null) {
throw new FileNotFoundException("java"); //$NON-NLS-1$
}
final long totalMemory = Runtime.getRuntime().maxMemory() / 1024;
final String userDir = FileSystem.getUserHomeDirectoryName();
final int nParams = 4;
final String[] params = new String[additionalParams.length + nParams];
params[0] = javaBin;
params[1] = "-Xmx" + totalMemory + "k"; //$NON-NLS-1$ //$NON-NLS-2$
params[2] = "-jar"; //$NON-NLS-1$
params[3] = jarFile.getAbsolutePath();
System.arraycopy(additionalParams, 0, params, nParams, additionalParams.length);
return Runtime.getRuntime().exec(params, null, new File(userDir));
} | java | @SuppressWarnings("checkstyle:magicnumber")
public static Process launchVMWithJar(File jarFile, String... additionalParams) throws IOException {
final String javaBin = getVMBinary();
if (javaBin == null) {
throw new FileNotFoundException("java"); //$NON-NLS-1$
}
final long totalMemory = Runtime.getRuntime().maxMemory() / 1024;
final String userDir = FileSystem.getUserHomeDirectoryName();
final int nParams = 4;
final String[] params = new String[additionalParams.length + nParams];
params[0] = javaBin;
params[1] = "-Xmx" + totalMemory + "k"; //$NON-NLS-1$ //$NON-NLS-2$
params[2] = "-jar"; //$NON-NLS-1$
params[3] = jarFile.getAbsolutePath();
System.arraycopy(additionalParams, 0, params, nParams, additionalParams.length);
return Runtime.getRuntime().exec(params, null, new File(userDir));
} | [
"@",
"SuppressWarnings",
"(",
"\"checkstyle:magicnumber\"",
")",
"public",
"static",
"Process",
"launchVMWithJar",
"(",
"File",
"jarFile",
",",
"String",
"...",
"additionalParams",
")",
"throws",
"IOException",
"{",
"final",
"String",
"javaBin",
"=",
"getVMBinary",
"(",
")",
";",
"if",
"(",
"javaBin",
"==",
"null",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"\"java\"",
")",
";",
"//$NON-NLS-1$",
"}",
"final",
"long",
"totalMemory",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"maxMemory",
"(",
")",
"/",
"1024",
";",
"final",
"String",
"userDir",
"=",
"FileSystem",
".",
"getUserHomeDirectoryName",
"(",
")",
";",
"final",
"int",
"nParams",
"=",
"4",
";",
"final",
"String",
"[",
"]",
"params",
"=",
"new",
"String",
"[",
"additionalParams",
".",
"length",
"+",
"nParams",
"]",
";",
"params",
"[",
"0",
"]",
"=",
"javaBin",
";",
"params",
"[",
"1",
"]",
"=",
"\"-Xmx\"",
"+",
"totalMemory",
"+",
"\"k\"",
";",
"//$NON-NLS-1$ //$NON-NLS-2$",
"params",
"[",
"2",
"]",
"=",
"\"-jar\"",
";",
"//$NON-NLS-1$",
"params",
"[",
"3",
"]",
"=",
"jarFile",
".",
"getAbsolutePath",
"(",
")",
";",
"System",
".",
"arraycopy",
"(",
"additionalParams",
",",
"0",
",",
"params",
",",
"nParams",
",",
"additionalParams",
".",
"length",
")",
";",
"return",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"exec",
"(",
"params",
",",
"null",
",",
"new",
"File",
"(",
"userDir",
")",
")",
";",
"}"
] | Run a jar file inside a new VM.
@param jarFile is the jar file to launch.
@param additionalParams is the list of additional parameters
@return the process that is running the new virtual machine, neither <code>null</code>
@throws IOException when a IO error occurs.
@since 6.2 | [
"Run",
"a",
"jar",
"file",
"inside",
"a",
"new",
"VM",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java#L255-L271 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java | VMCommandLine.getAllCommandLineParameters | @Pure
@SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity"})
public static String[] getAllCommandLineParameters() {
final int osize = commandLineOptions == null ? 0 : commandLineOptions.size();
final int psize = commandLineParameters == null ? 0 : commandLineParameters.length;
final int tsize = (osize > 0 && psize > 0) ? 1 : 0;
final List<String> params = new ArrayList<>(osize + tsize);
if (osize > 0) {
List<Object> values;
String name;
String prefix;
String v;
for (final Entry<String, List<Object>> entry : commandLineOptions.entrySet()) {
name = entry.getKey();
prefix = (name.length() > 1) ? "--" : "-"; //$NON-NLS-1$ //$NON-NLS-2$
values = entry.getValue();
if (values == null || values.isEmpty()) {
params.add(prefix + name);
} else {
for (final Object value : values) {
if (value != null) {
v = value.toString();
if (v != null && v.length() > 0) {
params.add(prefix + name + "=" + v); //$NON-NLS-1$
} else {
params.add(prefix + name);
}
}
}
}
}
}
if (tsize > 0) {
params.add("--"); //$NON-NLS-1$
}
final String[] tab = new String[params.size() + psize];
params.toArray(tab);
params.clear();
if (psize > 0) {
System.arraycopy(commandLineParameters, 0, tab, osize + tsize, psize);
}
return tab;
} | java | @Pure
@SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity"})
public static String[] getAllCommandLineParameters() {
final int osize = commandLineOptions == null ? 0 : commandLineOptions.size();
final int psize = commandLineParameters == null ? 0 : commandLineParameters.length;
final int tsize = (osize > 0 && psize > 0) ? 1 : 0;
final List<String> params = new ArrayList<>(osize + tsize);
if (osize > 0) {
List<Object> values;
String name;
String prefix;
String v;
for (final Entry<String, List<Object>> entry : commandLineOptions.entrySet()) {
name = entry.getKey();
prefix = (name.length() > 1) ? "--" : "-"; //$NON-NLS-1$ //$NON-NLS-2$
values = entry.getValue();
if (values == null || values.isEmpty()) {
params.add(prefix + name);
} else {
for (final Object value : values) {
if (value != null) {
v = value.toString();
if (v != null && v.length() > 0) {
params.add(prefix + name + "=" + v); //$NON-NLS-1$
} else {
params.add(prefix + name);
}
}
}
}
}
}
if (tsize > 0) {
params.add("--"); //$NON-NLS-1$
}
final String[] tab = new String[params.size() + psize];
params.toArray(tab);
params.clear();
if (psize > 0) {
System.arraycopy(commandLineParameters, 0, tab, osize + tsize, psize);
}
return tab;
} | [
"@",
"Pure",
"@",
"SuppressWarnings",
"(",
"{",
"\"checkstyle:cyclomaticcomplexity\"",
",",
"\"checkstyle:npathcomplexity\"",
"}",
")",
"public",
"static",
"String",
"[",
"]",
"getAllCommandLineParameters",
"(",
")",
"{",
"final",
"int",
"osize",
"=",
"commandLineOptions",
"==",
"null",
"?",
"0",
":",
"commandLineOptions",
".",
"size",
"(",
")",
";",
"final",
"int",
"psize",
"=",
"commandLineParameters",
"==",
"null",
"?",
"0",
":",
"commandLineParameters",
".",
"length",
";",
"final",
"int",
"tsize",
"=",
"(",
"osize",
">",
"0",
"&&",
"psize",
">",
"0",
")",
"?",
"1",
":",
"0",
";",
"final",
"List",
"<",
"String",
">",
"params",
"=",
"new",
"ArrayList",
"<>",
"(",
"osize",
"+",
"tsize",
")",
";",
"if",
"(",
"osize",
">",
"0",
")",
"{",
"List",
"<",
"Object",
">",
"values",
";",
"String",
"name",
";",
"String",
"prefix",
";",
"String",
"v",
";",
"for",
"(",
"final",
"Entry",
"<",
"String",
",",
"List",
"<",
"Object",
">",
">",
"entry",
":",
"commandLineOptions",
".",
"entrySet",
"(",
")",
")",
"{",
"name",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"prefix",
"=",
"(",
"name",
".",
"length",
"(",
")",
">",
"1",
")",
"?",
"\"--\"",
":",
"\"-\"",
";",
"//$NON-NLS-1$ //$NON-NLS-2$",
"values",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"values",
"==",
"null",
"||",
"values",
".",
"isEmpty",
"(",
")",
")",
"{",
"params",
".",
"add",
"(",
"prefix",
"+",
"name",
")",
";",
"}",
"else",
"{",
"for",
"(",
"final",
"Object",
"value",
":",
"values",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"v",
"=",
"value",
".",
"toString",
"(",
")",
";",
"if",
"(",
"v",
"!=",
"null",
"&&",
"v",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"params",
".",
"add",
"(",
"prefix",
"+",
"name",
"+",
"\"=\"",
"+",
"v",
")",
";",
"//$NON-NLS-1$",
"}",
"else",
"{",
"params",
".",
"add",
"(",
"prefix",
"+",
"name",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"if",
"(",
"tsize",
">",
"0",
")",
"{",
"params",
".",
"add",
"(",
"\"--\"",
")",
";",
"//$NON-NLS-1$",
"}",
"final",
"String",
"[",
"]",
"tab",
"=",
"new",
"String",
"[",
"params",
".",
"size",
"(",
")",
"+",
"psize",
"]",
";",
"params",
".",
"toArray",
"(",
"tab",
")",
";",
"params",
".",
"clear",
"(",
")",
";",
"if",
"(",
"psize",
">",
"0",
")",
"{",
"System",
".",
"arraycopy",
"(",
"commandLineParameters",
",",
"0",
",",
"tab",
",",
"osize",
"+",
"tsize",
",",
"psize",
")",
";",
"}",
"return",
"tab",
";",
"}"
] | Replies the command line including the options and the standard parameters.
@return the command line. | [
"Replies",
"the",
"command",
"line",
"including",
"the",
"options",
"and",
"the",
"standard",
"parameters",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java#L377-L421 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java | VMCommandLine.shiftCommandLineParameters | public static String shiftCommandLineParameters() {
String removed = null;
if (commandLineParameters != null) {
if (commandLineParameters.length == 0) {
commandLineParameters = null;
} else if (commandLineParameters.length == 1) {
removed = commandLineParameters[0];
commandLineParameters = null;
} else {
removed = commandLineParameters[0];
final String[] newTab = new String[commandLineParameters.length - 1];
System.arraycopy(commandLineParameters, 1, newTab, 0, commandLineParameters.length - 1);
commandLineParameters = newTab;
}
}
return removed;
} | java | public static String shiftCommandLineParameters() {
String removed = null;
if (commandLineParameters != null) {
if (commandLineParameters.length == 0) {
commandLineParameters = null;
} else if (commandLineParameters.length == 1) {
removed = commandLineParameters[0];
commandLineParameters = null;
} else {
removed = commandLineParameters[0];
final String[] newTab = new String[commandLineParameters.length - 1];
System.arraycopy(commandLineParameters, 1, newTab, 0, commandLineParameters.length - 1);
commandLineParameters = newTab;
}
}
return removed;
} | [
"public",
"static",
"String",
"shiftCommandLineParameters",
"(",
")",
"{",
"String",
"removed",
"=",
"null",
";",
"if",
"(",
"commandLineParameters",
"!=",
"null",
")",
"{",
"if",
"(",
"commandLineParameters",
".",
"length",
"==",
"0",
")",
"{",
"commandLineParameters",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"commandLineParameters",
".",
"length",
"==",
"1",
")",
"{",
"removed",
"=",
"commandLineParameters",
"[",
"0",
"]",
";",
"commandLineParameters",
"=",
"null",
";",
"}",
"else",
"{",
"removed",
"=",
"commandLineParameters",
"[",
"0",
"]",
";",
"final",
"String",
"[",
"]",
"newTab",
"=",
"new",
"String",
"[",
"commandLineParameters",
".",
"length",
"-",
"1",
"]",
";",
"System",
".",
"arraycopy",
"(",
"commandLineParameters",
",",
"1",
",",
"newTab",
",",
"0",
",",
"commandLineParameters",
".",
"length",
"-",
"1",
")",
";",
"commandLineParameters",
"=",
"newTab",
";",
"}",
"}",
"return",
"removed",
";",
"}"
] | Shift the command line parameters by one on the left.
The first parameter is removed from the list.
@return the removed element or <code>null</code> | [
"Shift",
"the",
"command",
"line",
"parameters",
"by",
"one",
"on",
"the",
"left",
".",
"The",
"first",
"parameter",
"is",
"removed",
"from",
"the",
"list",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java#L437-L453 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java | VMCommandLine.getCommandLineOptions | @Pure
public static Map<String, List<Object>> getCommandLineOptions() {
if (commandLineOptions != null) {
return Collections.unmodifiableSortedMap(commandLineOptions);
}
return Collections.emptyMap();
} | java | @Pure
public static Map<String, List<Object>> getCommandLineOptions() {
if (commandLineOptions != null) {
return Collections.unmodifiableSortedMap(commandLineOptions);
}
return Collections.emptyMap();
} | [
"@",
"Pure",
"public",
"static",
"Map",
"<",
"String",
",",
"List",
"<",
"Object",
">",
">",
"getCommandLineOptions",
"(",
")",
"{",
"if",
"(",
"commandLineOptions",
"!=",
"null",
")",
"{",
"return",
"Collections",
".",
"unmodifiableSortedMap",
"(",
"commandLineOptions",
")",
";",
"}",
"return",
"Collections",
".",
"emptyMap",
"(",
")",
";",
"}"
] | Replies the command line options.
@return the list of options passed on the command line | [
"Replies",
"the",
"command",
"line",
"options",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java#L459-L465 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java | VMCommandLine.getCommandLineOption | @Pure
public static List<Object> getCommandLineOption(String name) {
if (commandLineOptions != null && commandLineOptions.containsKey(name)) {
final List<Object> value = commandLineOptions.get(name);
return value == null ? Collections.emptyList() : value;
}
return Collections.emptyList();
} | java | @Pure
public static List<Object> getCommandLineOption(String name) {
if (commandLineOptions != null && commandLineOptions.containsKey(name)) {
final List<Object> value = commandLineOptions.get(name);
return value == null ? Collections.emptyList() : value;
}
return Collections.emptyList();
} | [
"@",
"Pure",
"public",
"static",
"List",
"<",
"Object",
">",
"getCommandLineOption",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"commandLineOptions",
"!=",
"null",
"&&",
"commandLineOptions",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"final",
"List",
"<",
"Object",
">",
"value",
"=",
"commandLineOptions",
".",
"get",
"(",
"name",
")",
";",
"return",
"value",
"==",
"null",
"?",
"Collections",
".",
"emptyList",
"(",
")",
":",
"value",
";",
"}",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}"
] | Replies one command option.
@param name is the name of the option
@return the option value or <code>null</code> if the option is not on the command line. | [
"Replies",
"one",
"command",
"option",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java#L472-L479 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java | VMCommandLine.getFirstOptionValue | @Pure
@SuppressWarnings("static-method")
public Object getFirstOptionValue(String optionLabel) {
final List<Object> options = getCommandLineOption(optionLabel);
if (options == null || options.isEmpty()) {
return null;
}
return options.get(0);
} | java | @Pure
@SuppressWarnings("static-method")
public Object getFirstOptionValue(String optionLabel) {
final List<Object> options = getCommandLineOption(optionLabel);
if (options == null || options.isEmpty()) {
return null;
}
return options.get(0);
} | [
"@",
"Pure",
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"public",
"Object",
"getFirstOptionValue",
"(",
"String",
"optionLabel",
")",
"{",
"final",
"List",
"<",
"Object",
">",
"options",
"=",
"getCommandLineOption",
"(",
"optionLabel",
")",
";",
"if",
"(",
"options",
"==",
"null",
"||",
"options",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"options",
".",
"get",
"(",
"0",
")",
";",
"}"
] | Replies the first value of the option.
@param optionLabel is the name of the option
@return the option value or <code>null</code> if the option is not present or has no value. | [
"Replies",
"the",
"first",
"value",
"of",
"the",
"option",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java#L813-L821 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java | VMCommandLine.getOptionValues | @Pure
@SuppressWarnings("static-method")
public List<Object> getOptionValues(String optionLabel) {
final List<Object> options = getCommandLineOption(optionLabel);
if (options == null) {
return Collections.emptyList();
}
return Collections.unmodifiableList(options);
} | java | @Pure
@SuppressWarnings("static-method")
public List<Object> getOptionValues(String optionLabel) {
final List<Object> options = getCommandLineOption(optionLabel);
if (options == null) {
return Collections.emptyList();
}
return Collections.unmodifiableList(options);
} | [
"@",
"Pure",
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"public",
"List",
"<",
"Object",
">",
"getOptionValues",
"(",
"String",
"optionLabel",
")",
"{",
"final",
"List",
"<",
"Object",
">",
"options",
"=",
"getCommandLineOption",
"(",
"optionLabel",
")",
";",
"if",
"(",
"options",
"==",
"null",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"return",
"Collections",
".",
"unmodifiableList",
"(",
"options",
")",
";",
"}"
] | Replies the values of the option.
@param optionLabel is the name of the option
@return the option values or <code>null</code> if the option is not present. | [
"Replies",
"the",
"values",
"of",
"the",
"option",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java#L828-L836 | train |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java | VMCommandLine.isParameterExists | @Pure
@SuppressWarnings("static-method")
public boolean isParameterExists(int index) {
final String[] params = getCommandLineParameters();
return index >= 0 && index < params.length && params[index] != null;
} | java | @Pure
@SuppressWarnings("static-method")
public boolean isParameterExists(int index) {
final String[] params = getCommandLineParameters();
return index >= 0 && index < params.length && params[index] != null;
} | [
"@",
"Pure",
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"public",
"boolean",
"isParameterExists",
"(",
"int",
"index",
")",
"{",
"final",
"String",
"[",
"]",
"params",
"=",
"getCommandLineParameters",
"(",
")",
";",
"return",
"index",
">=",
"0",
"&&",
"index",
"<",
"params",
".",
"length",
"&&",
"params",
"[",
"index",
"]",
"!=",
"null",
";",
"}"
] | Replies if the given index corresponds to a command line parameter.
@param index position of the parameter to test.
@return <code>true</code> if the given index corresponds to a parameter,
otherwise <code>false</code>
@throws IndexOutOfBoundsException if the given index is out of bounds. | [
"Replies",
"if",
"the",
"given",
"index",
"corresponds",
"to",
"a",
"command",
"line",
"parameter",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/VMCommandLine.java#L887-L892 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.firstInGroup | private int firstInGroup(int groupIndex) {
if (this.pointCoordinates == null) {
throw new IndexOutOfBoundsException();
}
final int count = getGroupCount();
if (groupIndex < 0) {
throw new IndexOutOfBoundsException(groupIndex + "<0"); //$NON-NLS-1$
}
if (groupIndex >= count) {
throw new IndexOutOfBoundsException(groupIndex + ">=" + count); //$NON-NLS-1$
}
final int g = groupIndex - 1;
if (g >= 0 && this.partIndexes != null && g < this.partIndexes.length) {
return this.partIndexes[g];
}
return 0;
} | java | private int firstInGroup(int groupIndex) {
if (this.pointCoordinates == null) {
throw new IndexOutOfBoundsException();
}
final int count = getGroupCount();
if (groupIndex < 0) {
throw new IndexOutOfBoundsException(groupIndex + "<0"); //$NON-NLS-1$
}
if (groupIndex >= count) {
throw new IndexOutOfBoundsException(groupIndex + ">=" + count); //$NON-NLS-1$
}
final int g = groupIndex - 1;
if (g >= 0 && this.partIndexes != null && g < this.partIndexes.length) {
return this.partIndexes[g];
}
return 0;
} | [
"private",
"int",
"firstInGroup",
"(",
"int",
"groupIndex",
")",
"{",
"if",
"(",
"this",
".",
"pointCoordinates",
"==",
"null",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"}",
"final",
"int",
"count",
"=",
"getGroupCount",
"(",
")",
";",
"if",
"(",
"groupIndex",
"<",
"0",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"groupIndex",
"+",
"\"<0\"",
")",
";",
"//$NON-NLS-1$",
"}",
"if",
"(",
"groupIndex",
">=",
"count",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"groupIndex",
"+",
"\">=\"",
"+",
"count",
")",
";",
"//$NON-NLS-1$",
"}",
"final",
"int",
"g",
"=",
"groupIndex",
"-",
"1",
";",
"if",
"(",
"g",
">=",
"0",
"&&",
"this",
".",
"partIndexes",
"!=",
"null",
"&&",
"g",
"<",
"this",
".",
"partIndexes",
".",
"length",
")",
"{",
"return",
"this",
".",
"partIndexes",
"[",
"g",
"]",
";",
"}",
"return",
"0",
";",
"}"
] | Replies the starting index of a point in a group.
@param groupIndex is the index of the desired group
@return the index of the point in the list of points.
This value is between <code>0</code> and <code>this.pointCoordinates.length()-2</code>
@throws IndexOutOfBoundsException in case of error. | [
"Replies",
"the",
"starting",
"index",
"of",
"a",
"point",
"in",
"a",
"group",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L325-L341 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.lastInGroup | private int lastInGroup(int groupIndex) {
if (this.pointCoordinates == null) {
throw new IndexOutOfBoundsException();
}
final int count = getGroupCount();
if (groupIndex < 0) {
throw new IndexOutOfBoundsException(groupIndex + "<0"); //$NON-NLS-1$
}
if (groupIndex >= count) {
throw new IndexOutOfBoundsException(groupIndex + ">=" + count); //$NON-NLS-1$
}
if (this.partIndexes != null && groupIndex < this.partIndexes.length) {
return this.partIndexes[groupIndex] - 2;
}
return this.pointCoordinates.length - 2;
} | java | private int lastInGroup(int groupIndex) {
if (this.pointCoordinates == null) {
throw new IndexOutOfBoundsException();
}
final int count = getGroupCount();
if (groupIndex < 0) {
throw new IndexOutOfBoundsException(groupIndex + "<0"); //$NON-NLS-1$
}
if (groupIndex >= count) {
throw new IndexOutOfBoundsException(groupIndex + ">=" + count); //$NON-NLS-1$
}
if (this.partIndexes != null && groupIndex < this.partIndexes.length) {
return this.partIndexes[groupIndex] - 2;
}
return this.pointCoordinates.length - 2;
} | [
"private",
"int",
"lastInGroup",
"(",
"int",
"groupIndex",
")",
"{",
"if",
"(",
"this",
".",
"pointCoordinates",
"==",
"null",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"}",
"final",
"int",
"count",
"=",
"getGroupCount",
"(",
")",
";",
"if",
"(",
"groupIndex",
"<",
"0",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"groupIndex",
"+",
"\"<0\"",
")",
";",
"//$NON-NLS-1$",
"}",
"if",
"(",
"groupIndex",
">=",
"count",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"groupIndex",
"+",
"\">=\"",
"+",
"count",
")",
";",
"//$NON-NLS-1$",
"}",
"if",
"(",
"this",
".",
"partIndexes",
"!=",
"null",
"&&",
"groupIndex",
"<",
"this",
".",
"partIndexes",
".",
"length",
")",
"{",
"return",
"this",
".",
"partIndexes",
"[",
"groupIndex",
"]",
"-",
"2",
";",
"}",
"return",
"this",
".",
"pointCoordinates",
".",
"length",
"-",
"2",
";",
"}"
] | Replies the ending index of a point in a group.
@param groupIndex is the index of the desired group
@return the index of the point in the list of points.
This value is between <code>0</code> and <code>this.pointCoordinates.length()-2</code>
@throws IndexOutOfBoundsException in case of error. | [
"Replies",
"the",
"ending",
"index",
"of",
"a",
"point",
"in",
"a",
"group",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L350-L365 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.groupIndexForPoint | private int groupIndexForPoint(int pointIndex) {
if (this.pointCoordinates == null || pointIndex < 0 || pointIndex >= this.pointCoordinates.length) {
throw new IndexOutOfBoundsException();
}
if (this.partIndexes == null) {
return 0;
}
for (int i = 0; i < this.partIndexes.length; ++i) {
if (pointIndex < this.partIndexes[i]) {
return i;
}
}
return this.partIndexes.length;
} | java | private int groupIndexForPoint(int pointIndex) {
if (this.pointCoordinates == null || pointIndex < 0 || pointIndex >= this.pointCoordinates.length) {
throw new IndexOutOfBoundsException();
}
if (this.partIndexes == null) {
return 0;
}
for (int i = 0; i < this.partIndexes.length; ++i) {
if (pointIndex < this.partIndexes[i]) {
return i;
}
}
return this.partIndexes.length;
} | [
"private",
"int",
"groupIndexForPoint",
"(",
"int",
"pointIndex",
")",
"{",
"if",
"(",
"this",
".",
"pointCoordinates",
"==",
"null",
"||",
"pointIndex",
"<",
"0",
"||",
"pointIndex",
">=",
"this",
".",
"pointCoordinates",
".",
"length",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"}",
"if",
"(",
"this",
".",
"partIndexes",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"partIndexes",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"pointIndex",
"<",
"this",
".",
"partIndexes",
"[",
"i",
"]",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"this",
".",
"partIndexes",
".",
"length",
";",
"}"
] | Replies the group index inside which the point is located at the specified index.
@param pointIndex is the global index of the point.
@return the index of the group.
This value is between <code>0</code> and <code>this.getGroupCount()</code>
@throws IndexOutOfBoundsException in case of error. | [
"Replies",
"the",
"group",
"index",
"inside",
"which",
"the",
"point",
"is",
"located",
"at",
"the",
"specified",
"index",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L374-L390 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.getPointCountInGroup | @Pure
public int getPointCountInGroup(int groupIndex) {
if (groupIndex == 0 && this.pointCoordinates == null) {
return 0;
}
final int firstInGroup = firstInGroup(groupIndex);
final int lastInGroup = lastInGroup(groupIndex);
return (lastInGroup - firstInGroup) / 2 + 1;
} | java | @Pure
public int getPointCountInGroup(int groupIndex) {
if (groupIndex == 0 && this.pointCoordinates == null) {
return 0;
}
final int firstInGroup = firstInGroup(groupIndex);
final int lastInGroup = lastInGroup(groupIndex);
return (lastInGroup - firstInGroup) / 2 + 1;
} | [
"@",
"Pure",
"public",
"int",
"getPointCountInGroup",
"(",
"int",
"groupIndex",
")",
"{",
"if",
"(",
"groupIndex",
"==",
"0",
"&&",
"this",
".",
"pointCoordinates",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"final",
"int",
"firstInGroup",
"=",
"firstInGroup",
"(",
"groupIndex",
")",
";",
"final",
"int",
"lastInGroup",
"=",
"lastInGroup",
"(",
"groupIndex",
")",
";",
"return",
"(",
"lastInGroup",
"-",
"firstInGroup",
")",
"/",
"2",
"+",
"1",
";",
"}"
] | Replies the count of points in the specified group.
@param groupIndex the group index.
@return the count of points in the specified group.
@throws IndexOutOfBoundsException in case of error. | [
"Replies",
"the",
"count",
"of",
"points",
"in",
"the",
"specified",
"group",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L398-L406 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.getPointIndex | @Pure
public int getPointIndex(int groupIndex, int position) {
final int groupMemberCount = getPointCountInGroup(groupIndex);
final int pos;
if (position < 0) {
pos = 0;
} else if (position >= groupMemberCount) {
pos = groupMemberCount - 1;
} else {
pos = position;
}
// Move the start/end indexes to corresponds to the bounds of the new points
return (firstInGroup(groupIndex) + pos * 2) / 2;
} | java | @Pure
public int getPointIndex(int groupIndex, int position) {
final int groupMemberCount = getPointCountInGroup(groupIndex);
final int pos;
if (position < 0) {
pos = 0;
} else if (position >= groupMemberCount) {
pos = groupMemberCount - 1;
} else {
pos = position;
}
// Move the start/end indexes to corresponds to the bounds of the new points
return (firstInGroup(groupIndex) + pos * 2) / 2;
} | [
"@",
"Pure",
"public",
"int",
"getPointIndex",
"(",
"int",
"groupIndex",
",",
"int",
"position",
")",
"{",
"final",
"int",
"groupMemberCount",
"=",
"getPointCountInGroup",
"(",
"groupIndex",
")",
";",
"final",
"int",
"pos",
";",
"if",
"(",
"position",
"<",
"0",
")",
"{",
"pos",
"=",
"0",
";",
"}",
"else",
"if",
"(",
"position",
">=",
"groupMemberCount",
")",
"{",
"pos",
"=",
"groupMemberCount",
"-",
"1",
";",
"}",
"else",
"{",
"pos",
"=",
"position",
";",
"}",
"// Move the start/end indexes to corresponds to the bounds of the new points",
"return",
"(",
"firstInGroup",
"(",
"groupIndex",
")",
"+",
"pos",
"*",
"2",
")",
"/",
"2",
";",
"}"
] | Replies the global index of the point that corresponds to
the position in the given group.
@param groupIndex the group index.
@param position is the index of the point in the group
@return the global index of the point
@throws IndexOutOfBoundsException in case of error. | [
"Replies",
"the",
"global",
"index",
"of",
"the",
"point",
"that",
"corresponds",
"to",
"the",
"position",
"in",
"the",
"given",
"group",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L416-L430 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.getPointIndex | @Pure
public int getPointIndex(int groupIndex, Point2D<?, ?> point2d) {
if (!this.containsPoint(point2d, groupIndex)) {
return -1;
}
Point2d cur = null;
int pos = -1;
for (int i = 0; i < getPointCountInGroup(groupIndex); ++i) {
cur = getPointAt(groupIndex, i);
if (cur.epsilonEquals(point2d, MapElementConstants.POINT_FUSION_DISTANCE)) {
pos = i;
break;
}
}
return (firstInGroup(groupIndex) + pos * 2) / 2;
} | java | @Pure
public int getPointIndex(int groupIndex, Point2D<?, ?> point2d) {
if (!this.containsPoint(point2d, groupIndex)) {
return -1;
}
Point2d cur = null;
int pos = -1;
for (int i = 0; i < getPointCountInGroup(groupIndex); ++i) {
cur = getPointAt(groupIndex, i);
if (cur.epsilonEquals(point2d, MapElementConstants.POINT_FUSION_DISTANCE)) {
pos = i;
break;
}
}
return (firstInGroup(groupIndex) + pos * 2) / 2;
} | [
"@",
"Pure",
"public",
"int",
"getPointIndex",
"(",
"int",
"groupIndex",
",",
"Point2D",
"<",
"?",
",",
"?",
">",
"point2d",
")",
"{",
"if",
"(",
"!",
"this",
".",
"containsPoint",
"(",
"point2d",
",",
"groupIndex",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"Point2d",
"cur",
"=",
"null",
";",
"int",
"pos",
"=",
"-",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"getPointCountInGroup",
"(",
"groupIndex",
")",
";",
"++",
"i",
")",
"{",
"cur",
"=",
"getPointAt",
"(",
"groupIndex",
",",
"i",
")",
";",
"if",
"(",
"cur",
".",
"epsilonEquals",
"(",
"point2d",
",",
"MapElementConstants",
".",
"POINT_FUSION_DISTANCE",
")",
")",
"{",
"pos",
"=",
"i",
";",
"break",
";",
"}",
"}",
"return",
"(",
"firstInGroup",
"(",
"groupIndex",
")",
"+",
"pos",
"*",
"2",
")",
"/",
"2",
";",
"}"
] | Replies the global index of the point2d in the given group.
@param groupIndex the group index.
@param point2d is the point in the group
@return the global index of the point or <code>-1</code> if not found | [
"Replies",
"the",
"global",
"index",
"of",
"the",
"point2d",
"in",
"the",
"given",
"group",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L438-L454 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.getGroupAt | @Pure
public PointGroup getGroupAt(int index) {
final int count = getGroupCount();
if (index < 0) {
throw new IndexOutOfBoundsException(index + "<0"); //$NON-NLS-1$
}
if (index >= count) {
throw new IndexOutOfBoundsException(index + ">=" + count); //$NON-NLS-1$
}
return new PointGroup(index);
} | java | @Pure
public PointGroup getGroupAt(int index) {
final int count = getGroupCount();
if (index < 0) {
throw new IndexOutOfBoundsException(index + "<0"); //$NON-NLS-1$
}
if (index >= count) {
throw new IndexOutOfBoundsException(index + ">=" + count); //$NON-NLS-1$
}
return new PointGroup(index);
} | [
"@",
"Pure",
"public",
"PointGroup",
"getGroupAt",
"(",
"int",
"index",
")",
"{",
"final",
"int",
"count",
"=",
"getGroupCount",
"(",
")",
";",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"index",
"+",
"\"<0\"",
")",
";",
"//$NON-NLS-1$",
"}",
"if",
"(",
"index",
">=",
"count",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"index",
"+",
"\">=\"",
"+",
"count",
")",
";",
"//$NON-NLS-1$",
"}",
"return",
"new",
"PointGroup",
"(",
"index",
")",
";",
"}"
] | Replies the part at the specified index.
@param index the index.
@return the group
@throws IndexOutOfBoundsException in case of error. | [
"Replies",
"the",
"part",
"at",
"the",
"specified",
"index",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L486-L496 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.groups | @Pure
public Iterable<PointGroup> groups() {
return new Iterable<PointGroup>() {
@Override
public Iterator<PointGroup> iterator() {
return MapComposedElement.this.groupIterator();
}
};
} | java | @Pure
public Iterable<PointGroup> groups() {
return new Iterable<PointGroup>() {
@Override
public Iterator<PointGroup> iterator() {
return MapComposedElement.this.groupIterator();
}
};
} | [
"@",
"Pure",
"public",
"Iterable",
"<",
"PointGroup",
">",
"groups",
"(",
")",
"{",
"return",
"new",
"Iterable",
"<",
"PointGroup",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Iterator",
"<",
"PointGroup",
">",
"iterator",
"(",
")",
"{",
"return",
"MapComposedElement",
".",
"this",
".",
"groupIterator",
"(",
")",
";",
"}",
"}",
";",
"}"
] | Replies the iterator on the groups.
@return the iterator on the groups. | [
"Replies",
"the",
"iterator",
"on",
"the",
"groups",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L502-L510 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.points | @Pure
public Iterable<Point2d> points() {
return new Iterable<Point2d>() {
@Override
public Iterator<Point2d> iterator() {
return MapComposedElement.this.pointIterator();
}
};
} | java | @Pure
public Iterable<Point2d> points() {
return new Iterable<Point2d>() {
@Override
public Iterator<Point2d> iterator() {
return MapComposedElement.this.pointIterator();
}
};
} | [
"@",
"Pure",
"public",
"Iterable",
"<",
"Point2d",
">",
"points",
"(",
")",
"{",
"return",
"new",
"Iterable",
"<",
"Point2d",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Iterator",
"<",
"Point2d",
">",
"iterator",
"(",
")",
"{",
"return",
"MapComposedElement",
".",
"this",
".",
"pointIterator",
"(",
")",
";",
"}",
"}",
";",
"}"
] | Replies the iterator on the points.
@return the iterator on the points. | [
"Replies",
"the",
"iterator",
"on",
"the",
"points",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L525-L533 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.addPoint | public int addPoint(double x, double y) {
int pointIndex;
if (this.pointCoordinates == null) {
this.pointCoordinates = new double[] {x, y};
this.partIndexes = null;
pointIndex = 0;
} else {
double[] pts = new double[this.pointCoordinates.length + 2];
System.arraycopy(this.pointCoordinates, 0, pts, 0, this.pointCoordinates.length);
pointIndex = pts.length - 2;
pts[pointIndex] = x;
pts[pointIndex + 1] = y;
this.pointCoordinates = pts;
pts = null;
pointIndex /= 2;
}
fireShapeChanged();
fireElementChanged();
return pointIndex;
} | java | public int addPoint(double x, double y) {
int pointIndex;
if (this.pointCoordinates == null) {
this.pointCoordinates = new double[] {x, y};
this.partIndexes = null;
pointIndex = 0;
} else {
double[] pts = new double[this.pointCoordinates.length + 2];
System.arraycopy(this.pointCoordinates, 0, pts, 0, this.pointCoordinates.length);
pointIndex = pts.length - 2;
pts[pointIndex] = x;
pts[pointIndex + 1] = y;
this.pointCoordinates = pts;
pts = null;
pointIndex /= 2;
}
fireShapeChanged();
fireElementChanged();
return pointIndex;
} | [
"public",
"int",
"addPoint",
"(",
"double",
"x",
",",
"double",
"y",
")",
"{",
"int",
"pointIndex",
";",
"if",
"(",
"this",
".",
"pointCoordinates",
"==",
"null",
")",
"{",
"this",
".",
"pointCoordinates",
"=",
"new",
"double",
"[",
"]",
"{",
"x",
",",
"y",
"}",
";",
"this",
".",
"partIndexes",
"=",
"null",
";",
"pointIndex",
"=",
"0",
";",
"}",
"else",
"{",
"double",
"[",
"]",
"pts",
"=",
"new",
"double",
"[",
"this",
".",
"pointCoordinates",
".",
"length",
"+",
"2",
"]",
";",
"System",
".",
"arraycopy",
"(",
"this",
".",
"pointCoordinates",
",",
"0",
",",
"pts",
",",
"0",
",",
"this",
".",
"pointCoordinates",
".",
"length",
")",
";",
"pointIndex",
"=",
"pts",
".",
"length",
"-",
"2",
";",
"pts",
"[",
"pointIndex",
"]",
"=",
"x",
";",
"pts",
"[",
"pointIndex",
"+",
"1",
"]",
"=",
"y",
";",
"this",
".",
"pointCoordinates",
"=",
"pts",
";",
"pts",
"=",
"null",
";",
"pointIndex",
"/=",
"2",
";",
"}",
"fireShapeChanged",
"(",
")",
";",
"fireElementChanged",
"(",
")",
";",
"return",
"pointIndex",
";",
"}"
] | Add the specified point at the end of the last group.
@param x x coordinate
@param y y coordinate
@return the index of the new point in the element. | [
"Add",
"the",
"specified",
"point",
"at",
"the",
"end",
"of",
"the",
"last",
"group",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L559-L582 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.addGroup | public int addGroup(double x, double y) {
int pointIndex;
if (this.pointCoordinates == null) {
this.pointCoordinates = new double[] {x, y};
this.partIndexes = null;
pointIndex = 0;
} else {
double[] pts = new double[this.pointCoordinates.length + 2];
System.arraycopy(this.pointCoordinates, 0, pts, 0, this.pointCoordinates.length);
pointIndex = pts.length - 2;
pts[pointIndex] = x;
pts[pointIndex + 1] = y;
final int groupCount = getGroupCount();
int[] grps = new int[groupCount];
if (this.partIndexes != null) {
System.arraycopy(this.partIndexes, 0, grps, 0, groupCount - 1);
}
grps[groupCount - 1] = pointIndex;
this.pointCoordinates = pts;
pts = null;
this.partIndexes = grps;
grps = null;
pointIndex /= 2;
}
fireShapeChanged();
fireElementChanged();
return pointIndex;
} | java | public int addGroup(double x, double y) {
int pointIndex;
if (this.pointCoordinates == null) {
this.pointCoordinates = new double[] {x, y};
this.partIndexes = null;
pointIndex = 0;
} else {
double[] pts = new double[this.pointCoordinates.length + 2];
System.arraycopy(this.pointCoordinates, 0, pts, 0, this.pointCoordinates.length);
pointIndex = pts.length - 2;
pts[pointIndex] = x;
pts[pointIndex + 1] = y;
final int groupCount = getGroupCount();
int[] grps = new int[groupCount];
if (this.partIndexes != null) {
System.arraycopy(this.partIndexes, 0, grps, 0, groupCount - 1);
}
grps[groupCount - 1] = pointIndex;
this.pointCoordinates = pts;
pts = null;
this.partIndexes = grps;
grps = null;
pointIndex /= 2;
}
fireShapeChanged();
fireElementChanged();
return pointIndex;
} | [
"public",
"int",
"addGroup",
"(",
"double",
"x",
",",
"double",
"y",
")",
"{",
"int",
"pointIndex",
";",
"if",
"(",
"this",
".",
"pointCoordinates",
"==",
"null",
")",
"{",
"this",
".",
"pointCoordinates",
"=",
"new",
"double",
"[",
"]",
"{",
"x",
",",
"y",
"}",
";",
"this",
".",
"partIndexes",
"=",
"null",
";",
"pointIndex",
"=",
"0",
";",
"}",
"else",
"{",
"double",
"[",
"]",
"pts",
"=",
"new",
"double",
"[",
"this",
".",
"pointCoordinates",
".",
"length",
"+",
"2",
"]",
";",
"System",
".",
"arraycopy",
"(",
"this",
".",
"pointCoordinates",
",",
"0",
",",
"pts",
",",
"0",
",",
"this",
".",
"pointCoordinates",
".",
"length",
")",
";",
"pointIndex",
"=",
"pts",
".",
"length",
"-",
"2",
";",
"pts",
"[",
"pointIndex",
"]",
"=",
"x",
";",
"pts",
"[",
"pointIndex",
"+",
"1",
"]",
"=",
"y",
";",
"final",
"int",
"groupCount",
"=",
"getGroupCount",
"(",
")",
";",
"int",
"[",
"]",
"grps",
"=",
"new",
"int",
"[",
"groupCount",
"]",
";",
"if",
"(",
"this",
".",
"partIndexes",
"!=",
"null",
")",
"{",
"System",
".",
"arraycopy",
"(",
"this",
".",
"partIndexes",
",",
"0",
",",
"grps",
",",
"0",
",",
"groupCount",
"-",
"1",
")",
";",
"}",
"grps",
"[",
"groupCount",
"-",
"1",
"]",
"=",
"pointIndex",
";",
"this",
".",
"pointCoordinates",
"=",
"pts",
";",
"pts",
"=",
"null",
";",
"this",
".",
"partIndexes",
"=",
"grps",
";",
"grps",
"=",
"null",
";",
"pointIndex",
"/=",
"2",
";",
"}",
"fireShapeChanged",
"(",
")",
";",
"fireElementChanged",
"(",
")",
";",
"return",
"pointIndex",
";",
"}"
] | Add the specified point into a newgroup.
@param x x coordinate
@param y y coordinate
@return the index of the new point in this element. | [
"Add",
"the",
"specified",
"point",
"into",
"a",
"newgroup",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L663-L696 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.invertPointsIn | public MapComposedElement invertPointsIn(int groupIndex) {
if (this.pointCoordinates == null) {
throw new IndexOutOfBoundsException();
}
final int grpCount = getGroupCount();
if (groupIndex < 0) {
throw new IndexOutOfBoundsException(groupIndex + "<0"); //$NON-NLS-1$
}
if (groupIndex > grpCount) {
throw new IndexOutOfBoundsException(groupIndex + ">" + grpCount); //$NON-NLS-1$
}
final int count = this.getPointCountInGroup(groupIndex);
final int first = firstInGroup(groupIndex);
double[] tmp = new double[count * 2];
for (int i = 0; i < count * 2; i += 2) {
tmp[i] = this.pointCoordinates[first + 2 * count - 1 - (i + 1)];
tmp[i + 1] = this.pointCoordinates[first + 2 * count - 1 - i];
}
System.arraycopy(tmp, 0, this.pointCoordinates, first, tmp.length);
tmp = null;
return this;
} | java | public MapComposedElement invertPointsIn(int groupIndex) {
if (this.pointCoordinates == null) {
throw new IndexOutOfBoundsException();
}
final int grpCount = getGroupCount();
if (groupIndex < 0) {
throw new IndexOutOfBoundsException(groupIndex + "<0"); //$NON-NLS-1$
}
if (groupIndex > grpCount) {
throw new IndexOutOfBoundsException(groupIndex + ">" + grpCount); //$NON-NLS-1$
}
final int count = this.getPointCountInGroup(groupIndex);
final int first = firstInGroup(groupIndex);
double[] tmp = new double[count * 2];
for (int i = 0; i < count * 2; i += 2) {
tmp[i] = this.pointCoordinates[first + 2 * count - 1 - (i + 1)];
tmp[i + 1] = this.pointCoordinates[first + 2 * count - 1 - i];
}
System.arraycopy(tmp, 0, this.pointCoordinates, first, tmp.length);
tmp = null;
return this;
} | [
"public",
"MapComposedElement",
"invertPointsIn",
"(",
"int",
"groupIndex",
")",
"{",
"if",
"(",
"this",
".",
"pointCoordinates",
"==",
"null",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"}",
"final",
"int",
"grpCount",
"=",
"getGroupCount",
"(",
")",
";",
"if",
"(",
"groupIndex",
"<",
"0",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"groupIndex",
"+",
"\"<0\"",
")",
";",
"//$NON-NLS-1$",
"}",
"if",
"(",
"groupIndex",
">",
"grpCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"groupIndex",
"+",
"\">\"",
"+",
"grpCount",
")",
";",
"//$NON-NLS-1$",
"}",
"final",
"int",
"count",
"=",
"this",
".",
"getPointCountInGroup",
"(",
"groupIndex",
")",
";",
"final",
"int",
"first",
"=",
"firstInGroup",
"(",
"groupIndex",
")",
";",
"double",
"[",
"]",
"tmp",
"=",
"new",
"double",
"[",
"count",
"*",
"2",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"count",
"*",
"2",
";",
"i",
"+=",
"2",
")",
"{",
"tmp",
"[",
"i",
"]",
"=",
"this",
".",
"pointCoordinates",
"[",
"first",
"+",
"2",
"*",
"count",
"-",
"1",
"-",
"(",
"i",
"+",
"1",
")",
"]",
";",
"tmp",
"[",
"i",
"+",
"1",
"]",
"=",
"this",
".",
"pointCoordinates",
"[",
"first",
"+",
"2",
"*",
"count",
"-",
"1",
"-",
"i",
"]",
";",
"}",
"System",
".",
"arraycopy",
"(",
"tmp",
",",
"0",
",",
"this",
".",
"pointCoordinates",
",",
"first",
",",
"tmp",
".",
"length",
")",
";",
"tmp",
"=",
"null",
";",
"return",
"this",
";",
"}"
] | invert the points coordinates of this element on the groupIndex in argument.
<p>This method is reversible:
{@code this.invertPointsIn(sameIndex) == this.invertPointsIn(sameIndex).invertPointsIn(sameIndex)}
<p>NOTE: invert each parts with {@link MapComposedElement#invertPointsIn(int)}
does'nt produce the same result as {@link MapComposedElement#invert()}.
<p>This method invert points coordinates only.
this.invertPointsIn(0 .. indexCount) != this.invert()
@param groupIndex int element on which invert points
@return this | [
"invert",
"the",
"points",
"coordinates",
"of",
"this",
"element",
"on",
"the",
"groupIndex",
"in",
"argument",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L713-L735 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.invert | public MapComposedElement invert() {
if (this.pointCoordinates == null) {
throw new IndexOutOfBoundsException();
}
double[] tmp = new double[this.pointCoordinates.length];
for (int i = 0; i < this.pointCoordinates.length; i += 2) {
tmp[i] = this.pointCoordinates[this.pointCoordinates.length - 1 - (i + 1)];
tmp[i + 1] = this.pointCoordinates[this.pointCoordinates.length - 1 - i];
}
System.arraycopy(tmp, 0, this.pointCoordinates, 0, this.pointCoordinates.length);
if (this.partIndexes != null) {
int[] tmpint = new int[this.partIndexes.length];
//part 0 not inside the index array
for (int i = 0; i < this.partIndexes.length; ++i) {
tmpint[this.partIndexes.length - 1 - i] = this.pointCoordinates.length - this.partIndexes[i];
}
System.arraycopy(tmpint, 0, this.partIndexes, 0, this.partIndexes.length);
tmpint = null;
}
tmp = null;
return this;
} | java | public MapComposedElement invert() {
if (this.pointCoordinates == null) {
throw new IndexOutOfBoundsException();
}
double[] tmp = new double[this.pointCoordinates.length];
for (int i = 0; i < this.pointCoordinates.length; i += 2) {
tmp[i] = this.pointCoordinates[this.pointCoordinates.length - 1 - (i + 1)];
tmp[i + 1] = this.pointCoordinates[this.pointCoordinates.length - 1 - i];
}
System.arraycopy(tmp, 0, this.pointCoordinates, 0, this.pointCoordinates.length);
if (this.partIndexes != null) {
int[] tmpint = new int[this.partIndexes.length];
//part 0 not inside the index array
for (int i = 0; i < this.partIndexes.length; ++i) {
tmpint[this.partIndexes.length - 1 - i] = this.pointCoordinates.length - this.partIndexes[i];
}
System.arraycopy(tmpint, 0, this.partIndexes, 0, this.partIndexes.length);
tmpint = null;
}
tmp = null;
return this;
} | [
"public",
"MapComposedElement",
"invert",
"(",
")",
"{",
"if",
"(",
"this",
".",
"pointCoordinates",
"==",
"null",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"}",
"double",
"[",
"]",
"tmp",
"=",
"new",
"double",
"[",
"this",
".",
"pointCoordinates",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"pointCoordinates",
".",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"tmp",
"[",
"i",
"]",
"=",
"this",
".",
"pointCoordinates",
"[",
"this",
".",
"pointCoordinates",
".",
"length",
"-",
"1",
"-",
"(",
"i",
"+",
"1",
")",
"]",
";",
"tmp",
"[",
"i",
"+",
"1",
"]",
"=",
"this",
".",
"pointCoordinates",
"[",
"this",
".",
"pointCoordinates",
".",
"length",
"-",
"1",
"-",
"i",
"]",
";",
"}",
"System",
".",
"arraycopy",
"(",
"tmp",
",",
"0",
",",
"this",
".",
"pointCoordinates",
",",
"0",
",",
"this",
".",
"pointCoordinates",
".",
"length",
")",
";",
"if",
"(",
"this",
".",
"partIndexes",
"!=",
"null",
")",
"{",
"int",
"[",
"]",
"tmpint",
"=",
"new",
"int",
"[",
"this",
".",
"partIndexes",
".",
"length",
"]",
";",
"//part 0 not inside the index array",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"partIndexes",
".",
"length",
";",
"++",
"i",
")",
"{",
"tmpint",
"[",
"this",
".",
"partIndexes",
".",
"length",
"-",
"1",
"-",
"i",
"]",
"=",
"this",
".",
"pointCoordinates",
".",
"length",
"-",
"this",
".",
"partIndexes",
"[",
"i",
"]",
";",
"}",
"System",
".",
"arraycopy",
"(",
"tmpint",
",",
"0",
",",
"this",
".",
"partIndexes",
",",
"0",
",",
"this",
".",
"partIndexes",
".",
"length",
")",
";",
"tmpint",
"=",
"null",
";",
"}",
"tmp",
"=",
"null",
";",
"return",
"this",
";",
"}"
] | Invert the order of points coordinates of this element and reorder the groupIndex too.
<p>NOTE: invert each parts with {@link MapComposedElement#invertPointsIn(int)}
does'nt produce the same result as {@link MapComposedElement#invert()}
<p>This method invert points coordinates AND start index of parts to
keep the logical order of points
this method is reversible
<p>{@code this.invert() == this.invert().invert()}
@return the inverted element | [
"Invert",
"the",
"order",
"of",
"points",
"coordinates",
"of",
"this",
"element",
"and",
"reorder",
"the",
"groupIndex",
"too",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L750-L772 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.getPointAt | @Pure
public Point2d getPointAt(int index) {
final int count = getPointCount();
int idx = index;
if (idx < 0) {
idx = count + idx;
}
if (idx < 0) {
throw new IndexOutOfBoundsException(idx + "<0"); //$NON-NLS-1$
}
if (idx >= count) {
throw new IndexOutOfBoundsException(idx + ">=" + count); //$NON-NLS-1$
}
return new Point2d(
this.pointCoordinates[idx * 2],
this.pointCoordinates[idx * 2 + 1]);
} | java | @Pure
public Point2d getPointAt(int index) {
final int count = getPointCount();
int idx = index;
if (idx < 0) {
idx = count + idx;
}
if (idx < 0) {
throw new IndexOutOfBoundsException(idx + "<0"); //$NON-NLS-1$
}
if (idx >= count) {
throw new IndexOutOfBoundsException(idx + ">=" + count); //$NON-NLS-1$
}
return new Point2d(
this.pointCoordinates[idx * 2],
this.pointCoordinates[idx * 2 + 1]);
} | [
"@",
"Pure",
"public",
"Point2d",
"getPointAt",
"(",
"int",
"index",
")",
"{",
"final",
"int",
"count",
"=",
"getPointCount",
"(",
")",
";",
"int",
"idx",
"=",
"index",
";",
"if",
"(",
"idx",
"<",
"0",
")",
"{",
"idx",
"=",
"count",
"+",
"idx",
";",
"}",
"if",
"(",
"idx",
"<",
"0",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"idx",
"+",
"\"<0\"",
")",
";",
"//$NON-NLS-1$",
"}",
"if",
"(",
"idx",
">=",
"count",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"idx",
"+",
"\">=\"",
"+",
"count",
")",
";",
"//$NON-NLS-1$",
"}",
"return",
"new",
"Point2d",
"(",
"this",
".",
"pointCoordinates",
"[",
"idx",
"*",
"2",
"]",
",",
"this",
".",
"pointCoordinates",
"[",
"idx",
"*",
"2",
"+",
"1",
"]",
")",
";",
"}"
] | Replies the specified point at the given index.
<p>If the <var>index</var> is negative, it will corresponds
to an index starting from the end of the list.
@param index is the index of the desired point
@return the point at the given index
@throws IndexOutOfBoundsException in case of error. | [
"Replies",
"the",
"specified",
"point",
"at",
"the",
"given",
"index",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L864-L880 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.getPointAt | @Pure
public Point2d getPointAt(int groupIndex, int indexInGroup) {
final int startIndex = firstInGroup(groupIndex);
// Besure that the member's index is in the group index's range
final int groupMemberCount = getPointCountInGroup(groupIndex);
if (indexInGroup < 0) {
throw new IndexOutOfBoundsException(indexInGroup + "<0"); //$NON-NLS-1$
}
if (indexInGroup >= groupMemberCount) {
throw new IndexOutOfBoundsException(indexInGroup + ">=" + groupMemberCount); //$NON-NLS-1$
}
return new Point2d(
this.pointCoordinates[startIndex + indexInGroup * 2],
this.pointCoordinates[startIndex + indexInGroup * 2 + 1]);
} | java | @Pure
public Point2d getPointAt(int groupIndex, int indexInGroup) {
final int startIndex = firstInGroup(groupIndex);
// Besure that the member's index is in the group index's range
final int groupMemberCount = getPointCountInGroup(groupIndex);
if (indexInGroup < 0) {
throw new IndexOutOfBoundsException(indexInGroup + "<0"); //$NON-NLS-1$
}
if (indexInGroup >= groupMemberCount) {
throw new IndexOutOfBoundsException(indexInGroup + ">=" + groupMemberCount); //$NON-NLS-1$
}
return new Point2d(
this.pointCoordinates[startIndex + indexInGroup * 2],
this.pointCoordinates[startIndex + indexInGroup * 2 + 1]);
} | [
"@",
"Pure",
"public",
"Point2d",
"getPointAt",
"(",
"int",
"groupIndex",
",",
"int",
"indexInGroup",
")",
"{",
"final",
"int",
"startIndex",
"=",
"firstInGroup",
"(",
"groupIndex",
")",
";",
"// Besure that the member's index is in the group index's range",
"final",
"int",
"groupMemberCount",
"=",
"getPointCountInGroup",
"(",
"groupIndex",
")",
";",
"if",
"(",
"indexInGroup",
"<",
"0",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"indexInGroup",
"+",
"\"<0\"",
")",
";",
"//$NON-NLS-1$",
"}",
"if",
"(",
"indexInGroup",
">=",
"groupMemberCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"indexInGroup",
"+",
"\">=\"",
"+",
"groupMemberCount",
")",
";",
"//$NON-NLS-1$",
"}",
"return",
"new",
"Point2d",
"(",
"this",
".",
"pointCoordinates",
"[",
"startIndex",
"+",
"indexInGroup",
"*",
"2",
"]",
",",
"this",
".",
"pointCoordinates",
"[",
"startIndex",
"+",
"indexInGroup",
"*",
"2",
"+",
"1",
"]",
")",
";",
"}"
] | Replies the specified point at the given index in the specified group.
@param groupIndex is the index of the group
@param indexInGroup is the index of the point in the group (0 for the
first point of the group...).
@return the point
@throws IndexOutOfBoundsException in case of error. | [
"Replies",
"the",
"specified",
"point",
"at",
"the",
"given",
"index",
"in",
"the",
"specified",
"group",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L890-L906 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.removeGroupAt | public boolean removeGroupAt(int groupIndex) {
try {
final int startIndex = firstInGroup(groupIndex);
final int lastIndex = lastInGroup(groupIndex);
final int ptsToRemoveCount = (lastIndex - startIndex + 2) / 2;
int rest = this.pointCoordinates.length / 2 - ptsToRemoveCount;
if (rest > 0) {
// Remove the points
rest *= 2;
final double[] newPts = new double[rest];
System.arraycopy(this.pointCoordinates, 0, newPts, 0, startIndex);
System.arraycopy(
this.pointCoordinates, lastIndex + 2,
newPts, startIndex,
rest - startIndex);
this.pointCoordinates = newPts;
// Remove the group
if (this.partIndexes != null) {
// Shift the group's indexes
for (int i = groupIndex; i < this.partIndexes.length; ++i) {
this.partIndexes[i] -= ptsToRemoveCount * 2;
}
// Removing the group
int[] newGroups = null;
if (this.partIndexes.length > 1) {
newGroups = new int[this.partIndexes.length - 1];
if (groupIndex == 0) {
System.arraycopy(this.partIndexes, 1, newGroups, 0, this.partIndexes.length - 1);
} else {
System.arraycopy(this.partIndexes, 0, newGroups, 0, groupIndex - 1);
System.arraycopy(
this.partIndexes, groupIndex,
newGroups, groupIndex - 1,
this.partIndexes.length - groupIndex);
}
}
this.partIndexes = newGroups;
}
} else {
// Remove all the points
this.pointCoordinates = null;
this.partIndexes = null;
}
fireShapeChanged();
fireElementChanged();
return true;
} catch (IndexOutOfBoundsException exception) {
//
}
return false;
} | java | public boolean removeGroupAt(int groupIndex) {
try {
final int startIndex = firstInGroup(groupIndex);
final int lastIndex = lastInGroup(groupIndex);
final int ptsToRemoveCount = (lastIndex - startIndex + 2) / 2;
int rest = this.pointCoordinates.length / 2 - ptsToRemoveCount;
if (rest > 0) {
// Remove the points
rest *= 2;
final double[] newPts = new double[rest];
System.arraycopy(this.pointCoordinates, 0, newPts, 0, startIndex);
System.arraycopy(
this.pointCoordinates, lastIndex + 2,
newPts, startIndex,
rest - startIndex);
this.pointCoordinates = newPts;
// Remove the group
if (this.partIndexes != null) {
// Shift the group's indexes
for (int i = groupIndex; i < this.partIndexes.length; ++i) {
this.partIndexes[i] -= ptsToRemoveCount * 2;
}
// Removing the group
int[] newGroups = null;
if (this.partIndexes.length > 1) {
newGroups = new int[this.partIndexes.length - 1];
if (groupIndex == 0) {
System.arraycopy(this.partIndexes, 1, newGroups, 0, this.partIndexes.length - 1);
} else {
System.arraycopy(this.partIndexes, 0, newGroups, 0, groupIndex - 1);
System.arraycopy(
this.partIndexes, groupIndex,
newGroups, groupIndex - 1,
this.partIndexes.length - groupIndex);
}
}
this.partIndexes = newGroups;
}
} else {
// Remove all the points
this.pointCoordinates = null;
this.partIndexes = null;
}
fireShapeChanged();
fireElementChanged();
return true;
} catch (IndexOutOfBoundsException exception) {
//
}
return false;
} | [
"public",
"boolean",
"removeGroupAt",
"(",
"int",
"groupIndex",
")",
"{",
"try",
"{",
"final",
"int",
"startIndex",
"=",
"firstInGroup",
"(",
"groupIndex",
")",
";",
"final",
"int",
"lastIndex",
"=",
"lastInGroup",
"(",
"groupIndex",
")",
";",
"final",
"int",
"ptsToRemoveCount",
"=",
"(",
"lastIndex",
"-",
"startIndex",
"+",
"2",
")",
"/",
"2",
";",
"int",
"rest",
"=",
"this",
".",
"pointCoordinates",
".",
"length",
"/",
"2",
"-",
"ptsToRemoveCount",
";",
"if",
"(",
"rest",
">",
"0",
")",
"{",
"// Remove the points",
"rest",
"*=",
"2",
";",
"final",
"double",
"[",
"]",
"newPts",
"=",
"new",
"double",
"[",
"rest",
"]",
";",
"System",
".",
"arraycopy",
"(",
"this",
".",
"pointCoordinates",
",",
"0",
",",
"newPts",
",",
"0",
",",
"startIndex",
")",
";",
"System",
".",
"arraycopy",
"(",
"this",
".",
"pointCoordinates",
",",
"lastIndex",
"+",
"2",
",",
"newPts",
",",
"startIndex",
",",
"rest",
"-",
"startIndex",
")",
";",
"this",
".",
"pointCoordinates",
"=",
"newPts",
";",
"// Remove the group",
"if",
"(",
"this",
".",
"partIndexes",
"!=",
"null",
")",
"{",
"// Shift the group's indexes",
"for",
"(",
"int",
"i",
"=",
"groupIndex",
";",
"i",
"<",
"this",
".",
"partIndexes",
".",
"length",
";",
"++",
"i",
")",
"{",
"this",
".",
"partIndexes",
"[",
"i",
"]",
"-=",
"ptsToRemoveCount",
"*",
"2",
";",
"}",
"// Removing the group",
"int",
"[",
"]",
"newGroups",
"=",
"null",
";",
"if",
"(",
"this",
".",
"partIndexes",
".",
"length",
">",
"1",
")",
"{",
"newGroups",
"=",
"new",
"int",
"[",
"this",
".",
"partIndexes",
".",
"length",
"-",
"1",
"]",
";",
"if",
"(",
"groupIndex",
"==",
"0",
")",
"{",
"System",
".",
"arraycopy",
"(",
"this",
".",
"partIndexes",
",",
"1",
",",
"newGroups",
",",
"0",
",",
"this",
".",
"partIndexes",
".",
"length",
"-",
"1",
")",
";",
"}",
"else",
"{",
"System",
".",
"arraycopy",
"(",
"this",
".",
"partIndexes",
",",
"0",
",",
"newGroups",
",",
"0",
",",
"groupIndex",
"-",
"1",
")",
";",
"System",
".",
"arraycopy",
"(",
"this",
".",
"partIndexes",
",",
"groupIndex",
",",
"newGroups",
",",
"groupIndex",
"-",
"1",
",",
"this",
".",
"partIndexes",
".",
"length",
"-",
"groupIndex",
")",
";",
"}",
"}",
"this",
".",
"partIndexes",
"=",
"newGroups",
";",
"}",
"}",
"else",
"{",
"// Remove all the points",
"this",
".",
"pointCoordinates",
"=",
"null",
";",
"this",
".",
"partIndexes",
"=",
"null",
";",
"}",
"fireShapeChanged",
"(",
")",
";",
"fireElementChanged",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"IndexOutOfBoundsException",
"exception",
")",
"{",
"//",
"}",
"return",
"false",
";",
"}"
] | Remove the specified group.
@param groupIndex the index of the group.
@return <code>true</code> on success, otherwise <code>false</code> | [
"Remove",
"the",
"specified",
"group",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L1090-L1147 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.removePointAt | public Point2d removePointAt(int groupIndex, int indexInGroup) {
final int startIndex = firstInGroup(groupIndex);
final int lastIndex = lastInGroup(groupIndex);
// Translate local point's coordinate into global point's coordinate
final int g = indexInGroup * 2 + startIndex;
// Be sure that the member's index is in the group index's range
if (g < startIndex) {
throw new IndexOutOfBoundsException(g + "<" + startIndex); //$NON-NLS-1$
}
if (g > lastIndex) {
throw new IndexOutOfBoundsException(g + ">" + lastIndex); //$NON-NLS-1$
}
final Point2d p = new Point2d(
this.pointCoordinates[g],
this.pointCoordinates[g + 1]);
// Deleting the point
final double[] newPtsArray;
if (this.pointCoordinates.length <= 2) {
newPtsArray = null;
} else {
newPtsArray = new double[this.pointCoordinates.length - 2];
System.arraycopy(this.pointCoordinates, 0, newPtsArray, 0, g);
System.arraycopy(
this.pointCoordinates, g + 2,
newPtsArray, g, this.pointCoordinates.length - g - 2);
}
this.pointCoordinates = newPtsArray;
if (this.partIndexes != null) {
// Shift the group's indexes
for (int i = groupIndex; i < this.partIndexes.length; ++i) {
this.partIndexes[i] -= 2;
}
// Removing the group
final int ptsCount = (lastIndex - startIndex) / 2;
if (ptsCount <= 0) {
int[] newGroups = null;
if (this.partIndexes.length > 1) {
newGroups = new int[this.partIndexes.length - 1];
if (groupIndex == 0) {
System.arraycopy(this.partIndexes, 1, newGroups, 0, this.partIndexes.length - 1);
} else {
System.arraycopy(this.partIndexes, 0, newGroups, 0, groupIndex - 1);
System.arraycopy(
this.partIndexes, groupIndex,
newGroups, groupIndex - 1,
this.partIndexes.length - groupIndex);
}
}
this.partIndexes = newGroups;
}
}
fireShapeChanged();
fireElementChanged();
return p;
} | java | public Point2d removePointAt(int groupIndex, int indexInGroup) {
final int startIndex = firstInGroup(groupIndex);
final int lastIndex = lastInGroup(groupIndex);
// Translate local point's coordinate into global point's coordinate
final int g = indexInGroup * 2 + startIndex;
// Be sure that the member's index is in the group index's range
if (g < startIndex) {
throw new IndexOutOfBoundsException(g + "<" + startIndex); //$NON-NLS-1$
}
if (g > lastIndex) {
throw new IndexOutOfBoundsException(g + ">" + lastIndex); //$NON-NLS-1$
}
final Point2d p = new Point2d(
this.pointCoordinates[g],
this.pointCoordinates[g + 1]);
// Deleting the point
final double[] newPtsArray;
if (this.pointCoordinates.length <= 2) {
newPtsArray = null;
} else {
newPtsArray = new double[this.pointCoordinates.length - 2];
System.arraycopy(this.pointCoordinates, 0, newPtsArray, 0, g);
System.arraycopy(
this.pointCoordinates, g + 2,
newPtsArray, g, this.pointCoordinates.length - g - 2);
}
this.pointCoordinates = newPtsArray;
if (this.partIndexes != null) {
// Shift the group's indexes
for (int i = groupIndex; i < this.partIndexes.length; ++i) {
this.partIndexes[i] -= 2;
}
// Removing the group
final int ptsCount = (lastIndex - startIndex) / 2;
if (ptsCount <= 0) {
int[] newGroups = null;
if (this.partIndexes.length > 1) {
newGroups = new int[this.partIndexes.length - 1];
if (groupIndex == 0) {
System.arraycopy(this.partIndexes, 1, newGroups, 0, this.partIndexes.length - 1);
} else {
System.arraycopy(this.partIndexes, 0, newGroups, 0, groupIndex - 1);
System.arraycopy(
this.partIndexes, groupIndex,
newGroups, groupIndex - 1,
this.partIndexes.length - groupIndex);
}
}
this.partIndexes = newGroups;
}
}
fireShapeChanged();
fireElementChanged();
return p;
} | [
"public",
"Point2d",
"removePointAt",
"(",
"int",
"groupIndex",
",",
"int",
"indexInGroup",
")",
"{",
"final",
"int",
"startIndex",
"=",
"firstInGroup",
"(",
"groupIndex",
")",
";",
"final",
"int",
"lastIndex",
"=",
"lastInGroup",
"(",
"groupIndex",
")",
";",
"// Translate local point's coordinate into global point's coordinate",
"final",
"int",
"g",
"=",
"indexInGroup",
"*",
"2",
"+",
"startIndex",
";",
"// Be sure that the member's index is in the group index's range",
"if",
"(",
"g",
"<",
"startIndex",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"g",
"+",
"\"<\"",
"+",
"startIndex",
")",
";",
"//$NON-NLS-1$",
"}",
"if",
"(",
"g",
">",
"lastIndex",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"g",
"+",
"\">\"",
"+",
"lastIndex",
")",
";",
"//$NON-NLS-1$",
"}",
"final",
"Point2d",
"p",
"=",
"new",
"Point2d",
"(",
"this",
".",
"pointCoordinates",
"[",
"g",
"]",
",",
"this",
".",
"pointCoordinates",
"[",
"g",
"+",
"1",
"]",
")",
";",
"// Deleting the point",
"final",
"double",
"[",
"]",
"newPtsArray",
";",
"if",
"(",
"this",
".",
"pointCoordinates",
".",
"length",
"<=",
"2",
")",
"{",
"newPtsArray",
"=",
"null",
";",
"}",
"else",
"{",
"newPtsArray",
"=",
"new",
"double",
"[",
"this",
".",
"pointCoordinates",
".",
"length",
"-",
"2",
"]",
";",
"System",
".",
"arraycopy",
"(",
"this",
".",
"pointCoordinates",
",",
"0",
",",
"newPtsArray",
",",
"0",
",",
"g",
")",
";",
"System",
".",
"arraycopy",
"(",
"this",
".",
"pointCoordinates",
",",
"g",
"+",
"2",
",",
"newPtsArray",
",",
"g",
",",
"this",
".",
"pointCoordinates",
".",
"length",
"-",
"g",
"-",
"2",
")",
";",
"}",
"this",
".",
"pointCoordinates",
"=",
"newPtsArray",
";",
"if",
"(",
"this",
".",
"partIndexes",
"!=",
"null",
")",
"{",
"// Shift the group's indexes",
"for",
"(",
"int",
"i",
"=",
"groupIndex",
";",
"i",
"<",
"this",
".",
"partIndexes",
".",
"length",
";",
"++",
"i",
")",
"{",
"this",
".",
"partIndexes",
"[",
"i",
"]",
"-=",
"2",
";",
"}",
"// Removing the group",
"final",
"int",
"ptsCount",
"=",
"(",
"lastIndex",
"-",
"startIndex",
")",
"/",
"2",
";",
"if",
"(",
"ptsCount",
"<=",
"0",
")",
"{",
"int",
"[",
"]",
"newGroups",
"=",
"null",
";",
"if",
"(",
"this",
".",
"partIndexes",
".",
"length",
">",
"1",
")",
"{",
"newGroups",
"=",
"new",
"int",
"[",
"this",
".",
"partIndexes",
".",
"length",
"-",
"1",
"]",
";",
"if",
"(",
"groupIndex",
"==",
"0",
")",
"{",
"System",
".",
"arraycopy",
"(",
"this",
".",
"partIndexes",
",",
"1",
",",
"newGroups",
",",
"0",
",",
"this",
".",
"partIndexes",
".",
"length",
"-",
"1",
")",
";",
"}",
"else",
"{",
"System",
".",
"arraycopy",
"(",
"this",
".",
"partIndexes",
",",
"0",
",",
"newGroups",
",",
"0",
",",
"groupIndex",
"-",
"1",
")",
";",
"System",
".",
"arraycopy",
"(",
"this",
".",
"partIndexes",
",",
"groupIndex",
",",
"newGroups",
",",
"groupIndex",
"-",
"1",
",",
"this",
".",
"partIndexes",
".",
"length",
"-",
"groupIndex",
")",
";",
"}",
"}",
"this",
".",
"partIndexes",
"=",
"newGroups",
";",
"}",
"}",
"fireShapeChanged",
"(",
")",
";",
"fireElementChanged",
"(",
")",
";",
"return",
"p",
";",
"}"
] | Remove the specified point at the given index in the specified group.
@param groupIndex is the index of the group
@param indexInGroup is the index of the ponit in the group (0 for the
first point of the group...).
@return the removed point
@throws IndexOutOfBoundsException in case of error. | [
"Remove",
"the",
"specified",
"point",
"at",
"the",
"given",
"index",
"in",
"the",
"specified",
"group",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L1157-L1220 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.canonize | private boolean canonize(int index) {
final int count = getPointCount();
int ix = index;
if (ix < 0) {
ix = count + ix;
}
if (ix < 0) {
throw new IndexOutOfBoundsException(ix + "<0"); //$NON-NLS-1$
}
if (ix >= count) {
throw new IndexOutOfBoundsException(ix + ">=" + count); //$NON-NLS-1$
}
final int partIndex = groupIndexForPoint(ix);
final int firstPts = firstInGroup(partIndex);
final int endPts = lastInGroup(partIndex);
final int myIndex = ix * 2;
int firstToRemove = myIndex;
int lastToRemove = myIndex;
boolean removeOne = false;
final double xbase = this.pointCoordinates[ix * 2];
final double ybase = this.pointCoordinates[ix * 2 + 1];
final PointFusionValidator validator = getPointFusionValidator();
// Search for the first point to remove
for (int idx = myIndex - 2; idx >= firstPts; idx -= 2) {
final double x = this.pointCoordinates[idx];
final double y = this.pointCoordinates[idx + 1];
if (validator.isSame(xbase, ybase, x, y)) {
firstToRemove = idx;
removeOne = true;
} else {
// Stop search
break;
}
}
// Search for the last point to remove
for (int idx = myIndex + 2; idx <= endPts; idx += 2) {
final double x = this.pointCoordinates[idx];
final double y = this.pointCoordinates[idx + 1];
if (validator.isSame(xbase, ybase, x, y)) {
lastToRemove = idx;
removeOne = true;
} else {
// Stop search
break;
}
}
if (removeOne) {
// A set of points are detected as too near.
// They should be removed and replaced by the reference point
final int removalCount = (lastToRemove / 2 - firstToRemove / 2) * 2;
// Deleting the point
final double[] newPtsArray = new double[this.pointCoordinates.length - removalCount];
assert newPtsArray.length >= 2;
System.arraycopy(this.pointCoordinates, 0, newPtsArray, 0, firstToRemove);
System.arraycopy(this.pointCoordinates, lastToRemove + 2, newPtsArray,
firstToRemove + 2, this.pointCoordinates.length - lastToRemove - 2);
newPtsArray[firstToRemove] = xbase;
newPtsArray[firstToRemove + 1] = ybase;
this.pointCoordinates = newPtsArray;
if (this.partIndexes != null) {
// Shift the group's indexes
for (int i = partIndex; i < this.partIndexes.length; ++i) {
this.partIndexes[i] -= removalCount;
}
}
return true;
}
return false;
} | java | private boolean canonize(int index) {
final int count = getPointCount();
int ix = index;
if (ix < 0) {
ix = count + ix;
}
if (ix < 0) {
throw new IndexOutOfBoundsException(ix + "<0"); //$NON-NLS-1$
}
if (ix >= count) {
throw new IndexOutOfBoundsException(ix + ">=" + count); //$NON-NLS-1$
}
final int partIndex = groupIndexForPoint(ix);
final int firstPts = firstInGroup(partIndex);
final int endPts = lastInGroup(partIndex);
final int myIndex = ix * 2;
int firstToRemove = myIndex;
int lastToRemove = myIndex;
boolean removeOne = false;
final double xbase = this.pointCoordinates[ix * 2];
final double ybase = this.pointCoordinates[ix * 2 + 1];
final PointFusionValidator validator = getPointFusionValidator();
// Search for the first point to remove
for (int idx = myIndex - 2; idx >= firstPts; idx -= 2) {
final double x = this.pointCoordinates[idx];
final double y = this.pointCoordinates[idx + 1];
if (validator.isSame(xbase, ybase, x, y)) {
firstToRemove = idx;
removeOne = true;
} else {
// Stop search
break;
}
}
// Search for the last point to remove
for (int idx = myIndex + 2; idx <= endPts; idx += 2) {
final double x = this.pointCoordinates[idx];
final double y = this.pointCoordinates[idx + 1];
if (validator.isSame(xbase, ybase, x, y)) {
lastToRemove = idx;
removeOne = true;
} else {
// Stop search
break;
}
}
if (removeOne) {
// A set of points are detected as too near.
// They should be removed and replaced by the reference point
final int removalCount = (lastToRemove / 2 - firstToRemove / 2) * 2;
// Deleting the point
final double[] newPtsArray = new double[this.pointCoordinates.length - removalCount];
assert newPtsArray.length >= 2;
System.arraycopy(this.pointCoordinates, 0, newPtsArray, 0, firstToRemove);
System.arraycopy(this.pointCoordinates, lastToRemove + 2, newPtsArray,
firstToRemove + 2, this.pointCoordinates.length - lastToRemove - 2);
newPtsArray[firstToRemove] = xbase;
newPtsArray[firstToRemove + 1] = ybase;
this.pointCoordinates = newPtsArray;
if (this.partIndexes != null) {
// Shift the group's indexes
for (int i = partIndex; i < this.partIndexes.length; ++i) {
this.partIndexes[i] -= removalCount;
}
}
return true;
}
return false;
} | [
"private",
"boolean",
"canonize",
"(",
"int",
"index",
")",
"{",
"final",
"int",
"count",
"=",
"getPointCount",
"(",
")",
";",
"int",
"ix",
"=",
"index",
";",
"if",
"(",
"ix",
"<",
"0",
")",
"{",
"ix",
"=",
"count",
"+",
"ix",
";",
"}",
"if",
"(",
"ix",
"<",
"0",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"ix",
"+",
"\"<0\"",
")",
";",
"//$NON-NLS-1$",
"}",
"if",
"(",
"ix",
">=",
"count",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"ix",
"+",
"\">=\"",
"+",
"count",
")",
";",
"//$NON-NLS-1$",
"}",
"final",
"int",
"partIndex",
"=",
"groupIndexForPoint",
"(",
"ix",
")",
";",
"final",
"int",
"firstPts",
"=",
"firstInGroup",
"(",
"partIndex",
")",
";",
"final",
"int",
"endPts",
"=",
"lastInGroup",
"(",
"partIndex",
")",
";",
"final",
"int",
"myIndex",
"=",
"ix",
"*",
"2",
";",
"int",
"firstToRemove",
"=",
"myIndex",
";",
"int",
"lastToRemove",
"=",
"myIndex",
";",
"boolean",
"removeOne",
"=",
"false",
";",
"final",
"double",
"xbase",
"=",
"this",
".",
"pointCoordinates",
"[",
"ix",
"*",
"2",
"]",
";",
"final",
"double",
"ybase",
"=",
"this",
".",
"pointCoordinates",
"[",
"ix",
"*",
"2",
"+",
"1",
"]",
";",
"final",
"PointFusionValidator",
"validator",
"=",
"getPointFusionValidator",
"(",
")",
";",
"// Search for the first point to remove",
"for",
"(",
"int",
"idx",
"=",
"myIndex",
"-",
"2",
";",
"idx",
">=",
"firstPts",
";",
"idx",
"-=",
"2",
")",
"{",
"final",
"double",
"x",
"=",
"this",
".",
"pointCoordinates",
"[",
"idx",
"]",
";",
"final",
"double",
"y",
"=",
"this",
".",
"pointCoordinates",
"[",
"idx",
"+",
"1",
"]",
";",
"if",
"(",
"validator",
".",
"isSame",
"(",
"xbase",
",",
"ybase",
",",
"x",
",",
"y",
")",
")",
"{",
"firstToRemove",
"=",
"idx",
";",
"removeOne",
"=",
"true",
";",
"}",
"else",
"{",
"// Stop search",
"break",
";",
"}",
"}",
"// Search for the last point to remove",
"for",
"(",
"int",
"idx",
"=",
"myIndex",
"+",
"2",
";",
"idx",
"<=",
"endPts",
";",
"idx",
"+=",
"2",
")",
"{",
"final",
"double",
"x",
"=",
"this",
".",
"pointCoordinates",
"[",
"idx",
"]",
";",
"final",
"double",
"y",
"=",
"this",
".",
"pointCoordinates",
"[",
"idx",
"+",
"1",
"]",
";",
"if",
"(",
"validator",
".",
"isSame",
"(",
"xbase",
",",
"ybase",
",",
"x",
",",
"y",
")",
")",
"{",
"lastToRemove",
"=",
"idx",
";",
"removeOne",
"=",
"true",
";",
"}",
"else",
"{",
"// Stop search",
"break",
";",
"}",
"}",
"if",
"(",
"removeOne",
")",
"{",
"// A set of points are detected as too near.",
"// They should be removed and replaced by the reference point",
"final",
"int",
"removalCount",
"=",
"(",
"lastToRemove",
"/",
"2",
"-",
"firstToRemove",
"/",
"2",
")",
"*",
"2",
";",
"// Deleting the point",
"final",
"double",
"[",
"]",
"newPtsArray",
"=",
"new",
"double",
"[",
"this",
".",
"pointCoordinates",
".",
"length",
"-",
"removalCount",
"]",
";",
"assert",
"newPtsArray",
".",
"length",
">=",
"2",
";",
"System",
".",
"arraycopy",
"(",
"this",
".",
"pointCoordinates",
",",
"0",
",",
"newPtsArray",
",",
"0",
",",
"firstToRemove",
")",
";",
"System",
".",
"arraycopy",
"(",
"this",
".",
"pointCoordinates",
",",
"lastToRemove",
"+",
"2",
",",
"newPtsArray",
",",
"firstToRemove",
"+",
"2",
",",
"this",
".",
"pointCoordinates",
".",
"length",
"-",
"lastToRemove",
"-",
"2",
")",
";",
"newPtsArray",
"[",
"firstToRemove",
"]",
"=",
"xbase",
";",
"newPtsArray",
"[",
"firstToRemove",
"+",
"1",
"]",
"=",
"ybase",
";",
"this",
".",
"pointCoordinates",
"=",
"newPtsArray",
";",
"if",
"(",
"this",
".",
"partIndexes",
"!=",
"null",
")",
"{",
"// Shift the group's indexes",
"for",
"(",
"int",
"i",
"=",
"partIndex",
";",
"i",
"<",
"this",
".",
"partIndexes",
".",
"length",
";",
"++",
"i",
")",
"{",
"this",
".",
"partIndexes",
"[",
"i",
"]",
"-=",
"removalCount",
";",
"}",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Remove unnecessary points from the specified index.
@return <code>true</code> if points are removed, otherwise <code>false</code> | [
"Remove",
"unnecessary",
"points",
"from",
"the",
"specified",
"index",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L1234-L1318 | train |
digitalfondue/stampo | src/main/java/ch/digitalfondue/stampo/processor/IncludeAllPaginator.java | IncludeAllPaginator.addOutputInformation | private Optional<IncludeAllPageWithOutput> addOutputInformation(IncludeAllPage pages, FileResource baseResource, Path includeAllBasePath, Locale locale) {
// depth = 0 is the file that has the include-all directive
if (pages.depth == 0) {
return of(new IncludeAllPageWithOutput(pages, pages.files.get(0), pages.files.get(0).getPath(), locale));
}
Path baseResourceParentPath = baseResource.getPath().getParent();
Optional<FileResource> virtualResource = pages.files.stream().findFirst()
.map(fr -> new VirtualPathFileResource(baseResourceParentPath.resolve(includeAllBasePath.relativize(fr.getPath()).toString()), fr));
return virtualResource.map(vr -> {
Path finalOutputPath = outputPathExtractor.apply(vr).normalize();
return new IncludeAllPageWithOutput(pages, vr, finalOutputPath, locale);
});
} | java | private Optional<IncludeAllPageWithOutput> addOutputInformation(IncludeAllPage pages, FileResource baseResource, Path includeAllBasePath, Locale locale) {
// depth = 0 is the file that has the include-all directive
if (pages.depth == 0) {
return of(new IncludeAllPageWithOutput(pages, pages.files.get(0), pages.files.get(0).getPath(), locale));
}
Path baseResourceParentPath = baseResource.getPath().getParent();
Optional<FileResource> virtualResource = pages.files.stream().findFirst()
.map(fr -> new VirtualPathFileResource(baseResourceParentPath.resolve(includeAllBasePath.relativize(fr.getPath()).toString()), fr));
return virtualResource.map(vr -> {
Path finalOutputPath = outputPathExtractor.apply(vr).normalize();
return new IncludeAllPageWithOutput(pages, vr, finalOutputPath, locale);
});
} | [
"private",
"Optional",
"<",
"IncludeAllPageWithOutput",
">",
"addOutputInformation",
"(",
"IncludeAllPage",
"pages",
",",
"FileResource",
"baseResource",
",",
"Path",
"includeAllBasePath",
",",
"Locale",
"locale",
")",
"{",
"// depth = 0 is the file that has the include-all directive",
"if",
"(",
"pages",
".",
"depth",
"==",
"0",
")",
"{",
"return",
"of",
"(",
"new",
"IncludeAllPageWithOutput",
"(",
"pages",
",",
"pages",
".",
"files",
".",
"get",
"(",
"0",
")",
",",
"pages",
".",
"files",
".",
"get",
"(",
"0",
")",
".",
"getPath",
"(",
")",
",",
"locale",
")",
")",
";",
"}",
"Path",
"baseResourceParentPath",
"=",
"baseResource",
".",
"getPath",
"(",
")",
".",
"getParent",
"(",
")",
";",
"Optional",
"<",
"FileResource",
">",
"virtualResource",
"=",
"pages",
".",
"files",
".",
"stream",
"(",
")",
".",
"findFirst",
"(",
")",
".",
"map",
"(",
"fr",
"->",
"new",
"VirtualPathFileResource",
"(",
"baseResourceParentPath",
".",
"resolve",
"(",
"includeAllBasePath",
".",
"relativize",
"(",
"fr",
".",
"getPath",
"(",
")",
")",
".",
"toString",
"(",
")",
")",
",",
"fr",
")",
")",
";",
"return",
"virtualResource",
".",
"map",
"(",
"vr",
"->",
"{",
"Path",
"finalOutputPath",
"=",
"outputPathExtractor",
".",
"apply",
"(",
"vr",
")",
".",
"normalize",
"(",
")",
";",
"return",
"new",
"IncludeAllPageWithOutput",
"(",
"pages",
",",
"vr",
",",
"finalOutputPath",
",",
"locale",
")",
";",
"}",
")",
";",
"}"
] | generate the final output path | [
"generate",
"the",
"final",
"output",
"path"
] | 5a41f20acd9211cf3951c30d0e0825994ae95573 | https://github.com/digitalfondue/stampo/blob/5a41f20acd9211cf3951c30d0e0825994ae95573/src/main/java/ch/digitalfondue/stampo/processor/IncludeAllPaginator.java#L214-L230 | train |
killme2008/hs4j | src/main/java/com/google/code/hs4j/network/nio/impl/SelectorManager.java | SelectorManager.getReactorByIndex | public Reactor getReactorByIndex(int index) {
if (index < 0 || index > reactorSet.length - 1) {
throw new ArrayIndexOutOfBoundsException();
}
return reactorSet[index];
} | java | public Reactor getReactorByIndex(int index) {
if (index < 0 || index > reactorSet.length - 1) {
throw new ArrayIndexOutOfBoundsException();
}
return reactorSet[index];
} | [
"public",
"Reactor",
"getReactorByIndex",
"(",
"int",
"index",
")",
"{",
"if",
"(",
"index",
"<",
"0",
"||",
"index",
">",
"reactorSet",
".",
"length",
"-",
"1",
")",
"{",
"throw",
"new",
"ArrayIndexOutOfBoundsException",
"(",
")",
";",
"}",
"return",
"reactorSet",
"[",
"index",
"]",
";",
"}"
] | Find reactor by index
@param index
@return | [
"Find",
"reactor",
"by",
"index"
] | 805fe14bfe270d95009514c224d93c5fe3575f11 | https://github.com/killme2008/hs4j/blob/805fe14bfe270d95009514c224d93c5fe3575f11/src/main/java/com/google/code/hs4j/network/nio/impl/SelectorManager.java#L82-L87 | train |
lightblueseas/swing-components | src/main/java/de/alpharogroup/swing/paint/PainterExtensions.java | PainterExtensions.getCompoundPainter | @SuppressWarnings("rawtypes")
public static CompoundPainter getCompoundPainter(final Color matte, final Color gloss,
final GlossPainter.GlossPosition position, final double angle, final Color pinstripe)
{
final MattePainter mp = new MattePainter(matte);
final GlossPainter gp = new GlossPainter(gloss, position);
final PinstripePainter pp = new PinstripePainter(pinstripe, angle);
final CompoundPainter compoundPainter = new CompoundPainter(mp, pp, gp);
return compoundPainter;
} | java | @SuppressWarnings("rawtypes")
public static CompoundPainter getCompoundPainter(final Color matte, final Color gloss,
final GlossPainter.GlossPosition position, final double angle, final Color pinstripe)
{
final MattePainter mp = new MattePainter(matte);
final GlossPainter gp = new GlossPainter(gloss, position);
final PinstripePainter pp = new PinstripePainter(pinstripe, angle);
final CompoundPainter compoundPainter = new CompoundPainter(mp, pp, gp);
return compoundPainter;
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"public",
"static",
"CompoundPainter",
"getCompoundPainter",
"(",
"final",
"Color",
"matte",
",",
"final",
"Color",
"gloss",
",",
"final",
"GlossPainter",
".",
"GlossPosition",
"position",
",",
"final",
"double",
"angle",
",",
"final",
"Color",
"pinstripe",
")",
"{",
"final",
"MattePainter",
"mp",
"=",
"new",
"MattePainter",
"(",
"matte",
")",
";",
"final",
"GlossPainter",
"gp",
"=",
"new",
"GlossPainter",
"(",
"gloss",
",",
"position",
")",
";",
"final",
"PinstripePainter",
"pp",
"=",
"new",
"PinstripePainter",
"(",
"pinstripe",
",",
"angle",
")",
";",
"final",
"CompoundPainter",
"compoundPainter",
"=",
"new",
"CompoundPainter",
"(",
"mp",
",",
"pp",
",",
"gp",
")",
";",
"return",
"compoundPainter",
";",
"}"
] | Gets a CompoundPainter object.
@param matte
the matte color
@param gloss
the gloss color
@param position
the position
@param angle
the angle
@param pinstripe
the pinstripe painter
@return the CompoundPainter object. | [
"Gets",
"a",
"CompoundPainter",
"object",
"."
] | 4045e85cabd8f0ce985cbfff134c3c9873930c79 | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/paint/PainterExtensions.java#L56-L66 | train |
lightblueseas/swing-components | src/main/java/de/alpharogroup/swing/paint/PainterExtensions.java | PainterExtensions.getCompoundPainter | @SuppressWarnings("rawtypes")
public static CompoundPainter getCompoundPainter(final Color color,
final GlossPainter.GlossPosition position, final double angle)
{
final MattePainter mp = new MattePainter(color);
final GlossPainter gp = new GlossPainter(color, position);
final PinstripePainter pp = new PinstripePainter(color, angle);
final CompoundPainter compoundPainter = new CompoundPainter(mp, pp, gp);
return compoundPainter;
} | java | @SuppressWarnings("rawtypes")
public static CompoundPainter getCompoundPainter(final Color color,
final GlossPainter.GlossPosition position, final double angle)
{
final MattePainter mp = new MattePainter(color);
final GlossPainter gp = new GlossPainter(color, position);
final PinstripePainter pp = new PinstripePainter(color, angle);
final CompoundPainter compoundPainter = new CompoundPainter(mp, pp, gp);
return compoundPainter;
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"public",
"static",
"CompoundPainter",
"getCompoundPainter",
"(",
"final",
"Color",
"color",
",",
"final",
"GlossPainter",
".",
"GlossPosition",
"position",
",",
"final",
"double",
"angle",
")",
"{",
"final",
"MattePainter",
"mp",
"=",
"new",
"MattePainter",
"(",
"color",
")",
";",
"final",
"GlossPainter",
"gp",
"=",
"new",
"GlossPainter",
"(",
"color",
",",
"position",
")",
";",
"final",
"PinstripePainter",
"pp",
"=",
"new",
"PinstripePainter",
"(",
"color",
",",
"angle",
")",
";",
"final",
"CompoundPainter",
"compoundPainter",
"=",
"new",
"CompoundPainter",
"(",
"mp",
",",
"pp",
",",
"gp",
")",
";",
"return",
"compoundPainter",
";",
"}"
] | Gets the compound painter.
@param color
the color
@param position
the position
@param angle
the angle
@return the compound painter | [
"Gets",
"the",
"compound",
"painter",
"."
] | 4045e85cabd8f0ce985cbfff134c3c9873930c79 | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/paint/PainterExtensions.java#L79-L89 | train |
lightblueseas/swing-components | src/main/java/de/alpharogroup/swing/paint/PainterExtensions.java | PainterExtensions.getMattePainter | public static MattePainter getMattePainter(final int width, final int height,
final float[] fractions, final Color... colors)
{
final LinearGradientPaint gradientPaint = new LinearGradientPaint(0.0f, 0.0f, width, height,
fractions, colors);
final MattePainter mattePainter = new MattePainter(gradientPaint);
return mattePainter;
} | java | public static MattePainter getMattePainter(final int width, final int height,
final float[] fractions, final Color... colors)
{
final LinearGradientPaint gradientPaint = new LinearGradientPaint(0.0f, 0.0f, width, height,
fractions, colors);
final MattePainter mattePainter = new MattePainter(gradientPaint);
return mattePainter;
} | [
"public",
"static",
"MattePainter",
"getMattePainter",
"(",
"final",
"int",
"width",
",",
"final",
"int",
"height",
",",
"final",
"float",
"[",
"]",
"fractions",
",",
"final",
"Color",
"...",
"colors",
")",
"{",
"final",
"LinearGradientPaint",
"gradientPaint",
"=",
"new",
"LinearGradientPaint",
"(",
"0.0f",
",",
"0.0f",
",",
"width",
",",
"height",
",",
"fractions",
",",
"colors",
")",
";",
"final",
"MattePainter",
"mattePainter",
"=",
"new",
"MattePainter",
"(",
"gradientPaint",
")",
";",
"return",
"mattePainter",
";",
"}"
] | Gets a MattePainter object.
@param width
the width
@param height
the height
@param fractions
the fractions
@param colors
the colors
@return the MattePainter object | [
"Gets",
"a",
"MattePainter",
"object",
"."
] | 4045e85cabd8f0ce985cbfff134c3c9873930c79 | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/paint/PainterExtensions.java#L104-L112 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Sphere3f.java | Sphere3f.set | @Override
public void set(Point3D center, double radius1) {
this.cx = center.getX();
this.cy = center.getY();
this.cz = center.getZ();
this.radius = Math.abs(radius1);
} | java | @Override
public void set(Point3D center, double radius1) {
this.cx = center.getX();
this.cy = center.getY();
this.cz = center.getZ();
this.radius = Math.abs(radius1);
} | [
"@",
"Override",
"public",
"void",
"set",
"(",
"Point3D",
"center",
",",
"double",
"radius1",
")",
"{",
"this",
".",
"cx",
"=",
"center",
".",
"getX",
"(",
")",
";",
"this",
".",
"cy",
"=",
"center",
".",
"getY",
"(",
")",
";",
"this",
".",
"cz",
"=",
"center",
".",
"getZ",
"(",
")",
";",
"this",
".",
"radius",
"=",
"Math",
".",
"abs",
"(",
"radius1",
")",
";",
"}"
] | Change the frame of te sphere.
@param center
@param radius1 | [
"Change",
"the",
"frame",
"of",
"te",
"sphere",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Sphere3f.java#L80-L86 | train |
gallandarakhneorg/afc | advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d3/dfx/MultiShape3dfx.java | MultiShape3dfx.elementsProperty | public ListProperty<T> elementsProperty() {
if (this.elements == null) {
this.elements = new SimpleListProperty<>(this,
MathFXAttributeNames.ELEMENTS, new InternalObservableList<>());
}
return this.elements;
} | java | public ListProperty<T> elementsProperty() {
if (this.elements == null) {
this.elements = new SimpleListProperty<>(this,
MathFXAttributeNames.ELEMENTS, new InternalObservableList<>());
}
return this.elements;
} | [
"public",
"ListProperty",
"<",
"T",
">",
"elementsProperty",
"(",
")",
"{",
"if",
"(",
"this",
".",
"elements",
"==",
"null",
")",
"{",
"this",
".",
"elements",
"=",
"new",
"SimpleListProperty",
"<>",
"(",
"this",
",",
"MathFXAttributeNames",
".",
"ELEMENTS",
",",
"new",
"InternalObservableList",
"<>",
"(",
")",
")",
";",
"}",
"return",
"this",
".",
"elements",
";",
"}"
] | Replies the property that contains all the shapes in this multishape.
@return the elements property. | [
"Replies",
"the",
"property",
"that",
"contains",
"all",
"the",
"shapes",
"in",
"this",
"multishape",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d3/dfx/MultiShape3dfx.java#L102-L108 | train |
gallandarakhneorg/afc | core/util/src/main/java/org/arakhne/afc/util/InformedArrayList.java | InformedArrayList.extractClassFrom | @SuppressWarnings("unchecked")
protected static <E> Class<? extends E> extractClassFrom(Collection<? extends E> collection) {
Class<? extends E> clazz = null;
for (final E elt : collection) {
clazz = (Class<? extends E>) ReflectionUtil.getCommonType(clazz, elt.getClass());
}
return clazz == null ? (Class<E>) Object.class : clazz;
} | java | @SuppressWarnings("unchecked")
protected static <E> Class<? extends E> extractClassFrom(Collection<? extends E> collection) {
Class<? extends E> clazz = null;
for (final E elt : collection) {
clazz = (Class<? extends E>) ReflectionUtil.getCommonType(clazz, elt.getClass());
}
return clazz == null ? (Class<E>) Object.class : clazz;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"static",
"<",
"E",
">",
"Class",
"<",
"?",
"extends",
"E",
">",
"extractClassFrom",
"(",
"Collection",
"<",
"?",
"extends",
"E",
">",
"collection",
")",
"{",
"Class",
"<",
"?",
"extends",
"E",
">",
"clazz",
"=",
"null",
";",
"for",
"(",
"final",
"E",
"elt",
":",
"collection",
")",
"{",
"clazz",
"=",
"(",
"Class",
"<",
"?",
"extends",
"E",
">",
")",
"ReflectionUtil",
".",
"getCommonType",
"(",
"clazz",
",",
"elt",
".",
"getClass",
"(",
")",
")",
";",
"}",
"return",
"clazz",
"==",
"null",
"?",
"(",
"Class",
"<",
"E",
">",
")",
"Object",
".",
"class",
":",
"clazz",
";",
"}"
] | Extract the upper class that contains all the elements of
this array.
@param <E> is the type of the list's elements.
@param collection is the collection to scan
@return the top class of all the elements. | [
"Extract",
"the",
"upper",
"class",
"that",
"contains",
"all",
"the",
"elements",
"of",
"this",
"array",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/util/src/main/java/org/arakhne/afc/util/InformedArrayList.java#L120-L127 | train |
lightblueseas/swing-components | src/main/java/de/alpharogroup/swing/base/BaseDesktopMenu.java | BaseDesktopMenu.getHelpSet | public HelpSet getHelpSet()
{
HelpSet hs = null;
final String filename = "simple-hs.xml";
final String path = "help/" + filename;
URL hsURL;
hsURL = ClassExtensions.getResource(path);
try
{
if(hsURL != null) {
hs = new HelpSet(ClassExtensions.getClassLoader(), hsURL);
} else {
hs = new HelpSet();
}
}
catch (final HelpSetException e)
{
String title = e.getLocalizedMessage();
String htmlMessage = "<html><body width='650'>" + "<h2>" + title + "</h2>" + "<p>"
+ e.getMessage() + "\n" + path ;
JOptionPane.showMessageDialog(this.getParent(), htmlMessage, title,
JOptionPane.ERROR_MESSAGE);
log.log(Level.SEVERE, e.getMessage(), e);
}
return hs;
} | java | public HelpSet getHelpSet()
{
HelpSet hs = null;
final String filename = "simple-hs.xml";
final String path = "help/" + filename;
URL hsURL;
hsURL = ClassExtensions.getResource(path);
try
{
if(hsURL != null) {
hs = new HelpSet(ClassExtensions.getClassLoader(), hsURL);
} else {
hs = new HelpSet();
}
}
catch (final HelpSetException e)
{
String title = e.getLocalizedMessage();
String htmlMessage = "<html><body width='650'>" + "<h2>" + title + "</h2>" + "<p>"
+ e.getMessage() + "\n" + path ;
JOptionPane.showMessageDialog(this.getParent(), htmlMessage, title,
JOptionPane.ERROR_MESSAGE);
log.log(Level.SEVERE, e.getMessage(), e);
}
return hs;
} | [
"public",
"HelpSet",
"getHelpSet",
"(",
")",
"{",
"HelpSet",
"hs",
"=",
"null",
";",
"final",
"String",
"filename",
"=",
"\"simple-hs.xml\"",
";",
"final",
"String",
"path",
"=",
"\"help/\"",
"+",
"filename",
";",
"URL",
"hsURL",
";",
"hsURL",
"=",
"ClassExtensions",
".",
"getResource",
"(",
"path",
")",
";",
"try",
"{",
"if",
"(",
"hsURL",
"!=",
"null",
")",
"{",
"hs",
"=",
"new",
"HelpSet",
"(",
"ClassExtensions",
".",
"getClassLoader",
"(",
")",
",",
"hsURL",
")",
";",
"}",
"else",
"{",
"hs",
"=",
"new",
"HelpSet",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"HelpSetException",
"e",
")",
"{",
"String",
"title",
"=",
"e",
".",
"getLocalizedMessage",
"(",
")",
";",
"String",
"htmlMessage",
"=",
"\"<html><body width='650'>\"",
"+",
"\"<h2>\"",
"+",
"title",
"+",
"\"</h2>\"",
"+",
"\"<p>\"",
"+",
"e",
".",
"getMessage",
"(",
")",
"+",
"\"\\n\"",
"+",
"path",
";",
"JOptionPane",
".",
"showMessageDialog",
"(",
"this",
".",
"getParent",
"(",
")",
",",
"htmlMessage",
",",
"title",
",",
"JOptionPane",
".",
"ERROR_MESSAGE",
")",
";",
"log",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"return",
"hs",
";",
"}"
] | Gets the help set.
@return the help set | [
"Gets",
"the",
"help",
"set",
"."
] | 4045e85cabd8f0ce985cbfff134c3c9873930c79 | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/base/BaseDesktopMenu.java#L131-L156 | train |
lightblueseas/swing-components | src/main/java/de/alpharogroup/swing/base/BaseDesktopMenu.java | BaseDesktopMenu.newHelpMenu | protected JMenu newHelpMenu(final ActionListener listener)
{
// Help menu
final JMenu menuHelp = new JMenu(newLabelTextHelp());
menuHelp.setMnemonic('H');
// Help JMenuItems
// Help content
final JMenuItem mihHelpContent = JComponentFactory.newJMenuItem(newLabelTextContent(), 'c',
'H');
menuHelp.add(mihHelpContent);
// 2. assign help to components
CSH.setHelpIDString(mihHelpContent, newLabelTextOverview());
// 3. handle events
final CSH.DisplayHelpFromSource displayHelpFromSource = new CSH.DisplayHelpFromSource(
helpBroker);
mihHelpContent.addActionListener(displayHelpFromSource);
// Donate
final JMenuItem mihDonate = new JMenuItem(newLabelTextDonate());
mihDonate.addActionListener(
newOpenBrowserToDonateAction(newLabelTextDonate(), applicationFrame));
menuHelp.add(mihDonate);
// Licence
final JMenuItem mihLicence = new JMenuItem(newLabelTextLicence());
mihLicence.addActionListener(
newShowLicenseFrameAction(newLabelTextLicence() + "Action", newLabelTextLicence()));
menuHelp.add(mihLicence);
// Info
final JMenuItem mihInfo = new JMenuItem(newLabelTextInfo(), 'i'); // $NON-NLS-1$
MenuExtensions.setCtrlAccelerator(mihInfo, 'I');
mihInfo.addActionListener(newShowInfoDialogAction(newLabelTextInfo(),
(Frame)applicationFrame, newLabelTextInfo()));
menuHelp.add(mihInfo);
return menuHelp;
} | java | protected JMenu newHelpMenu(final ActionListener listener)
{
// Help menu
final JMenu menuHelp = new JMenu(newLabelTextHelp());
menuHelp.setMnemonic('H');
// Help JMenuItems
// Help content
final JMenuItem mihHelpContent = JComponentFactory.newJMenuItem(newLabelTextContent(), 'c',
'H');
menuHelp.add(mihHelpContent);
// 2. assign help to components
CSH.setHelpIDString(mihHelpContent, newLabelTextOverview());
// 3. handle events
final CSH.DisplayHelpFromSource displayHelpFromSource = new CSH.DisplayHelpFromSource(
helpBroker);
mihHelpContent.addActionListener(displayHelpFromSource);
// Donate
final JMenuItem mihDonate = new JMenuItem(newLabelTextDonate());
mihDonate.addActionListener(
newOpenBrowserToDonateAction(newLabelTextDonate(), applicationFrame));
menuHelp.add(mihDonate);
// Licence
final JMenuItem mihLicence = new JMenuItem(newLabelTextLicence());
mihLicence.addActionListener(
newShowLicenseFrameAction(newLabelTextLicence() + "Action", newLabelTextLicence()));
menuHelp.add(mihLicence);
// Info
final JMenuItem mihInfo = new JMenuItem(newLabelTextInfo(), 'i'); // $NON-NLS-1$
MenuExtensions.setCtrlAccelerator(mihInfo, 'I');
mihInfo.addActionListener(newShowInfoDialogAction(newLabelTextInfo(),
(Frame)applicationFrame, newLabelTextInfo()));
menuHelp.add(mihInfo);
return menuHelp;
} | [
"protected",
"JMenu",
"newHelpMenu",
"(",
"final",
"ActionListener",
"listener",
")",
"{",
"// Help menu",
"final",
"JMenu",
"menuHelp",
"=",
"new",
"JMenu",
"(",
"newLabelTextHelp",
"(",
")",
")",
";",
"menuHelp",
".",
"setMnemonic",
"(",
"'",
"'",
")",
";",
"// Help JMenuItems",
"// Help content",
"final",
"JMenuItem",
"mihHelpContent",
"=",
"JComponentFactory",
".",
"newJMenuItem",
"(",
"newLabelTextContent",
"(",
")",
",",
"'",
"'",
",",
"'",
"'",
")",
";",
"menuHelp",
".",
"add",
"(",
"mihHelpContent",
")",
";",
"// 2. assign help to components",
"CSH",
".",
"setHelpIDString",
"(",
"mihHelpContent",
",",
"newLabelTextOverview",
"(",
")",
")",
";",
"// 3. handle events",
"final",
"CSH",
".",
"DisplayHelpFromSource",
"displayHelpFromSource",
"=",
"new",
"CSH",
".",
"DisplayHelpFromSource",
"(",
"helpBroker",
")",
";",
"mihHelpContent",
".",
"addActionListener",
"(",
"displayHelpFromSource",
")",
";",
"// Donate",
"final",
"JMenuItem",
"mihDonate",
"=",
"new",
"JMenuItem",
"(",
"newLabelTextDonate",
"(",
")",
")",
";",
"mihDonate",
".",
"addActionListener",
"(",
"newOpenBrowserToDonateAction",
"(",
"newLabelTextDonate",
"(",
")",
",",
"applicationFrame",
")",
")",
";",
"menuHelp",
".",
"add",
"(",
"mihDonate",
")",
";",
"// Licence",
"final",
"JMenuItem",
"mihLicence",
"=",
"new",
"JMenuItem",
"(",
"newLabelTextLicence",
"(",
")",
")",
";",
"mihLicence",
".",
"addActionListener",
"(",
"newShowLicenseFrameAction",
"(",
"newLabelTextLicence",
"(",
")",
"+",
"\"Action\"",
",",
"newLabelTextLicence",
"(",
")",
")",
")",
";",
"menuHelp",
".",
"add",
"(",
"mihLicence",
")",
";",
"// Info",
"final",
"JMenuItem",
"mihInfo",
"=",
"new",
"JMenuItem",
"(",
"newLabelTextInfo",
"(",
")",
",",
"'",
"'",
")",
";",
"// $NON-NLS-1$",
"MenuExtensions",
".",
"setCtrlAccelerator",
"(",
"mihInfo",
",",
"'",
"'",
")",
";",
"mihInfo",
".",
"addActionListener",
"(",
"newShowInfoDialogAction",
"(",
"newLabelTextInfo",
"(",
")",
",",
"(",
"Frame",
")",
"applicationFrame",
",",
"newLabelTextInfo",
"(",
")",
")",
")",
";",
"menuHelp",
".",
"add",
"(",
"mihInfo",
")",
";",
"return",
"menuHelp",
";",
"}"
] | Creates the help menu.
@param listener
the listener
@return the j menu | [
"Creates",
"the",
"help",
"menu",
"."
] | 4045e85cabd8f0ce985cbfff134c3c9873930c79 | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/base/BaseDesktopMenu.java#L204-L241 | train |
lightblueseas/swing-components | src/main/java/de/alpharogroup/swing/base/BaseDesktopMenu.java | BaseDesktopMenu.newLookAndFeelMenu | protected JMenu newLookAndFeelMenu(final ActionListener listener)
{
final JMenu menuLookAndFeel = new JMenu("Look and Feel");
menuLookAndFeel.setMnemonic('L');
// Look and Feel JMenuItems
// GTK
JMenuItem jmiPlafGTK;
jmiPlafGTK = new JMenuItem("GTK", 'g'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafGTK, 'G');
jmiPlafGTK.addActionListener(new LookAndFeelGTKAction("GTK", this.applicationFrame));
menuLookAndFeel.add(jmiPlafGTK);
// Metal default Metal theme
JMenuItem jmiPlafMetal;
jmiPlafMetal = new JMenuItem("Metal", 'm'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafMetal, 'M');
jmiPlafMetal.addActionListener(new LookAndFeelMetalAction("Metal", this.applicationFrame));
menuLookAndFeel.add(jmiPlafMetal);
// Metal Ocean theme
JMenuItem jmiPlafOcean;
jmiPlafOcean = new JMenuItem("Ocean", 'o'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafOcean, 'O');
jmiPlafOcean.addActionListener(new LookAndFeelMetalAction("Ocean", this.applicationFrame));
menuLookAndFeel.add(jmiPlafOcean);
// Motif
JMenuItem jmiPlafMotiv;
jmiPlafMotiv = new JMenuItem("Motif", 't'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafMotiv, 'T');
jmiPlafMotiv.addActionListener(new LookAndFeelMotifAction("Motif", this.applicationFrame));
menuLookAndFeel.add(jmiPlafMotiv);
// Nimbus
JMenuItem jmiPlafNimbus;
jmiPlafNimbus = new JMenuItem("Nimbus", 'n'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafNimbus, 'N');
jmiPlafNimbus
.addActionListener(new LookAndFeelNimbusAction("Nimbus", this.applicationFrame));
menuLookAndFeel.add(jmiPlafNimbus);
// Windows
JMenuItem jmiPlafSystem;
jmiPlafSystem = new JMenuItem("System", 'd'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafSystem, 'W');
jmiPlafSystem
.addActionListener(new LookAndFeelSystemAction("System", this.applicationFrame));
menuLookAndFeel.add(jmiPlafSystem);
return menuLookAndFeel;
} | java | protected JMenu newLookAndFeelMenu(final ActionListener listener)
{
final JMenu menuLookAndFeel = new JMenu("Look and Feel");
menuLookAndFeel.setMnemonic('L');
// Look and Feel JMenuItems
// GTK
JMenuItem jmiPlafGTK;
jmiPlafGTK = new JMenuItem("GTK", 'g'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafGTK, 'G');
jmiPlafGTK.addActionListener(new LookAndFeelGTKAction("GTK", this.applicationFrame));
menuLookAndFeel.add(jmiPlafGTK);
// Metal default Metal theme
JMenuItem jmiPlafMetal;
jmiPlafMetal = new JMenuItem("Metal", 'm'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafMetal, 'M');
jmiPlafMetal.addActionListener(new LookAndFeelMetalAction("Metal", this.applicationFrame));
menuLookAndFeel.add(jmiPlafMetal);
// Metal Ocean theme
JMenuItem jmiPlafOcean;
jmiPlafOcean = new JMenuItem("Ocean", 'o'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafOcean, 'O');
jmiPlafOcean.addActionListener(new LookAndFeelMetalAction("Ocean", this.applicationFrame));
menuLookAndFeel.add(jmiPlafOcean);
// Motif
JMenuItem jmiPlafMotiv;
jmiPlafMotiv = new JMenuItem("Motif", 't'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafMotiv, 'T');
jmiPlafMotiv.addActionListener(new LookAndFeelMotifAction("Motif", this.applicationFrame));
menuLookAndFeel.add(jmiPlafMotiv);
// Nimbus
JMenuItem jmiPlafNimbus;
jmiPlafNimbus = new JMenuItem("Nimbus", 'n'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafNimbus, 'N');
jmiPlafNimbus
.addActionListener(new LookAndFeelNimbusAction("Nimbus", this.applicationFrame));
menuLookAndFeel.add(jmiPlafNimbus);
// Windows
JMenuItem jmiPlafSystem;
jmiPlafSystem = new JMenuItem("System", 'd'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafSystem, 'W');
jmiPlafSystem
.addActionListener(new LookAndFeelSystemAction("System", this.applicationFrame));
menuLookAndFeel.add(jmiPlafSystem);
return menuLookAndFeel;
} | [
"protected",
"JMenu",
"newLookAndFeelMenu",
"(",
"final",
"ActionListener",
"listener",
")",
"{",
"final",
"JMenu",
"menuLookAndFeel",
"=",
"new",
"JMenu",
"(",
"\"Look and Feel\"",
")",
";",
"menuLookAndFeel",
".",
"setMnemonic",
"(",
"'",
"'",
")",
";",
"// Look and Feel JMenuItems",
"// GTK",
"JMenuItem",
"jmiPlafGTK",
";",
"jmiPlafGTK",
"=",
"new",
"JMenuItem",
"(",
"\"GTK\"",
",",
"'",
"'",
")",
";",
"//$NON-NLS-1$",
"MenuExtensions",
".",
"setCtrlAccelerator",
"(",
"jmiPlafGTK",
",",
"'",
"'",
")",
";",
"jmiPlafGTK",
".",
"addActionListener",
"(",
"new",
"LookAndFeelGTKAction",
"(",
"\"GTK\"",
",",
"this",
".",
"applicationFrame",
")",
")",
";",
"menuLookAndFeel",
".",
"add",
"(",
"jmiPlafGTK",
")",
";",
"// Metal default Metal theme",
"JMenuItem",
"jmiPlafMetal",
";",
"jmiPlafMetal",
"=",
"new",
"JMenuItem",
"(",
"\"Metal\"",
",",
"'",
"'",
")",
";",
"//$NON-NLS-1$",
"MenuExtensions",
".",
"setCtrlAccelerator",
"(",
"jmiPlafMetal",
",",
"'",
"'",
")",
";",
"jmiPlafMetal",
".",
"addActionListener",
"(",
"new",
"LookAndFeelMetalAction",
"(",
"\"Metal\"",
",",
"this",
".",
"applicationFrame",
")",
")",
";",
"menuLookAndFeel",
".",
"add",
"(",
"jmiPlafMetal",
")",
";",
"// Metal Ocean theme",
"JMenuItem",
"jmiPlafOcean",
";",
"jmiPlafOcean",
"=",
"new",
"JMenuItem",
"(",
"\"Ocean\"",
",",
"'",
"'",
")",
";",
"//$NON-NLS-1$",
"MenuExtensions",
".",
"setCtrlAccelerator",
"(",
"jmiPlafOcean",
",",
"'",
"'",
")",
";",
"jmiPlafOcean",
".",
"addActionListener",
"(",
"new",
"LookAndFeelMetalAction",
"(",
"\"Ocean\"",
",",
"this",
".",
"applicationFrame",
")",
")",
";",
"menuLookAndFeel",
".",
"add",
"(",
"jmiPlafOcean",
")",
";",
"// Motif",
"JMenuItem",
"jmiPlafMotiv",
";",
"jmiPlafMotiv",
"=",
"new",
"JMenuItem",
"(",
"\"Motif\"",
",",
"'",
"'",
")",
";",
"//$NON-NLS-1$",
"MenuExtensions",
".",
"setCtrlAccelerator",
"(",
"jmiPlafMotiv",
",",
"'",
"'",
")",
";",
"jmiPlafMotiv",
".",
"addActionListener",
"(",
"new",
"LookAndFeelMotifAction",
"(",
"\"Motif\"",
",",
"this",
".",
"applicationFrame",
")",
")",
";",
"menuLookAndFeel",
".",
"add",
"(",
"jmiPlafMotiv",
")",
";",
"// Nimbus",
"JMenuItem",
"jmiPlafNimbus",
";",
"jmiPlafNimbus",
"=",
"new",
"JMenuItem",
"(",
"\"Nimbus\"",
",",
"'",
"'",
")",
";",
"//$NON-NLS-1$",
"MenuExtensions",
".",
"setCtrlAccelerator",
"(",
"jmiPlafNimbus",
",",
"'",
"'",
")",
";",
"jmiPlafNimbus",
".",
"addActionListener",
"(",
"new",
"LookAndFeelNimbusAction",
"(",
"\"Nimbus\"",
",",
"this",
".",
"applicationFrame",
")",
")",
";",
"menuLookAndFeel",
".",
"add",
"(",
"jmiPlafNimbus",
")",
";",
"// Windows",
"JMenuItem",
"jmiPlafSystem",
";",
"jmiPlafSystem",
"=",
"new",
"JMenuItem",
"(",
"\"System\"",
",",
"'",
"'",
")",
";",
"//$NON-NLS-1$",
"MenuExtensions",
".",
"setCtrlAccelerator",
"(",
"jmiPlafSystem",
",",
"'",
"'",
")",
";",
"jmiPlafSystem",
".",
"addActionListener",
"(",
"new",
"LookAndFeelSystemAction",
"(",
"\"System\"",
",",
"this",
".",
"applicationFrame",
")",
")",
";",
"menuLookAndFeel",
".",
"add",
"(",
"jmiPlafSystem",
")",
";",
"return",
"menuLookAndFeel",
";",
"}"
] | Creates the look and feel menu.
@param listener
the listener
@return the j menu | [
"Creates",
"the",
"look",
"and",
"feel",
"menu",
"."
] | 4045e85cabd8f0ce985cbfff134c3c9873930c79 | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/base/BaseDesktopMenu.java#L357-L405 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.