id int32 0 165k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
137,900 | TheHortonMachine/hortonmachine | dbs/src/main/java/org/hortonmachine/dbs/spatialite/SpatialiteCommonMethods.java | SpatialiteCommonMethods.checkCompatibilityIssues | public static String checkCompatibilityIssues( String sql ) {
sql = sql.replaceAll("LONG PRIMARY KEY AUTOINCREMENT", "INTEGER PRIMARY KEY AUTOINCREMENT");
sql = sql.replaceAll("AUTO_INCREMENT", "AUTOINCREMENT");
return sql;
} | java | public static String checkCompatibilityIssues( String sql ) {
sql = sql.replaceAll("LONG PRIMARY KEY AUTOINCREMENT", "INTEGER PRIMARY KEY AUTOINCREMENT");
sql = sql.replaceAll("AUTO_INCREMENT", "AUTOINCREMENT");
return sql;
} | [
"public",
"static",
"String",
"checkCompatibilityIssues",
"(",
"String",
"sql",
")",
"{",
"sql",
"=",
"sql",
".",
"replaceAll",
"(",
"\"LONG PRIMARY KEY AUTOINCREMENT\"",
",",
"\"INTEGER PRIMARY KEY AUTOINCREMENT\"",
")",
";",
"sql",
"=",
"sql",
".",
"replaceAll",
"(",
"\"AUTO_INCREMENT\"",
",",
"\"AUTOINCREMENT\"",
")",
";",
"return",
"sql",
";",
"}"
] | Check for compatibility issues with other databases.
@param sql the original sql.
@return the fixed sql. | [
"Check",
"for",
"compatibility",
"issues",
"with",
"other",
"databases",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/dbs/spatialite/SpatialiteCommonMethods.java#L76-L80 |
137,901 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/Controller.java | Controller.mapOut | void mapOut(String out, Object comp, String comp_out) {
if (comp == ca.getComponent()) {
throw new ComponentException("cannot connect 'Out' with itself for " + out);
}
ComponentAccess ac_dest = lookup(comp);
FieldAccess destAccess = (FieldAccess) ac_dest.output(comp_out);
FieldAccess srcAccess = (FieldAccess) ca.output(out);
checkFA(destAccess, comp, comp_out);
checkFA(srcAccess, ca.getComponent(), out);
FieldContent data = srcAccess.getData();
data.tagLeaf();
data.tagOut();
destAccess.setData(data);
dataSet.add(data);
if (log.isLoggable(Level.CONFIG)) {
log.log(Level.CONFIG, String.format("@Out(%s) -> @Out(%s)", srcAccess, destAccess));
}
// ens.fireMapOut(srcAccess, destAccess);
} | java | void mapOut(String out, Object comp, String comp_out) {
if (comp == ca.getComponent()) {
throw new ComponentException("cannot connect 'Out' with itself for " + out);
}
ComponentAccess ac_dest = lookup(comp);
FieldAccess destAccess = (FieldAccess) ac_dest.output(comp_out);
FieldAccess srcAccess = (FieldAccess) ca.output(out);
checkFA(destAccess, comp, comp_out);
checkFA(srcAccess, ca.getComponent(), out);
FieldContent data = srcAccess.getData();
data.tagLeaf();
data.tagOut();
destAccess.setData(data);
dataSet.add(data);
if (log.isLoggable(Level.CONFIG)) {
log.log(Level.CONFIG, String.format("@Out(%s) -> @Out(%s)", srcAccess, destAccess));
}
// ens.fireMapOut(srcAccess, destAccess);
} | [
"void",
"mapOut",
"(",
"String",
"out",
",",
"Object",
"comp",
",",
"String",
"comp_out",
")",
"{",
"if",
"(",
"comp",
"==",
"ca",
".",
"getComponent",
"(",
")",
")",
"{",
"throw",
"new",
"ComponentException",
"(",
"\"cannot connect 'Out' with itself for \"",
"+",
"out",
")",
";",
"}",
"ComponentAccess",
"ac_dest",
"=",
"lookup",
"(",
"comp",
")",
";",
"FieldAccess",
"destAccess",
"=",
"(",
"FieldAccess",
")",
"ac_dest",
".",
"output",
"(",
"comp_out",
")",
";",
"FieldAccess",
"srcAccess",
"=",
"(",
"FieldAccess",
")",
"ca",
".",
"output",
"(",
"out",
")",
";",
"checkFA",
"(",
"destAccess",
",",
"comp",
",",
"comp_out",
")",
";",
"checkFA",
"(",
"srcAccess",
",",
"ca",
".",
"getComponent",
"(",
")",
",",
"out",
")",
";",
"FieldContent",
"data",
"=",
"srcAccess",
".",
"getData",
"(",
")",
";",
"data",
".",
"tagLeaf",
"(",
")",
";",
"data",
".",
"tagOut",
"(",
")",
";",
"destAccess",
".",
"setData",
"(",
"data",
")",
";",
"dataSet",
".",
"add",
"(",
"data",
")",
";",
"if",
"(",
"log",
".",
"isLoggable",
"(",
"Level",
".",
"CONFIG",
")",
")",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"CONFIG",
",",
"String",
".",
"format",
"(",
"\"@Out(%s) -> @Out(%s)\"",
",",
"srcAccess",
",",
"destAccess",
")",
")",
";",
"}",
"// ens.fireMapOut(srcAccess, destAccess);",
"}"
] | Map two output fields.
@param out the output field name of this component
@param comp the component
@param comp_out the component output name; | [
"Map",
"two",
"output",
"fields",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/Controller.java#L85-L106 |
137,902 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/Controller.java | Controller.mapIn | void mapIn(String in, Object comp, String comp_in) {
if (comp == ca.getComponent()) {
throw new ComponentException("cannot connect 'In' with itself for " + in);
}
ComponentAccess ac_dest = lookup(comp);
FieldAccess destAccess = (FieldAccess) ac_dest.input(comp_in);
checkFA(destAccess, comp, comp_in);
FieldAccess srcAccess = (FieldAccess) ca.input(in);
checkFA(srcAccess, ca.getComponent(), in);
FieldContent data = srcAccess.getData();
data.tagLeaf();
data.tagIn();
destAccess.setData(data);
dataSet.add(data);
if (log.isLoggable(Level.CONFIG)) {
log.config(String.format("@In(%s) -> @In(%s)", srcAccess, destAccess));
}
// ens.fireMapIn(srcAccess, destAccess);
} | java | void mapIn(String in, Object comp, String comp_in) {
if (comp == ca.getComponent()) {
throw new ComponentException("cannot connect 'In' with itself for " + in);
}
ComponentAccess ac_dest = lookup(comp);
FieldAccess destAccess = (FieldAccess) ac_dest.input(comp_in);
checkFA(destAccess, comp, comp_in);
FieldAccess srcAccess = (FieldAccess) ca.input(in);
checkFA(srcAccess, ca.getComponent(), in);
FieldContent data = srcAccess.getData();
data.tagLeaf();
data.tagIn();
destAccess.setData(data);
dataSet.add(data);
if (log.isLoggable(Level.CONFIG)) {
log.config(String.format("@In(%s) -> @In(%s)", srcAccess, destAccess));
}
// ens.fireMapIn(srcAccess, destAccess);
} | [
"void",
"mapIn",
"(",
"String",
"in",
",",
"Object",
"comp",
",",
"String",
"comp_in",
")",
"{",
"if",
"(",
"comp",
"==",
"ca",
".",
"getComponent",
"(",
")",
")",
"{",
"throw",
"new",
"ComponentException",
"(",
"\"cannot connect 'In' with itself for \"",
"+",
"in",
")",
";",
"}",
"ComponentAccess",
"ac_dest",
"=",
"lookup",
"(",
"comp",
")",
";",
"FieldAccess",
"destAccess",
"=",
"(",
"FieldAccess",
")",
"ac_dest",
".",
"input",
"(",
"comp_in",
")",
";",
"checkFA",
"(",
"destAccess",
",",
"comp",
",",
"comp_in",
")",
";",
"FieldAccess",
"srcAccess",
"=",
"(",
"FieldAccess",
")",
"ca",
".",
"input",
"(",
"in",
")",
";",
"checkFA",
"(",
"srcAccess",
",",
"ca",
".",
"getComponent",
"(",
")",
",",
"in",
")",
";",
"FieldContent",
"data",
"=",
"srcAccess",
".",
"getData",
"(",
")",
";",
"data",
".",
"tagLeaf",
"(",
")",
";",
"data",
".",
"tagIn",
"(",
")",
";",
"destAccess",
".",
"setData",
"(",
"data",
")",
";",
"dataSet",
".",
"add",
"(",
"data",
")",
";",
"if",
"(",
"log",
".",
"isLoggable",
"(",
"Level",
".",
"CONFIG",
")",
")",
"{",
"log",
".",
"config",
"(",
"String",
".",
"format",
"(",
"\"@In(%s) -> @In(%s)\"",
",",
"srcAccess",
",",
"destAccess",
")",
")",
";",
"}",
"// ens.fireMapIn(srcAccess, destAccess);",
"}"
] | Map two input fields.
@param in
@param comp
@param comp_in | [
"Map",
"two",
"input",
"fields",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/Controller.java#L114-L134 |
137,903 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/Controller.java | Controller.mapInVal | void mapInVal(Object val, Object to, String to_in) {
if (val == null) {
throw new ComponentException("Null value for " + name(to, to_in));
}
if (to == ca.getComponent()) {
throw new ComponentException("field and component ar ethe same for mapping :" + to_in);
}
ComponentAccess ca_to = lookup(to);
Access to_access = ca_to.input(to_in);
checkFA(to_access, to, to_in);
ca_to.setInput(to_in, new FieldValueAccess(to_access, val));
if (log.isLoggable(Level.CONFIG)) {
log.config(String.format("Value(%s) -> @In(%s)", val.toString(), to_access.toString()));
}
} | java | void mapInVal(Object val, Object to, String to_in) {
if (val == null) {
throw new ComponentException("Null value for " + name(to, to_in));
}
if (to == ca.getComponent()) {
throw new ComponentException("field and component ar ethe same for mapping :" + to_in);
}
ComponentAccess ca_to = lookup(to);
Access to_access = ca_to.input(to_in);
checkFA(to_access, to, to_in);
ca_to.setInput(to_in, new FieldValueAccess(to_access, val));
if (log.isLoggable(Level.CONFIG)) {
log.config(String.format("Value(%s) -> @In(%s)", val.toString(), to_access.toString()));
}
} | [
"void",
"mapInVal",
"(",
"Object",
"val",
",",
"Object",
"to",
",",
"String",
"to_in",
")",
"{",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"throw",
"new",
"ComponentException",
"(",
"\"Null value for \"",
"+",
"name",
"(",
"to",
",",
"to_in",
")",
")",
";",
"}",
"if",
"(",
"to",
"==",
"ca",
".",
"getComponent",
"(",
")",
")",
"{",
"throw",
"new",
"ComponentException",
"(",
"\"field and component ar ethe same for mapping :\"",
"+",
"to_in",
")",
";",
"}",
"ComponentAccess",
"ca_to",
"=",
"lookup",
"(",
"to",
")",
";",
"Access",
"to_access",
"=",
"ca_to",
".",
"input",
"(",
"to_in",
")",
";",
"checkFA",
"(",
"to_access",
",",
"to",
",",
"to_in",
")",
";",
"ca_to",
".",
"setInput",
"(",
"to_in",
",",
"new",
"FieldValueAccess",
"(",
"to_access",
",",
"val",
")",
")",
";",
"if",
"(",
"log",
".",
"isLoggable",
"(",
"Level",
".",
"CONFIG",
")",
")",
"{",
"log",
".",
"config",
"(",
"String",
".",
"format",
"(",
"\"Value(%s) -> @In(%s)\"",
",",
"val",
".",
"toString",
"(",
")",
",",
"to_access",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"}"
] | Directly map a value to a input field.
@param val
@param to
@param to_in | [
"Directly",
"map",
"a",
"value",
"to",
"a",
"input",
"field",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/Controller.java#L142-L156 |
137,904 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/Controller.java | Controller.mapInField | void mapInField(Object from, String from_field, Object to, String to_in) {
if (to == ca.getComponent()) {
throw new ComponentException("wrong connect:" + from_field);
}
ComponentAccess ca_to = lookup(to);
Access to_access = ca_to.input(to_in);
checkFA(to_access, to, to_in);
try {
FieldContent.FA f = new FieldContent.FA(from, from_field);
ca_to.setInput(to_in, new FieldObjectAccess(to_access, f, ens));
if (log.isLoggable(Level.CONFIG)) {
log.config(String.format("Field(%s) -> @In(%s)", f.toString(), to_access.toString()));
}
} catch (Exception E) {
throw new ComponentException("No such field '" + from.getClass().getCanonicalName() + "." + from_field + "'");
}
} | java | void mapInField(Object from, String from_field, Object to, String to_in) {
if (to == ca.getComponent()) {
throw new ComponentException("wrong connect:" + from_field);
}
ComponentAccess ca_to = lookup(to);
Access to_access = ca_to.input(to_in);
checkFA(to_access, to, to_in);
try {
FieldContent.FA f = new FieldContent.FA(from, from_field);
ca_to.setInput(to_in, new FieldObjectAccess(to_access, f, ens));
if (log.isLoggable(Level.CONFIG)) {
log.config(String.format("Field(%s) -> @In(%s)", f.toString(), to_access.toString()));
}
} catch (Exception E) {
throw new ComponentException("No such field '" + from.getClass().getCanonicalName() + "." + from_field + "'");
}
} | [
"void",
"mapInField",
"(",
"Object",
"from",
",",
"String",
"from_field",
",",
"Object",
"to",
",",
"String",
"to_in",
")",
"{",
"if",
"(",
"to",
"==",
"ca",
".",
"getComponent",
"(",
")",
")",
"{",
"throw",
"new",
"ComponentException",
"(",
"\"wrong connect:\"",
"+",
"from_field",
")",
";",
"}",
"ComponentAccess",
"ca_to",
"=",
"lookup",
"(",
"to",
")",
";",
"Access",
"to_access",
"=",
"ca_to",
".",
"input",
"(",
"to_in",
")",
";",
"checkFA",
"(",
"to_access",
",",
"to",
",",
"to_in",
")",
";",
"try",
"{",
"FieldContent",
".",
"FA",
"f",
"=",
"new",
"FieldContent",
".",
"FA",
"(",
"from",
",",
"from_field",
")",
";",
"ca_to",
".",
"setInput",
"(",
"to_in",
",",
"new",
"FieldObjectAccess",
"(",
"to_access",
",",
"f",
",",
"ens",
")",
")",
";",
"if",
"(",
"log",
".",
"isLoggable",
"(",
"Level",
".",
"CONFIG",
")",
")",
"{",
"log",
".",
"config",
"(",
"String",
".",
"format",
"(",
"\"Field(%s) -> @In(%s)\"",
",",
"f",
".",
"toString",
"(",
")",
",",
"to_access",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"E",
")",
"{",
"throw",
"new",
"ComponentException",
"(",
"\"No such field '\"",
"+",
"from",
".",
"getClass",
"(",
")",
".",
"getCanonicalName",
"(",
")",
"+",
"\".\"",
"+",
"from_field",
"+",
"\"'\"",
")",
";",
"}",
"}"
] | Map an input field.
@param from
@param from_field
@param to
@param to_in | [
"Map",
"an",
"input",
"field",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/Controller.java#L165-L182 |
137,905 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/Controller.java | Controller.mapOutField | void mapOutField(Object from, String from_out, Object to, String to_field) {
if (from == ca.getComponent()) {
throw new ComponentException("wrong connect:" + to_field);
}
ComponentAccess ca_from = lookup(from);
Access from_access = ca_from.output(from_out);
checkFA(from_access, from, from_out);
try {
FieldContent.FA f = new FieldContent.FA(to, to_field);
ca_from.setOutput(from_out, new FieldObjectAccess(from_access, f, ens));
if (log.isLoggable(Level.CONFIG)) {
log.config(String.format("@Out(%s) -> field(%s)", from_access, f.toString()));
}
} catch (Exception E) {
throw new ComponentException("No such field '" + to.getClass().getCanonicalName() + "." + to_field + "'");
}
} | java | void mapOutField(Object from, String from_out, Object to, String to_field) {
if (from == ca.getComponent()) {
throw new ComponentException("wrong connect:" + to_field);
}
ComponentAccess ca_from = lookup(from);
Access from_access = ca_from.output(from_out);
checkFA(from_access, from, from_out);
try {
FieldContent.FA f = new FieldContent.FA(to, to_field);
ca_from.setOutput(from_out, new FieldObjectAccess(from_access, f, ens));
if (log.isLoggable(Level.CONFIG)) {
log.config(String.format("@Out(%s) -> field(%s)", from_access, f.toString()));
}
} catch (Exception E) {
throw new ComponentException("No such field '" + to.getClass().getCanonicalName() + "." + to_field + "'");
}
} | [
"void",
"mapOutField",
"(",
"Object",
"from",
",",
"String",
"from_out",
",",
"Object",
"to",
",",
"String",
"to_field",
")",
"{",
"if",
"(",
"from",
"==",
"ca",
".",
"getComponent",
"(",
")",
")",
"{",
"throw",
"new",
"ComponentException",
"(",
"\"wrong connect:\"",
"+",
"to_field",
")",
";",
"}",
"ComponentAccess",
"ca_from",
"=",
"lookup",
"(",
"from",
")",
";",
"Access",
"from_access",
"=",
"ca_from",
".",
"output",
"(",
"from_out",
")",
";",
"checkFA",
"(",
"from_access",
",",
"from",
",",
"from_out",
")",
";",
"try",
"{",
"FieldContent",
".",
"FA",
"f",
"=",
"new",
"FieldContent",
".",
"FA",
"(",
"to",
",",
"to_field",
")",
";",
"ca_from",
".",
"setOutput",
"(",
"from_out",
",",
"new",
"FieldObjectAccess",
"(",
"from_access",
",",
"f",
",",
"ens",
")",
")",
";",
"if",
"(",
"log",
".",
"isLoggable",
"(",
"Level",
".",
"CONFIG",
")",
")",
"{",
"log",
".",
"config",
"(",
"String",
".",
"format",
"(",
"\"@Out(%s) -> field(%s)\"",
",",
"from_access",
",",
"f",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"E",
")",
"{",
"throw",
"new",
"ComponentException",
"(",
"\"No such field '\"",
"+",
"to",
".",
"getClass",
"(",
")",
".",
"getCanonicalName",
"(",
")",
"+",
"\".\"",
"+",
"to_field",
"+",
"\"'\"",
")",
";",
"}",
"}"
] | Map a object to an output field.
@param from
@param from_out
@param to
@param to_field | [
"Map",
"a",
"object",
"to",
"an",
"output",
"field",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/Controller.java#L191-L209 |
137,906 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/Controller.java | Controller.connect | void connect(Object from, String from_out, Object to, String to_in) {
// add them to the set of commands
if (from == to) {
throw new ComponentException("src == dest.");
}
if (to_in == null || from_out == null) {
throw new ComponentException("Some field arguments are null");
}
ComponentAccess ca_from = lookup(from);
ComponentAccess ca_to = lookup(to);
Access from_access = ca_from.output(from_out);
checkFA(from_access, from, from_out);
Access to_access = ca_to.input(to_in);
checkFA(to_access, to, to_in);
if (!canConnect(from_access, to_access)) {
throw new ComponentException("Type/Access mismatch, Cannot connect: " + from + '.' + to_in + " -> " + to + '.' + from_out);
}
// src data object
FieldContent data = from_access.getData();
data.tagIn();
data.tagOut();
dataSet.add(data);
to_access.setData(data); // connect the two
if (checkCircular) {
validator.addConnection(from, to);
validator.checkCircular();
}
if (log.isLoggable(Level.CONFIG)) {
log.config(String.format("@Out(%s) -> @In(%s)", from_access.toString() , to_access.toString()));
}
// ens.fireConnect(from_access, to_access);
} | java | void connect(Object from, String from_out, Object to, String to_in) {
// add them to the set of commands
if (from == to) {
throw new ComponentException("src == dest.");
}
if (to_in == null || from_out == null) {
throw new ComponentException("Some field arguments are null");
}
ComponentAccess ca_from = lookup(from);
ComponentAccess ca_to = lookup(to);
Access from_access = ca_from.output(from_out);
checkFA(from_access, from, from_out);
Access to_access = ca_to.input(to_in);
checkFA(to_access, to, to_in);
if (!canConnect(from_access, to_access)) {
throw new ComponentException("Type/Access mismatch, Cannot connect: " + from + '.' + to_in + " -> " + to + '.' + from_out);
}
// src data object
FieldContent data = from_access.getData();
data.tagIn();
data.tagOut();
dataSet.add(data);
to_access.setData(data); // connect the two
if (checkCircular) {
validator.addConnection(from, to);
validator.checkCircular();
}
if (log.isLoggable(Level.CONFIG)) {
log.config(String.format("@Out(%s) -> @In(%s)", from_access.toString() , to_access.toString()));
}
// ens.fireConnect(from_access, to_access);
} | [
"void",
"connect",
"(",
"Object",
"from",
",",
"String",
"from_out",
",",
"Object",
"to",
",",
"String",
"to_in",
")",
"{",
"// add them to the set of commands",
"if",
"(",
"from",
"==",
"to",
")",
"{",
"throw",
"new",
"ComponentException",
"(",
"\"src == dest.\"",
")",
";",
"}",
"if",
"(",
"to_in",
"==",
"null",
"||",
"from_out",
"==",
"null",
")",
"{",
"throw",
"new",
"ComponentException",
"(",
"\"Some field arguments are null\"",
")",
";",
"}",
"ComponentAccess",
"ca_from",
"=",
"lookup",
"(",
"from",
")",
";",
"ComponentAccess",
"ca_to",
"=",
"lookup",
"(",
"to",
")",
";",
"Access",
"from_access",
"=",
"ca_from",
".",
"output",
"(",
"from_out",
")",
";",
"checkFA",
"(",
"from_access",
",",
"from",
",",
"from_out",
")",
";",
"Access",
"to_access",
"=",
"ca_to",
".",
"input",
"(",
"to_in",
")",
";",
"checkFA",
"(",
"to_access",
",",
"to",
",",
"to_in",
")",
";",
"if",
"(",
"!",
"canConnect",
"(",
"from_access",
",",
"to_access",
")",
")",
"{",
"throw",
"new",
"ComponentException",
"(",
"\"Type/Access mismatch, Cannot connect: \"",
"+",
"from",
"+",
"'",
"'",
"+",
"to_in",
"+",
"\" -> \"",
"+",
"to",
"+",
"'",
"'",
"+",
"from_out",
")",
";",
"}",
"// src data object",
"FieldContent",
"data",
"=",
"from_access",
".",
"getData",
"(",
")",
";",
"data",
".",
"tagIn",
"(",
")",
";",
"data",
".",
"tagOut",
"(",
")",
";",
"dataSet",
".",
"add",
"(",
"data",
")",
";",
"to_access",
".",
"setData",
"(",
"data",
")",
";",
"// connect the two",
"if",
"(",
"checkCircular",
")",
"{",
"validator",
".",
"addConnection",
"(",
"from",
",",
"to",
")",
";",
"validator",
".",
"checkCircular",
"(",
")",
";",
"}",
"if",
"(",
"log",
".",
"isLoggable",
"(",
"Level",
".",
"CONFIG",
")",
")",
"{",
"log",
".",
"config",
"(",
"String",
".",
"format",
"(",
"\"@Out(%s) -> @In(%s)\"",
",",
"from_access",
".",
"toString",
"(",
")",
",",
"to_access",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"// ens.fireConnect(from_access, to_access);",
"}"
] | Connect out to in
@param from
@param from_out
@param to
@param to_in | [
"Connect",
"out",
"to",
"in"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/Controller.java#L218-L257 |
137,907 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/Controller.java | Controller.feedback | void feedback(Object from, String from_out, Object to, String to_in) {
// add them to the set of commands
if (from == to) {
throw new ComponentException("src == dest.");
}
if (to_in == null || from_out == null) {
throw new ComponentException("Some field arguments are null");
}
ComponentAccess ca_from = lookup(from);
ComponentAccess ca_to = lookup(to);
Access from_access = ca_from.output(from_out);
checkFA(from_access, from, from_out);
Access to_access = ca_to.input(to_in);
checkFA(to_access, to, to_in);
if (!canConnect(from_access, to_access)) {
throw new ComponentException("Type/Access mismatch, Cannot connect: " + from + '.' + to_in + " -> " + to + '.' + from_out);
}
// src data object
FieldContent data = from_access.getData();
data.tagIn();
data.tagOut();
// dataSet.add(data);
to_access.setData(data); // connect the two
ca_from.setOutput(from_out, new AsyncFieldAccess(from_access));
ca_to.setInput(to_in, new AsyncFieldAccess(to_access));
if (checkCircular) {
// val.addConnection(from, to);
// val.checkCircular();
}
if (log.isLoggable(Level.CONFIG)) {
log.config(String.format("feedback @Out(%s) -> @In(%s)", from_access.toString() , to_access.toString()));
}
// ens.fireConnect(from_access, to_access);
} | java | void feedback(Object from, String from_out, Object to, String to_in) {
// add them to the set of commands
if (from == to) {
throw new ComponentException("src == dest.");
}
if (to_in == null || from_out == null) {
throw new ComponentException("Some field arguments are null");
}
ComponentAccess ca_from = lookup(from);
ComponentAccess ca_to = lookup(to);
Access from_access = ca_from.output(from_out);
checkFA(from_access, from, from_out);
Access to_access = ca_to.input(to_in);
checkFA(to_access, to, to_in);
if (!canConnect(from_access, to_access)) {
throw new ComponentException("Type/Access mismatch, Cannot connect: " + from + '.' + to_in + " -> " + to + '.' + from_out);
}
// src data object
FieldContent data = from_access.getData();
data.tagIn();
data.tagOut();
// dataSet.add(data);
to_access.setData(data); // connect the two
ca_from.setOutput(from_out, new AsyncFieldAccess(from_access));
ca_to.setInput(to_in, new AsyncFieldAccess(to_access));
if (checkCircular) {
// val.addConnection(from, to);
// val.checkCircular();
}
if (log.isLoggable(Level.CONFIG)) {
log.config(String.format("feedback @Out(%s) -> @In(%s)", from_access.toString() , to_access.toString()));
}
// ens.fireConnect(from_access, to_access);
} | [
"void",
"feedback",
"(",
"Object",
"from",
",",
"String",
"from_out",
",",
"Object",
"to",
",",
"String",
"to_in",
")",
"{",
"// add them to the set of commands",
"if",
"(",
"from",
"==",
"to",
")",
"{",
"throw",
"new",
"ComponentException",
"(",
"\"src == dest.\"",
")",
";",
"}",
"if",
"(",
"to_in",
"==",
"null",
"||",
"from_out",
"==",
"null",
")",
"{",
"throw",
"new",
"ComponentException",
"(",
"\"Some field arguments are null\"",
")",
";",
"}",
"ComponentAccess",
"ca_from",
"=",
"lookup",
"(",
"from",
")",
";",
"ComponentAccess",
"ca_to",
"=",
"lookup",
"(",
"to",
")",
";",
"Access",
"from_access",
"=",
"ca_from",
".",
"output",
"(",
"from_out",
")",
";",
"checkFA",
"(",
"from_access",
",",
"from",
",",
"from_out",
")",
";",
"Access",
"to_access",
"=",
"ca_to",
".",
"input",
"(",
"to_in",
")",
";",
"checkFA",
"(",
"to_access",
",",
"to",
",",
"to_in",
")",
";",
"if",
"(",
"!",
"canConnect",
"(",
"from_access",
",",
"to_access",
")",
")",
"{",
"throw",
"new",
"ComponentException",
"(",
"\"Type/Access mismatch, Cannot connect: \"",
"+",
"from",
"+",
"'",
"'",
"+",
"to_in",
"+",
"\" -> \"",
"+",
"to",
"+",
"'",
"'",
"+",
"from_out",
")",
";",
"}",
"// src data object",
"FieldContent",
"data",
"=",
"from_access",
".",
"getData",
"(",
")",
";",
"data",
".",
"tagIn",
"(",
")",
";",
"data",
".",
"tagOut",
"(",
")",
";",
"// dataSet.add(data);",
"to_access",
".",
"setData",
"(",
"data",
")",
";",
"// connect the two",
"ca_from",
".",
"setOutput",
"(",
"from_out",
",",
"new",
"AsyncFieldAccess",
"(",
"from_access",
")",
")",
";",
"ca_to",
".",
"setInput",
"(",
"to_in",
",",
"new",
"AsyncFieldAccess",
"(",
"to_access",
")",
")",
";",
"if",
"(",
"checkCircular",
")",
"{",
"// val.addConnection(from, to);",
"// val.checkCircular();",
"}",
"if",
"(",
"log",
".",
"isLoggable",
"(",
"Level",
".",
"CONFIG",
")",
")",
"{",
"log",
".",
"config",
"(",
"String",
".",
"format",
"(",
"\"feedback @Out(%s) -> @In(%s)\"",
",",
"from_access",
".",
"toString",
"(",
")",
",",
"to_access",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"// ens.fireConnect(from_access, to_access);",
"}"
] | Feedback connect out to in
@param from
@param from_out
@param to
@param to_in | [
"Feedback",
"connect",
"out",
"to",
"in"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/Controller.java#L266-L307 |
137,908 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/Controller.java | Controller.callAnnotated | void callAnnotated(Class<? extends Annotation> ann, boolean lazy) {
for (ComponentAccess p : oMap.values()) {
p.callAnnotatedMethod(ann, lazy);
}
} | java | void callAnnotated(Class<? extends Annotation> ann, boolean lazy) {
for (ComponentAccess p : oMap.values()) {
p.callAnnotatedMethod(ann, lazy);
}
} | [
"void",
"callAnnotated",
"(",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"ann",
",",
"boolean",
"lazy",
")",
"{",
"for",
"(",
"ComponentAccess",
"p",
":",
"oMap",
".",
"values",
"(",
")",
")",
"{",
"p",
".",
"callAnnotatedMethod",
"(",
"ann",
",",
"lazy",
")",
";",
"}",
"}"
] | Call an annotated method.
@param ann | [
"Call",
"an",
"annotated",
"method",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/Controller.java#L484-L488 |
137,909 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/interpolation/splines/ControlCurve.java | ControlCurve.addPoint | public double addPoint( double x, double y ) {
pts.add(new Coordinate(x, y));
return selection = pts.size() - 1;
} | java | public double addPoint( double x, double y ) {
pts.add(new Coordinate(x, y));
return selection = pts.size() - 1;
} | [
"public",
"double",
"addPoint",
"(",
"double",
"x",
",",
"double",
"y",
")",
"{",
"pts",
".",
"add",
"(",
"new",
"Coordinate",
"(",
"x",
",",
"y",
")",
")",
";",
"return",
"selection",
"=",
"pts",
".",
"size",
"(",
")",
"-",
"1",
";",
"}"
] | add a control point, return index of new control point | [
"add",
"a",
"control",
"point",
"return",
"index",
"of",
"new",
"control",
"point"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/interpolation/splines/ControlCurve.java#L64-L67 |
137,910 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/interpolation/splines/ControlCurve.java | ControlCurve.setPoint | public void setPoint( double x, double y ) {
if (selection >= 0) {
Coordinate coordinate = new Coordinate(x, y);
pts.set(selection, coordinate);
}
} | java | public void setPoint( double x, double y ) {
if (selection >= 0) {
Coordinate coordinate = new Coordinate(x, y);
pts.set(selection, coordinate);
}
} | [
"public",
"void",
"setPoint",
"(",
"double",
"x",
",",
"double",
"y",
")",
"{",
"if",
"(",
"selection",
">=",
"0",
")",
"{",
"Coordinate",
"coordinate",
"=",
"new",
"Coordinate",
"(",
"x",
",",
"y",
")",
";",
"pts",
".",
"set",
"(",
"selection",
",",
"coordinate",
")",
";",
"}",
"}"
] | set selected control point | [
"set",
"selected",
"control",
"point"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/interpolation/splines/ControlCurve.java#L70-L75 |
137,911 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/utils/oms/CLI.java | CLI.sim | public static Object sim( String file, String ll, String cmd ) throws Exception {
String f = CLI.readFile(file);
Object o = CLI.createSim(f, false, ll);
return CLI.invoke(o, cmd);
} | java | public static Object sim( String file, String ll, String cmd ) throws Exception {
String f = CLI.readFile(file);
Object o = CLI.createSim(f, false, ll);
return CLI.invoke(o, cmd);
} | [
"public",
"static",
"Object",
"sim",
"(",
"String",
"file",
",",
"String",
"ll",
",",
"String",
"cmd",
")",
"throws",
"Exception",
"{",
"String",
"f",
"=",
"CLI",
".",
"readFile",
"(",
"file",
")",
";",
"Object",
"o",
"=",
"CLI",
".",
"createSim",
"(",
"f",
",",
"false",
",",
"ll",
")",
";",
"return",
"CLI",
".",
"invoke",
"(",
"o",
",",
"cmd",
")",
";",
"}"
] | Executes a simulation.
@param file the file to execute
@param ll the log level
@param cmd the command to call (e.g. run)
@throws Exception | [
"Executes",
"a",
"simulation",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/utils/oms/CLI.java#L52-L56 |
137,912 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/utils/oms/CLI.java | CLI.groovy | public static void groovy( String file, String ll, String cmd ) throws Exception {
String f = CLI.readFile(file);
Object o = CLI.createSim(f, true, ll);
} | java | public static void groovy( String file, String ll, String cmd ) throws Exception {
String f = CLI.readFile(file);
Object o = CLI.createSim(f, true, ll);
} | [
"public",
"static",
"void",
"groovy",
"(",
"String",
"file",
",",
"String",
"ll",
",",
"String",
"cmd",
")",
"throws",
"Exception",
"{",
"String",
"f",
"=",
"CLI",
".",
"readFile",
"(",
"file",
")",
";",
"Object",
"o",
"=",
"CLI",
".",
"createSim",
"(",
"f",
",",
"true",
",",
"ll",
")",
";",
"}"
] | Executed plain groovy.
@param file the groovy file
@param ll the log level.
@param cmd
@throws Exception | [
"Executed",
"plain",
"groovy",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/utils/oms/CLI.java#L66-L69 |
137,913 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/utils/oms/CLI.java | CLI.readFile | public static String readFile( String name ) throws IOException {
StringBuilder b = new StringBuilder();
BufferedReader r = new BufferedReader(new FileReader(name));
String line;
while( (line = r.readLine()) != null ) {
b.append(line).append('\n');
}
r.close();
return b.toString();
} | java | public static String readFile( String name ) throws IOException {
StringBuilder b = new StringBuilder();
BufferedReader r = new BufferedReader(new FileReader(name));
String line;
while( (line = r.readLine()) != null ) {
b.append(line).append('\n');
}
r.close();
return b.toString();
} | [
"public",
"static",
"String",
"readFile",
"(",
"String",
"name",
")",
"throws",
"IOException",
"{",
"StringBuilder",
"b",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"BufferedReader",
"r",
"=",
"new",
"BufferedReader",
"(",
"new",
"FileReader",
"(",
"name",
")",
")",
";",
"String",
"line",
";",
"while",
"(",
"(",
"line",
"=",
"r",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"b",
".",
"append",
"(",
"line",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"r",
".",
"close",
"(",
")",
";",
"return",
"b",
".",
"toString",
"(",
")",
";",
"}"
] | Read a file and provide its content as String.
@param name the file name
@return the content as String
@throws IOException something bad happened. | [
"Read",
"a",
"file",
"and",
"provide",
"its",
"content",
"as",
"String",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/utils/oms/CLI.java#L89-L98 |
137,914 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/utils/oms/CLI.java | CLI.createSim | public static Object createSim( String script, boolean groovy, String ll ) throws Exception {
setOMSProperties();
Level.parse(ll); // may throw IAE
String prefix = groovy ? "" : "import static oms3.SimConst.*\n" + "def __sb__ = new oms3.SimBuilder(logging:'" + ll
+ "')\n" + "__sb__.";
ClassLoader parent = Thread.currentThread().getContextClassLoader();
Binding b = new Binding();
b.setVariable("oms_version", System.getProperty("oms.version"));
b.setVariable("oms_home", System.getProperty("oms.home"));
b.setVariable("oms_prj", System.getProperty("oms.prj"));
GroovyShell shell = new GroovyShell(new GroovyClassLoader(parent), b);
return shell.evaluate(prefix + script);
} | java | public static Object createSim( String script, boolean groovy, String ll ) throws Exception {
setOMSProperties();
Level.parse(ll); // may throw IAE
String prefix = groovy ? "" : "import static oms3.SimConst.*\n" + "def __sb__ = new oms3.SimBuilder(logging:'" + ll
+ "')\n" + "__sb__.";
ClassLoader parent = Thread.currentThread().getContextClassLoader();
Binding b = new Binding();
b.setVariable("oms_version", System.getProperty("oms.version"));
b.setVariable("oms_home", System.getProperty("oms.home"));
b.setVariable("oms_prj", System.getProperty("oms.prj"));
GroovyShell shell = new GroovyShell(new GroovyClassLoader(parent), b);
return shell.evaluate(prefix + script);
} | [
"public",
"static",
"Object",
"createSim",
"(",
"String",
"script",
",",
"boolean",
"groovy",
",",
"String",
"ll",
")",
"throws",
"Exception",
"{",
"setOMSProperties",
"(",
")",
";",
"Level",
".",
"parse",
"(",
"ll",
")",
";",
"// may throw IAE",
"String",
"prefix",
"=",
"groovy",
"?",
"\"\"",
":",
"\"import static oms3.SimConst.*\\n\"",
"+",
"\"def __sb__ = new oms3.SimBuilder(logging:'\"",
"+",
"ll",
"+",
"\"')\\n\"",
"+",
"\"__sb__.\"",
";",
"ClassLoader",
"parent",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"Binding",
"b",
"=",
"new",
"Binding",
"(",
")",
";",
"b",
".",
"setVariable",
"(",
"\"oms_version\"",
",",
"System",
".",
"getProperty",
"(",
"\"oms.version\"",
")",
")",
";",
"b",
".",
"setVariable",
"(",
"\"oms_home\"",
",",
"System",
".",
"getProperty",
"(",
"\"oms.home\"",
")",
")",
";",
"b",
".",
"setVariable",
"(",
"\"oms_prj\"",
",",
"System",
".",
"getProperty",
"(",
"\"oms.prj\"",
")",
")",
";",
"GroovyShell",
"shell",
"=",
"new",
"GroovyShell",
"(",
"new",
"GroovyClassLoader",
"(",
"parent",
")",
",",
"b",
")",
";",
"return",
"shell",
".",
"evaluate",
"(",
"prefix",
"+",
"script",
")",
";",
"}"
] | Create a simulation object.
@param script the script
@param groovy
@param ll
@return the simulation object. | [
"Create",
"a",
"simulation",
"object",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/utils/oms/CLI.java#L108-L121 |
137,915 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/dsl/BeanBuilder.java | BeanBuilder.getPropertyTypeValue | private Object getPropertyTypeValue(Class propertyType, Object value) {
if (propertyType.equals(String.class)) {
return value.toString();
} else if (propertyType.equals(Boolean.class) || propertyType.equals(Boolean.TYPE)) {
Boolean arg = null;
if (value instanceof Boolean) {
arg = (Boolean) value;
} else {
arg = Boolean.parseBoolean(value.toString());
}
return arg;
} else if (propertyType.equals(Short.class) || propertyType.equals(Short.TYPE)) {
Short arg = null;
if (value instanceof Short) {
arg = (Short) value;
} else {
arg = Short.parseShort(value.toString());
}
return arg;
} else if (propertyType.equals(Integer.class) || propertyType.equals(Integer.TYPE)) {
Integer arg = null;
if (value instanceof Integer) {
arg = (Integer) value;
} else {
arg = Integer.parseInt(value.toString());
}
return arg;
} else if (propertyType.equals(Long.class) || propertyType.equals(Long.TYPE)) {
Long arg = null;
if (value instanceof Long) {
arg = (Long) value;
} else {
arg = Long.parseLong(value.toString());
}
return arg;
} else if (propertyType.equals(Float.class) || propertyType.equals(Float.TYPE)) {
Float arg = null;
if (value instanceof Float) {
arg = (Float) value;
} else {
arg = Float.parseFloat(value.toString());
}
return arg;
} else if (propertyType.equals(Double.class) || propertyType.equals(Double.TYPE)) {
Double arg = null;
if (value instanceof Double) {
arg = (Double) value;
} else {
arg = Double.parseDouble(value.toString());
}
return arg;
} else { // Object
return value;
}
} | java | private Object getPropertyTypeValue(Class propertyType, Object value) {
if (propertyType.equals(String.class)) {
return value.toString();
} else if (propertyType.equals(Boolean.class) || propertyType.equals(Boolean.TYPE)) {
Boolean arg = null;
if (value instanceof Boolean) {
arg = (Boolean) value;
} else {
arg = Boolean.parseBoolean(value.toString());
}
return arg;
} else if (propertyType.equals(Short.class) || propertyType.equals(Short.TYPE)) {
Short arg = null;
if (value instanceof Short) {
arg = (Short) value;
} else {
arg = Short.parseShort(value.toString());
}
return arg;
} else if (propertyType.equals(Integer.class) || propertyType.equals(Integer.TYPE)) {
Integer arg = null;
if (value instanceof Integer) {
arg = (Integer) value;
} else {
arg = Integer.parseInt(value.toString());
}
return arg;
} else if (propertyType.equals(Long.class) || propertyType.equals(Long.TYPE)) {
Long arg = null;
if (value instanceof Long) {
arg = (Long) value;
} else {
arg = Long.parseLong(value.toString());
}
return arg;
} else if (propertyType.equals(Float.class) || propertyType.equals(Float.TYPE)) {
Float arg = null;
if (value instanceof Float) {
arg = (Float) value;
} else {
arg = Float.parseFloat(value.toString());
}
return arg;
} else if (propertyType.equals(Double.class) || propertyType.equals(Double.TYPE)) {
Double arg = null;
if (value instanceof Double) {
arg = (Double) value;
} else {
arg = Double.parseDouble(value.toString());
}
return arg;
} else { // Object
return value;
}
} | [
"private",
"Object",
"getPropertyTypeValue",
"(",
"Class",
"propertyType",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"propertyType",
".",
"equals",
"(",
"String",
".",
"class",
")",
")",
"{",
"return",
"value",
".",
"toString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"propertyType",
".",
"equals",
"(",
"Boolean",
".",
"class",
")",
"||",
"propertyType",
".",
"equals",
"(",
"Boolean",
".",
"TYPE",
")",
")",
"{",
"Boolean",
"arg",
"=",
"null",
";",
"if",
"(",
"value",
"instanceof",
"Boolean",
")",
"{",
"arg",
"=",
"(",
"Boolean",
")",
"value",
";",
"}",
"else",
"{",
"arg",
"=",
"Boolean",
".",
"parseBoolean",
"(",
"value",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"arg",
";",
"}",
"else",
"if",
"(",
"propertyType",
".",
"equals",
"(",
"Short",
".",
"class",
")",
"||",
"propertyType",
".",
"equals",
"(",
"Short",
".",
"TYPE",
")",
")",
"{",
"Short",
"arg",
"=",
"null",
";",
"if",
"(",
"value",
"instanceof",
"Short",
")",
"{",
"arg",
"=",
"(",
"Short",
")",
"value",
";",
"}",
"else",
"{",
"arg",
"=",
"Short",
".",
"parseShort",
"(",
"value",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"arg",
";",
"}",
"else",
"if",
"(",
"propertyType",
".",
"equals",
"(",
"Integer",
".",
"class",
")",
"||",
"propertyType",
".",
"equals",
"(",
"Integer",
".",
"TYPE",
")",
")",
"{",
"Integer",
"arg",
"=",
"null",
";",
"if",
"(",
"value",
"instanceof",
"Integer",
")",
"{",
"arg",
"=",
"(",
"Integer",
")",
"value",
";",
"}",
"else",
"{",
"arg",
"=",
"Integer",
".",
"parseInt",
"(",
"value",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"arg",
";",
"}",
"else",
"if",
"(",
"propertyType",
".",
"equals",
"(",
"Long",
".",
"class",
")",
"||",
"propertyType",
".",
"equals",
"(",
"Long",
".",
"TYPE",
")",
")",
"{",
"Long",
"arg",
"=",
"null",
";",
"if",
"(",
"value",
"instanceof",
"Long",
")",
"{",
"arg",
"=",
"(",
"Long",
")",
"value",
";",
"}",
"else",
"{",
"arg",
"=",
"Long",
".",
"parseLong",
"(",
"value",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"arg",
";",
"}",
"else",
"if",
"(",
"propertyType",
".",
"equals",
"(",
"Float",
".",
"class",
")",
"||",
"propertyType",
".",
"equals",
"(",
"Float",
".",
"TYPE",
")",
")",
"{",
"Float",
"arg",
"=",
"null",
";",
"if",
"(",
"value",
"instanceof",
"Float",
")",
"{",
"arg",
"=",
"(",
"Float",
")",
"value",
";",
"}",
"else",
"{",
"arg",
"=",
"Float",
".",
"parseFloat",
"(",
"value",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"arg",
";",
"}",
"else",
"if",
"(",
"propertyType",
".",
"equals",
"(",
"Double",
".",
"class",
")",
"||",
"propertyType",
".",
"equals",
"(",
"Double",
".",
"TYPE",
")",
")",
"{",
"Double",
"arg",
"=",
"null",
";",
"if",
"(",
"value",
"instanceof",
"Double",
")",
"{",
"arg",
"=",
"(",
"Double",
")",
"value",
";",
"}",
"else",
"{",
"arg",
"=",
"Double",
".",
"parseDouble",
"(",
"value",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"arg",
";",
"}",
"else",
"{",
"// Object",
"return",
"value",
";",
"}",
"}"
] | converts ths incoming value to an object for the property type. | [
"converts",
"ths",
"incoming",
"value",
"to",
"an",
"object",
"for",
"the",
"property",
"type",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/dsl/BeanBuilder.java#L115-L169 |
137,916 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/StreamUtils.java | StreamUtils.toMap | public static <T, K, V> Map<K, V> toMap( Stream<T> stream, Function<T, K> keySupplier, Function<T, V> valueSupplier ) {
return stream.collect(Collectors.toMap(keySupplier, valueSupplier));
} | java | public static <T, K, V> Map<K, V> toMap( Stream<T> stream, Function<T, K> keySupplier, Function<T, V> valueSupplier ) {
return stream.collect(Collectors.toMap(keySupplier, valueSupplier));
} | [
"public",
"static",
"<",
"T",
",",
"K",
",",
"V",
">",
"Map",
"<",
"K",
",",
"V",
">",
"toMap",
"(",
"Stream",
"<",
"T",
">",
"stream",
",",
"Function",
"<",
"T",
",",
"K",
">",
"keySupplier",
",",
"Function",
"<",
"T",
",",
"V",
">",
"valueSupplier",
")",
"{",
"return",
"stream",
".",
"collect",
"(",
"Collectors",
".",
"toMap",
"(",
"keySupplier",
",",
"valueSupplier",
")",
")",
";",
"}"
] | Collect stream to map.
@param stream the stream to convert.
@param keySupplier the supplier for the key, ex. Object::getId()
@param valueSupplier the value supplier, ex. Object::getValue()
@return the map. | [
"Collect",
"stream",
"to",
"map",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/StreamUtils.java#L149-L151 |
137,917 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/StreamUtils.java | StreamUtils.toMapGroupBy | public static <T, K, R> Map<R, List<T>> toMapGroupBy( Stream<T> stream, Function<T, R> groupingFunction ) {
return stream.collect(Collectors.groupingBy(groupingFunction));
// to get a set: Collectors.groupingBy(groupingFunction, Collectors.toSet())
} | java | public static <T, K, R> Map<R, List<T>> toMapGroupBy( Stream<T> stream, Function<T, R> groupingFunction ) {
return stream.collect(Collectors.groupingBy(groupingFunction));
// to get a set: Collectors.groupingBy(groupingFunction, Collectors.toSet())
} | [
"public",
"static",
"<",
"T",
",",
"K",
",",
"R",
">",
"Map",
"<",
"R",
",",
"List",
"<",
"T",
">",
">",
"toMapGroupBy",
"(",
"Stream",
"<",
"T",
">",
"stream",
",",
"Function",
"<",
"T",
",",
"R",
">",
"groupingFunction",
")",
"{",
"return",
"stream",
".",
"collect",
"(",
"Collectors",
".",
"groupingBy",
"(",
"groupingFunction",
")",
")",
";",
"// to get a set: Collectors.groupingBy(groupingFunction, Collectors.toSet())",
"}"
] | Collect a map by grouping based on the object's field.
@param stream the stream to collect.
@param groupingFunction the function supplying the grouping field, ex. Object::getField()
@return the map of lists. | [
"Collect",
"a",
"map",
"by",
"grouping",
"based",
"on",
"the",
"object",
"s",
"field",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/StreamUtils.java#L164-L167 |
137,918 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/StreamUtils.java | StreamUtils.toMapPartition | public static <T> Map<Boolean, List<T>> toMapPartition( Stream<T> stream, Predicate<T> predicate ) {
return stream.collect(Collectors.partitioningBy(predicate));
} | java | public static <T> Map<Boolean, List<T>> toMapPartition( Stream<T> stream, Predicate<T> predicate ) {
return stream.collect(Collectors.partitioningBy(predicate));
} | [
"public",
"static",
"<",
"T",
">",
"Map",
"<",
"Boolean",
",",
"List",
"<",
"T",
">",
">",
"toMapPartition",
"(",
"Stream",
"<",
"T",
">",
"stream",
",",
"Predicate",
"<",
"T",
">",
"predicate",
")",
"{",
"return",
"stream",
".",
"collect",
"(",
"Collectors",
".",
"partitioningBy",
"(",
"predicate",
")",
")",
";",
"}"
] | Split a stream into a map with true and false.
@param stream the stream to collect.
@param predicate the predicate to use to define true or false, ex. e->e.getValue().equals("test")
@return the map of lists. | [
"Split",
"a",
"stream",
"into",
"a",
"map",
"with",
"true",
"and",
"false",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/StreamUtils.java#L176-L178 |
137,919 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/StreamUtils.java | StreamUtils.findAny | public static <T> T findAny( Stream<T> stream, Predicate<T> predicate ) {
Optional<T> element = stream.filter(predicate).findAny();
return element.orElse(null);
} | java | public static <T> T findAny( Stream<T> stream, Predicate<T> predicate ) {
Optional<T> element = stream.filter(predicate).findAny();
return element.orElse(null);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"findAny",
"(",
"Stream",
"<",
"T",
">",
"stream",
",",
"Predicate",
"<",
"T",
">",
"predicate",
")",
"{",
"Optional",
"<",
"T",
">",
"element",
"=",
"stream",
".",
"filter",
"(",
"predicate",
")",
".",
"findAny",
"(",
")",
";",
"return",
"element",
".",
"orElse",
"(",
"null",
")",
";",
"}"
] | Find an element in the stream.
@param stream the stream to check. This should be parallel.
@param predicate the predicate to use.
@return the element or null. | [
"Find",
"an",
"element",
"in",
"the",
"stream",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/StreamUtils.java#L197-L200 |
137,920 | TheHortonMachine/hortonmachine | dbs/src/main/java/org/hortonmachine/dbs/compat/ASpatialDb.java | ASpatialDb.createSpatialTable | public void createSpatialTable( String tableName, int tableSrid, String geometryFieldData, String[] fieldData )
throws Exception {
createSpatialTable(tableName, tableSrid, geometryFieldData, fieldData, null, false);
} | java | public void createSpatialTable( String tableName, int tableSrid, String geometryFieldData, String[] fieldData )
throws Exception {
createSpatialTable(tableName, tableSrid, geometryFieldData, fieldData, null, false);
} | [
"public",
"void",
"createSpatialTable",
"(",
"String",
"tableName",
",",
"int",
"tableSrid",
",",
"String",
"geometryFieldData",
",",
"String",
"[",
"]",
"fieldData",
")",
"throws",
"Exception",
"{",
"createSpatialTable",
"(",
"tableName",
",",
"tableSrid",
",",
"geometryFieldData",
",",
"fieldData",
",",
"null",
",",
"false",
")",
";",
"}"
] | Creates a spatial table with default values for foreign keys and index.
@param tableName
the table name.
@param tableSrid the table's epsg code.
@param geometryFieldData the data for the geometry column, ex. the_geom MULTIPOLYGON
@param fieldData
the data for each the field (ex. id INTEGER NOT NULL PRIMARY
KEY).
@throws Exception | [
"Creates",
"a",
"spatial",
"table",
"with",
"default",
"values",
"for",
"foreign",
"keys",
"and",
"index",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/dbs/compat/ASpatialDb.java#L86-L89 |
137,921 | TheHortonMachine/hortonmachine | dbs/src/main/java/org/hortonmachine/dbs/compat/ASpatialDb.java | ASpatialDb.createSpatialIndex | public void createSpatialIndex( String tableName, String geomColumnName ) throws Exception {
if (geomColumnName == null) {
geomColumnName = "the_geom";
}
String realColumnName = getProperColumnNameCase(tableName, geomColumnName);
String realTableName = getProperTableNameCase(tableName);
String sql = "CREATE SPATIAL INDEX ON " + realTableName + "(" + realColumnName + ");";
execOnConnection(connection -> {
try (IHMStatement stmt = connection.createStatement()) {
stmt.execute(sql.toString());
}
return null;
});
} | java | public void createSpatialIndex( String tableName, String geomColumnName ) throws Exception {
if (geomColumnName == null) {
geomColumnName = "the_geom";
}
String realColumnName = getProperColumnNameCase(tableName, geomColumnName);
String realTableName = getProperTableNameCase(tableName);
String sql = "CREATE SPATIAL INDEX ON " + realTableName + "(" + realColumnName + ");";
execOnConnection(connection -> {
try (IHMStatement stmt = connection.createStatement()) {
stmt.execute(sql.toString());
}
return null;
});
} | [
"public",
"void",
"createSpatialIndex",
"(",
"String",
"tableName",
",",
"String",
"geomColumnName",
")",
"throws",
"Exception",
"{",
"if",
"(",
"geomColumnName",
"==",
"null",
")",
"{",
"geomColumnName",
"=",
"\"the_geom\"",
";",
"}",
"String",
"realColumnName",
"=",
"getProperColumnNameCase",
"(",
"tableName",
",",
"geomColumnName",
")",
";",
"String",
"realTableName",
"=",
"getProperTableNameCase",
"(",
"tableName",
")",
";",
"String",
"sql",
"=",
"\"CREATE SPATIAL INDEX ON \"",
"+",
"realTableName",
"+",
"\"(\"",
"+",
"realColumnName",
"+",
"\");\"",
";",
"execOnConnection",
"(",
"connection",
"->",
"{",
"try",
"(",
"IHMStatement",
"stmt",
"=",
"connection",
".",
"createStatement",
"(",
")",
")",
"{",
"stmt",
".",
"execute",
"(",
"sql",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"null",
";",
"}",
")",
";",
"}"
] | Create a spatial index.
@param tableName the table name.
@param geomColumnName the geometry column name.
@throws Exception | [
"Create",
"a",
"spatial",
"index",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/dbs/compat/ASpatialDb.java#L165-L180 |
137,922 | TheHortonMachine/hortonmachine | dbs/src/main/java/org/hortonmachine/dbs/compat/ASpatialDb.java | ASpatialDb.insertGeometry | public void insertGeometry( String tableName, Geometry geometry, String epsg ) throws Exception {
String epsgStr = "4326";
if (epsg == null) {
epsgStr = epsg;
}
GeometryColumn gc = getGeometryColumnsForTable(tableName);
String sql = "INSERT INTO " + tableName + " (" + gc.geometryColumnName + ") VALUES (ST_GeomFromText(?, " + epsgStr + "))";
execOnConnection(connection -> {
try (IHMPreparedStatement pStmt = connection.prepareStatement(sql)) {
pStmt.setString(1, geometry.toText());
pStmt.executeUpdate();
}
return null;
});
} | java | public void insertGeometry( String tableName, Geometry geometry, String epsg ) throws Exception {
String epsgStr = "4326";
if (epsg == null) {
epsgStr = epsg;
}
GeometryColumn gc = getGeometryColumnsForTable(tableName);
String sql = "INSERT INTO " + tableName + " (" + gc.geometryColumnName + ") VALUES (ST_GeomFromText(?, " + epsgStr + "))";
execOnConnection(connection -> {
try (IHMPreparedStatement pStmt = connection.prepareStatement(sql)) {
pStmt.setString(1, geometry.toText());
pStmt.executeUpdate();
}
return null;
});
} | [
"public",
"void",
"insertGeometry",
"(",
"String",
"tableName",
",",
"Geometry",
"geometry",
",",
"String",
"epsg",
")",
"throws",
"Exception",
"{",
"String",
"epsgStr",
"=",
"\"4326\"",
";",
"if",
"(",
"epsg",
"==",
"null",
")",
"{",
"epsgStr",
"=",
"epsg",
";",
"}",
"GeometryColumn",
"gc",
"=",
"getGeometryColumnsForTable",
"(",
"tableName",
")",
";",
"String",
"sql",
"=",
"\"INSERT INTO \"",
"+",
"tableName",
"+",
"\" (\"",
"+",
"gc",
".",
"geometryColumnName",
"+",
"\") VALUES (ST_GeomFromText(?, \"",
"+",
"epsgStr",
"+",
"\"))\"",
";",
"execOnConnection",
"(",
"connection",
"->",
"{",
"try",
"(",
"IHMPreparedStatement",
"pStmt",
"=",
"connection",
".",
"prepareStatement",
"(",
"sql",
")",
")",
"{",
"pStmt",
".",
"setString",
"(",
"1",
",",
"geometry",
".",
"toText",
"(",
")",
")",
";",
"pStmt",
".",
"executeUpdate",
"(",
")",
";",
"}",
"return",
"null",
";",
"}",
")",
";",
"}"
] | Insert a geometry into a table.
@param tableName
the table to use.
@param geometry
the geometry to insert.
@param epsg
the optional epsg.
@throws Exception | [
"Insert",
"a",
"geometry",
"into",
"a",
"table",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/dbs/compat/ASpatialDb.java#L193-L210 |
137,923 | TheHortonMachine/hortonmachine | dbs/src/main/java/org/hortonmachine/dbs/compat/ASpatialDb.java | ASpatialDb.isTableSpatial | public boolean isTableSpatial( String tableName ) throws Exception {
GeometryColumn geometryColumns = getGeometryColumnsForTable(tableName);
return geometryColumns != null;
} | java | public boolean isTableSpatial( String tableName ) throws Exception {
GeometryColumn geometryColumns = getGeometryColumnsForTable(tableName);
return geometryColumns != null;
} | [
"public",
"boolean",
"isTableSpatial",
"(",
"String",
"tableName",
")",
"throws",
"Exception",
"{",
"GeometryColumn",
"geometryColumns",
"=",
"getGeometryColumnsForTable",
"(",
"tableName",
")",
";",
"return",
"geometryColumns",
"!=",
"null",
";",
"}"
] | Checks if a table is spatial.
@param tableName
the table to check.
@return <code>true</code> if a geometry column is present.
@throws Exception | [
"Checks",
"if",
"a",
"table",
"is",
"spatial",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/dbs/compat/ASpatialDb.java#L220-L223 |
137,924 | TheHortonMachine/hortonmachine | dbs/src/main/java/org/hortonmachine/dbs/compat/ASpatialDb.java | ASpatialDb.getGeometriesIn | public List<Geometry> getGeometriesIn( String tableName, Envelope envelope, String... prePostWhere ) throws Exception {
List<Geometry> geoms = new ArrayList<Geometry>();
List<String> wheres = new ArrayList<>();
String pre = "";
String post = "";
String where = "";
if (prePostWhere != null && prePostWhere.length == 3) {
if (prePostWhere[0] != null)
pre = prePostWhere[0];
if (prePostWhere[1] != null)
post = prePostWhere[1];
if (prePostWhere[2] != null) {
where = prePostWhere[2];
wheres.add(where);
}
}
GeometryColumn gCol = getGeometryColumnsForTable(tableName);
String sql = "SELECT " + pre + gCol.geometryColumnName + post + " FROM " + tableName;
if (envelope != null) {
double x1 = envelope.getMinX();
double y1 = envelope.getMinY();
double x2 = envelope.getMaxX();
double y2 = envelope.getMaxY();
wheres.add(getSpatialindexBBoxWherePiece(tableName, null, x1, y1, x2, y2));
}
if (wheres.size() > 0) {
sql += " WHERE " + DbsUtilities.joinBySeparator(wheres, " AND ");
}
String _sql = sql;
IGeometryParser geometryParser = getType().getGeometryParser();
return execOnConnection(connection -> {
try (IHMStatement stmt = connection.createStatement(); IHMResultSet rs = stmt.executeQuery(_sql)) {
while( rs.next() ) {
Geometry geometry = geometryParser.fromResultSet(rs, 1);
geoms.add(geometry);
}
return geoms;
}
});
} | java | public List<Geometry> getGeometriesIn( String tableName, Envelope envelope, String... prePostWhere ) throws Exception {
List<Geometry> geoms = new ArrayList<Geometry>();
List<String> wheres = new ArrayList<>();
String pre = "";
String post = "";
String where = "";
if (prePostWhere != null && prePostWhere.length == 3) {
if (prePostWhere[0] != null)
pre = prePostWhere[0];
if (prePostWhere[1] != null)
post = prePostWhere[1];
if (prePostWhere[2] != null) {
where = prePostWhere[2];
wheres.add(where);
}
}
GeometryColumn gCol = getGeometryColumnsForTable(tableName);
String sql = "SELECT " + pre + gCol.geometryColumnName + post + " FROM " + tableName;
if (envelope != null) {
double x1 = envelope.getMinX();
double y1 = envelope.getMinY();
double x2 = envelope.getMaxX();
double y2 = envelope.getMaxY();
wheres.add(getSpatialindexBBoxWherePiece(tableName, null, x1, y1, x2, y2));
}
if (wheres.size() > 0) {
sql += " WHERE " + DbsUtilities.joinBySeparator(wheres, " AND ");
}
String _sql = sql;
IGeometryParser geometryParser = getType().getGeometryParser();
return execOnConnection(connection -> {
try (IHMStatement stmt = connection.createStatement(); IHMResultSet rs = stmt.executeQuery(_sql)) {
while( rs.next() ) {
Geometry geometry = geometryParser.fromResultSet(rs, 1);
geoms.add(geometry);
}
return geoms;
}
});
} | [
"public",
"List",
"<",
"Geometry",
">",
"getGeometriesIn",
"(",
"String",
"tableName",
",",
"Envelope",
"envelope",
",",
"String",
"...",
"prePostWhere",
")",
"throws",
"Exception",
"{",
"List",
"<",
"Geometry",
">",
"geoms",
"=",
"new",
"ArrayList",
"<",
"Geometry",
">",
"(",
")",
";",
"List",
"<",
"String",
">",
"wheres",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"String",
"pre",
"=",
"\"\"",
";",
"String",
"post",
"=",
"\"\"",
";",
"String",
"where",
"=",
"\"\"",
";",
"if",
"(",
"prePostWhere",
"!=",
"null",
"&&",
"prePostWhere",
".",
"length",
"==",
"3",
")",
"{",
"if",
"(",
"prePostWhere",
"[",
"0",
"]",
"!=",
"null",
")",
"pre",
"=",
"prePostWhere",
"[",
"0",
"]",
";",
"if",
"(",
"prePostWhere",
"[",
"1",
"]",
"!=",
"null",
")",
"post",
"=",
"prePostWhere",
"[",
"1",
"]",
";",
"if",
"(",
"prePostWhere",
"[",
"2",
"]",
"!=",
"null",
")",
"{",
"where",
"=",
"prePostWhere",
"[",
"2",
"]",
";",
"wheres",
".",
"add",
"(",
"where",
")",
";",
"}",
"}",
"GeometryColumn",
"gCol",
"=",
"getGeometryColumnsForTable",
"(",
"tableName",
")",
";",
"String",
"sql",
"=",
"\"SELECT \"",
"+",
"pre",
"+",
"gCol",
".",
"geometryColumnName",
"+",
"post",
"+",
"\" FROM \"",
"+",
"tableName",
";",
"if",
"(",
"envelope",
"!=",
"null",
")",
"{",
"double",
"x1",
"=",
"envelope",
".",
"getMinX",
"(",
")",
";",
"double",
"y1",
"=",
"envelope",
".",
"getMinY",
"(",
")",
";",
"double",
"x2",
"=",
"envelope",
".",
"getMaxX",
"(",
")",
";",
"double",
"y2",
"=",
"envelope",
".",
"getMaxY",
"(",
")",
";",
"wheres",
".",
"add",
"(",
"getSpatialindexBBoxWherePiece",
"(",
"tableName",
",",
"null",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
")",
")",
";",
"}",
"if",
"(",
"wheres",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"sql",
"+=",
"\" WHERE \"",
"+",
"DbsUtilities",
".",
"joinBySeparator",
"(",
"wheres",
",",
"\" AND \"",
")",
";",
"}",
"String",
"_sql",
"=",
"sql",
";",
"IGeometryParser",
"geometryParser",
"=",
"getType",
"(",
")",
".",
"getGeometryParser",
"(",
")",
";",
"return",
"execOnConnection",
"(",
"connection",
"->",
"{",
"try",
"(",
"IHMStatement",
"stmt",
"=",
"connection",
".",
"createStatement",
"(",
")",
";",
"IHMResultSet",
"rs",
"=",
"stmt",
".",
"executeQuery",
"(",
"_sql",
")",
")",
"{",
"while",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"Geometry",
"geometry",
"=",
"geometryParser",
".",
"fromResultSet",
"(",
"rs",
",",
"1",
")",
";",
"geoms",
".",
"add",
"(",
"geometry",
")",
";",
"}",
"return",
"geoms",
";",
"}",
"}",
")",
";",
"}"
] | Get the geometries of a table inside a given envelope.
@param tableName
the table name.
@param envelope
the envelope to check.
@param prePostWhere an optional set of 3 parameters. The parameters are: a
prefix wrapper for geom, a postfix for the same and a where string
to apply. They all need to be existing if the parameter is passed.
@return The list of geometries intersecting the envelope.
@throws Exception | [
"Get",
"the",
"geometries",
"of",
"a",
"table",
"inside",
"a",
"given",
"envelope",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/dbs/compat/ASpatialDb.java#L282-L325 |
137,925 | TheHortonMachine/hortonmachine | dbs/src/main/java/org/hortonmachine/dbs/compat/ASpatialDb.java | ASpatialDb.getGeometriesIn | public List<Geometry> getGeometriesIn( String tableName, Geometry intersectionGeometry, String... prePostWhere )
throws Exception {
List<Geometry> geoms = new ArrayList<Geometry>();
List<String> wheres = new ArrayList<>();
String pre = "";
String post = "";
String where = "";
if (prePostWhere != null && prePostWhere.length == 3) {
if (prePostWhere[0] != null)
pre = prePostWhere[0];
if (prePostWhere[1] != null)
post = prePostWhere[1];
if (prePostWhere[2] != null) {
where = prePostWhere[2];
wheres.add(where);
}
}
GeometryColumn gCol = getGeometryColumnsForTable(tableName);
String sql = "SELECT " + pre + gCol.geometryColumnName + post + " FROM " + tableName;
if (intersectionGeometry != null) {
intersectionGeometry.setSRID(gCol.srid);
wheres.add(getSpatialindexGeometryWherePiece(tableName, null, intersectionGeometry));
}
if (wheres.size() > 0) {
sql += " WHERE " + DbsUtilities.joinBySeparator(wheres, " AND ");
}
IGeometryParser geometryParser = getType().getGeometryParser();
String _sql = sql;
return execOnConnection(connection -> {
try (IHMStatement stmt = connection.createStatement(); IHMResultSet rs = stmt.executeQuery(_sql)) {
while( rs.next() ) {
Geometry geometry = geometryParser.fromResultSet(rs, 1);
geoms.add(geometry);
}
return geoms;
}
});
} | java | public List<Geometry> getGeometriesIn( String tableName, Geometry intersectionGeometry, String... prePostWhere )
throws Exception {
List<Geometry> geoms = new ArrayList<Geometry>();
List<String> wheres = new ArrayList<>();
String pre = "";
String post = "";
String where = "";
if (prePostWhere != null && prePostWhere.length == 3) {
if (prePostWhere[0] != null)
pre = prePostWhere[0];
if (prePostWhere[1] != null)
post = prePostWhere[1];
if (prePostWhere[2] != null) {
where = prePostWhere[2];
wheres.add(where);
}
}
GeometryColumn gCol = getGeometryColumnsForTable(tableName);
String sql = "SELECT " + pre + gCol.geometryColumnName + post + " FROM " + tableName;
if (intersectionGeometry != null) {
intersectionGeometry.setSRID(gCol.srid);
wheres.add(getSpatialindexGeometryWherePiece(tableName, null, intersectionGeometry));
}
if (wheres.size() > 0) {
sql += " WHERE " + DbsUtilities.joinBySeparator(wheres, " AND ");
}
IGeometryParser geometryParser = getType().getGeometryParser();
String _sql = sql;
return execOnConnection(connection -> {
try (IHMStatement stmt = connection.createStatement(); IHMResultSet rs = stmt.executeQuery(_sql)) {
while( rs.next() ) {
Geometry geometry = geometryParser.fromResultSet(rs, 1);
geoms.add(geometry);
}
return geoms;
}
});
} | [
"public",
"List",
"<",
"Geometry",
">",
"getGeometriesIn",
"(",
"String",
"tableName",
",",
"Geometry",
"intersectionGeometry",
",",
"String",
"...",
"prePostWhere",
")",
"throws",
"Exception",
"{",
"List",
"<",
"Geometry",
">",
"geoms",
"=",
"new",
"ArrayList",
"<",
"Geometry",
">",
"(",
")",
";",
"List",
"<",
"String",
">",
"wheres",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"String",
"pre",
"=",
"\"\"",
";",
"String",
"post",
"=",
"\"\"",
";",
"String",
"where",
"=",
"\"\"",
";",
"if",
"(",
"prePostWhere",
"!=",
"null",
"&&",
"prePostWhere",
".",
"length",
"==",
"3",
")",
"{",
"if",
"(",
"prePostWhere",
"[",
"0",
"]",
"!=",
"null",
")",
"pre",
"=",
"prePostWhere",
"[",
"0",
"]",
";",
"if",
"(",
"prePostWhere",
"[",
"1",
"]",
"!=",
"null",
")",
"post",
"=",
"prePostWhere",
"[",
"1",
"]",
";",
"if",
"(",
"prePostWhere",
"[",
"2",
"]",
"!=",
"null",
")",
"{",
"where",
"=",
"prePostWhere",
"[",
"2",
"]",
";",
"wheres",
".",
"add",
"(",
"where",
")",
";",
"}",
"}",
"GeometryColumn",
"gCol",
"=",
"getGeometryColumnsForTable",
"(",
"tableName",
")",
";",
"String",
"sql",
"=",
"\"SELECT \"",
"+",
"pre",
"+",
"gCol",
".",
"geometryColumnName",
"+",
"post",
"+",
"\" FROM \"",
"+",
"tableName",
";",
"if",
"(",
"intersectionGeometry",
"!=",
"null",
")",
"{",
"intersectionGeometry",
".",
"setSRID",
"(",
"gCol",
".",
"srid",
")",
";",
"wheres",
".",
"add",
"(",
"getSpatialindexGeometryWherePiece",
"(",
"tableName",
",",
"null",
",",
"intersectionGeometry",
")",
")",
";",
"}",
"if",
"(",
"wheres",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"sql",
"+=",
"\" WHERE \"",
"+",
"DbsUtilities",
".",
"joinBySeparator",
"(",
"wheres",
",",
"\" AND \"",
")",
";",
"}",
"IGeometryParser",
"geometryParser",
"=",
"getType",
"(",
")",
".",
"getGeometryParser",
"(",
")",
";",
"String",
"_sql",
"=",
"sql",
";",
"return",
"execOnConnection",
"(",
"connection",
"->",
"{",
"try",
"(",
"IHMStatement",
"stmt",
"=",
"connection",
".",
"createStatement",
"(",
")",
";",
"IHMResultSet",
"rs",
"=",
"stmt",
".",
"executeQuery",
"(",
"_sql",
")",
")",
"{",
"while",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"Geometry",
"geometry",
"=",
"geometryParser",
".",
"fromResultSet",
"(",
"rs",
",",
"1",
")",
";",
"geoms",
".",
"add",
"(",
"geometry",
")",
";",
"}",
"return",
"geoms",
";",
"}",
"}",
")",
";",
"}"
] | Get the geometries of a table intersecting a given geometry.
@param tableName
the table name.
@param intersectionGeometry
the geometry to check, assumed in the same srid of the table geometry.
@param prePostWhere an optional set of 3 parameters. The parameters are: a
prefix wrapper for geom, a postfix for the same and a where string
to apply. They all need to be existing if the parameter is passed.
@return The list of geometries intersecting the geometry.
@throws Exception | [
"Get",
"the",
"geometries",
"of",
"a",
"table",
"intersecting",
"a",
"given",
"geometry",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/dbs/compat/ASpatialDb.java#L340-L382 |
137,926 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/NumericsUtilities.java | NumericsUtilities.fEq | public static boolean fEq( float a, float b, float epsilon ) {
if (isNaN(a) && isNaN(b)) {
return true;
}
float diffAbs = abs(a - b);
return a == b ? true : diffAbs < epsilon ? true : diffAbs / Math.max(abs(a), abs(b)) < epsilon;
} | java | public static boolean fEq( float a, float b, float epsilon ) {
if (isNaN(a) && isNaN(b)) {
return true;
}
float diffAbs = abs(a - b);
return a == b ? true : diffAbs < epsilon ? true : diffAbs / Math.max(abs(a), abs(b)) < epsilon;
} | [
"public",
"static",
"boolean",
"fEq",
"(",
"float",
"a",
",",
"float",
"b",
",",
"float",
"epsilon",
")",
"{",
"if",
"(",
"isNaN",
"(",
"a",
")",
"&&",
"isNaN",
"(",
"b",
")",
")",
"{",
"return",
"true",
";",
"}",
"float",
"diffAbs",
"=",
"abs",
"(",
"a",
"-",
"b",
")",
";",
"return",
"a",
"==",
"b",
"?",
"true",
":",
"diffAbs",
"<",
"epsilon",
"?",
"true",
":",
"diffAbs",
"/",
"Math",
".",
"max",
"(",
"abs",
"(",
"a",
")",
",",
"abs",
"(",
"b",
")",
")",
"<",
"epsilon",
";",
"}"
] | Returns true if two floats are considered equal based on an supplied epsilon.
<p>Note that two {@link Float#NaN} are seen as equal and return true.</p>
@param a float to compare.
@param b float to compare.
@return true if two float are considered equal. | [
"Returns",
"true",
"if",
"two",
"floats",
"are",
"considered",
"equal",
"based",
"on",
"an",
"supplied",
"epsilon",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/NumericsUtilities.java#L170-L176 |
137,927 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/NumericsUtilities.java | NumericsUtilities.logGamma | public static double logGamma( double x ) {
double ret;
if (Double.isNaN(x) || (x <= 0.0)) {
ret = Double.NaN;
} else {
double g = 607.0 / 128.0;
double sum = 0.0;
for( int i = LANCZOS.length - 1; i > 0; --i ) {
sum = sum + (LANCZOS[i] / (x + i));
}
sum = sum + LANCZOS[0];
double tmp = x + g + .5;
ret = ((x + .5) * log(tmp)) - tmp + HALF_LOG_2_PI + log(sum / x);
}
return ret;
} | java | public static double logGamma( double x ) {
double ret;
if (Double.isNaN(x) || (x <= 0.0)) {
ret = Double.NaN;
} else {
double g = 607.0 / 128.0;
double sum = 0.0;
for( int i = LANCZOS.length - 1; i > 0; --i ) {
sum = sum + (LANCZOS[i] / (x + i));
}
sum = sum + LANCZOS[0];
double tmp = x + g + .5;
ret = ((x + .5) * log(tmp)) - tmp + HALF_LOG_2_PI + log(sum / x);
}
return ret;
} | [
"public",
"static",
"double",
"logGamma",
"(",
"double",
"x",
")",
"{",
"double",
"ret",
";",
"if",
"(",
"Double",
".",
"isNaN",
"(",
"x",
")",
"||",
"(",
"x",
"<=",
"0.0",
")",
")",
"{",
"ret",
"=",
"Double",
".",
"NaN",
";",
"}",
"else",
"{",
"double",
"g",
"=",
"607.0",
"/",
"128.0",
";",
"double",
"sum",
"=",
"0.0",
";",
"for",
"(",
"int",
"i",
"=",
"LANCZOS",
".",
"length",
"-",
"1",
";",
"i",
">",
"0",
";",
"--",
"i",
")",
"{",
"sum",
"=",
"sum",
"+",
"(",
"LANCZOS",
"[",
"i",
"]",
"/",
"(",
"x",
"+",
"i",
")",
")",
";",
"}",
"sum",
"=",
"sum",
"+",
"LANCZOS",
"[",
"0",
"]",
";",
"double",
"tmp",
"=",
"x",
"+",
"g",
"+",
".5",
";",
"ret",
"=",
"(",
"(",
"x",
"+",
".5",
")",
"*",
"log",
"(",
"tmp",
")",
")",
"-",
"tmp",
"+",
"HALF_LOG_2_PI",
"+",
"log",
"(",
"sum",
"/",
"x",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | Gamma function ported from the apache math package.
<b>This should be removed if the apache math lib gets in use by HortonMachine.</b>
<p>Returns the natural logarithm of the gamma function Γ(x).
The implementation of this method is based on:
<ul>
<li><a href="http://mathworld.wolfram.com/GammaFunction.html">
Gamma Function</a>, equation (28).</li>
<li><a href="http://mathworld.wolfram.com/LanczosApproximation.html">
Lanczos Approximation</a>, equations (1) through (5).</li>
<li><a href="http://my.fit.edu/~gabdo/gamma.txt">Paul Godfrey, A note on
the computation of the convergent Lanczos complex Gamma approximation
</a></li>
</ul>
@param x Value.
@return log(Γ(x)) | [
"Gamma",
"function",
"ported",
"from",
"the",
"apache",
"math",
"package",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/NumericsUtilities.java#L293-L312 |
137,928 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/NumericsUtilities.java | NumericsUtilities.getNegativeRanges | public static List<int[]> getNegativeRanges( double[] x ) {
int firstNegative = -1;
int lastNegative = -1;
List<int[]> rangeList = new ArrayList<int[]>();
for( int i = 0; i < x.length; i++ ) {
double xValue = x[i];
if (firstNegative == -1 && xValue < 0) {
firstNegative = i;
} else if (firstNegative != -1 && lastNegative == -1 && xValue > 0) {
lastNegative = i - 1;
}
if (i == x.length - 1 && firstNegative != -1 && lastNegative == -1) {
// need to close the range with the last value available, even if negative
lastNegative = i;
}
if (firstNegative != -1 && lastNegative != -1) {
rangeList.add(new int[]{firstNegative, lastNegative});
firstNegative = -1;
lastNegative = -1;
}
}
return rangeList;
} | java | public static List<int[]> getNegativeRanges( double[] x ) {
int firstNegative = -1;
int lastNegative = -1;
List<int[]> rangeList = new ArrayList<int[]>();
for( int i = 0; i < x.length; i++ ) {
double xValue = x[i];
if (firstNegative == -1 && xValue < 0) {
firstNegative = i;
} else if (firstNegative != -1 && lastNegative == -1 && xValue > 0) {
lastNegative = i - 1;
}
if (i == x.length - 1 && firstNegative != -1 && lastNegative == -1) {
// need to close the range with the last value available, even if negative
lastNegative = i;
}
if (firstNegative != -1 && lastNegative != -1) {
rangeList.add(new int[]{firstNegative, lastNegative});
firstNegative = -1;
lastNegative = -1;
}
}
return rangeList;
} | [
"public",
"static",
"List",
"<",
"int",
"[",
"]",
">",
"getNegativeRanges",
"(",
"double",
"[",
"]",
"x",
")",
"{",
"int",
"firstNegative",
"=",
"-",
"1",
";",
"int",
"lastNegative",
"=",
"-",
"1",
";",
"List",
"<",
"int",
"[",
"]",
">",
"rangeList",
"=",
"new",
"ArrayList",
"<",
"int",
"[",
"]",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"x",
".",
"length",
";",
"i",
"++",
")",
"{",
"double",
"xValue",
"=",
"x",
"[",
"i",
"]",
";",
"if",
"(",
"firstNegative",
"==",
"-",
"1",
"&&",
"xValue",
"<",
"0",
")",
"{",
"firstNegative",
"=",
"i",
";",
"}",
"else",
"if",
"(",
"firstNegative",
"!=",
"-",
"1",
"&&",
"lastNegative",
"==",
"-",
"1",
"&&",
"xValue",
">",
"0",
")",
"{",
"lastNegative",
"=",
"i",
"-",
"1",
";",
"}",
"if",
"(",
"i",
"==",
"x",
".",
"length",
"-",
"1",
"&&",
"firstNegative",
"!=",
"-",
"1",
"&&",
"lastNegative",
"==",
"-",
"1",
")",
"{",
"// need to close the range with the last value available, even if negative",
"lastNegative",
"=",
"i",
";",
"}",
"if",
"(",
"firstNegative",
"!=",
"-",
"1",
"&&",
"lastNegative",
"!=",
"-",
"1",
")",
"{",
"rangeList",
".",
"add",
"(",
"new",
"int",
"[",
"]",
"{",
"firstNegative",
",",
"lastNegative",
"}",
")",
";",
"firstNegative",
"=",
"-",
"1",
";",
"lastNegative",
"=",
"-",
"1",
";",
"}",
"}",
"return",
"rangeList",
";",
"}"
] | Get the range index for which x is negative.
@param x
@return | [
"Get",
"the",
"range",
"index",
"for",
"which",
"x",
"is",
"negative",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/NumericsUtilities.java#L337-L363 |
137,929 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/NumericsUtilities.java | NumericsUtilities.range2Bins | public static double[] range2Bins( double min, double max, int binsNum ) {
double delta = (max - min) / binsNum;
double[] bins = new double[binsNum + 1];
int count = 0;
double running = min;
for( int i = 0; i < binsNum; i++ ) {
bins[count] = running;
running = running + delta;
count++;
}
bins[binsNum] = max;
return bins;
} | java | public static double[] range2Bins( double min, double max, int binsNum ) {
double delta = (max - min) / binsNum;
double[] bins = new double[binsNum + 1];
int count = 0;
double running = min;
for( int i = 0; i < binsNum; i++ ) {
bins[count] = running;
running = running + delta;
count++;
}
bins[binsNum] = max;
return bins;
} | [
"public",
"static",
"double",
"[",
"]",
"range2Bins",
"(",
"double",
"min",
",",
"double",
"max",
",",
"int",
"binsNum",
")",
"{",
"double",
"delta",
"=",
"(",
"max",
"-",
"min",
")",
"/",
"binsNum",
";",
"double",
"[",
"]",
"bins",
"=",
"new",
"double",
"[",
"binsNum",
"+",
"1",
"]",
";",
"int",
"count",
"=",
"0",
";",
"double",
"running",
"=",
"min",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"binsNum",
";",
"i",
"++",
")",
"{",
"bins",
"[",
"count",
"]",
"=",
"running",
";",
"running",
"=",
"running",
"+",
"delta",
";",
"count",
"++",
";",
"}",
"bins",
"[",
"binsNum",
"]",
"=",
"max",
";",
"return",
"bins",
";",
"}"
] | Creates an array of equal bin from a range and the number of bins.
@param min the min value.
@param max the max value.
@param binsNum the number of wanted bins.
@return the array of bin bounds of size [binNum+1], since it contains the min and max. | [
"Creates",
"an",
"array",
"of",
"equal",
"bin",
"from",
"a",
"range",
"and",
"the",
"number",
"of",
"bins",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/NumericsUtilities.java#L373-L385 |
137,930 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/NumericsUtilities.java | NumericsUtilities.range2Bins | public static double[] range2Bins( double min, double max, double step, boolean doLastEqual ) {
double intervalsDouble = (max - min) / step;
int intervals = (int) intervalsDouble;
double rest = intervalsDouble - intervals;
if (rest > D_TOLERANCE) {
intervals++;
}
double[] bins = new double[intervals + 1];
int count = 0;
double running = min;
for( int i = 0; i < intervals; i++ ) {
bins[count] = running;
running = running + step;
count++;
}
if (doLastEqual) {
bins[intervals] = running;
} else {
bins[intervals] = max;
}
return bins;
} | java | public static double[] range2Bins( double min, double max, double step, boolean doLastEqual ) {
double intervalsDouble = (max - min) / step;
int intervals = (int) intervalsDouble;
double rest = intervalsDouble - intervals;
if (rest > D_TOLERANCE) {
intervals++;
}
double[] bins = new double[intervals + 1];
int count = 0;
double running = min;
for( int i = 0; i < intervals; i++ ) {
bins[count] = running;
running = running + step;
count++;
}
if (doLastEqual) {
bins[intervals] = running;
} else {
bins[intervals] = max;
}
return bins;
} | [
"public",
"static",
"double",
"[",
"]",
"range2Bins",
"(",
"double",
"min",
",",
"double",
"max",
",",
"double",
"step",
",",
"boolean",
"doLastEqual",
")",
"{",
"double",
"intervalsDouble",
"=",
"(",
"max",
"-",
"min",
")",
"/",
"step",
";",
"int",
"intervals",
"=",
"(",
"int",
")",
"intervalsDouble",
";",
"double",
"rest",
"=",
"intervalsDouble",
"-",
"intervals",
";",
"if",
"(",
"rest",
">",
"D_TOLERANCE",
")",
"{",
"intervals",
"++",
";",
"}",
"double",
"[",
"]",
"bins",
"=",
"new",
"double",
"[",
"intervals",
"+",
"1",
"]",
";",
"int",
"count",
"=",
"0",
";",
"double",
"running",
"=",
"min",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"intervals",
";",
"i",
"++",
")",
"{",
"bins",
"[",
"count",
"]",
"=",
"running",
";",
"running",
"=",
"running",
"+",
"step",
";",
"count",
"++",
";",
"}",
"if",
"(",
"doLastEqual",
")",
"{",
"bins",
"[",
"intervals",
"]",
"=",
"running",
";",
"}",
"else",
"{",
"bins",
"[",
"intervals",
"]",
"=",
"max",
";",
"}",
"return",
"bins",
";",
"}"
] | Creates an array of bins from a range and a step to use.
<p>Note that if the step doesn't split the range exactly, the last bin
will be smaller if doLastEqual is set to <code>false</code>.</p>
@param min the min value.
@param max the max value.
@param step the wanted size of the bins.
@param doLastEqual make also the last bin of equal step size.
@return the array of bin bounds. | [
"Creates",
"an",
"array",
"of",
"bins",
"from",
"a",
"range",
"and",
"a",
"step",
"to",
"use",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/NumericsUtilities.java#L399-L422 |
137,931 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/statistics/kriging/OmsKriging.java | OmsKriging.verifyInput | private void verifyInput() {
if (inData == null || inStations == null) {
throw new NullPointerException(msg.message("kriging.stationproblem"));
}
if (pMode < 0 || pMode > 1) {
throw new IllegalArgumentException(msg.message("kriging.defaultMode"));
}
if (defaultVariogramMode != 0 && defaultVariogramMode != 1) {
throw new IllegalArgumentException(msg.message("kriging.variogramMode"));
}
if (defaultVariogramMode == 0) {
if (pVariance == 0 || pIntegralscale[0] == 0 || pIntegralscale[1] == 0 || pIntegralscale[2] == 0) {
pm.errorMessage(msg.message("kriging.noParam"));
pm.errorMessage("varianza " + pVariance);
pm.errorMessage("Integral scale x " + pIntegralscale[0]);
pm.errorMessage("Integral scale y " + pIntegralscale[1]);
pm.errorMessage("Integral scale z " + pIntegralscale[2]);
}
}
if (defaultVariogramMode == 1) {
if (pNug == 0 || pS == 0 || pA == 0) {
pm.errorMessage(msg.message("kriging.noParam"));
pm.errorMessage("Nugget " + pNug);
pm.errorMessage("Sill " + pS);
pm.errorMessage("Range " + pA);
}
}
if ((pMode == 0) && inInterpolate == null) {
throw new ModelsIllegalargumentException(msg.message("kriging.noPoint"), this, pm);
}
if (pMode == 1 && inInterpolationGrid == null) {
throw new ModelsIllegalargumentException("The gridded interpolation needs a gridgeometry in input.", this, pm);
}
} | java | private void verifyInput() {
if (inData == null || inStations == null) {
throw new NullPointerException(msg.message("kriging.stationproblem"));
}
if (pMode < 0 || pMode > 1) {
throw new IllegalArgumentException(msg.message("kriging.defaultMode"));
}
if (defaultVariogramMode != 0 && defaultVariogramMode != 1) {
throw new IllegalArgumentException(msg.message("kriging.variogramMode"));
}
if (defaultVariogramMode == 0) {
if (pVariance == 0 || pIntegralscale[0] == 0 || pIntegralscale[1] == 0 || pIntegralscale[2] == 0) {
pm.errorMessage(msg.message("kriging.noParam"));
pm.errorMessage("varianza " + pVariance);
pm.errorMessage("Integral scale x " + pIntegralscale[0]);
pm.errorMessage("Integral scale y " + pIntegralscale[1]);
pm.errorMessage("Integral scale z " + pIntegralscale[2]);
}
}
if (defaultVariogramMode == 1) {
if (pNug == 0 || pS == 0 || pA == 0) {
pm.errorMessage(msg.message("kriging.noParam"));
pm.errorMessage("Nugget " + pNug);
pm.errorMessage("Sill " + pS);
pm.errorMessage("Range " + pA);
}
}
if ((pMode == 0) && inInterpolate == null) {
throw new ModelsIllegalargumentException(msg.message("kriging.noPoint"), this, pm);
}
if (pMode == 1 && inInterpolationGrid == null) {
throw new ModelsIllegalargumentException("The gridded interpolation needs a gridgeometry in input.", this, pm);
}
} | [
"private",
"void",
"verifyInput",
"(",
")",
"{",
"if",
"(",
"inData",
"==",
"null",
"||",
"inStations",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"msg",
".",
"message",
"(",
"\"kriging.stationproblem\"",
")",
")",
";",
"}",
"if",
"(",
"pMode",
"<",
"0",
"||",
"pMode",
">",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"msg",
".",
"message",
"(",
"\"kriging.defaultMode\"",
")",
")",
";",
"}",
"if",
"(",
"defaultVariogramMode",
"!=",
"0",
"&&",
"defaultVariogramMode",
"!=",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"msg",
".",
"message",
"(",
"\"kriging.variogramMode\"",
")",
")",
";",
"}",
"if",
"(",
"defaultVariogramMode",
"==",
"0",
")",
"{",
"if",
"(",
"pVariance",
"==",
"0",
"||",
"pIntegralscale",
"[",
"0",
"]",
"==",
"0",
"||",
"pIntegralscale",
"[",
"1",
"]",
"==",
"0",
"||",
"pIntegralscale",
"[",
"2",
"]",
"==",
"0",
")",
"{",
"pm",
".",
"errorMessage",
"(",
"msg",
".",
"message",
"(",
"\"kriging.noParam\"",
")",
")",
";",
"pm",
".",
"errorMessage",
"(",
"\"varianza \"",
"+",
"pVariance",
")",
";",
"pm",
".",
"errorMessage",
"(",
"\"Integral scale x \"",
"+",
"pIntegralscale",
"[",
"0",
"]",
")",
";",
"pm",
".",
"errorMessage",
"(",
"\"Integral scale y \"",
"+",
"pIntegralscale",
"[",
"1",
"]",
")",
";",
"pm",
".",
"errorMessage",
"(",
"\"Integral scale z \"",
"+",
"pIntegralscale",
"[",
"2",
"]",
")",
";",
"}",
"}",
"if",
"(",
"defaultVariogramMode",
"==",
"1",
")",
"{",
"if",
"(",
"pNug",
"==",
"0",
"||",
"pS",
"==",
"0",
"||",
"pA",
"==",
"0",
")",
"{",
"pm",
".",
"errorMessage",
"(",
"msg",
".",
"message",
"(",
"\"kriging.noParam\"",
")",
")",
";",
"pm",
".",
"errorMessage",
"(",
"\"Nugget \"",
"+",
"pNug",
")",
";",
"pm",
".",
"errorMessage",
"(",
"\"Sill \"",
"+",
"pS",
")",
";",
"pm",
".",
"errorMessage",
"(",
"\"Range \"",
"+",
"pA",
")",
";",
"}",
"}",
"if",
"(",
"(",
"pMode",
"==",
"0",
")",
"&&",
"inInterpolate",
"==",
"null",
")",
"{",
"throw",
"new",
"ModelsIllegalargumentException",
"(",
"msg",
".",
"message",
"(",
"\"kriging.noPoint\"",
")",
",",
"this",
",",
"pm",
")",
";",
"}",
"if",
"(",
"pMode",
"==",
"1",
"&&",
"inInterpolationGrid",
"==",
"null",
")",
"{",
"throw",
"new",
"ModelsIllegalargumentException",
"(",
"\"The gridded interpolation needs a gridgeometry in input.\"",
",",
"this",
",",
"pm",
")",
";",
"}",
"}"
] | Verify the input of the model. | [
"Verify",
"the",
"input",
"of",
"the",
"model",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/statistics/kriging/OmsKriging.java#L486-L523 |
137,932 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/statistics/kriging/OmsKriging.java | OmsKriging.getCoordinate | private LinkedHashMap<Integer, Coordinate> getCoordinate( int nStaz, SimpleFeatureCollection collection, String idField )
throws Exception {
LinkedHashMap<Integer, Coordinate> id2CoordinatesMap = new LinkedHashMap<Integer, Coordinate>();
FeatureIterator<SimpleFeature> iterator = collection.features();
Coordinate coordinate = null;
try {
while( iterator.hasNext() ) {
SimpleFeature feature = iterator.next();
int name = ((Number) feature.getAttribute(idField)).intValue();
coordinate = ((Geometry) feature.getDefaultGeometry()).getCentroid().getCoordinate();
double z = 0;
if (fPointZ != null) {
try {
z = ((Number) feature.getAttribute(fPointZ)).doubleValue();
} catch (NullPointerException e) {
pm.errorMessage(msg.message("kriging.noPointZ"));
throw new Exception(msg.message("kriging.noPointZ"));
}
}
coordinate.z = z;
id2CoordinatesMap.put(name, coordinate);
}
} finally {
iterator.close();
}
return id2CoordinatesMap;
} | java | private LinkedHashMap<Integer, Coordinate> getCoordinate( int nStaz, SimpleFeatureCollection collection, String idField )
throws Exception {
LinkedHashMap<Integer, Coordinate> id2CoordinatesMap = new LinkedHashMap<Integer, Coordinate>();
FeatureIterator<SimpleFeature> iterator = collection.features();
Coordinate coordinate = null;
try {
while( iterator.hasNext() ) {
SimpleFeature feature = iterator.next();
int name = ((Number) feature.getAttribute(idField)).intValue();
coordinate = ((Geometry) feature.getDefaultGeometry()).getCentroid().getCoordinate();
double z = 0;
if (fPointZ != null) {
try {
z = ((Number) feature.getAttribute(fPointZ)).doubleValue();
} catch (NullPointerException e) {
pm.errorMessage(msg.message("kriging.noPointZ"));
throw new Exception(msg.message("kriging.noPointZ"));
}
}
coordinate.z = z;
id2CoordinatesMap.put(name, coordinate);
}
} finally {
iterator.close();
}
return id2CoordinatesMap;
} | [
"private",
"LinkedHashMap",
"<",
"Integer",
",",
"Coordinate",
">",
"getCoordinate",
"(",
"int",
"nStaz",
",",
"SimpleFeatureCollection",
"collection",
",",
"String",
"idField",
")",
"throws",
"Exception",
"{",
"LinkedHashMap",
"<",
"Integer",
",",
"Coordinate",
">",
"id2CoordinatesMap",
"=",
"new",
"LinkedHashMap",
"<",
"Integer",
",",
"Coordinate",
">",
"(",
")",
";",
"FeatureIterator",
"<",
"SimpleFeature",
">",
"iterator",
"=",
"collection",
".",
"features",
"(",
")",
";",
"Coordinate",
"coordinate",
"=",
"null",
";",
"try",
"{",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"SimpleFeature",
"feature",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"int",
"name",
"=",
"(",
"(",
"Number",
")",
"feature",
".",
"getAttribute",
"(",
"idField",
")",
")",
".",
"intValue",
"(",
")",
";",
"coordinate",
"=",
"(",
"(",
"Geometry",
")",
"feature",
".",
"getDefaultGeometry",
"(",
")",
")",
".",
"getCentroid",
"(",
")",
".",
"getCoordinate",
"(",
")",
";",
"double",
"z",
"=",
"0",
";",
"if",
"(",
"fPointZ",
"!=",
"null",
")",
"{",
"try",
"{",
"z",
"=",
"(",
"(",
"Number",
")",
"feature",
".",
"getAttribute",
"(",
"fPointZ",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"}",
"catch",
"(",
"NullPointerException",
"e",
")",
"{",
"pm",
".",
"errorMessage",
"(",
"msg",
".",
"message",
"(",
"\"kriging.noPointZ\"",
")",
")",
";",
"throw",
"new",
"Exception",
"(",
"msg",
".",
"message",
"(",
"\"kriging.noPointZ\"",
")",
")",
";",
"}",
"}",
"coordinate",
".",
"z",
"=",
"z",
";",
"id2CoordinatesMap",
".",
"put",
"(",
"name",
",",
"coordinate",
")",
";",
"}",
"}",
"finally",
"{",
"iterator",
".",
"close",
"(",
")",
";",
"}",
"return",
"id2CoordinatesMap",
";",
"}"
] | Extract the coordinate of a FeatureCollection in a HashMap with an ID as
a key.
@param nStaz
@param collection
@throws Exception
if a fiel of elevation isn't the same of the collection | [
"Extract",
"the",
"coordinate",
"of",
"a",
"FeatureCollection",
"in",
"a",
"HashMap",
"with",
"an",
"ID",
"as",
"a",
"key",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/statistics/kriging/OmsKriging.java#L624-L651 |
137,933 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/statistics/kriging/OmsKriging.java | OmsKriging.variogram | private double variogram( double c0, double a, double sill, double rx, double ry, double rz ) {
if (isNovalue(rz)) {
rz = 0;
}
double value = 0;
double h2 = Math.sqrt(rx * rx + rz * rz + ry * ry);
if (pSemivariogramType == 0) {
value = c0 + sill * (1 - Math.exp(-(h2 * h2) / (a * a)));
}
if (pSemivariogramType == 1) {
// primotest semivariogram
value = c0 + sill * (1 - Math.exp(-(h2) / (a)));
}
return value;
} | java | private double variogram( double c0, double a, double sill, double rx, double ry, double rz ) {
if (isNovalue(rz)) {
rz = 0;
}
double value = 0;
double h2 = Math.sqrt(rx * rx + rz * rz + ry * ry);
if (pSemivariogramType == 0) {
value = c0 + sill * (1 - Math.exp(-(h2 * h2) / (a * a)));
}
if (pSemivariogramType == 1) {
// primotest semivariogram
value = c0 + sill * (1 - Math.exp(-(h2) / (a)));
}
return value;
} | [
"private",
"double",
"variogram",
"(",
"double",
"c0",
",",
"double",
"a",
",",
"double",
"sill",
",",
"double",
"rx",
",",
"double",
"ry",
",",
"double",
"rz",
")",
"{",
"if",
"(",
"isNovalue",
"(",
"rz",
")",
")",
"{",
"rz",
"=",
"0",
";",
"}",
"double",
"value",
"=",
"0",
";",
"double",
"h2",
"=",
"Math",
".",
"sqrt",
"(",
"rx",
"*",
"rx",
"+",
"rz",
"*",
"rz",
"+",
"ry",
"*",
"ry",
")",
";",
"if",
"(",
"pSemivariogramType",
"==",
"0",
")",
"{",
"value",
"=",
"c0",
"+",
"sill",
"*",
"(",
"1",
"-",
"Math",
".",
"exp",
"(",
"-",
"(",
"h2",
"*",
"h2",
")",
"/",
"(",
"a",
"*",
"a",
")",
")",
")",
";",
"}",
"if",
"(",
"pSemivariogramType",
"==",
"1",
")",
"{",
"// primotest semivariogram",
"value",
"=",
"c0",
"+",
"sill",
"*",
"(",
"1",
"-",
"Math",
".",
"exp",
"(",
"-",
"(",
"h2",
")",
"/",
"(",
"a",
")",
")",
")",
";",
"}",
"return",
"value",
";",
"}"
] | The gaussian variogram
@param c0
nugget.
@param a
range.
@param sill
sill.
@param rx
x distance.
@param ry
y distance.
@param rz
z distance.
@return the variogram value | [
"The",
"gaussian",
"variogram"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/statistics/kriging/OmsKriging.java#L670-L684 |
137,934 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/util/Components.java | Components.figureOutConnect | public static void figureOutConnect(PrintStream w, Object... comps) {
// add all the components via Proxy.
List<ComponentAccess> l = new ArrayList<ComponentAccess>();
for (Object c : comps) {
l.add(new ComponentAccess(c));
}
// find all out slots
for (ComponentAccess cp_out : l) {
w.println("// connect " + objName(cp_out));
// over all input slots.
for (Access fout : cp_out.outputs()) {
String s = " out2in(" + objName(cp_out) + ", \"" + fout.getField().getName() + "\"";
for (ComponentAccess cp_in : l) {
// skip if it is the same component.
if (cp_in == cp_out) {
continue;
}
// out points to in
for (Access fin : cp_in.inputs()) {
// name equivalence enought for now.
if (fout.getField().getName().equals(fin.getField().getName())) {
s = s + ", " + objName(cp_in);
}
}
}
w.println(s + ");");
}
w.println();
}
} | java | public static void figureOutConnect(PrintStream w, Object... comps) {
// add all the components via Proxy.
List<ComponentAccess> l = new ArrayList<ComponentAccess>();
for (Object c : comps) {
l.add(new ComponentAccess(c));
}
// find all out slots
for (ComponentAccess cp_out : l) {
w.println("// connect " + objName(cp_out));
// over all input slots.
for (Access fout : cp_out.outputs()) {
String s = " out2in(" + objName(cp_out) + ", \"" + fout.getField().getName() + "\"";
for (ComponentAccess cp_in : l) {
// skip if it is the same component.
if (cp_in == cp_out) {
continue;
}
// out points to in
for (Access fin : cp_in.inputs()) {
// name equivalence enought for now.
if (fout.getField().getName().equals(fin.getField().getName())) {
s = s + ", " + objName(cp_in);
}
}
}
w.println(s + ");");
}
w.println();
}
} | [
"public",
"static",
"void",
"figureOutConnect",
"(",
"PrintStream",
"w",
",",
"Object",
"...",
"comps",
")",
"{",
"// add all the components via Proxy.",
"List",
"<",
"ComponentAccess",
">",
"l",
"=",
"new",
"ArrayList",
"<",
"ComponentAccess",
">",
"(",
")",
";",
"for",
"(",
"Object",
"c",
":",
"comps",
")",
"{",
"l",
".",
"add",
"(",
"new",
"ComponentAccess",
"(",
"c",
")",
")",
";",
"}",
"// find all out slots",
"for",
"(",
"ComponentAccess",
"cp_out",
":",
"l",
")",
"{",
"w",
".",
"println",
"(",
"\"// connect \"",
"+",
"objName",
"(",
"cp_out",
")",
")",
";",
"// over all input slots.",
"for",
"(",
"Access",
"fout",
":",
"cp_out",
".",
"outputs",
"(",
")",
")",
"{",
"String",
"s",
"=",
"\" out2in(\"",
"+",
"objName",
"(",
"cp_out",
")",
"+",
"\", \\\"\"",
"+",
"fout",
".",
"getField",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"\\\"\"",
";",
"for",
"(",
"ComponentAccess",
"cp_in",
":",
"l",
")",
"{",
"// skip if it is the same component.",
"if",
"(",
"cp_in",
"==",
"cp_out",
")",
"{",
"continue",
";",
"}",
"// out points to in",
"for",
"(",
"Access",
"fin",
":",
"cp_in",
".",
"inputs",
"(",
")",
")",
"{",
"// name equivalence enought for now.",
"if",
"(",
"fout",
".",
"getField",
"(",
")",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"fin",
".",
"getField",
"(",
")",
".",
"getName",
"(",
")",
")",
")",
"{",
"s",
"=",
"s",
"+",
"\", \"",
"+",
"objName",
"(",
"cp_in",
")",
";",
"}",
"}",
"}",
"w",
".",
"println",
"(",
"s",
"+",
"\");\"",
")",
";",
"}",
"w",
".",
"println",
"(",
")",
";",
"}",
"}"
] | Figure out connectivity and generate Java statements.
@param comps | [
"Figure",
"out",
"connectivity",
"and",
"generate",
"Java",
"statements",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/util/Components.java#L155-L185 |
137,935 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/util/Components.java | Components.getComponentClasses | public static List<Class<?>> getComponentClasses(URL jar) throws IOException {
JarInputStream jarFile = new JarInputStream(jar.openStream());
URLClassLoader cl = new URLClassLoader(new URL[]{jar}, Thread.currentThread().getContextClassLoader());
List<Class<?>> idx = new ArrayList<Class<?>>();
JarEntry jarEntry = jarFile.getNextJarEntry();
while (jarEntry != null) {
String classname = jarEntry.getName();
// System.out.println(classname);
if (classname.endsWith(".class")) {
classname = classname.substring(0, classname.indexOf(".class")).replace('/', '.');
try {
Class<?> c = Class.forName(classname, false, cl);
for (Method method : c.getMethods()) {
if ((method.getAnnotation(Execute.class)) != null) {
idx.add(c);
break;
}
}
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
}
jarEntry = jarFile.getNextJarEntry();
}
jarFile.close();
return idx;
} | java | public static List<Class<?>> getComponentClasses(URL jar) throws IOException {
JarInputStream jarFile = new JarInputStream(jar.openStream());
URLClassLoader cl = new URLClassLoader(new URL[]{jar}, Thread.currentThread().getContextClassLoader());
List<Class<?>> idx = new ArrayList<Class<?>>();
JarEntry jarEntry = jarFile.getNextJarEntry();
while (jarEntry != null) {
String classname = jarEntry.getName();
// System.out.println(classname);
if (classname.endsWith(".class")) {
classname = classname.substring(0, classname.indexOf(".class")).replace('/', '.');
try {
Class<?> c = Class.forName(classname, false, cl);
for (Method method : c.getMethods()) {
if ((method.getAnnotation(Execute.class)) != null) {
idx.add(c);
break;
}
}
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
}
jarEntry = jarFile.getNextJarEntry();
}
jarFile.close();
return idx;
} | [
"public",
"static",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"getComponentClasses",
"(",
"URL",
"jar",
")",
"throws",
"IOException",
"{",
"JarInputStream",
"jarFile",
"=",
"new",
"JarInputStream",
"(",
"jar",
".",
"openStream",
"(",
")",
")",
";",
"URLClassLoader",
"cl",
"=",
"new",
"URLClassLoader",
"(",
"new",
"URL",
"[",
"]",
"{",
"jar",
"}",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
")",
";",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"idx",
"=",
"new",
"ArrayList",
"<",
"Class",
"<",
"?",
">",
">",
"(",
")",
";",
"JarEntry",
"jarEntry",
"=",
"jarFile",
".",
"getNextJarEntry",
"(",
")",
";",
"while",
"(",
"jarEntry",
"!=",
"null",
")",
"{",
"String",
"classname",
"=",
"jarEntry",
".",
"getName",
"(",
")",
";",
"// System.out.println(classname);",
"if",
"(",
"classname",
".",
"endsWith",
"(",
"\".class\"",
")",
")",
"{",
"classname",
"=",
"classname",
".",
"substring",
"(",
"0",
",",
"classname",
".",
"indexOf",
"(",
"\".class\"",
")",
")",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"try",
"{",
"Class",
"<",
"?",
">",
"c",
"=",
"Class",
".",
"forName",
"(",
"classname",
",",
"false",
",",
"cl",
")",
";",
"for",
"(",
"Method",
"method",
":",
"c",
".",
"getMethods",
"(",
")",
")",
"{",
"if",
"(",
"(",
"method",
".",
"getAnnotation",
"(",
"Execute",
".",
"class",
")",
")",
"!=",
"null",
")",
"{",
"idx",
".",
"add",
"(",
"c",
")",
";",
"break",
";",
"}",
"}",
"}",
"catch",
"(",
"ClassNotFoundException",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"jarEntry",
"=",
"jarFile",
".",
"getNextJarEntry",
"(",
")",
";",
"}",
"jarFile",
".",
"close",
"(",
")",
";",
"return",
"idx",
";",
"}"
] | Get all components from a jar file
@param jar
@return the list of components from the jar. (Implement 'Execute' annotation)
@throws IOException
@throws ClassNotFoundException | [
"Get",
"all",
"components",
"from",
"a",
"jar",
"file"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/util/Components.java#L304-L331 |
137,936 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/util/Components.java | Components.getDocumentation | public static URL getDocumentation(Class<?> comp, Locale loc) {
Documentation doc = (Documentation) comp.getAnnotation(Documentation.class);
if (doc != null) {
String v = doc.value();
try {
// try full URL first (external reference)
URL url = new URL(v);
return url;
} catch (MalformedURLException E) {
// local resource bundled with the class
String name = v.substring(0, v.lastIndexOf('.'));
String ext = v.substring(v.lastIndexOf('.'));
String lang = loc.getLanguage();
URL f = comp.getResource(name + "_" + lang + ext);
if (f != null) {
return f;
}
f = comp.getResource(v);
if (f != null) {
return f;
}
}
}
return null;
} | java | public static URL getDocumentation(Class<?> comp, Locale loc) {
Documentation doc = (Documentation) comp.getAnnotation(Documentation.class);
if (doc != null) {
String v = doc.value();
try {
// try full URL first (external reference)
URL url = new URL(v);
return url;
} catch (MalformedURLException E) {
// local resource bundled with the class
String name = v.substring(0, v.lastIndexOf('.'));
String ext = v.substring(v.lastIndexOf('.'));
String lang = loc.getLanguage();
URL f = comp.getResource(name + "_" + lang + ext);
if (f != null) {
return f;
}
f = comp.getResource(v);
if (f != null) {
return f;
}
}
}
return null;
} | [
"public",
"static",
"URL",
"getDocumentation",
"(",
"Class",
"<",
"?",
">",
"comp",
",",
"Locale",
"loc",
")",
"{",
"Documentation",
"doc",
"=",
"(",
"Documentation",
")",
"comp",
".",
"getAnnotation",
"(",
"Documentation",
".",
"class",
")",
";",
"if",
"(",
"doc",
"!=",
"null",
")",
"{",
"String",
"v",
"=",
"doc",
".",
"value",
"(",
")",
";",
"try",
"{",
"// try full URL first (external reference)",
"URL",
"url",
"=",
"new",
"URL",
"(",
"v",
")",
";",
"return",
"url",
";",
"}",
"catch",
"(",
"MalformedURLException",
"E",
")",
"{",
"// local resource bundled with the class",
"String",
"name",
"=",
"v",
".",
"substring",
"(",
"0",
",",
"v",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
")",
";",
"String",
"ext",
"=",
"v",
".",
"substring",
"(",
"v",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
")",
";",
"String",
"lang",
"=",
"loc",
".",
"getLanguage",
"(",
")",
";",
"URL",
"f",
"=",
"comp",
".",
"getResource",
"(",
"name",
"+",
"\"_\"",
"+",
"lang",
"+",
"ext",
")",
";",
"if",
"(",
"f",
"!=",
"null",
")",
"{",
"return",
"f",
";",
"}",
"f",
"=",
"comp",
".",
"getResource",
"(",
"v",
")",
";",
"if",
"(",
"f",
"!=",
"null",
")",
"{",
"return",
"f",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Get the documentation as URL reference;
@param comp The class to get the 'Documentation' tag from
@param loc The locale
@return the URL of the documentation file, null if no documentation is available. | [
"Get",
"the",
"documentation",
"as",
"URL",
"reference",
";"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/util/Components.java#L393-L419 |
137,937 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/util/Components.java | Components.getDescription | public static String getDescription(Class<?> comp, Locale loc) {
Description descr = (Description) comp.getAnnotation(Description.class);
if (descr != null) {
String lang = loc.getLanguage();
Method[] m = descr.getClass().getMethods();
for (Method method : m) {
// System.out.println(method);
if (method.getName().equals(lang)) {
try {
String d = (String) method.invoke(descr, (Object[]) null);
if (d != null && !d.isEmpty()) {
return d;
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
return descr.value();
}
return null;
} | java | public static String getDescription(Class<?> comp, Locale loc) {
Description descr = (Description) comp.getAnnotation(Description.class);
if (descr != null) {
String lang = loc.getLanguage();
Method[] m = descr.getClass().getMethods();
for (Method method : m) {
// System.out.println(method);
if (method.getName().equals(lang)) {
try {
String d = (String) method.invoke(descr, (Object[]) null);
if (d != null && !d.isEmpty()) {
return d;
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
return descr.value();
}
return null;
} | [
"public",
"static",
"String",
"getDescription",
"(",
"Class",
"<",
"?",
">",
"comp",
",",
"Locale",
"loc",
")",
"{",
"Description",
"descr",
"=",
"(",
"Description",
")",
"comp",
".",
"getAnnotation",
"(",
"Description",
".",
"class",
")",
";",
"if",
"(",
"descr",
"!=",
"null",
")",
"{",
"String",
"lang",
"=",
"loc",
".",
"getLanguage",
"(",
")",
";",
"Method",
"[",
"]",
"m",
"=",
"descr",
".",
"getClass",
"(",
")",
".",
"getMethods",
"(",
")",
";",
"for",
"(",
"Method",
"method",
":",
"m",
")",
"{",
"// System.out.println(method);",
"if",
"(",
"method",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"lang",
")",
")",
"{",
"try",
"{",
"String",
"d",
"=",
"(",
"String",
")",
"method",
".",
"invoke",
"(",
"descr",
",",
"(",
"Object",
"[",
"]",
")",
"null",
")",
";",
"if",
"(",
"d",
"!=",
"null",
"&&",
"!",
"d",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"d",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}",
"return",
"descr",
".",
"value",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Get the Component Description
@param comp the component class
@param loc the locale
@return the localized description | [
"Get",
"the",
"Component",
"Description"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/util/Components.java#L431-L452 |
137,938 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/api/validation/helper/Utils.java | Utils.stringListToArray | public static Object[] stringListToArray(List<String> list) {
Object[] params = null;
if (list != null) {
params = list.toArray(new String[list.size()]);
}
return params;
} | java | public static Object[] stringListToArray(List<String> list) {
Object[] params = null;
if (list != null) {
params = list.toArray(new String[list.size()]);
}
return params;
} | [
"public",
"static",
"Object",
"[",
"]",
"stringListToArray",
"(",
"List",
"<",
"String",
">",
"list",
")",
"{",
"Object",
"[",
"]",
"params",
"=",
"null",
";",
"if",
"(",
"list",
"!=",
"null",
")",
"{",
"params",
"=",
"list",
".",
"toArray",
"(",
"new",
"String",
"[",
"list",
".",
"size",
"(",
")",
"]",
")",
";",
"}",
"return",
"params",
";",
"}"
] | Converts list of strings to an array.
@param list a list of strings to be converted
@return an array | [
"Converts",
"list",
"of",
"strings",
"to",
"an",
"array",
"."
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/helper/Utils.java#L113-L119 |
137,939 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/api/validation/helper/Utils.java | Utils.notMatches | public static boolean notMatches(String value, String prefix, String middle,
String postfix) {
return !matches(value, prefix, middle, postfix);
} | java | public static boolean notMatches(String value, String prefix, String middle,
String postfix) {
return !matches(value, prefix, middle, postfix);
} | [
"public",
"static",
"boolean",
"notMatches",
"(",
"String",
"value",
",",
"String",
"prefix",
",",
"String",
"middle",
",",
"String",
"postfix",
")",
"{",
"return",
"!",
"matches",
"(",
"value",
",",
"prefix",
",",
"middle",
",",
"postfix",
")",
";",
"}"
] | Check whether value NOT matches the pattern build with prefix, middle
part and post-fixer.
@param value a value to be checked
@param prefix a prefix pattern
@param middle a middle pattern
@param postfix a post-fixer pattern
@return true if value not matches pattern otherwise false | [
"Check",
"whether",
"value",
"NOT",
"matches",
"the",
"pattern",
"build",
"with",
"prefix",
"middle",
"part",
"and",
"post",
"-",
"fixer",
"."
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/helper/Utils.java#L131-L134 |
137,940 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/api/validation/helper/Utils.java | Utils.matches | public static boolean matches(String value, String prefix, String middle,
String postfix) {
String pattern = prefix + middle + postfix;
boolean result = value.matches(pattern);
return result;
} | java | public static boolean matches(String value, String prefix, String middle,
String postfix) {
String pattern = prefix + middle + postfix;
boolean result = value.matches(pattern);
return result;
} | [
"public",
"static",
"boolean",
"matches",
"(",
"String",
"value",
",",
"String",
"prefix",
",",
"String",
"middle",
",",
"String",
"postfix",
")",
"{",
"String",
"pattern",
"=",
"prefix",
"+",
"middle",
"+",
"postfix",
";",
"boolean",
"result",
"=",
"value",
".",
"matches",
"(",
"pattern",
")",
";",
"return",
"result",
";",
"}"
] | Check whether value matches the pattern build with prefix, middle part
and post-fixer.
@param value a value to be checked
@param prefix a prefix pattern
@param middle a middle pattern
@param postfix a post-fixer pattern
@return true if value matches pattern otherwise false | [
"Check",
"whether",
"value",
"matches",
"the",
"pattern",
"build",
"with",
"prefix",
"middle",
"part",
"and",
"post",
"-",
"fixer",
"."
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/helper/Utils.java#L146-L151 |
137,941 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/api/validation/helper/Utils.java | Utils.matchesWithoutPrefixes | public static boolean matchesWithoutPrefixes(String value1, String prefix1,
String value2, String prefix2) {
if (!value1.startsWith(prefix1)) {
return false;
}
value1 = value1.substring(prefix1.length());
if (!value2.startsWith(prefix2)) {
return false;
}
value2 = value2.substring(prefix2.length());
return value1.equals(value2);
} | java | public static boolean matchesWithoutPrefixes(String value1, String prefix1,
String value2, String prefix2) {
if (!value1.startsWith(prefix1)) {
return false;
}
value1 = value1.substring(prefix1.length());
if (!value2.startsWith(prefix2)) {
return false;
}
value2 = value2.substring(prefix2.length());
return value1.equals(value2);
} | [
"public",
"static",
"boolean",
"matchesWithoutPrefixes",
"(",
"String",
"value1",
",",
"String",
"prefix1",
",",
"String",
"value2",
",",
"String",
"prefix2",
")",
"{",
"if",
"(",
"!",
"value1",
".",
"startsWith",
"(",
"prefix1",
")",
")",
"{",
"return",
"false",
";",
"}",
"value1",
"=",
"value1",
".",
"substring",
"(",
"prefix1",
".",
"length",
"(",
")",
")",
";",
"if",
"(",
"!",
"value2",
".",
"startsWith",
"(",
"prefix2",
")",
")",
"{",
"return",
"false",
";",
"}",
"value2",
"=",
"value2",
".",
"substring",
"(",
"prefix2",
".",
"length",
"(",
")",
")",
";",
"return",
"value1",
".",
"equals",
"(",
"value2",
")",
";",
"}"
] | It removes prefixes from values and compare remaining parts.
@param value1 first value to be checked
@param prefix1 prefix of the first value
@param value2 second value to be checked
@param prefix2 prefix of the second value
@return true when both values without their prefixes are equal | [
"It",
"removes",
"prefixes",
"from",
"values",
"and",
"compare",
"remaining",
"parts",
"."
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/helper/Utils.java#L162-L175 |
137,942 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/api/validation/helper/Utils.java | Utils.shiftReferenceLocation | public static ValidationMessage shiftReferenceLocation(Entry entry,
long newSequenceLength) {
Collection<Reference> references = entry.getReferences();
for (Reference reference : references) {
for (Location rlocation : reference.getLocations().getLocations()) {
{
rlocation.setEndPosition(newSequenceLength);
if (rlocation.getBeginPosition().equals(
rlocation.getEndPosition())) {
return ValidationMessage.message(Severity.WARNING,
UTILS_6, rlocation.getBeginPosition(),
rlocation.getEndPosition());
}
}
}
}
return null;
} | java | public static ValidationMessage shiftReferenceLocation(Entry entry,
long newSequenceLength) {
Collection<Reference> references = entry.getReferences();
for (Reference reference : references) {
for (Location rlocation : reference.getLocations().getLocations()) {
{
rlocation.setEndPosition(newSequenceLength);
if (rlocation.getBeginPosition().equals(
rlocation.getEndPosition())) {
return ValidationMessage.message(Severity.WARNING,
UTILS_6, rlocation.getBeginPosition(),
rlocation.getEndPosition());
}
}
}
}
return null;
} | [
"public",
"static",
"ValidationMessage",
"shiftReferenceLocation",
"(",
"Entry",
"entry",
",",
"long",
"newSequenceLength",
")",
"{",
"Collection",
"<",
"Reference",
">",
"references",
"=",
"entry",
".",
"getReferences",
"(",
")",
";",
"for",
"(",
"Reference",
"reference",
":",
"references",
")",
"{",
"for",
"(",
"Location",
"rlocation",
":",
"reference",
".",
"getLocations",
"(",
")",
".",
"getLocations",
"(",
")",
")",
"{",
"{",
"rlocation",
".",
"setEndPosition",
"(",
"newSequenceLength",
")",
";",
"if",
"(",
"rlocation",
".",
"getBeginPosition",
"(",
")",
".",
"equals",
"(",
"rlocation",
".",
"getEndPosition",
"(",
")",
")",
")",
"{",
"return",
"ValidationMessage",
".",
"message",
"(",
"Severity",
".",
"WARNING",
",",
"UTILS_6",
",",
"rlocation",
".",
"getBeginPosition",
"(",
")",
",",
"rlocation",
".",
"getEndPosition",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Reference Location shifting | [
"Reference",
"Location",
"shifting"
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/helper/Utils.java#L532-L550 |
137,943 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/images/LineChartGenerator.java | LineChartGenerator.dumpChart | @SuppressWarnings("nls")
public void dumpChart( File chartFile, boolean autoRange, boolean withLegend, int imageWidth, int imageHeight )
throws IOException {
JFreeChart chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, collection, PlotOrientation.VERTICAL, withLegend,
false, false);
XYPlot plot = (XYPlot) chart.getPlot();
// plot.setDomainPannable(true);
// plot.setRangePannable(true);
// plot.setForegroundAlpha(0.85f);
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
if (autoRange) {
double delta = (max - min) * 0.1;
yAxis.setRange(min - delta, max + delta);
// TODO reactivate if newer jfree is used
// yAxis.setMinorTickCount(4);
// yAxis.setMinorTickMarksVisible(true);
}
// ValueAxis xAxis = plot.getDomainAxis();
// xAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US));
// XYItemRenderer renderer = plot.getRenderer();
// renderer.setDrawBarOutline(false);
// // flat bars look best...
// renderer.setBarPainter(new StandardXYBarPainter());
// renderer.setShadowVisible(false);
if (!chartFile.getName().endsWith(".png")) {
chartFile = FileUtilities.substituteExtention(chartFile, "png");
}
if (imageWidth == -1) {
imageWidth = IMAGEWIDTH;
}
if (imageHeight == -1) {
imageHeight = IMAGEHEIGHT;
}
BufferedImage bufferedImage = chart.createBufferedImage(imageWidth, imageHeight);
ImageIO.write(bufferedImage, "png", chartFile);
} | java | @SuppressWarnings("nls")
public void dumpChart( File chartFile, boolean autoRange, boolean withLegend, int imageWidth, int imageHeight )
throws IOException {
JFreeChart chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, collection, PlotOrientation.VERTICAL, withLegend,
false, false);
XYPlot plot = (XYPlot) chart.getPlot();
// plot.setDomainPannable(true);
// plot.setRangePannable(true);
// plot.setForegroundAlpha(0.85f);
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
if (autoRange) {
double delta = (max - min) * 0.1;
yAxis.setRange(min - delta, max + delta);
// TODO reactivate if newer jfree is used
// yAxis.setMinorTickCount(4);
// yAxis.setMinorTickMarksVisible(true);
}
// ValueAxis xAxis = plot.getDomainAxis();
// xAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US));
// XYItemRenderer renderer = plot.getRenderer();
// renderer.setDrawBarOutline(false);
// // flat bars look best...
// renderer.setBarPainter(new StandardXYBarPainter());
// renderer.setShadowVisible(false);
if (!chartFile.getName().endsWith(".png")) {
chartFile = FileUtilities.substituteExtention(chartFile, "png");
}
if (imageWidth == -1) {
imageWidth = IMAGEWIDTH;
}
if (imageHeight == -1) {
imageHeight = IMAGEHEIGHT;
}
BufferedImage bufferedImage = chart.createBufferedImage(imageWidth, imageHeight);
ImageIO.write(bufferedImage, "png", chartFile);
} | [
"@",
"SuppressWarnings",
"(",
"\"nls\"",
")",
"public",
"void",
"dumpChart",
"(",
"File",
"chartFile",
",",
"boolean",
"autoRange",
",",
"boolean",
"withLegend",
",",
"int",
"imageWidth",
",",
"int",
"imageHeight",
")",
"throws",
"IOException",
"{",
"JFreeChart",
"chart",
"=",
"ChartFactory",
".",
"createXYLineChart",
"(",
"title",
",",
"xLabel",
",",
"yLabel",
",",
"collection",
",",
"PlotOrientation",
".",
"VERTICAL",
",",
"withLegend",
",",
"false",
",",
"false",
")",
";",
"XYPlot",
"plot",
"=",
"(",
"XYPlot",
")",
"chart",
".",
"getPlot",
"(",
")",
";",
"// plot.setDomainPannable(true);",
"// plot.setRangePannable(true);",
"// plot.setForegroundAlpha(0.85f);",
"NumberAxis",
"yAxis",
"=",
"(",
"NumberAxis",
")",
"plot",
".",
"getRangeAxis",
"(",
")",
";",
"yAxis",
".",
"setStandardTickUnits",
"(",
"NumberAxis",
".",
"createStandardTickUnits",
"(",
")",
")",
";",
"if",
"(",
"autoRange",
")",
"{",
"double",
"delta",
"=",
"(",
"max",
"-",
"min",
")",
"*",
"0.1",
";",
"yAxis",
".",
"setRange",
"(",
"min",
"-",
"delta",
",",
"max",
"+",
"delta",
")",
";",
"// TODO reactivate if newer jfree is used",
"// yAxis.setMinorTickCount(4);",
"// yAxis.setMinorTickMarksVisible(true);",
"}",
"// ValueAxis xAxis = plot.getDomainAxis();",
"// xAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US));",
"// XYItemRenderer renderer = plot.getRenderer();",
"// renderer.setDrawBarOutline(false);",
"// // flat bars look best...",
"// renderer.setBarPainter(new StandardXYBarPainter());",
"// renderer.setShadowVisible(false);",
"if",
"(",
"!",
"chartFile",
".",
"getName",
"(",
")",
".",
"endsWith",
"(",
"\".png\"",
")",
")",
"{",
"chartFile",
"=",
"FileUtilities",
".",
"substituteExtention",
"(",
"chartFile",
",",
"\"png\"",
")",
";",
"}",
"if",
"(",
"imageWidth",
"==",
"-",
"1",
")",
"{",
"imageWidth",
"=",
"IMAGEWIDTH",
";",
"}",
"if",
"(",
"imageHeight",
"==",
"-",
"1",
")",
"{",
"imageHeight",
"=",
"IMAGEHEIGHT",
";",
"}",
"BufferedImage",
"bufferedImage",
"=",
"chart",
".",
"createBufferedImage",
"(",
"imageWidth",
",",
"imageHeight",
")",
";",
"ImageIO",
".",
"write",
"(",
"bufferedImage",
",",
"\"png\"",
",",
"chartFile",
")",
";",
"}"
] | Creates the chart image and dumps it to file.
@param chartFile the file to which to write to.
@param autoRange flag to define if to auto define the range from the bounds.
@param withLegend flag to define the legend presence.
@param imageWidth the output image width (if -1 default is used).
@param imageHeight the output image height (if -1 default is used).
@throws IOException | [
"Creates",
"the",
"chart",
"image",
"and",
"dumps",
"it",
"to",
"file",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/images/LineChartGenerator.java#L85-L125 |
137,944 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/style/StyleWrapper.java | StyleWrapper.getFirstRule | public RuleWrapper getFirstRule() {
if (featureTypeStylesWrapperList.size() > 0) {
FeatureTypeStyleWrapper featureTypeStyleWrapper = featureTypeStylesWrapperList.get(0);
List<RuleWrapper> rulesWrapperList = featureTypeStyleWrapper.getRulesWrapperList();
if (rulesWrapperList.size() > 0) {
RuleWrapper ruleWrapper = rulesWrapperList.get(0);
return ruleWrapper;
}
}
return null;
} | java | public RuleWrapper getFirstRule() {
if (featureTypeStylesWrapperList.size() > 0) {
FeatureTypeStyleWrapper featureTypeStyleWrapper = featureTypeStylesWrapperList.get(0);
List<RuleWrapper> rulesWrapperList = featureTypeStyleWrapper.getRulesWrapperList();
if (rulesWrapperList.size() > 0) {
RuleWrapper ruleWrapper = rulesWrapperList.get(0);
return ruleWrapper;
}
}
return null;
} | [
"public",
"RuleWrapper",
"getFirstRule",
"(",
")",
"{",
"if",
"(",
"featureTypeStylesWrapperList",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"FeatureTypeStyleWrapper",
"featureTypeStyleWrapper",
"=",
"featureTypeStylesWrapperList",
".",
"get",
"(",
"0",
")",
";",
"List",
"<",
"RuleWrapper",
">",
"rulesWrapperList",
"=",
"featureTypeStyleWrapper",
".",
"getRulesWrapperList",
"(",
")",
";",
"if",
"(",
"rulesWrapperList",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"RuleWrapper",
"ruleWrapper",
"=",
"rulesWrapperList",
".",
"get",
"(",
"0",
")",
";",
"return",
"ruleWrapper",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Facility to get the first rule, if available.
@return the first rule or <code>null</code>. | [
"Facility",
"to",
"get",
"the",
"first",
"rule",
"if",
"available",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/style/StyleWrapper.java#L63-L73 |
137,945 | TheHortonMachine/hortonmachine | gui/src/main/java/org/hortonmachine/gui/spatialtoolbox/core/FieldData.java | FieldData.isSimpleType | public boolean isSimpleType() {
if (//
fieldType.equals(Double.class.getCanonicalName()) || //
fieldType.equals(Float.class.getCanonicalName()) || //
fieldType.equals(Integer.class.getCanonicalName()) || //
fieldType.equals(double.class.getCanonicalName()) || //
fieldType.equals(float.class.getCanonicalName()) || //
fieldType.equals(int.class.getCanonicalName()) || //
fieldType.equals(Boolean.class.getCanonicalName()) || //
fieldType.equals(boolean.class.getCanonicalName()) || //
fieldType.equals(String.class.getCanonicalName()) //
) {
return true;
}
return false;
} | java | public boolean isSimpleType() {
if (//
fieldType.equals(Double.class.getCanonicalName()) || //
fieldType.equals(Float.class.getCanonicalName()) || //
fieldType.equals(Integer.class.getCanonicalName()) || //
fieldType.equals(double.class.getCanonicalName()) || //
fieldType.equals(float.class.getCanonicalName()) || //
fieldType.equals(int.class.getCanonicalName()) || //
fieldType.equals(Boolean.class.getCanonicalName()) || //
fieldType.equals(boolean.class.getCanonicalName()) || //
fieldType.equals(String.class.getCanonicalName()) //
) {
return true;
}
return false;
} | [
"public",
"boolean",
"isSimpleType",
"(",
")",
"{",
"if",
"(",
"//",
"fieldType",
".",
"equals",
"(",
"Double",
".",
"class",
".",
"getCanonicalName",
"(",
")",
")",
"||",
"//",
"fieldType",
".",
"equals",
"(",
"Float",
".",
"class",
".",
"getCanonicalName",
"(",
")",
")",
"||",
"//",
"fieldType",
".",
"equals",
"(",
"Integer",
".",
"class",
".",
"getCanonicalName",
"(",
")",
")",
"||",
"//",
"fieldType",
".",
"equals",
"(",
"double",
".",
"class",
".",
"getCanonicalName",
"(",
")",
")",
"||",
"//",
"fieldType",
".",
"equals",
"(",
"float",
".",
"class",
".",
"getCanonicalName",
"(",
")",
")",
"||",
"//",
"fieldType",
".",
"equals",
"(",
"int",
".",
"class",
".",
"getCanonicalName",
"(",
")",
")",
"||",
"//",
"fieldType",
".",
"equals",
"(",
"Boolean",
".",
"class",
".",
"getCanonicalName",
"(",
")",
")",
"||",
"//",
"fieldType",
".",
"equals",
"(",
"boolean",
".",
"class",
".",
"getCanonicalName",
"(",
")",
")",
"||",
"//",
"fieldType",
".",
"equals",
"(",
"String",
".",
"class",
".",
"getCanonicalName",
"(",
")",
")",
"//",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks if this field is a simple type.
<p>
Simple types are:
<ul>
<li>double</li>
<li>float</li>
<li>int</li>
<li>...</li>
<li>Double</li>
<li>Float</li>
<li>...</li>
<li>boolean</li>
<li>Boolean</li>
<li>String</li>
</ul>
</p>
@return true if the type is simple. | [
"Checks",
"if",
"this",
"field",
"is",
"a",
"simple",
"type",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gui/src/main/java/org/hortonmachine/gui/spatialtoolbox/core/FieldData.java#L109-L124 |
137,946 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/api/validation/check/sourcefeature/SequenceCoverageCheck.java | SequenceCoverageCheck.checkLocation | private Long[] checkLocation(Location location) {
Long[] positions = new Long[2];
if (location.isComplement()) {
positions[0] = location.getEndPosition();
positions[1] = location.getBeginPosition();
} else {
positions[0] = location.getBeginPosition();
positions[1] = location.getEndPosition();
}
return positions;
} | java | private Long[] checkLocation(Location location) {
Long[] positions = new Long[2];
if (location.isComplement()) {
positions[0] = location.getEndPosition();
positions[1] = location.getBeginPosition();
} else {
positions[0] = location.getBeginPosition();
positions[1] = location.getEndPosition();
}
return positions;
} | [
"private",
"Long",
"[",
"]",
"checkLocation",
"(",
"Location",
"location",
")",
"{",
"Long",
"[",
"]",
"positions",
"=",
"new",
"Long",
"[",
"2",
"]",
";",
"if",
"(",
"location",
".",
"isComplement",
"(",
")",
")",
"{",
"positions",
"[",
"0",
"]",
"=",
"location",
".",
"getEndPosition",
"(",
")",
";",
"positions",
"[",
"1",
"]",
"=",
"location",
".",
"getBeginPosition",
"(",
")",
";",
"}",
"else",
"{",
"positions",
"[",
"0",
"]",
"=",
"location",
".",
"getBeginPosition",
"(",
")",
";",
"positions",
"[",
"1",
"]",
"=",
"location",
".",
"getEndPosition",
"(",
")",
";",
"}",
"return",
"positions",
";",
"}"
] | Checks and swaps positions if in wrong order.
@param location location to be checked
@return an array of positions (in proper order) | [
"Checks",
"and",
"swaps",
"positions",
"if",
"in",
"wrong",
"order",
"."
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/check/sourcefeature/SequenceCoverageCheck.java#L179-L189 |
137,947 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/api/entry/sequence/Sequence.java | Sequence.getSequence | @Deprecated
@Override
public String getSequence(Long beginPosition, Long endPosition) {
if (beginPosition == null || endPosition == null
|| (beginPosition > endPosition) || beginPosition < 1
|| endPosition >getLength()) {
return null;
}
int length = (int) (endPosition.longValue() - beginPosition.longValue()) + 1;
int offset = beginPosition.intValue() - 1;
String subSequence=null;
try{
subSequence= ByteBufferUtils.string(getSequenceBuffer(), offset, length);
}
catch(Exception e)
{
e.printStackTrace();
return subSequence;
}
return subSequence;
/*// note begin:1 end:4 has length 4
byte[] subsequence = new byte[length];
synchronized (sequence) {
sequence.position(offset);
sequence.get(subsequence, 0, length);
}
String string = new String(subsequence);
return string;*/
} | java | @Deprecated
@Override
public String getSequence(Long beginPosition, Long endPosition) {
if (beginPosition == null || endPosition == null
|| (beginPosition > endPosition) || beginPosition < 1
|| endPosition >getLength()) {
return null;
}
int length = (int) (endPosition.longValue() - beginPosition.longValue()) + 1;
int offset = beginPosition.intValue() - 1;
String subSequence=null;
try{
subSequence= ByteBufferUtils.string(getSequenceBuffer(), offset, length);
}
catch(Exception e)
{
e.printStackTrace();
return subSequence;
}
return subSequence;
/*// note begin:1 end:4 has length 4
byte[] subsequence = new byte[length];
synchronized (sequence) {
sequence.position(offset);
sequence.get(subsequence, 0, length);
}
String string = new String(subsequence);
return string;*/
} | [
"@",
"Deprecated",
"@",
"Override",
"public",
"String",
"getSequence",
"(",
"Long",
"beginPosition",
",",
"Long",
"endPosition",
")",
"{",
"if",
"(",
"beginPosition",
"==",
"null",
"||",
"endPosition",
"==",
"null",
"||",
"(",
"beginPosition",
">",
"endPosition",
")",
"||",
"beginPosition",
"<",
"1",
"||",
"endPosition",
">",
"getLength",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"int",
"length",
"=",
"(",
"int",
")",
"(",
"endPosition",
".",
"longValue",
"(",
")",
"-",
"beginPosition",
".",
"longValue",
"(",
")",
")",
"+",
"1",
";",
"int",
"offset",
"=",
"beginPosition",
".",
"intValue",
"(",
")",
"-",
"1",
";",
"String",
"subSequence",
"=",
"null",
";",
"try",
"{",
"subSequence",
"=",
"ByteBufferUtils",
".",
"string",
"(",
"getSequenceBuffer",
"(",
")",
",",
"offset",
",",
"length",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"return",
"subSequence",
";",
"}",
"return",
"subSequence",
";",
"/*// note begin:1 end:4 has length 4\n\t\t\n\n\t\tbyte[] subsequence = new byte[length];\n\n\t\t\n\t\tsynchronized (sequence) {\n\t\t\tsequence.position(offset);\n\t\t\tsequence.get(subsequence, 0, length);\n\t\t}\n\t\t\n\t\tString string = new String(subsequence);\n\n\t\treturn string;*/",
"}"
] | Overridden so we can create appropriate sized buffer before making
string.
@see uk.ac.ebi.embl.api.entry.sequence.AbstractSequence#getSequence(java.lang.Long,
java.lang.Long) | [
"Overridden",
"so",
"we",
"can",
"create",
"appropriate",
"sized",
"buffer",
"before",
"making",
"string",
"."
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/entry/sequence/Sequence.java#L137-L173 |
137,948 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/ngmf/util/IOCase.java | IOCase.convertCase | String convertCase(String str) {
if (str == null) {
return null;
}
return sensitive ? str : str.toLowerCase();
} | java | String convertCase(String str) {
if (str == null) {
return null;
}
return sensitive ? str : str.toLowerCase();
} | [
"String",
"convertCase",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"sensitive",
"?",
"str",
":",
"str",
".",
"toLowerCase",
"(",
")",
";",
"}"
] | Converts the case of the input String to a standard format.
Subsequent operations can then use standard String methods.
@param str the string to convert, null returns null
@return the lower-case version if case-insensitive | [
"Converts",
"the",
"case",
"of",
"the",
"input",
"String",
"to",
"a",
"standard",
"format",
".",
"Subsequent",
"operations",
"can",
"then",
"use",
"standard",
"String",
"methods",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/ngmf/util/IOCase.java#L221-L226 |
137,949 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/RowVector.java | RowVector.set | private void set(Matrix m)
{
this.nRows = 1;
this.nCols = m.nCols;
this.values = m.values;
} | java | private void set(Matrix m)
{
this.nRows = 1;
this.nCols = m.nCols;
this.values = m.values;
} | [
"private",
"void",
"set",
"(",
"Matrix",
"m",
")",
"{",
"this",
".",
"nRows",
"=",
"1",
";",
"this",
".",
"nCols",
"=",
"m",
".",
"nCols",
";",
"this",
".",
"values",
"=",
"m",
".",
"values",
";",
"}"
] | Set this row vector from a matrix. Only the first row is used.
@param m the matrix | [
"Set",
"this",
"row",
"vector",
"from",
"a",
"matrix",
".",
"Only",
"the",
"first",
"row",
"is",
"used",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/RowVector.java#L71-L76 |
137,950 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java | Matrix.getRow | public RowVector getRow(int r) throws MatrixException
{
if ((r < 0) || (r >= nRows)) {
throw new MatrixException(MatrixException.INVALID_INDEX);
}
RowVector rv = new RowVector(nCols);
for (int c = 0; c < nCols; ++c) {
rv.values[0][c] = this.values[r][c];
}
return rv;
} | java | public RowVector getRow(int r) throws MatrixException
{
if ((r < 0) || (r >= nRows)) {
throw new MatrixException(MatrixException.INVALID_INDEX);
}
RowVector rv = new RowVector(nCols);
for (int c = 0; c < nCols; ++c) {
rv.values[0][c] = this.values[r][c];
}
return rv;
} | [
"public",
"RowVector",
"getRow",
"(",
"int",
"r",
")",
"throws",
"MatrixException",
"{",
"if",
"(",
"(",
"r",
"<",
"0",
")",
"||",
"(",
"r",
">=",
"nRows",
")",
")",
"{",
"throw",
"new",
"MatrixException",
"(",
"MatrixException",
".",
"INVALID_INDEX",
")",
";",
"}",
"RowVector",
"rv",
"=",
"new",
"RowVector",
"(",
"nCols",
")",
";",
"for",
"(",
"int",
"c",
"=",
"0",
";",
"c",
"<",
"nCols",
";",
"++",
"c",
")",
"{",
"rv",
".",
"values",
"[",
"0",
"]",
"[",
"c",
"]",
"=",
"this",
".",
"values",
"[",
"r",
"]",
"[",
"c",
"]",
";",
"}",
"return",
"rv",
";",
"}"
] | Get a row of this matrix.
@param r the row index
@return the row as a row vector
@throws numbercruncher.MatrixException for an invalid index | [
"Get",
"a",
"row",
"of",
"this",
"matrix",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java#L82-L94 |
137,951 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java | Matrix.getColumn | public ColumnVector getColumn(int c) throws MatrixException
{
if ((c < 0) || (c >= nCols)) {
throw new MatrixException(MatrixException.INVALID_INDEX);
}
ColumnVector cv = new ColumnVector(nRows);
for (int r = 0; r < nRows; ++r) {
cv.values[r][0] = this.values[r][c];
}
return cv;
} | java | public ColumnVector getColumn(int c) throws MatrixException
{
if ((c < 0) || (c >= nCols)) {
throw new MatrixException(MatrixException.INVALID_INDEX);
}
ColumnVector cv = new ColumnVector(nRows);
for (int r = 0; r < nRows; ++r) {
cv.values[r][0] = this.values[r][c];
}
return cv;
} | [
"public",
"ColumnVector",
"getColumn",
"(",
"int",
"c",
")",
"throws",
"MatrixException",
"{",
"if",
"(",
"(",
"c",
"<",
"0",
")",
"||",
"(",
"c",
">=",
"nCols",
")",
")",
"{",
"throw",
"new",
"MatrixException",
"(",
"MatrixException",
".",
"INVALID_INDEX",
")",
";",
"}",
"ColumnVector",
"cv",
"=",
"new",
"ColumnVector",
"(",
"nRows",
")",
";",
"for",
"(",
"int",
"r",
"=",
"0",
";",
"r",
"<",
"nRows",
";",
"++",
"r",
")",
"{",
"cv",
".",
"values",
"[",
"r",
"]",
"[",
"0",
"]",
"=",
"this",
".",
"values",
"[",
"r",
"]",
"[",
"c",
"]",
";",
"}",
"return",
"cv",
";",
"}"
] | Get a column of this matrix.
@param c the column index
@return the column as a column vector
@throws numbercruncher.MatrixException for an invalid index | [
"Get",
"a",
"column",
"of",
"this",
"matrix",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java#L102-L114 |
137,952 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java | Matrix.set | protected void set(double values[][])
{
this.nRows = values.length;
this.nCols = values[0].length;
this.values = values;
for (int r = 1; r < nRows; ++r) {
nCols = Math.min(nCols, values[r].length);
}
} | java | protected void set(double values[][])
{
this.nRows = values.length;
this.nCols = values[0].length;
this.values = values;
for (int r = 1; r < nRows; ++r) {
nCols = Math.min(nCols, values[r].length);
}
} | [
"protected",
"void",
"set",
"(",
"double",
"values",
"[",
"]",
"[",
"]",
")",
"{",
"this",
".",
"nRows",
"=",
"values",
".",
"length",
";",
"this",
".",
"nCols",
"=",
"values",
"[",
"0",
"]",
".",
"length",
";",
"this",
".",
"values",
"=",
"values",
";",
"for",
"(",
"int",
"r",
"=",
"1",
";",
"r",
"<",
"nRows",
";",
"++",
"r",
")",
"{",
"nCols",
"=",
"Math",
".",
"min",
"(",
"nCols",
",",
"values",
"[",
"r",
"]",
".",
"length",
")",
";",
"}",
"}"
] | Set this matrix from a 2-d array of values.
If the rows do not have the same length, then the matrix
column count is the length of the shortest row.
@param values the 2-d array of values | [
"Set",
"this",
"matrix",
"from",
"a",
"2",
"-",
"d",
"array",
"of",
"values",
".",
"If",
"the",
"rows",
"do",
"not",
"have",
"the",
"same",
"length",
"then",
"the",
"matrix",
"column",
"count",
"is",
"the",
"length",
"of",
"the",
"shortest",
"row",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java#L165-L174 |
137,953 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java | Matrix.setRow | public void setRow(RowVector rv, int r) throws MatrixException
{
if ((r < 0) || (r >= nRows)) {
throw new MatrixException(MatrixException.INVALID_INDEX);
}
if (nCols != rv.nCols) {
throw new MatrixException(
MatrixException.INVALID_DIMENSIONS);
}
for (int c = 0; c < nCols; ++c) {
this.values[r][c] = rv.values[0][c];
}
} | java | public void setRow(RowVector rv, int r) throws MatrixException
{
if ((r < 0) || (r >= nRows)) {
throw new MatrixException(MatrixException.INVALID_INDEX);
}
if (nCols != rv.nCols) {
throw new MatrixException(
MatrixException.INVALID_DIMENSIONS);
}
for (int c = 0; c < nCols; ++c) {
this.values[r][c] = rv.values[0][c];
}
} | [
"public",
"void",
"setRow",
"(",
"RowVector",
"rv",
",",
"int",
"r",
")",
"throws",
"MatrixException",
"{",
"if",
"(",
"(",
"r",
"<",
"0",
")",
"||",
"(",
"r",
">=",
"nRows",
")",
")",
"{",
"throw",
"new",
"MatrixException",
"(",
"MatrixException",
".",
"INVALID_INDEX",
")",
";",
"}",
"if",
"(",
"nCols",
"!=",
"rv",
".",
"nCols",
")",
"{",
"throw",
"new",
"MatrixException",
"(",
"MatrixException",
".",
"INVALID_DIMENSIONS",
")",
";",
"}",
"for",
"(",
"int",
"c",
"=",
"0",
";",
"c",
"<",
"nCols",
";",
"++",
"c",
")",
"{",
"this",
".",
"values",
"[",
"r",
"]",
"[",
"c",
"]",
"=",
"rv",
".",
"values",
"[",
"0",
"]",
"[",
"c",
"]",
";",
"}",
"}"
] | Set a row of this matrix from a row vector.
@param rv the row vector
@param r the row index
@throws numbercruncher.MatrixException for an invalid index or
an invalid vector size | [
"Set",
"a",
"row",
"of",
"this",
"matrix",
"from",
"a",
"row",
"vector",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java#L183-L196 |
137,954 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java | Matrix.setColumn | public void setColumn(ColumnVector cv, int c)
throws MatrixException
{
if ((c < 0) || (c >= nCols)) {
throw new MatrixException(MatrixException.INVALID_INDEX);
}
if (nRows != cv.nRows) {
throw new MatrixException(
MatrixException.INVALID_DIMENSIONS);
}
for (int r = 0; r < nRows; ++r) {
this.values[r][c] = cv.values[r][0];
}
} | java | public void setColumn(ColumnVector cv, int c)
throws MatrixException
{
if ((c < 0) || (c >= nCols)) {
throw new MatrixException(MatrixException.INVALID_INDEX);
}
if (nRows != cv.nRows) {
throw new MatrixException(
MatrixException.INVALID_DIMENSIONS);
}
for (int r = 0; r < nRows; ++r) {
this.values[r][c] = cv.values[r][0];
}
} | [
"public",
"void",
"setColumn",
"(",
"ColumnVector",
"cv",
",",
"int",
"c",
")",
"throws",
"MatrixException",
"{",
"if",
"(",
"(",
"c",
"<",
"0",
")",
"||",
"(",
"c",
">=",
"nCols",
")",
")",
"{",
"throw",
"new",
"MatrixException",
"(",
"MatrixException",
".",
"INVALID_INDEX",
")",
";",
"}",
"if",
"(",
"nRows",
"!=",
"cv",
".",
"nRows",
")",
"{",
"throw",
"new",
"MatrixException",
"(",
"MatrixException",
".",
"INVALID_DIMENSIONS",
")",
";",
"}",
"for",
"(",
"int",
"r",
"=",
"0",
";",
"r",
"<",
"nRows",
";",
"++",
"r",
")",
"{",
"this",
".",
"values",
"[",
"r",
"]",
"[",
"c",
"]",
"=",
"cv",
".",
"values",
"[",
"r",
"]",
"[",
"0",
"]",
";",
"}",
"}"
] | Set a column of this matrix from a column vector.
@param cv the column vector
@param c the column index
@throws numbercruncher.MatrixException for an invalid index or
an invalid vector size | [
"Set",
"a",
"column",
"of",
"this",
"matrix",
"from",
"a",
"column",
"vector",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java#L205-L219 |
137,955 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java | Matrix.transpose | public Matrix transpose()
{
double tv[][] = new double[nCols][nRows]; // transposed values
// Set the values of the transpose.
for (int r = 0; r < nRows; ++r) {
for (int c = 0; c < nCols; ++c) {
tv[c][r] = values[r][c];
}
}
return new Matrix(tv);
} | java | public Matrix transpose()
{
double tv[][] = new double[nCols][nRows]; // transposed values
// Set the values of the transpose.
for (int r = 0; r < nRows; ++r) {
for (int c = 0; c < nCols; ++c) {
tv[c][r] = values[r][c];
}
}
return new Matrix(tv);
} | [
"public",
"Matrix",
"transpose",
"(",
")",
"{",
"double",
"tv",
"[",
"]",
"[",
"]",
"=",
"new",
"double",
"[",
"nCols",
"]",
"[",
"nRows",
"]",
";",
"// transposed values",
"// Set the values of the transpose.",
"for",
"(",
"int",
"r",
"=",
"0",
";",
"r",
"<",
"nRows",
";",
"++",
"r",
")",
"{",
"for",
"(",
"int",
"c",
"=",
"0",
";",
"c",
"<",
"nCols",
";",
"++",
"c",
")",
"{",
"tv",
"[",
"c",
"]",
"[",
"r",
"]",
"=",
"values",
"[",
"r",
"]",
"[",
"c",
"]",
";",
"}",
"}",
"return",
"new",
"Matrix",
"(",
"tv",
")",
";",
"}"
] | Return the transpose of this matrix.
@return the transposed matrix | [
"Return",
"the",
"transpose",
"of",
"this",
"matrix",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java#L229-L241 |
137,956 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java | Matrix.add | public Matrix add(Matrix m) throws MatrixException
{
// Validate m's size.
if ((nRows != m.nRows) && (nCols != m.nCols)) {
throw new MatrixException(
MatrixException.INVALID_DIMENSIONS);
}
double sv[][] = new double[nRows][nCols]; // sum values
// Compute values of the sum.
for (int r = 0; r < nRows; ++r) {
for (int c = 0; c < nCols; ++c) {
sv[r][c] = values[r][c] + m.values[r][c];
}
}
return new Matrix(sv);
} | java | public Matrix add(Matrix m) throws MatrixException
{
// Validate m's size.
if ((nRows != m.nRows) && (nCols != m.nCols)) {
throw new MatrixException(
MatrixException.INVALID_DIMENSIONS);
}
double sv[][] = new double[nRows][nCols]; // sum values
// Compute values of the sum.
for (int r = 0; r < nRows; ++r) {
for (int c = 0; c < nCols; ++c) {
sv[r][c] = values[r][c] + m.values[r][c];
}
}
return new Matrix(sv);
} | [
"public",
"Matrix",
"add",
"(",
"Matrix",
"m",
")",
"throws",
"MatrixException",
"{",
"// Validate m's size.",
"if",
"(",
"(",
"nRows",
"!=",
"m",
".",
"nRows",
")",
"&&",
"(",
"nCols",
"!=",
"m",
".",
"nCols",
")",
")",
"{",
"throw",
"new",
"MatrixException",
"(",
"MatrixException",
".",
"INVALID_DIMENSIONS",
")",
";",
"}",
"double",
"sv",
"[",
"]",
"[",
"]",
"=",
"new",
"double",
"[",
"nRows",
"]",
"[",
"nCols",
"]",
";",
"// sum values",
"// Compute values of the sum.",
"for",
"(",
"int",
"r",
"=",
"0",
";",
"r",
"<",
"nRows",
";",
"++",
"r",
")",
"{",
"for",
"(",
"int",
"c",
"=",
"0",
";",
"c",
"<",
"nCols",
";",
"++",
"c",
")",
"{",
"sv",
"[",
"r",
"]",
"[",
"c",
"]",
"=",
"values",
"[",
"r",
"]",
"[",
"c",
"]",
"+",
"m",
".",
"values",
"[",
"r",
"]",
"[",
"c",
"]",
";",
"}",
"}",
"return",
"new",
"Matrix",
"(",
"sv",
")",
";",
"}"
] | Add another matrix to this matrix.
@param m the matrix addend
@return the sum matrix
@throws numbercruncher.MatrixException for invalid size | [
"Add",
"another",
"matrix",
"to",
"this",
"matrix",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java#L249-L267 |
137,957 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java | Matrix.subtract | public Matrix subtract(Matrix m) throws MatrixException
{
// Validate m's size.
if ((nRows != m.nRows) && (nCols != m.nCols)) {
throw new MatrixException(
MatrixException.INVALID_DIMENSIONS);
}
double dv[][] = new double[nRows][nCols]; // difference values
// Compute values of the difference.
for (int r = 0; r < nRows; ++r) {
for (int c = 0; c < nCols; ++c) {
dv[r][c] = values[r][c] - m.values[r][c];
}
}
return new Matrix(dv);
} | java | public Matrix subtract(Matrix m) throws MatrixException
{
// Validate m's size.
if ((nRows != m.nRows) && (nCols != m.nCols)) {
throw new MatrixException(
MatrixException.INVALID_DIMENSIONS);
}
double dv[][] = new double[nRows][nCols]; // difference values
// Compute values of the difference.
for (int r = 0; r < nRows; ++r) {
for (int c = 0; c < nCols; ++c) {
dv[r][c] = values[r][c] - m.values[r][c];
}
}
return new Matrix(dv);
} | [
"public",
"Matrix",
"subtract",
"(",
"Matrix",
"m",
")",
"throws",
"MatrixException",
"{",
"// Validate m's size.",
"if",
"(",
"(",
"nRows",
"!=",
"m",
".",
"nRows",
")",
"&&",
"(",
"nCols",
"!=",
"m",
".",
"nCols",
")",
")",
"{",
"throw",
"new",
"MatrixException",
"(",
"MatrixException",
".",
"INVALID_DIMENSIONS",
")",
";",
"}",
"double",
"dv",
"[",
"]",
"[",
"]",
"=",
"new",
"double",
"[",
"nRows",
"]",
"[",
"nCols",
"]",
";",
"// difference values",
"// Compute values of the difference.",
"for",
"(",
"int",
"r",
"=",
"0",
";",
"r",
"<",
"nRows",
";",
"++",
"r",
")",
"{",
"for",
"(",
"int",
"c",
"=",
"0",
";",
"c",
"<",
"nCols",
";",
"++",
"c",
")",
"{",
"dv",
"[",
"r",
"]",
"[",
"c",
"]",
"=",
"values",
"[",
"r",
"]",
"[",
"c",
"]",
"-",
"m",
".",
"values",
"[",
"r",
"]",
"[",
"c",
"]",
";",
"}",
"}",
"return",
"new",
"Matrix",
"(",
"dv",
")",
";",
"}"
] | Subtract another matrix from this matrix.
@param m the matrix subrrahend
@return the difference matrix
@throws numbercruncher.MatrixException for invalid size | [
"Subtract",
"another",
"matrix",
"from",
"this",
"matrix",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java#L275-L293 |
137,958 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java | Matrix.multiply | public Matrix multiply(double k)
{
double pv[][] = new double[nRows][nCols]; // product values
// Compute values of the product.
for (int r = 0; r < nRows; ++r) {
for (int c = 0; c < nCols; ++c) {
pv[r][c] = k*values[r][c];
}
}
return new Matrix(pv);
} | java | public Matrix multiply(double k)
{
double pv[][] = new double[nRows][nCols]; // product values
// Compute values of the product.
for (int r = 0; r < nRows; ++r) {
for (int c = 0; c < nCols; ++c) {
pv[r][c] = k*values[r][c];
}
}
return new Matrix(pv);
} | [
"public",
"Matrix",
"multiply",
"(",
"double",
"k",
")",
"{",
"double",
"pv",
"[",
"]",
"[",
"]",
"=",
"new",
"double",
"[",
"nRows",
"]",
"[",
"nCols",
"]",
";",
"// product values",
"// Compute values of the product.",
"for",
"(",
"int",
"r",
"=",
"0",
";",
"r",
"<",
"nRows",
";",
"++",
"r",
")",
"{",
"for",
"(",
"int",
"c",
"=",
"0",
";",
"c",
"<",
"nCols",
";",
"++",
"c",
")",
"{",
"pv",
"[",
"r",
"]",
"[",
"c",
"]",
"=",
"k",
"*",
"values",
"[",
"r",
"]",
"[",
"c",
"]",
";",
"}",
"}",
"return",
"new",
"Matrix",
"(",
"pv",
")",
";",
"}"
] | Multiply this matrix by a constant.
@param k the constant
@return the product matrix | [
"Multiply",
"this",
"matrix",
"by",
"a",
"constant",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java#L300-L312 |
137,959 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java | Matrix.multiply | public Matrix multiply(Matrix m) throws MatrixException
{
// Validate m's dimensions.
if (nCols != m.nRows) {
throw new MatrixException(
MatrixException.INVALID_DIMENSIONS);
}
double pv[][] = new double[nRows][m.nCols]; // product values
// Compute values of the product.
for (int r = 0; r < nRows; ++r) {
for (int c = 0; c < m.nCols; ++c) {
double dot = 0;
for (int k = 0; k < nCols; ++k) {
dot += values[r][k] * m.values[k][c];
}
pv[r][c] = dot;
}
}
return new Matrix(pv);
} | java | public Matrix multiply(Matrix m) throws MatrixException
{
// Validate m's dimensions.
if (nCols != m.nRows) {
throw new MatrixException(
MatrixException.INVALID_DIMENSIONS);
}
double pv[][] = new double[nRows][m.nCols]; // product values
// Compute values of the product.
for (int r = 0; r < nRows; ++r) {
for (int c = 0; c < m.nCols; ++c) {
double dot = 0;
for (int k = 0; k < nCols; ++k) {
dot += values[r][k] * m.values[k][c];
}
pv[r][c] = dot;
}
}
return new Matrix(pv);
} | [
"public",
"Matrix",
"multiply",
"(",
"Matrix",
"m",
")",
"throws",
"MatrixException",
"{",
"// Validate m's dimensions.",
"if",
"(",
"nCols",
"!=",
"m",
".",
"nRows",
")",
"{",
"throw",
"new",
"MatrixException",
"(",
"MatrixException",
".",
"INVALID_DIMENSIONS",
")",
";",
"}",
"double",
"pv",
"[",
"]",
"[",
"]",
"=",
"new",
"double",
"[",
"nRows",
"]",
"[",
"m",
".",
"nCols",
"]",
";",
"// product values",
"// Compute values of the product.",
"for",
"(",
"int",
"r",
"=",
"0",
";",
"r",
"<",
"nRows",
";",
"++",
"r",
")",
"{",
"for",
"(",
"int",
"c",
"=",
"0",
";",
"c",
"<",
"m",
".",
"nCols",
";",
"++",
"c",
")",
"{",
"double",
"dot",
"=",
"0",
";",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"nCols",
";",
"++",
"k",
")",
"{",
"dot",
"+=",
"values",
"[",
"r",
"]",
"[",
"k",
"]",
"*",
"m",
".",
"values",
"[",
"k",
"]",
"[",
"c",
"]",
";",
"}",
"pv",
"[",
"r",
"]",
"[",
"c",
"]",
"=",
"dot",
";",
"}",
"}",
"return",
"new",
"Matrix",
"(",
"pv",
")",
";",
"}"
] | Multiply this matrix by another matrix.
@param m the matrix multiplier
@return the product matrix
@throws numbercruncher.MatrixException for invalid size | [
"Multiply",
"this",
"matrix",
"by",
"another",
"matrix",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java#L320-L342 |
137,960 | TheHortonMachine/hortonmachine | lesto/src/main/java/org/hortonmachine/lesto/modules/utilities/LasInfo.java | LasInfo.printInfo | public static void printInfo( String filePath ) throws Exception {
LasInfo lasInfo = new LasInfo();
lasInfo.inLas = filePath;
lasInfo.process();
} | java | public static void printInfo( String filePath ) throws Exception {
LasInfo lasInfo = new LasInfo();
lasInfo.inLas = filePath;
lasInfo.process();
} | [
"public",
"static",
"void",
"printInfo",
"(",
"String",
"filePath",
")",
"throws",
"Exception",
"{",
"LasInfo",
"lasInfo",
"=",
"new",
"LasInfo",
"(",
")",
";",
"lasInfo",
".",
"inLas",
"=",
"filePath",
";",
"lasInfo",
".",
"process",
"(",
")",
";",
"}"
] | Utility method to run info.
@param filePath the file to print info of.
@throws Exception | [
"Utility",
"method",
"to",
"run",
"info",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/lesto/src/main/java/org/hortonmachine/lesto/modules/utilities/LasInfo.java#L121-L125 |
137,961 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/NetworkCalibration.java | NetworkCalibration.internalPipeVerify | private double internalPipeVerify( int k, double[] cDelays, double[][] net, double[][] timeDischarge,
double[][] timeFillDegree, int tp ) {
int num;
double localdelay, olddelay, qMax, B, known, theta, u;
double[][] qPartial;
qPartial = new double[timeDischarge.length][timeDischarge[0].length];
calculateDelays(k, cDelays, net);
// First attempt local delay [min]
localdelay = 1;
double accuracy = networkPipes[0].getAccuracy();
int jMax = networkPipes[0].getjMax();
double minG = networkPipes[0].getMinG();
double maxtheta = networkPipes[0].getMaxTheta();
double tolerance = networkPipes[0].getTolerance();
int count = 0;
do {
olddelay = localdelay;
qMax = 0;
// Updates delays
for( int i = 0; i < net.length; i++ ) {
net[i][2] += localdelay;
};
for( int j = 0; j < net.length; ++j ) {
num = (int) net[j][0];
getHydrograph(num, qPartial, olddelay, net[j][2], tp);
}
getHydrograph(k, qPartial, olddelay, 0, tp);
qMax = ModelsEngine.sumDoublematrixColumns(k, qPartial, timeDischarge, 0, qPartial[0].length - 1, pm);
if (qMax <= 1)
qMax = 1;
// Resets delays
for( int i = 0; i < net.length; i++ ) {
net[i][2] -= localdelay;
}
calculateFillDegree(k, timeDischarge, timeFillDegree);
B = qMax / (CUBICMETER2LITER * networkPipes[k].getKs() * sqrt(networkPipes[k].verifyPipeSlope / METER2CM));
known = (B * TWO_THIRTEENOVERTHREE) / pow(networkPipes[k].diameterToVerify / METER2CM, EIGHTOVERTHREE);
theta = Utility.thisBisection(maxtheta, known, TWOOVERTHREE, minG, accuracy, jMax, pm, strBuilder);
// Average velocity in pipe [ m / s ]
u = qMax * 80 / (pow(networkPipes[k].diameterToVerify, 2) * (theta - sin(theta)));
localdelay = networkPipes[k].getLenght() / (celerityfactor1 * u * MINUTE2SEC);
count++;
// verify if it's an infiniteloop.
if (count > MAX_NUMBER_ITERATION) {
infiniteLoop = true;
throw new ArithmeticException();
}
} while( abs(localdelay - olddelay) / olddelay >= tolerance );
cDelays[k] = localdelay;
return qMax;
} | java | private double internalPipeVerify( int k, double[] cDelays, double[][] net, double[][] timeDischarge,
double[][] timeFillDegree, int tp ) {
int num;
double localdelay, olddelay, qMax, B, known, theta, u;
double[][] qPartial;
qPartial = new double[timeDischarge.length][timeDischarge[0].length];
calculateDelays(k, cDelays, net);
// First attempt local delay [min]
localdelay = 1;
double accuracy = networkPipes[0].getAccuracy();
int jMax = networkPipes[0].getjMax();
double minG = networkPipes[0].getMinG();
double maxtheta = networkPipes[0].getMaxTheta();
double tolerance = networkPipes[0].getTolerance();
int count = 0;
do {
olddelay = localdelay;
qMax = 0;
// Updates delays
for( int i = 0; i < net.length; i++ ) {
net[i][2] += localdelay;
};
for( int j = 0; j < net.length; ++j ) {
num = (int) net[j][0];
getHydrograph(num, qPartial, olddelay, net[j][2], tp);
}
getHydrograph(k, qPartial, olddelay, 0, tp);
qMax = ModelsEngine.sumDoublematrixColumns(k, qPartial, timeDischarge, 0, qPartial[0].length - 1, pm);
if (qMax <= 1)
qMax = 1;
// Resets delays
for( int i = 0; i < net.length; i++ ) {
net[i][2] -= localdelay;
}
calculateFillDegree(k, timeDischarge, timeFillDegree);
B = qMax / (CUBICMETER2LITER * networkPipes[k].getKs() * sqrt(networkPipes[k].verifyPipeSlope / METER2CM));
known = (B * TWO_THIRTEENOVERTHREE) / pow(networkPipes[k].diameterToVerify / METER2CM, EIGHTOVERTHREE);
theta = Utility.thisBisection(maxtheta, known, TWOOVERTHREE, minG, accuracy, jMax, pm, strBuilder);
// Average velocity in pipe [ m / s ]
u = qMax * 80 / (pow(networkPipes[k].diameterToVerify, 2) * (theta - sin(theta)));
localdelay = networkPipes[k].getLenght() / (celerityfactor1 * u * MINUTE2SEC);
count++;
// verify if it's an infiniteloop.
if (count > MAX_NUMBER_ITERATION) {
infiniteLoop = true;
throw new ArithmeticException();
}
} while( abs(localdelay - olddelay) / olddelay >= tolerance );
cDelays[k] = localdelay;
return qMax;
} | [
"private",
"double",
"internalPipeVerify",
"(",
"int",
"k",
",",
"double",
"[",
"]",
"cDelays",
",",
"double",
"[",
"]",
"[",
"]",
"net",
",",
"double",
"[",
"]",
"[",
"]",
"timeDischarge",
",",
"double",
"[",
"]",
"[",
"]",
"timeFillDegree",
",",
"int",
"tp",
")",
"{",
"int",
"num",
";",
"double",
"localdelay",
",",
"olddelay",
",",
"qMax",
",",
"B",
",",
"known",
",",
"theta",
",",
"u",
";",
"double",
"[",
"]",
"[",
"]",
"qPartial",
";",
"qPartial",
"=",
"new",
"double",
"[",
"timeDischarge",
".",
"length",
"]",
"[",
"timeDischarge",
"[",
"0",
"]",
".",
"length",
"]",
";",
"calculateDelays",
"(",
"k",
",",
"cDelays",
",",
"net",
")",
";",
"// First attempt local delay [min]",
"localdelay",
"=",
"1",
";",
"double",
"accuracy",
"=",
"networkPipes",
"[",
"0",
"]",
".",
"getAccuracy",
"(",
")",
";",
"int",
"jMax",
"=",
"networkPipes",
"[",
"0",
"]",
".",
"getjMax",
"(",
")",
";",
"double",
"minG",
"=",
"networkPipes",
"[",
"0",
"]",
".",
"getMinG",
"(",
")",
";",
"double",
"maxtheta",
"=",
"networkPipes",
"[",
"0",
"]",
".",
"getMaxTheta",
"(",
")",
";",
"double",
"tolerance",
"=",
"networkPipes",
"[",
"0",
"]",
".",
"getTolerance",
"(",
")",
";",
"int",
"count",
"=",
"0",
";",
"do",
"{",
"olddelay",
"=",
"localdelay",
";",
"qMax",
"=",
"0",
";",
"// Updates delays",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"net",
".",
"length",
";",
"i",
"++",
")",
"{",
"net",
"[",
"i",
"]",
"[",
"2",
"]",
"+=",
"localdelay",
";",
"}",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"net",
".",
"length",
";",
"++",
"j",
")",
"{",
"num",
"=",
"(",
"int",
")",
"net",
"[",
"j",
"]",
"[",
"0",
"]",
";",
"getHydrograph",
"(",
"num",
",",
"qPartial",
",",
"olddelay",
",",
"net",
"[",
"j",
"]",
"[",
"2",
"]",
",",
"tp",
")",
";",
"}",
"getHydrograph",
"(",
"k",
",",
"qPartial",
",",
"olddelay",
",",
"0",
",",
"tp",
")",
";",
"qMax",
"=",
"ModelsEngine",
".",
"sumDoublematrixColumns",
"(",
"k",
",",
"qPartial",
",",
"timeDischarge",
",",
"0",
",",
"qPartial",
"[",
"0",
"]",
".",
"length",
"-",
"1",
",",
"pm",
")",
";",
"if",
"(",
"qMax",
"<=",
"1",
")",
"qMax",
"=",
"1",
";",
"// Resets delays",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"net",
".",
"length",
";",
"i",
"++",
")",
"{",
"net",
"[",
"i",
"]",
"[",
"2",
"]",
"-=",
"localdelay",
";",
"}",
"calculateFillDegree",
"(",
"k",
",",
"timeDischarge",
",",
"timeFillDegree",
")",
";",
"B",
"=",
"qMax",
"/",
"(",
"CUBICMETER2LITER",
"*",
"networkPipes",
"[",
"k",
"]",
".",
"getKs",
"(",
")",
"*",
"sqrt",
"(",
"networkPipes",
"[",
"k",
"]",
".",
"verifyPipeSlope",
"/",
"METER2CM",
")",
")",
";",
"known",
"=",
"(",
"B",
"*",
"TWO_THIRTEENOVERTHREE",
")",
"/",
"pow",
"(",
"networkPipes",
"[",
"k",
"]",
".",
"diameterToVerify",
"/",
"METER2CM",
",",
"EIGHTOVERTHREE",
")",
";",
"theta",
"=",
"Utility",
".",
"thisBisection",
"(",
"maxtheta",
",",
"known",
",",
"TWOOVERTHREE",
",",
"minG",
",",
"accuracy",
",",
"jMax",
",",
"pm",
",",
"strBuilder",
")",
";",
"// Average velocity in pipe [ m / s ]",
"u",
"=",
"qMax",
"*",
"80",
"/",
"(",
"pow",
"(",
"networkPipes",
"[",
"k",
"]",
".",
"diameterToVerify",
",",
"2",
")",
"*",
"(",
"theta",
"-",
"sin",
"(",
"theta",
")",
")",
")",
";",
"localdelay",
"=",
"networkPipes",
"[",
"k",
"]",
".",
"getLenght",
"(",
")",
"/",
"(",
"celerityfactor1",
"*",
"u",
"*",
"MINUTE2SEC",
")",
";",
"count",
"++",
";",
"// verify if it's an infiniteloop.",
"if",
"(",
"count",
">",
"MAX_NUMBER_ITERATION",
")",
"{",
"infiniteLoop",
"=",
"true",
";",
"throw",
"new",
"ArithmeticException",
"(",
")",
";",
"}",
"}",
"while",
"(",
"abs",
"(",
"localdelay",
"-",
"olddelay",
")",
"/",
"olddelay",
">=",
"tolerance",
")",
";",
"cDelays",
"[",
"k",
"]",
"=",
"localdelay",
";",
"return",
"qMax",
";",
"}"
] | verify of the no-head pipes.
<p>
It evaluate the discharge.
</p>
@param k ID of the pipe where evaluate the discharge.
@param cDelays delay matrix (for the evalutation of the flow wave).
@param net matrix that contains value of the network.
@return | [
"verify",
"of",
"the",
"no",
"-",
"head",
"pipes",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/NetworkCalibration.java#L376-L432 |
137,962 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/NetworkCalibration.java | NetworkCalibration.calculateDelays | private void calculateDelays( int k, double[] cDelays, double[][] net )
{
double t;
int ind, r = 1;
for( int j = 0; j < net.length; ++j ) {
t = 0;
r = 1;
ind = (int) net[j][0];
/*
* Area k is not included in delays
*/
while( networkPipes[ind].getIndexPipeWhereDrain() != k ) {
ind = networkPipes[ind].getIndexPipeWhereDrain();
t += cDelays[ind];
r++;
}
if (r > networkPipes.length) {
pm.errorMessage(msg.message("trentoP.error.incorrectmatrix"));
throw new ArithmeticException(msg.message("trentoP.error.incorrectmatrix"));
}
net[j][2] = t;
}
} | java | private void calculateDelays( int k, double[] cDelays, double[][] net )
{
double t;
int ind, r = 1;
for( int j = 0; j < net.length; ++j ) {
t = 0;
r = 1;
ind = (int) net[j][0];
/*
* Area k is not included in delays
*/
while( networkPipes[ind].getIndexPipeWhereDrain() != k ) {
ind = networkPipes[ind].getIndexPipeWhereDrain();
t += cDelays[ind];
r++;
}
if (r > networkPipes.length) {
pm.errorMessage(msg.message("trentoP.error.incorrectmatrix"));
throw new ArithmeticException(msg.message("trentoP.error.incorrectmatrix"));
}
net[j][2] = t;
}
} | [
"private",
"void",
"calculateDelays",
"(",
"int",
"k",
",",
"double",
"[",
"]",
"cDelays",
",",
"double",
"[",
"]",
"[",
"]",
"net",
")",
"{",
"double",
"t",
";",
"int",
"ind",
",",
"r",
"=",
"1",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"net",
".",
"length",
";",
"++",
"j",
")",
"{",
"t",
"=",
"0",
";",
"r",
"=",
"1",
";",
"ind",
"=",
"(",
"int",
")",
"net",
"[",
"j",
"]",
"[",
"0",
"]",
";",
"/*\n * Area k is not included in delays\n */",
"while",
"(",
"networkPipes",
"[",
"ind",
"]",
".",
"getIndexPipeWhereDrain",
"(",
")",
"!=",
"k",
")",
"{",
"ind",
"=",
"networkPipes",
"[",
"ind",
"]",
".",
"getIndexPipeWhereDrain",
"(",
")",
";",
"t",
"+=",
"cDelays",
"[",
"ind",
"]",
";",
"r",
"++",
";",
"}",
"if",
"(",
"r",
">",
"networkPipes",
".",
"length",
")",
"{",
"pm",
".",
"errorMessage",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.error.incorrectmatrix\"",
")",
")",
";",
"throw",
"new",
"ArithmeticException",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.error.incorrectmatrix\"",
")",
")",
";",
"}",
"net",
"[",
"j",
"]",
"[",
"2",
"]",
"=",
"t",
";",
"}",
"}"
] | Calcola il ritardo della tubazione k.
@param k indice della tubazione.
@param cDelays matrice dei ritardi.
@param net matrice che contiene la sottorete. | [
"Calcola",
"il",
"ritardo",
"della",
"tubazione",
"k",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/NetworkCalibration.java#L465-L491 |
137,963 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/NetworkCalibration.java | NetworkCalibration.getHydrograph | private double getHydrograph( int k, double[][] Qpartial, double localdelay, double delay, int tp )
{
double Qmax = 0;
double tmin = rainData[0][0]; /* [min] */
int j = 0;
double t = tmin;
double Q;
double rain;
int maxRain = 0;
if (tMax == tpMaxCalibration) {
maxRain = rainData.length;
} else {
maxRain = tp / dt;
}
double tMaxApproximate = ModelsEngine.approximate2Multiple(tMax, dt);
for( t = tmin, j = 0; t <= tMaxApproximate; t += dt, ++j ) {
Q = 0;
for( int i = 0; i <= maxRain - 1; ++i ) {
// [ l / s ]
rain = rainData[i][1] * networkPipes[k].getDrainArea() * networkPipes[k].getRunoffCoefficient()
* HAOVERH_TO_METEROVERS;
if (t <= i * dt) {
Q += 0;
} else if (t <= (i + 1) * dt) {
Q += rain * pFunction(k, t - i * dt, localdelay, delay);
} else {
Q += rain * (pFunction(k, t - i * dt, localdelay, delay) - pFunction(k, t - (i + 1) * dt, localdelay, delay));
}
}
Qpartial[j][k] = Q;
if (Q >= Qmax) {
Qmax = Q;
}
}
return Qmax;
} | java | private double getHydrograph( int k, double[][] Qpartial, double localdelay, double delay, int tp )
{
double Qmax = 0;
double tmin = rainData[0][0]; /* [min] */
int j = 0;
double t = tmin;
double Q;
double rain;
int maxRain = 0;
if (tMax == tpMaxCalibration) {
maxRain = rainData.length;
} else {
maxRain = tp / dt;
}
double tMaxApproximate = ModelsEngine.approximate2Multiple(tMax, dt);
for( t = tmin, j = 0; t <= tMaxApproximate; t += dt, ++j ) {
Q = 0;
for( int i = 0; i <= maxRain - 1; ++i ) {
// [ l / s ]
rain = rainData[i][1] * networkPipes[k].getDrainArea() * networkPipes[k].getRunoffCoefficient()
* HAOVERH_TO_METEROVERS;
if (t <= i * dt) {
Q += 0;
} else if (t <= (i + 1) * dt) {
Q += rain * pFunction(k, t - i * dt, localdelay, delay);
} else {
Q += rain * (pFunction(k, t - i * dt, localdelay, delay) - pFunction(k, t - (i + 1) * dt, localdelay, delay));
}
}
Qpartial[j][k] = Q;
if (Q >= Qmax) {
Qmax = Q;
}
}
return Qmax;
} | [
"private",
"double",
"getHydrograph",
"(",
"int",
"k",
",",
"double",
"[",
"]",
"[",
"]",
"Qpartial",
",",
"double",
"localdelay",
",",
"double",
"delay",
",",
"int",
"tp",
")",
"{",
"double",
"Qmax",
"=",
"0",
";",
"double",
"tmin",
"=",
"rainData",
"[",
"0",
"]",
"[",
"0",
"]",
";",
"/* [min] */",
"int",
"j",
"=",
"0",
";",
"double",
"t",
"=",
"tmin",
";",
"double",
"Q",
";",
"double",
"rain",
";",
"int",
"maxRain",
"=",
"0",
";",
"if",
"(",
"tMax",
"==",
"tpMaxCalibration",
")",
"{",
"maxRain",
"=",
"rainData",
".",
"length",
";",
"}",
"else",
"{",
"maxRain",
"=",
"tp",
"/",
"dt",
";",
"}",
"double",
"tMaxApproximate",
"=",
"ModelsEngine",
".",
"approximate2Multiple",
"(",
"tMax",
",",
"dt",
")",
";",
"for",
"(",
"t",
"=",
"tmin",
",",
"j",
"=",
"0",
";",
"t",
"<=",
"tMaxApproximate",
";",
"t",
"+=",
"dt",
",",
"++",
"j",
")",
"{",
"Q",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"maxRain",
"-",
"1",
";",
"++",
"i",
")",
"{",
"// [ l / s ]",
"rain",
"=",
"rainData",
"[",
"i",
"]",
"[",
"1",
"]",
"*",
"networkPipes",
"[",
"k",
"]",
".",
"getDrainArea",
"(",
")",
"*",
"networkPipes",
"[",
"k",
"]",
".",
"getRunoffCoefficient",
"(",
")",
"*",
"HAOVERH_TO_METEROVERS",
";",
"if",
"(",
"t",
"<=",
"i",
"*",
"dt",
")",
"{",
"Q",
"+=",
"0",
";",
"}",
"else",
"if",
"(",
"t",
"<=",
"(",
"i",
"+",
"1",
")",
"*",
"dt",
")",
"{",
"Q",
"+=",
"rain",
"*",
"pFunction",
"(",
"k",
",",
"t",
"-",
"i",
"*",
"dt",
",",
"localdelay",
",",
"delay",
")",
";",
"}",
"else",
"{",
"Q",
"+=",
"rain",
"*",
"(",
"pFunction",
"(",
"k",
",",
"t",
"-",
"i",
"*",
"dt",
",",
"localdelay",
",",
"delay",
")",
"-",
"pFunction",
"(",
"k",
",",
"t",
"-",
"(",
"i",
"+",
"1",
")",
"*",
"dt",
",",
"localdelay",
",",
"delay",
")",
")",
";",
"}",
"}",
"Qpartial",
"[",
"j",
"]",
"[",
"k",
"]",
"=",
"Q",
";",
"if",
"(",
"Q",
">=",
"Qmax",
")",
"{",
"Qmax",
"=",
"Q",
";",
"}",
"}",
"return",
"Qmax",
";",
"}"
] | Restituisce l'idrogramma.
@param k tratto di tubazione.
@param Qpartial matrice delle portate temporanee necessarie per costriure 'idrogramma.
@param localdelay ritardo della tubazione k.
@param delay ritardo temporale. | [
"Restituisce",
"l",
"idrogramma",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/NetworkCalibration.java#L501-L546 |
137,964 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/NetworkCalibration.java | NetworkCalibration.geoSewer | @Override
public void geoSewer() throws Exception {
if (!foundMaxrainTime) {
evaluateDischarge(lastTimeDischarge, lastTimeFillDegree, tpMaxCalibration);
} else {
/*
* start to evaluate the discharge from 15 minutes,evaluate the nearsted value to 15 minutes.
*/
int minTime = (int) ModelsEngine.approximate2Multiple(INITIAL_TIME, dt);
double qMax = 0;
for( int i = minTime; i < tpMaxCalibration; i = i + dt ) {
tpMax = i;
double[][] timeDischarge = createMatrix();
double[][] timeFillDegree = createMatrix();
double q = evaluateDischarge(timeDischarge, timeFillDegree, i);
if (q > qMax) {
qMax = q;
lastTimeDischarge = timeDischarge;
lastTimeFillDegree = timeFillDegree;
} else if (q < qMax) {
break;
}
if (isFill) {
break;
}
}
}
getNetData();
} | java | @Override
public void geoSewer() throws Exception {
if (!foundMaxrainTime) {
evaluateDischarge(lastTimeDischarge, lastTimeFillDegree, tpMaxCalibration);
} else {
/*
* start to evaluate the discharge from 15 minutes,evaluate the nearsted value to 15 minutes.
*/
int minTime = (int) ModelsEngine.approximate2Multiple(INITIAL_TIME, dt);
double qMax = 0;
for( int i = minTime; i < tpMaxCalibration; i = i + dt ) {
tpMax = i;
double[][] timeDischarge = createMatrix();
double[][] timeFillDegree = createMatrix();
double q = evaluateDischarge(timeDischarge, timeFillDegree, i);
if (q > qMax) {
qMax = q;
lastTimeDischarge = timeDischarge;
lastTimeFillDegree = timeFillDegree;
} else if (q < qMax) {
break;
}
if (isFill) {
break;
}
}
}
getNetData();
} | [
"@",
"Override",
"public",
"void",
"geoSewer",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"!",
"foundMaxrainTime",
")",
"{",
"evaluateDischarge",
"(",
"lastTimeDischarge",
",",
"lastTimeFillDegree",
",",
"tpMaxCalibration",
")",
";",
"}",
"else",
"{",
"/*\n * start to evaluate the discharge from 15 minutes,evaluate the nearsted value to 15 minutes.\n */",
"int",
"minTime",
"=",
"(",
"int",
")",
"ModelsEngine",
".",
"approximate2Multiple",
"(",
"INITIAL_TIME",
",",
"dt",
")",
";",
"double",
"qMax",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"minTime",
";",
"i",
"<",
"tpMaxCalibration",
";",
"i",
"=",
"i",
"+",
"dt",
")",
"{",
"tpMax",
"=",
"i",
";",
"double",
"[",
"]",
"[",
"]",
"timeDischarge",
"=",
"createMatrix",
"(",
")",
";",
"double",
"[",
"]",
"[",
"]",
"timeFillDegree",
"=",
"createMatrix",
"(",
")",
";",
"double",
"q",
"=",
"evaluateDischarge",
"(",
"timeDischarge",
",",
"timeFillDegree",
",",
"i",
")",
";",
"if",
"(",
"q",
">",
"qMax",
")",
"{",
"qMax",
"=",
"q",
";",
"lastTimeDischarge",
"=",
"timeDischarge",
";",
"lastTimeFillDegree",
"=",
"timeFillDegree",
";",
"}",
"else",
"if",
"(",
"q",
"<",
"qMax",
")",
"{",
"break",
";",
"}",
"if",
"(",
"isFill",
")",
"{",
"break",
";",
"}",
"}",
"}",
"getNetData",
"(",
")",
";",
"}"
] | Estimate the discharge for each time and for each pipes.
<p>
It can work with a single rain time step (if there is an actual rain) or search the maximum rain time, if the rain is unknown and
the rain data are builtthroghout the rain possibility curve.
</p>
<p>
It work throgout 2 loop:
<ol>
*
<li>The first on the head pipes.
<li>The second on the pipes which are internal.
</ol>
</p> | [
"Estimate",
"the",
"discharge",
"for",
"each",
"time",
"and",
"for",
"each",
"pipes",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/NetworkCalibration.java#L659-L689 |
137,965 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/NetworkCalibration.java | NetworkCalibration.scanNetwork | private double scanNetwork( int k, int l, double[] one, double[][] net ) {
int ind;
/*
* t Ritardo accumulato dall'onda prima di raggiungere il tratto si sta
* dimensionando.
*/
double t;
/*
* Distanza percorsa dall'acqua dall'area dove e' caduta per raggiungere
* l'ingresso del tratto che si sta dimensionando.
*/
double length;
/*
* Superfice del sottobacino con chiusura nel tratto che si sta
* analizzando.
*/
double totalarea = 0;
int r = 0;
int i = 0;
/*
* In one gli stati sono in ordine di magmitude crescente. Per ogni
* stato di magnitude inferiore a quella del tratto l che si sta
* progettando.
*/
for( int j = 0; j < k; j++ ) {
/* La portata e valutata all'uscita di ciascun tratto */
t = 0;
/*
* ID dello lo stato di magnitude inferiore a quello del tratto che
* si sta progettando.
*/
i = (int) one[j];
ind = i;
// la lunghezza del tubo precedentemente progettato
length = networkPipes[ind].getLenght();
// seguo il percorso dell'acqua finch� non si incontra l'uscita.
while( networkPipes[ind].getIdPipeWhereDrain() != OUT_ID_PIPE ) {
// lo stato dove drena a sua volta.
ind = networkPipes[ind].getIndexPipeWhereDrain();
/*
* se lo stato drena direttamente in quello che si sta
* progettando
*/
if (ind == l) {
/*
* ID dello stato che drena in l, piu o meno direttamente.
*/
net[r][0] = i;
/*
* lunghezza del percorsa dall'acqua prima di raggiungere lo
* stato l che si sta progettando
*/
net[r][1] = length + networkPipes[l].getLenght();
/*
* Ritardo accumulato dall'onda di piena formatasi in uno
* degli stati a monte, prima di raggiungere il tratto l che
* si sta progettando
*/
net[r][2] = t;
/*
* area di tutti gli stati a monte che direttamente o
* indirettamente drenano in l
*/
totalarea += networkPipes[i].getDrainArea();
r++;
break;
}
}
/*
* viene incrementato solo se l'area drena in l quindi non puo'
* superare net->nrh
*/
if (r > net.length)
break;
}
// area degli stati a monte che drenano in l, l compreso
totalarea += networkPipes[l].getDrainArea();
return totalarea;
} | java | private double scanNetwork( int k, int l, double[] one, double[][] net ) {
int ind;
/*
* t Ritardo accumulato dall'onda prima di raggiungere il tratto si sta
* dimensionando.
*/
double t;
/*
* Distanza percorsa dall'acqua dall'area dove e' caduta per raggiungere
* l'ingresso del tratto che si sta dimensionando.
*/
double length;
/*
* Superfice del sottobacino con chiusura nel tratto che si sta
* analizzando.
*/
double totalarea = 0;
int r = 0;
int i = 0;
/*
* In one gli stati sono in ordine di magmitude crescente. Per ogni
* stato di magnitude inferiore a quella del tratto l che si sta
* progettando.
*/
for( int j = 0; j < k; j++ ) {
/* La portata e valutata all'uscita di ciascun tratto */
t = 0;
/*
* ID dello lo stato di magnitude inferiore a quello del tratto che
* si sta progettando.
*/
i = (int) one[j];
ind = i;
// la lunghezza del tubo precedentemente progettato
length = networkPipes[ind].getLenght();
// seguo il percorso dell'acqua finch� non si incontra l'uscita.
while( networkPipes[ind].getIdPipeWhereDrain() != OUT_ID_PIPE ) {
// lo stato dove drena a sua volta.
ind = networkPipes[ind].getIndexPipeWhereDrain();
/*
* se lo stato drena direttamente in quello che si sta
* progettando
*/
if (ind == l) {
/*
* ID dello stato che drena in l, piu o meno direttamente.
*/
net[r][0] = i;
/*
* lunghezza del percorsa dall'acqua prima di raggiungere lo
* stato l che si sta progettando
*/
net[r][1] = length + networkPipes[l].getLenght();
/*
* Ritardo accumulato dall'onda di piena formatasi in uno
* degli stati a monte, prima di raggiungere il tratto l che
* si sta progettando
*/
net[r][2] = t;
/*
* area di tutti gli stati a monte che direttamente o
* indirettamente drenano in l
*/
totalarea += networkPipes[i].getDrainArea();
r++;
break;
}
}
/*
* viene incrementato solo se l'area drena in l quindi non puo'
* superare net->nrh
*/
if (r > net.length)
break;
}
// area degli stati a monte che drenano in l, l compreso
totalarea += networkPipes[l].getDrainArea();
return totalarea;
} | [
"private",
"double",
"scanNetwork",
"(",
"int",
"k",
",",
"int",
"l",
",",
"double",
"[",
"]",
"one",
",",
"double",
"[",
"]",
"[",
"]",
"net",
")",
"{",
"int",
"ind",
";",
"/*\n * t Ritardo accumulato dall'onda prima di raggiungere il tratto si sta\n * dimensionando.\n */",
"double",
"t",
";",
"/*\n * Distanza percorsa dall'acqua dall'area dove e' caduta per raggiungere\n * l'ingresso del tratto che si sta dimensionando.\n */",
"double",
"length",
";",
"/*\n * Superfice del sottobacino con chiusura nel tratto che si sta\n * analizzando.\n */",
"double",
"totalarea",
"=",
"0",
";",
"int",
"r",
"=",
"0",
";",
"int",
"i",
"=",
"0",
";",
"/*\n * In one gli stati sono in ordine di magmitude crescente. Per ogni\n * stato di magnitude inferiore a quella del tratto l che si sta\n * progettando.\n */",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"k",
";",
"j",
"++",
")",
"{",
"/* La portata e valutata all'uscita di ciascun tratto */",
"t",
"=",
"0",
";",
"/*\n * ID dello lo stato di magnitude inferiore a quello del tratto che\n * si sta progettando.\n */",
"i",
"=",
"(",
"int",
")",
"one",
"[",
"j",
"]",
";",
"ind",
"=",
"i",
";",
"// la lunghezza del tubo precedentemente progettato",
"length",
"=",
"networkPipes",
"[",
"ind",
"]",
".",
"getLenght",
"(",
")",
";",
"// seguo il percorso dell'acqua finch� non si incontra l'uscita.",
"while",
"(",
"networkPipes",
"[",
"ind",
"]",
".",
"getIdPipeWhereDrain",
"(",
")",
"!=",
"OUT_ID_PIPE",
")",
"{",
"// lo stato dove drena a sua volta.",
"ind",
"=",
"networkPipes",
"[",
"ind",
"]",
".",
"getIndexPipeWhereDrain",
"(",
")",
";",
"/*\n * se lo stato drena direttamente in quello che si sta\n * progettando\n */",
"if",
"(",
"ind",
"==",
"l",
")",
"{",
"/*\n * ID dello stato che drena in l, piu o meno direttamente.\n */",
"net",
"[",
"r",
"]",
"[",
"0",
"]",
"=",
"i",
";",
"/*\n * lunghezza del percorsa dall'acqua prima di raggiungere lo\n * stato l che si sta progettando\n */",
"net",
"[",
"r",
"]",
"[",
"1",
"]",
"=",
"length",
"+",
"networkPipes",
"[",
"l",
"]",
".",
"getLenght",
"(",
")",
";",
"/*\n * Ritardo accumulato dall'onda di piena formatasi in uno\n * degli stati a monte, prima di raggiungere il tratto l che\n * si sta progettando\n */",
"net",
"[",
"r",
"]",
"[",
"2",
"]",
"=",
"t",
";",
"/*\n * area di tutti gli stati a monte che direttamente o\n * indirettamente drenano in l\n */",
"totalarea",
"+=",
"networkPipes",
"[",
"i",
"]",
".",
"getDrainArea",
"(",
")",
";",
"r",
"++",
";",
"break",
";",
"}",
"}",
"/*\n * viene incrementato solo se l'area drena in l quindi non puo'\n * superare net->nrh\n */",
"if",
"(",
"r",
">",
"net",
".",
"length",
")",
"break",
";",
"}",
"// area degli stati a monte che drenano in l, l compreso",
"totalarea",
"+=",
"networkPipes",
"[",
"l",
"]",
".",
"getDrainArea",
"(",
")",
";",
"return",
"totalarea",
";",
"}"
] | Compila la mantrice net con tutte i dati del sottobacino con chiusura nel
tratto che si sta analizzando, e restituisce la sua superfice
@param k tratto analizzato del sottobacino chiuso in l.
@param l chiusura del bacino.
@param one indice dei versanti.
@param net sottobacino che si chiude in l. | [
"Compila",
"la",
"mantrice",
"net",
"con",
"tutte",
"i",
"dati",
"del",
"sottobacino",
"con",
"chiusura",
"nel",
"tratto",
"che",
"si",
"sta",
"analizzando",
"e",
"restituisce",
"la",
"sua",
"superfice"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/NetworkCalibration.java#L744-L835 |
137,966 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/objects/DwgBlock.java | DwgBlock.readDwgBlockV15 | public void readDwgBlockV15(int[] data, int offset) throws Exception {
int bitPos = offset;
bitPos = readObjectHeaderV15(data, bitPos);
Vector v = DwgUtil.getTextString(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
String text = (String)v.get(1);
name = text;
bitPos = readObjectTailV15(data, bitPos);
} | java | public void readDwgBlockV15(int[] data, int offset) throws Exception {
int bitPos = offset;
bitPos = readObjectHeaderV15(data, bitPos);
Vector v = DwgUtil.getTextString(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
String text = (String)v.get(1);
name = text;
bitPos = readObjectTailV15(data, bitPos);
} | [
"public",
"void",
"readDwgBlockV15",
"(",
"int",
"[",
"]",
"data",
",",
"int",
"offset",
")",
"throws",
"Exception",
"{",
"int",
"bitPos",
"=",
"offset",
";",
"bitPos",
"=",
"readObjectHeaderV15",
"(",
"data",
",",
"bitPos",
")",
";",
"Vector",
"v",
"=",
"DwgUtil",
".",
"getTextString",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"String",
"text",
"=",
"(",
"String",
")",
"v",
".",
"get",
"(",
"1",
")",
";",
"name",
"=",
"text",
";",
"bitPos",
"=",
"readObjectTailV15",
"(",
"data",
",",
"bitPos",
")",
";",
"}"
] | Read a Block in the DWG format Version 15
@param data Array of unsigned bytes obtained from the DWG binary file
@param offset The current bit offset where the value begins
@throws Exception If an unexpected bit value is found in the DWG file. Occurs
when we are looking for LwPolylines. | [
"Read",
"a",
"Block",
"in",
"the",
"DWG",
"format",
"Version",
"15"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/objects/DwgBlock.java#L42-L50 |
137,967 | TheHortonMachine/hortonmachine | apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsSelectListener.java | ViewControlsSelectListener.setRepeatTimerDelay | public void setRepeatTimerDelay(int delay)
{
if (delay <= 0)
{
String message = Logging.getMessage("generic.ArgumentOutOfRange", delay);
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.repeatTimer.setDelay(delay);
} | java | public void setRepeatTimerDelay(int delay)
{
if (delay <= 0)
{
String message = Logging.getMessage("generic.ArgumentOutOfRange", delay);
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.repeatTimer.setDelay(delay);
} | [
"public",
"void",
"setRepeatTimerDelay",
"(",
"int",
"delay",
")",
"{",
"if",
"(",
"delay",
"<=",
"0",
")",
"{",
"String",
"message",
"=",
"Logging",
".",
"getMessage",
"(",
"\"generic.ArgumentOutOfRange\"",
",",
"delay",
")",
";",
"Logging",
".",
"logger",
"(",
")",
".",
"severe",
"(",
"message",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
")",
";",
"}",
"this",
".",
"repeatTimer",
".",
"setDelay",
"(",
"delay",
")",
";",
"}"
] | Set the repeat timer delay in milliseconds.
@param delay the repeat timer delay in milliseconds.
@throws IllegalArgumentException | [
"Set",
"the",
"repeat",
"timer",
"delay",
"in",
"milliseconds",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsSelectListener.java#L105-L114 |
137,968 | TheHortonMachine/hortonmachine | apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsSelectListener.java | ViewControlsSelectListener.setPitchIncrement | public void setPitchIncrement(double value)
{
if (value < 0)
{
String message = Logging.getMessage("generic.ArgumentOutOfRange", value);
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.pitchStep = value;
} | java | public void setPitchIncrement(double value)
{
if (value < 0)
{
String message = Logging.getMessage("generic.ArgumentOutOfRange", value);
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.pitchStep = value;
} | [
"public",
"void",
"setPitchIncrement",
"(",
"double",
"value",
")",
"{",
"if",
"(",
"value",
"<",
"0",
")",
"{",
"String",
"message",
"=",
"Logging",
".",
"getMessage",
"(",
"\"generic.ArgumentOutOfRange\"",
",",
"value",
")",
";",
"Logging",
".",
"logger",
"(",
")",
".",
"severe",
"(",
"message",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
")",
";",
"}",
"this",
".",
"pitchStep",
"=",
"value",
";",
"}"
] | Set the pitch increment value in decimal degrees. Doubling this value will double the pitch change speed. Must be
positive. Default value is 1 degree.
@param value the pitch increment value in decimal degrees.
@throws IllegalArgumentException | [
"Set",
"the",
"pitch",
"increment",
"value",
"in",
"decimal",
"degrees",
".",
"Doubling",
"this",
"value",
"will",
"double",
"the",
"pitch",
"change",
"speed",
".",
"Must",
"be",
"positive",
".",
"Default",
"value",
"is",
"1",
"degree",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsSelectListener.java#L197-L206 |
137,969 | TheHortonMachine/hortonmachine | apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsSelectListener.java | ViewControlsSelectListener.setFovIncrement | public void setFovIncrement(double value)
{
if (value < 1)
{
String message = Logging.getMessage("generic.ArgumentOutOfRange", value);
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.fovStep = value;
} | java | public void setFovIncrement(double value)
{
if (value < 1)
{
String message = Logging.getMessage("generic.ArgumentOutOfRange", value);
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.fovStep = value;
} | [
"public",
"void",
"setFovIncrement",
"(",
"double",
"value",
")",
"{",
"if",
"(",
"value",
"<",
"1",
")",
"{",
"String",
"message",
"=",
"Logging",
".",
"getMessage",
"(",
"\"generic.ArgumentOutOfRange\"",
",",
"value",
")",
";",
"Logging",
".",
"logger",
"(",
")",
".",
"severe",
"(",
"message",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
")",
";",
"}",
"this",
".",
"fovStep",
"=",
"value",
";",
"}"
] | Set the field of view increment factor. At each iteration the current field of view will be multiplied or divided
by this value. Must be greater then or equal to one. Default value is 1.05.
@param value the field of view increment factor.
@throws IllegalArgumentException | [
"Set",
"the",
"field",
"of",
"view",
"increment",
"factor",
".",
"At",
"each",
"iteration",
"the",
"current",
"field",
"of",
"view",
"will",
"be",
"multiplied",
"or",
"divided",
"by",
"this",
"value",
".",
"Must",
"be",
"greater",
"then",
"or",
"equal",
"to",
"one",
".",
"Default",
"value",
"is",
"1",
".",
"05",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsSelectListener.java#L226-L235 |
137,970 | TheHortonMachine/hortonmachine | apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsSelectListener.java | ViewControlsSelectListener.setVeIncrement | public void setVeIncrement(double value)
{
if (value < 0)
{
String message = Logging.getMessage("generic.ArgumentOutOfRange", value);
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.veStep = value;
} | java | public void setVeIncrement(double value)
{
if (value < 0)
{
String message = Logging.getMessage("generic.ArgumentOutOfRange", value);
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.veStep = value;
} | [
"public",
"void",
"setVeIncrement",
"(",
"double",
"value",
")",
"{",
"if",
"(",
"value",
"<",
"0",
")",
"{",
"String",
"message",
"=",
"Logging",
".",
"getMessage",
"(",
"\"generic.ArgumentOutOfRange\"",
",",
"value",
")",
";",
"Logging",
".",
"logger",
"(",
")",
".",
"severe",
"(",
"message",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
")",
";",
"}",
"this",
".",
"veStep",
"=",
"value",
";",
"}"
] | Set the vertical exaggeration increment. At each iteration the current vertical exaggeration will be increased or
decreased by this amount. Must be greater than or equal to zero. Default value is 0.1.
@param value the vertical exaggeration increment.
@throws IllegalArgumentException | [
"Set",
"the",
"vertical",
"exaggeration",
"increment",
".",
"At",
"each",
"iteration",
"the",
"current",
"vertical",
"exaggeration",
"will",
"be",
"increased",
"or",
"decreased",
"by",
"this",
"amount",
".",
"Must",
"be",
"greater",
"than",
"or",
"equal",
"to",
"zero",
".",
"Default",
"value",
"is",
"0",
".",
"1",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsSelectListener.java#L255-L264 |
137,971 | TheHortonMachine/hortonmachine | apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsSelectListener.java | ViewControlsSelectListener.computeSurfacePoint | protected Vec4 computeSurfacePoint(OrbitView view, Angle heading, Angle pitch)
{
Globe globe = wwd.getModel().getGlobe();
// Compute transform to be applied to north pointing Y so that it would point in the view direction
// Move coordinate system to view center point
Matrix transform = globe.computeSurfaceOrientationAtPosition(view.getCenterPosition());
// Rotate so that the north pointing axes Y will point in the look at direction
transform = transform.multiply(Matrix.fromRotationZ(heading.multiply(-1)));
transform = transform.multiply(Matrix.fromRotationX(Angle.NEG90.add(pitch)));
// Compute forward vector
Vec4 forward = Vec4.UNIT_Y.transformBy4(transform);
// Return intersection with terrain
Intersection[] intersections = wwd.getSceneController().getTerrain().intersect(
new Line(view.getEyePoint(), forward));
return (intersections != null && intersections.length != 0) ? intersections[0].getIntersectionPoint() : null;
} | java | protected Vec4 computeSurfacePoint(OrbitView view, Angle heading, Angle pitch)
{
Globe globe = wwd.getModel().getGlobe();
// Compute transform to be applied to north pointing Y so that it would point in the view direction
// Move coordinate system to view center point
Matrix transform = globe.computeSurfaceOrientationAtPosition(view.getCenterPosition());
// Rotate so that the north pointing axes Y will point in the look at direction
transform = transform.multiply(Matrix.fromRotationZ(heading.multiply(-1)));
transform = transform.multiply(Matrix.fromRotationX(Angle.NEG90.add(pitch)));
// Compute forward vector
Vec4 forward = Vec4.UNIT_Y.transformBy4(transform);
// Return intersection with terrain
Intersection[] intersections = wwd.getSceneController().getTerrain().intersect(
new Line(view.getEyePoint(), forward));
return (intersections != null && intersections.length != 0) ? intersections[0].getIntersectionPoint() : null;
} | [
"protected",
"Vec4",
"computeSurfacePoint",
"(",
"OrbitView",
"view",
",",
"Angle",
"heading",
",",
"Angle",
"pitch",
")",
"{",
"Globe",
"globe",
"=",
"wwd",
".",
"getModel",
"(",
")",
".",
"getGlobe",
"(",
")",
";",
"// Compute transform to be applied to north pointing Y so that it would point in the view direction",
"// Move coordinate system to view center point",
"Matrix",
"transform",
"=",
"globe",
".",
"computeSurfaceOrientationAtPosition",
"(",
"view",
".",
"getCenterPosition",
"(",
")",
")",
";",
"// Rotate so that the north pointing axes Y will point in the look at direction",
"transform",
"=",
"transform",
".",
"multiply",
"(",
"Matrix",
".",
"fromRotationZ",
"(",
"heading",
".",
"multiply",
"(",
"-",
"1",
")",
")",
")",
";",
"transform",
"=",
"transform",
".",
"multiply",
"(",
"Matrix",
".",
"fromRotationX",
"(",
"Angle",
".",
"NEG90",
".",
"add",
"(",
"pitch",
")",
")",
")",
";",
"// Compute forward vector",
"Vec4",
"forward",
"=",
"Vec4",
".",
"UNIT_Y",
".",
"transformBy4",
"(",
"transform",
")",
";",
"// Return intersection with terrain",
"Intersection",
"[",
"]",
"intersections",
"=",
"wwd",
".",
"getSceneController",
"(",
")",
".",
"getTerrain",
"(",
")",
".",
"intersect",
"(",
"new",
"Line",
"(",
"view",
".",
"getEyePoint",
"(",
")",
",",
"forward",
")",
")",
";",
"return",
"(",
"intersections",
"!=",
"null",
"&&",
"intersections",
".",
"length",
"!=",
"0",
")",
"?",
"intersections",
"[",
"0",
"]",
".",
"getIntersectionPoint",
"(",
")",
":",
"null",
";",
"}"
] | Find out where on the terrain surface the eye would be looking at with the given heading and pitch angles.
@param view the orbit view
@param heading heading direction clockwise from north.
@param pitch view pitch angle from the surface normal at the center point.
@return the terrain surface point the view would be looking at in the viewport center. | [
"Find",
"out",
"where",
"on",
"the",
"terrain",
"surface",
"the",
"eye",
"would",
"be",
"looking",
"at",
"with",
"the",
"given",
"heading",
"and",
"pitch",
"angles",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/apps/src/main/java/org/hortonmachine/nww/gui/ViewControlsSelectListener.java#L626-L641 |
137,972 | TheHortonMachine/hortonmachine | dbs/src/main/java/org/hortonmachine/ssh/ProxyEnabler.java | ProxyEnabler.enableProxy | public static void enableProxy( String url, String port, String user, String pwd, String nonProxyHosts ) {
_url = url;
_port = port;
_user = user;
_pwd = pwd;
System.setProperty("http.proxyHost", url);
System.setProperty("https.proxyHost", url);
if (port != null && port.trim().length() != 0) {
System.setProperty("http.proxyPort", port);
System.setProperty("https.proxyPort", port);
}
if (user != null && pwd != null && user.trim().length() != 0 && pwd.trim().length() != 0) {
System.setProperty("http.proxyUserName", user);
System.setProperty("https.proxyUserName", user);
System.setProperty("http.proxyUser", user);
System.setProperty("https.proxyUser", user);
System.setProperty("http.proxyPassword", pwd);
System.setProperty("https.proxyPassword", pwd);
Authenticator.setDefault(new ProxyAuthenticator(user, pwd));
}
if (nonProxyHosts != null) {
System.setProperty("http.nonProxyHosts", nonProxyHosts);
}
hasProxy = true;
} | java | public static void enableProxy( String url, String port, String user, String pwd, String nonProxyHosts ) {
_url = url;
_port = port;
_user = user;
_pwd = pwd;
System.setProperty("http.proxyHost", url);
System.setProperty("https.proxyHost", url);
if (port != null && port.trim().length() != 0) {
System.setProperty("http.proxyPort", port);
System.setProperty("https.proxyPort", port);
}
if (user != null && pwd != null && user.trim().length() != 0 && pwd.trim().length() != 0) {
System.setProperty("http.proxyUserName", user);
System.setProperty("https.proxyUserName", user);
System.setProperty("http.proxyUser", user);
System.setProperty("https.proxyUser", user);
System.setProperty("http.proxyPassword", pwd);
System.setProperty("https.proxyPassword", pwd);
Authenticator.setDefault(new ProxyAuthenticator(user, pwd));
}
if (nonProxyHosts != null) {
System.setProperty("http.nonProxyHosts", nonProxyHosts);
}
hasProxy = true;
} | [
"public",
"static",
"void",
"enableProxy",
"(",
"String",
"url",
",",
"String",
"port",
",",
"String",
"user",
",",
"String",
"pwd",
",",
"String",
"nonProxyHosts",
")",
"{",
"_url",
"=",
"url",
";",
"_port",
"=",
"port",
";",
"_user",
"=",
"user",
";",
"_pwd",
"=",
"pwd",
";",
"System",
".",
"setProperty",
"(",
"\"http.proxyHost\"",
",",
"url",
")",
";",
"System",
".",
"setProperty",
"(",
"\"https.proxyHost\"",
",",
"url",
")",
";",
"if",
"(",
"port",
"!=",
"null",
"&&",
"port",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"!=",
"0",
")",
"{",
"System",
".",
"setProperty",
"(",
"\"http.proxyPort\"",
",",
"port",
")",
";",
"System",
".",
"setProperty",
"(",
"\"https.proxyPort\"",
",",
"port",
")",
";",
"}",
"if",
"(",
"user",
"!=",
"null",
"&&",
"pwd",
"!=",
"null",
"&&",
"user",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"!=",
"0",
"&&",
"pwd",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"!=",
"0",
")",
"{",
"System",
".",
"setProperty",
"(",
"\"http.proxyUserName\"",
",",
"user",
")",
";",
"System",
".",
"setProperty",
"(",
"\"https.proxyUserName\"",
",",
"user",
")",
";",
"System",
".",
"setProperty",
"(",
"\"http.proxyUser\"",
",",
"user",
")",
";",
"System",
".",
"setProperty",
"(",
"\"https.proxyUser\"",
",",
"user",
")",
";",
"System",
".",
"setProperty",
"(",
"\"http.proxyPassword\"",
",",
"pwd",
")",
";",
"System",
".",
"setProperty",
"(",
"\"https.proxyPassword\"",
",",
"pwd",
")",
";",
"Authenticator",
".",
"setDefault",
"(",
"new",
"ProxyAuthenticator",
"(",
"user",
",",
"pwd",
")",
")",
";",
"}",
"if",
"(",
"nonProxyHosts",
"!=",
"null",
")",
"{",
"System",
".",
"setProperty",
"(",
"\"http.nonProxyHosts\"",
",",
"nonProxyHosts",
")",
";",
"}",
"hasProxy",
"=",
"true",
";",
"}"
] | Enable the proxy usage based on the url, user and pwd.
@param url the proxy server url.
@param port the server port.
@param user the proxy user.
@param pwd the proxy password.
@param nonProxyHosts hosts that do not go through proxy.
<p>Default is: <code>localhost|127.*|[::1]</code>.</p>
<p>Other example: *.foo.com|localhost</p> | [
"Enable",
"the",
"proxy",
"usage",
"based",
"on",
"the",
"url",
"user",
"and",
"pwd",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/ssh/ProxyEnabler.java#L48-L77 |
137,973 | TheHortonMachine/hortonmachine | dbs/src/main/java/org/hortonmachine/ssh/ProxyEnabler.java | ProxyEnabler.disableProxy | public static void disableProxy() {
System.clearProperty("http.proxyHost");
System.clearProperty("http.proxyPort");
System.clearProperty("http.proxyUserName");
System.clearProperty("http.proxyUser");
System.clearProperty("http.proxyPassword");
System.clearProperty("https.proxyHost");
System.clearProperty("https.proxyPort");
System.clearProperty("https.proxyUserName");
System.clearProperty("https.proxyUser");
System.clearProperty("https.proxyPassword");
_url = null;
_port = null;
_user = null;
_pwd = null;
hasProxy = false;
} | java | public static void disableProxy() {
System.clearProperty("http.proxyHost");
System.clearProperty("http.proxyPort");
System.clearProperty("http.proxyUserName");
System.clearProperty("http.proxyUser");
System.clearProperty("http.proxyPassword");
System.clearProperty("https.proxyHost");
System.clearProperty("https.proxyPort");
System.clearProperty("https.proxyUserName");
System.clearProperty("https.proxyUser");
System.clearProperty("https.proxyPassword");
_url = null;
_port = null;
_user = null;
_pwd = null;
hasProxy = false;
} | [
"public",
"static",
"void",
"disableProxy",
"(",
")",
"{",
"System",
".",
"clearProperty",
"(",
"\"http.proxyHost\"",
")",
";",
"System",
".",
"clearProperty",
"(",
"\"http.proxyPort\"",
")",
";",
"System",
".",
"clearProperty",
"(",
"\"http.proxyUserName\"",
")",
";",
"System",
".",
"clearProperty",
"(",
"\"http.proxyUser\"",
")",
";",
"System",
".",
"clearProperty",
"(",
"\"http.proxyPassword\"",
")",
";",
"System",
".",
"clearProperty",
"(",
"\"https.proxyHost\"",
")",
";",
"System",
".",
"clearProperty",
"(",
"\"https.proxyPort\"",
")",
";",
"System",
".",
"clearProperty",
"(",
"\"https.proxyUserName\"",
")",
";",
"System",
".",
"clearProperty",
"(",
"\"https.proxyUser\"",
")",
";",
"System",
".",
"clearProperty",
"(",
"\"https.proxyPassword\"",
")",
";",
"_url",
"=",
"null",
";",
"_port",
"=",
"null",
";",
"_user",
"=",
"null",
";",
"_pwd",
"=",
"null",
";",
"hasProxy",
"=",
"false",
";",
"}"
] | Disable the proxy usage. | [
"Disable",
"the",
"proxy",
"usage",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/ssh/ProxyEnabler.java#L93-L110 |
137,974 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/las/core/liblas/LiblasWrapper.java | LiblasWrapper.loadNativeLibrary | public static String loadNativeLibrary( String nativeLibPath, String libName ) {
try {
String name = "las_c";
if (libName == null)
libName = name;
if (nativeLibPath != null) {
NativeLibrary.addSearchPath(libName, nativeLibPath);
}
WRAPPER = (LiblasJNALibrary) Native.loadLibrary(libName, LiblasJNALibrary.class);
} catch (UnsatisfiedLinkError e) {
return e.getLocalizedMessage();
}
return null;
} | java | public static String loadNativeLibrary( String nativeLibPath, String libName ) {
try {
String name = "las_c";
if (libName == null)
libName = name;
if (nativeLibPath != null) {
NativeLibrary.addSearchPath(libName, nativeLibPath);
}
WRAPPER = (LiblasJNALibrary) Native.loadLibrary(libName, LiblasJNALibrary.class);
} catch (UnsatisfiedLinkError e) {
return e.getLocalizedMessage();
}
return null;
} | [
"public",
"static",
"String",
"loadNativeLibrary",
"(",
"String",
"nativeLibPath",
",",
"String",
"libName",
")",
"{",
"try",
"{",
"String",
"name",
"=",
"\"las_c\"",
";",
"if",
"(",
"libName",
"==",
"null",
")",
"libName",
"=",
"name",
";",
"if",
"(",
"nativeLibPath",
"!=",
"null",
")",
"{",
"NativeLibrary",
".",
"addSearchPath",
"(",
"libName",
",",
"nativeLibPath",
")",
";",
"}",
"WRAPPER",
"=",
"(",
"LiblasJNALibrary",
")",
"Native",
".",
"loadLibrary",
"(",
"libName",
",",
"LiblasJNALibrary",
".",
"class",
")",
";",
"}",
"catch",
"(",
"UnsatisfiedLinkError",
"e",
")",
"{",
"return",
"e",
".",
"getLocalizedMessage",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Loads the native libs creating the native wrapper.
@param nativeLibPath the path to add or <code>null</code>.
@param libName the lib name or <code>null</code>, in which case "las_c" is used.
@return <code>null</code>, if the lib could be loaded, the error string else. | [
"Loads",
"the",
"native",
"libs",
"creating",
"the",
"native",
"wrapper",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/las/core/liblas/LiblasWrapper.java#L55-L68 |
137,975 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/geopap4/DaoLog.java | DaoLog.createTables | public static void createTables(Connection connection) throws Exception {
StringBuilder sB = new StringBuilder();
sB.append("CREATE TABLE ");
sB.append(TABLE_LOG);
sB.append(" (");
sB.append(COLUMN_ID);
sB.append(" INTEGER PRIMARY KEY AUTOINCREMENT, ");
sB.append(COLUMN_DATAORA).append(" INTEGER NOT NULL, ");
sB.append(COLUMN_LOGMSG).append(" TEXT ");
sB.append(");");
String CREATE_TABLE = sB.toString();
sB = new StringBuilder();
sB.append("CREATE INDEX " + TABLE_LOG + "_" + COLUMN_ID + " ON ");
sB.append(TABLE_LOG);
sB.append(" ( ");
sB.append(COLUMN_ID);
sB.append(" );");
String CREATE_INDEX = sB.toString();
sB = new StringBuilder();
sB.append("CREATE INDEX " + TABLE_LOG + "_" + COLUMN_DATAORA + " ON ");
sB.append(TABLE_LOG);
sB.append(" ( ");
sB.append(COLUMN_DATAORA);
sB.append(" );");
String CREATE_INDEX_DATE = sB.toString();
try (Statement statement = connection.createStatement()) {
statement.setQueryTimeout(30); // set timeout to 30 sec.
statement.executeUpdate(CREATE_TABLE);
statement.executeUpdate(CREATE_INDEX);
statement.executeUpdate(CREATE_INDEX_DATE);
} catch (Exception e) {
throw new IOException(e.getLocalizedMessage());
}
} | java | public static void createTables(Connection connection) throws Exception {
StringBuilder sB = new StringBuilder();
sB.append("CREATE TABLE ");
sB.append(TABLE_LOG);
sB.append(" (");
sB.append(COLUMN_ID);
sB.append(" INTEGER PRIMARY KEY AUTOINCREMENT, ");
sB.append(COLUMN_DATAORA).append(" INTEGER NOT NULL, ");
sB.append(COLUMN_LOGMSG).append(" TEXT ");
sB.append(");");
String CREATE_TABLE = sB.toString();
sB = new StringBuilder();
sB.append("CREATE INDEX " + TABLE_LOG + "_" + COLUMN_ID + " ON ");
sB.append(TABLE_LOG);
sB.append(" ( ");
sB.append(COLUMN_ID);
sB.append(" );");
String CREATE_INDEX = sB.toString();
sB = new StringBuilder();
sB.append("CREATE INDEX " + TABLE_LOG + "_" + COLUMN_DATAORA + " ON ");
sB.append(TABLE_LOG);
sB.append(" ( ");
sB.append(COLUMN_DATAORA);
sB.append(" );");
String CREATE_INDEX_DATE = sB.toString();
try (Statement statement = connection.createStatement()) {
statement.setQueryTimeout(30); // set timeout to 30 sec.
statement.executeUpdate(CREATE_TABLE);
statement.executeUpdate(CREATE_INDEX);
statement.executeUpdate(CREATE_INDEX_DATE);
} catch (Exception e) {
throw new IOException(e.getLocalizedMessage());
}
} | [
"public",
"static",
"void",
"createTables",
"(",
"Connection",
"connection",
")",
"throws",
"Exception",
"{",
"StringBuilder",
"sB",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sB",
".",
"append",
"(",
"\"CREATE TABLE \"",
")",
";",
"sB",
".",
"append",
"(",
"TABLE_LOG",
")",
";",
"sB",
".",
"append",
"(",
"\" (\"",
")",
";",
"sB",
".",
"append",
"(",
"COLUMN_ID",
")",
";",
"sB",
".",
"append",
"(",
"\" INTEGER PRIMARY KEY AUTOINCREMENT, \"",
")",
";",
"sB",
".",
"append",
"(",
"COLUMN_DATAORA",
")",
".",
"append",
"(",
"\" INTEGER NOT NULL, \"",
")",
";",
"sB",
".",
"append",
"(",
"COLUMN_LOGMSG",
")",
".",
"append",
"(",
"\" TEXT \"",
")",
";",
"sB",
".",
"append",
"(",
"\");\"",
")",
";",
"String",
"CREATE_TABLE",
"=",
"sB",
".",
"toString",
"(",
")",
";",
"sB",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sB",
".",
"append",
"(",
"\"CREATE INDEX \"",
"+",
"TABLE_LOG",
"+",
"\"_\"",
"+",
"COLUMN_ID",
"+",
"\" ON \"",
")",
";",
"sB",
".",
"append",
"(",
"TABLE_LOG",
")",
";",
"sB",
".",
"append",
"(",
"\" ( \"",
")",
";",
"sB",
".",
"append",
"(",
"COLUMN_ID",
")",
";",
"sB",
".",
"append",
"(",
"\" );\"",
")",
";",
"String",
"CREATE_INDEX",
"=",
"sB",
".",
"toString",
"(",
")",
";",
"sB",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sB",
".",
"append",
"(",
"\"CREATE INDEX \"",
"+",
"TABLE_LOG",
"+",
"\"_\"",
"+",
"COLUMN_DATAORA",
"+",
"\" ON \"",
")",
";",
"sB",
".",
"append",
"(",
"TABLE_LOG",
")",
";",
"sB",
".",
"append",
"(",
"\" ( \"",
")",
";",
"sB",
".",
"append",
"(",
"COLUMN_DATAORA",
")",
";",
"sB",
".",
"append",
"(",
"\" );\"",
")",
";",
"String",
"CREATE_INDEX_DATE",
"=",
"sB",
".",
"toString",
"(",
")",
";",
"try",
"(",
"Statement",
"statement",
"=",
"connection",
".",
"createStatement",
"(",
")",
")",
"{",
"statement",
".",
"setQueryTimeout",
"(",
"30",
")",
";",
"// set timeout to 30 sec.",
"statement",
".",
"executeUpdate",
"(",
"CREATE_TABLE",
")",
";",
"statement",
".",
"executeUpdate",
"(",
"CREATE_INDEX",
")",
";",
"statement",
".",
"executeUpdate",
"(",
"CREATE_INDEX_DATE",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
".",
"getLocalizedMessage",
"(",
")",
")",
";",
"}",
"}"
] | Create the default log table.
@param connection the db connection to use.
@throws Exception if something goes wrong. | [
"Create",
"the",
"default",
"log",
"table",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/geopaparazzi/geopap4/DaoLog.java#L57-L95 |
137,976 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/Format.java | Format.convert | public static String convert( long x, int n, String d ) {
if (x == 0) {
return "0";
}
String r = "";
int m = 1 << n;
m--;
while( x != 0 ) {
r = d.charAt((int) (x & m)) + r;
x = x >>> n;
}
return r;
} | java | public static String convert( long x, int n, String d ) {
if (x == 0) {
return "0";
}
String r = "";
int m = 1 << n;
m--;
while( x != 0 ) {
r = d.charAt((int) (x & m)) + r;
x = x >>> n;
}
return r;
} | [
"public",
"static",
"String",
"convert",
"(",
"long",
"x",
",",
"int",
"n",
",",
"String",
"d",
")",
"{",
"if",
"(",
"x",
"==",
"0",
")",
"{",
"return",
"\"0\"",
";",
"}",
"String",
"r",
"=",
"\"\"",
";",
"int",
"m",
"=",
"1",
"<<",
"n",
";",
"m",
"--",
";",
"while",
"(",
"x",
"!=",
"0",
")",
"{",
"r",
"=",
"d",
".",
"charAt",
"(",
"(",
"int",
")",
"(",
"x",
"&",
"m",
")",
")",
"+",
"r",
";",
"x",
"=",
"x",
">>>",
"n",
";",
"}",
"return",
"r",
";",
"}"
] | Converts number to string
@param x value to convert
@param n conversion base
@param d string with characters for conversion.
@return converted number as string | [
"Converts",
"number",
"to",
"string"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/Format.java#L725-L738 |
137,977 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/Format.java | Format.sprintf | public static String sprintf( String s, Object[] params ) {
if ((s == null) || (params == null)) {
return s;
}
StringBuffer result = new StringBuffer("");
String[] ss = split(s);
int p = 0;
for( int i = 0; i < ss.length; i++ ) {
char c = ss[i].charAt(0);
String t = ss[i].substring(1);
if (c == '+') {
result.append(t);
} else {
Object param = params[p];
if (param instanceof Integer) {
result.append(new Format(t).form((Integer) param));
} else if (param instanceof Long) {
result.append(new Format(t).form((Long) param));
} else if (param instanceof Character) {
result.append(new Format(t).form((Character) param));
} else if (param instanceof Double) {
result.append(new Format(t).form((Double) param));
} else if (param instanceof Double) {
result.append(new Format(t).form(new Float((Double) param)));
} else {
result.append(new Format(t).form(param.toString()));
}
p++;
}
}
return result.toString();
} | java | public static String sprintf( String s, Object[] params ) {
if ((s == null) || (params == null)) {
return s;
}
StringBuffer result = new StringBuffer("");
String[] ss = split(s);
int p = 0;
for( int i = 0; i < ss.length; i++ ) {
char c = ss[i].charAt(0);
String t = ss[i].substring(1);
if (c == '+') {
result.append(t);
} else {
Object param = params[p];
if (param instanceof Integer) {
result.append(new Format(t).form((Integer) param));
} else if (param instanceof Long) {
result.append(new Format(t).form((Long) param));
} else if (param instanceof Character) {
result.append(new Format(t).form((Character) param));
} else if (param instanceof Double) {
result.append(new Format(t).form((Double) param));
} else if (param instanceof Double) {
result.append(new Format(t).form(new Float((Double) param)));
} else {
result.append(new Format(t).form(param.toString()));
}
p++;
}
}
return result.toString();
} | [
"public",
"static",
"String",
"sprintf",
"(",
"String",
"s",
",",
"Object",
"[",
"]",
"params",
")",
"{",
"if",
"(",
"(",
"s",
"==",
"null",
")",
"||",
"(",
"params",
"==",
"null",
")",
")",
"{",
"return",
"s",
";",
"}",
"StringBuffer",
"result",
"=",
"new",
"StringBuffer",
"(",
"\"\"",
")",
";",
"String",
"[",
"]",
"ss",
"=",
"split",
"(",
"s",
")",
";",
"int",
"p",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ss",
".",
"length",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"ss",
"[",
"i",
"]",
".",
"charAt",
"(",
"0",
")",
";",
"String",
"t",
"=",
"ss",
"[",
"i",
"]",
".",
"substring",
"(",
"1",
")",
";",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"result",
".",
"append",
"(",
"t",
")",
";",
"}",
"else",
"{",
"Object",
"param",
"=",
"params",
"[",
"p",
"]",
";",
"if",
"(",
"param",
"instanceof",
"Integer",
")",
"{",
"result",
".",
"append",
"(",
"new",
"Format",
"(",
"t",
")",
".",
"form",
"(",
"(",
"Integer",
")",
"param",
")",
")",
";",
"}",
"else",
"if",
"(",
"param",
"instanceof",
"Long",
")",
"{",
"result",
".",
"append",
"(",
"new",
"Format",
"(",
"t",
")",
".",
"form",
"(",
"(",
"Long",
")",
"param",
")",
")",
";",
"}",
"else",
"if",
"(",
"param",
"instanceof",
"Character",
")",
"{",
"result",
".",
"append",
"(",
"new",
"Format",
"(",
"t",
")",
".",
"form",
"(",
"(",
"Character",
")",
"param",
")",
")",
";",
"}",
"else",
"if",
"(",
"param",
"instanceof",
"Double",
")",
"{",
"result",
".",
"append",
"(",
"new",
"Format",
"(",
"t",
")",
".",
"form",
"(",
"(",
"Double",
")",
"param",
")",
")",
";",
"}",
"else",
"if",
"(",
"param",
"instanceof",
"Double",
")",
"{",
"result",
".",
"append",
"(",
"new",
"Format",
"(",
"t",
")",
".",
"form",
"(",
"new",
"Float",
"(",
"(",
"Double",
")",
"param",
")",
")",
")",
";",
"}",
"else",
"{",
"result",
".",
"append",
"(",
"new",
"Format",
"(",
"t",
")",
".",
"form",
"(",
"param",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"p",
"++",
";",
"}",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] | Sprintf multiple strings.
@param s
@param params
@return formated string | [
"Sprintf",
"multiple",
"strings",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/Format.java#L887-L918 |
137,978 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/ngmf/util/cosu/luca/ParameterData.java | ParameterData.setLowerAndUpperBounds | public void setLowerAndUpperBounds(double lower, double upper) {
if (data == null) {
return;
}
this.originalLowerBound = lower;
this.originalUpperBound = upper;
if (originalLowerBound < min) {
offset = Math.abs(originalLowerBound) + 10;
} else {
offset = Math.abs(min) + 10;
}
if (calibrationType == MEAN) {
lowerBound = (originalLowerBound + offset) * (mean + offset) / (min + offset) - offset;
upperBound = (originalUpperBound + offset) * (mean + offset) / (max + offset) - offset;
} else {
lowerBound = originalLowerBound;
upperBound = originalUpperBound;
}
hasBounds = true;
setDeviation();
} | java | public void setLowerAndUpperBounds(double lower, double upper) {
if (data == null) {
return;
}
this.originalLowerBound = lower;
this.originalUpperBound = upper;
if (originalLowerBound < min) {
offset = Math.abs(originalLowerBound) + 10;
} else {
offset = Math.abs(min) + 10;
}
if (calibrationType == MEAN) {
lowerBound = (originalLowerBound + offset) * (mean + offset) / (min + offset) - offset;
upperBound = (originalUpperBound + offset) * (mean + offset) / (max + offset) - offset;
} else {
lowerBound = originalLowerBound;
upperBound = originalUpperBound;
}
hasBounds = true;
setDeviation();
} | [
"public",
"void",
"setLowerAndUpperBounds",
"(",
"double",
"lower",
",",
"double",
"upper",
")",
"{",
"if",
"(",
"data",
"==",
"null",
")",
"{",
"return",
";",
"}",
"this",
".",
"originalLowerBound",
"=",
"lower",
";",
"this",
".",
"originalUpperBound",
"=",
"upper",
";",
"if",
"(",
"originalLowerBound",
"<",
"min",
")",
"{",
"offset",
"=",
"Math",
".",
"abs",
"(",
"originalLowerBound",
")",
"+",
"10",
";",
"}",
"else",
"{",
"offset",
"=",
"Math",
".",
"abs",
"(",
"min",
")",
"+",
"10",
";",
"}",
"if",
"(",
"calibrationType",
"==",
"MEAN",
")",
"{",
"lowerBound",
"=",
"(",
"originalLowerBound",
"+",
"offset",
")",
"*",
"(",
"mean",
"+",
"offset",
")",
"/",
"(",
"min",
"+",
"offset",
")",
"-",
"offset",
";",
"upperBound",
"=",
"(",
"originalUpperBound",
"+",
"offset",
")",
"*",
"(",
"mean",
"+",
"offset",
")",
"/",
"(",
"max",
"+",
"offset",
")",
"-",
"offset",
";",
"}",
"else",
"{",
"lowerBound",
"=",
"originalLowerBound",
";",
"upperBound",
"=",
"originalUpperBound",
";",
"}",
"hasBounds",
"=",
"true",
";",
"setDeviation",
"(",
")",
";",
"}"
] | Set the lower and upper bounds, and the actual bounds are determined. | [
"Set",
"the",
"lower",
"and",
"upper",
"bounds",
"and",
"the",
"actual",
"bounds",
"are",
"determined",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/ngmf/util/cosu/luca/ParameterData.java#L229-L251 |
137,979 | enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/api/translation/CdsTranslator.java | CdsTranslator.checkLocations | private boolean checkLocations(long length, CompoundLocation<Location> locations) {
for(Location location : locations.getLocations()){
if(location instanceof RemoteLocation)
continue;
if(location.getIntBeginPosition() == null ||
location.getIntBeginPosition() < 0){
return false;
}
if(location.getIntEndPosition() == null ||
location.getIntEndPosition() > length){
return false;
}
}
return true;
} | java | private boolean checkLocations(long length, CompoundLocation<Location> locations) {
for(Location location : locations.getLocations()){
if(location instanceof RemoteLocation)
continue;
if(location.getIntBeginPosition() == null ||
location.getIntBeginPosition() < 0){
return false;
}
if(location.getIntEndPosition() == null ||
location.getIntEndPosition() > length){
return false;
}
}
return true;
} | [
"private",
"boolean",
"checkLocations",
"(",
"long",
"length",
",",
"CompoundLocation",
"<",
"Location",
">",
"locations",
")",
"{",
"for",
"(",
"Location",
"location",
":",
"locations",
".",
"getLocations",
"(",
")",
")",
"{",
"if",
"(",
"location",
"instanceof",
"RemoteLocation",
")",
"continue",
";",
"if",
"(",
"location",
".",
"getIntBeginPosition",
"(",
")",
"==",
"null",
"||",
"location",
".",
"getIntBeginPosition",
"(",
")",
"<",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"location",
".",
"getIntEndPosition",
"(",
")",
"==",
"null",
"||",
"location",
".",
"getIntEndPosition",
"(",
")",
">",
"length",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Checks that the locations are within the sequence length
@param length
@param locations
@return | [
"Checks",
"that",
"the",
"locations",
"are",
"within",
"the",
"sequence",
"length"
] | 4127f5e1a17540239f5810136153fbd6737fa262 | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/translation/CdsTranslator.java#L248-L262 |
137,980 | TheHortonMachine/hortonmachine | apps/src/main/java/org/hortonmachine/nww/utils/NwwUtilities.java | NwwUtilities.readFeatureSource | public static SimpleFeatureSource readFeatureSource( String path ) throws Exception {
File shapeFile = new File(path);
FileDataStore store = FileDataStoreFinder.getDataStore(shapeFile);
SimpleFeatureSource featureSource = store.getFeatureSource();
return featureSource;
} | java | public static SimpleFeatureSource readFeatureSource( String path ) throws Exception {
File shapeFile = new File(path);
FileDataStore store = FileDataStoreFinder.getDataStore(shapeFile);
SimpleFeatureSource featureSource = store.getFeatureSource();
return featureSource;
} | [
"public",
"static",
"SimpleFeatureSource",
"readFeatureSource",
"(",
"String",
"path",
")",
"throws",
"Exception",
"{",
"File",
"shapeFile",
"=",
"new",
"File",
"(",
"path",
")",
";",
"FileDataStore",
"store",
"=",
"FileDataStoreFinder",
".",
"getDataStore",
"(",
"shapeFile",
")",
";",
"SimpleFeatureSource",
"featureSource",
"=",
"store",
".",
"getFeatureSource",
"(",
")",
";",
"return",
"featureSource",
";",
"}"
] | Get the feature source from a file.
@param path
the path to the shapefile.
@return the feature source.
@throws Exception | [
"Get",
"the",
"feature",
"source",
"from",
"a",
"file",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/apps/src/main/java/org/hortonmachine/nww/utils/NwwUtilities.java#L111-L116 |
137,981 | TheHortonMachine/hortonmachine | apps/src/main/java/org/hortonmachine/nww/utils/NwwUtilities.java | NwwUtilities.getGeometryType | public static GEOMTYPE getGeometryType( SimpleFeatureCollection featureCollection ) {
GeometryDescriptor geometryDescriptor = featureCollection.getSchema().getGeometryDescriptor();
if (EGeometryType.isPolygon(geometryDescriptor)) {
return GEOMTYPE.POLYGON;
} else if (EGeometryType.isLine(geometryDescriptor)) {
return GEOMTYPE.LINE;
} else if (EGeometryType.isPoint(geometryDescriptor)) {
return GEOMTYPE.POINT;
} else {
return GEOMTYPE.UNKNOWN;
}
} | java | public static GEOMTYPE getGeometryType( SimpleFeatureCollection featureCollection ) {
GeometryDescriptor geometryDescriptor = featureCollection.getSchema().getGeometryDescriptor();
if (EGeometryType.isPolygon(geometryDescriptor)) {
return GEOMTYPE.POLYGON;
} else if (EGeometryType.isLine(geometryDescriptor)) {
return GEOMTYPE.LINE;
} else if (EGeometryType.isPoint(geometryDescriptor)) {
return GEOMTYPE.POINT;
} else {
return GEOMTYPE.UNKNOWN;
}
} | [
"public",
"static",
"GEOMTYPE",
"getGeometryType",
"(",
"SimpleFeatureCollection",
"featureCollection",
")",
"{",
"GeometryDescriptor",
"geometryDescriptor",
"=",
"featureCollection",
".",
"getSchema",
"(",
")",
".",
"getGeometryDescriptor",
"(",
")",
";",
"if",
"(",
"EGeometryType",
".",
"isPolygon",
"(",
"geometryDescriptor",
")",
")",
"{",
"return",
"GEOMTYPE",
".",
"POLYGON",
";",
"}",
"else",
"if",
"(",
"EGeometryType",
".",
"isLine",
"(",
"geometryDescriptor",
")",
")",
"{",
"return",
"GEOMTYPE",
".",
"LINE",
";",
"}",
"else",
"if",
"(",
"EGeometryType",
".",
"isPoint",
"(",
"geometryDescriptor",
")",
")",
"{",
"return",
"GEOMTYPE",
".",
"POINT",
";",
"}",
"else",
"{",
"return",
"GEOMTYPE",
".",
"UNKNOWN",
";",
"}",
"}"
] | Get the geometry type from a featurecollection.
@param featureCollection
the collection.
@return the {@link GEOMTYPE}. | [
"Get",
"the",
"geometry",
"type",
"from",
"a",
"featurecollection",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/apps/src/main/java/org/hortonmachine/nww/utils/NwwUtilities.java#L125-L136 |
137,982 | TheHortonMachine/hortonmachine | apps/src/main/java/org/hortonmachine/nww/utils/NwwUtilities.java | NwwUtilities.insertBeforeCompass | public static void insertBeforeCompass( WorldWindow wwd, Layer layer ) {
// Insert the layer into the layer list just before the compass.
int compassPosition = 0;
LayerList layers = wwd.getModel().getLayers();
for( Layer l : layers ) {
if (l instanceof CompassLayer)
compassPosition = layers.indexOf(l);
}
layers.add(compassPosition, layer);
} | java | public static void insertBeforeCompass( WorldWindow wwd, Layer layer ) {
// Insert the layer into the layer list just before the compass.
int compassPosition = 0;
LayerList layers = wwd.getModel().getLayers();
for( Layer l : layers ) {
if (l instanceof CompassLayer)
compassPosition = layers.indexOf(l);
}
layers.add(compassPosition, layer);
} | [
"public",
"static",
"void",
"insertBeforeCompass",
"(",
"WorldWindow",
"wwd",
",",
"Layer",
"layer",
")",
"{",
"// Insert the layer into the layer list just before the compass.",
"int",
"compassPosition",
"=",
"0",
";",
"LayerList",
"layers",
"=",
"wwd",
".",
"getModel",
"(",
")",
".",
"getLayers",
"(",
")",
";",
"for",
"(",
"Layer",
"l",
":",
"layers",
")",
"{",
"if",
"(",
"l",
"instanceof",
"CompassLayer",
")",
"compassPosition",
"=",
"layers",
".",
"indexOf",
"(",
"l",
")",
";",
"}",
"layers",
".",
"add",
"(",
"compassPosition",
",",
"layer",
")",
";",
"}"
] | Insert a layer before the compass layer.
@param wwd the {@link WorldWindow}.
@param layer the layer to insert. | [
"Insert",
"a",
"layer",
"before",
"the",
"compass",
"layer",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/apps/src/main/java/org/hortonmachine/nww/utils/NwwUtilities.java#L353-L362 |
137,983 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/objects/DwgVertex2D.java | DwgVertex2D.readDwgVertex2DV15 | public void readDwgVertex2DV15(int[] data, int offset) throws Exception {
//System.out.println("readDwgVertex2D executing ...");
int bitPos = offset;
bitPos = readObjectHeaderV15(data, bitPos);
Vector v = DwgUtil.getRawChar(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int flags = ((Integer)v.get(1)).intValue();
this.flags = flags;
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double x = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double y = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double z = ((Double)v.get(1)).doubleValue();
double[] coord = new double[]{x, y, z};
point = new double[]{x, y, z};
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double sw = ((Double)v.get(1)).doubleValue();
double ew = 0.0;
if (sw<0.0) {
ew = Math.abs(sw);
sw = ew;
} else {
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
ew = ((Double)v.get(1)).doubleValue();
}
initWidth = sw;
endWidth = ew;
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double bulge = ((Double)v.get(1)).doubleValue();
this.bulge = bulge;
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double tandir = ((Double)v.get(1)).doubleValue();
tangentDir = tandir;
bitPos = readObjectTailV15(data, bitPos);
} | java | public void readDwgVertex2DV15(int[] data, int offset) throws Exception {
//System.out.println("readDwgVertex2D executing ...");
int bitPos = offset;
bitPos = readObjectHeaderV15(data, bitPos);
Vector v = DwgUtil.getRawChar(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int flags = ((Integer)v.get(1)).intValue();
this.flags = flags;
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double x = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double y = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double z = ((Double)v.get(1)).doubleValue();
double[] coord = new double[]{x, y, z};
point = new double[]{x, y, z};
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double sw = ((Double)v.get(1)).doubleValue();
double ew = 0.0;
if (sw<0.0) {
ew = Math.abs(sw);
sw = ew;
} else {
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
ew = ((Double)v.get(1)).doubleValue();
}
initWidth = sw;
endWidth = ew;
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double bulge = ((Double)v.get(1)).doubleValue();
this.bulge = bulge;
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double tandir = ((Double)v.get(1)).doubleValue();
tangentDir = tandir;
bitPos = readObjectTailV15(data, bitPos);
} | [
"public",
"void",
"readDwgVertex2DV15",
"(",
"int",
"[",
"]",
"data",
",",
"int",
"offset",
")",
"throws",
"Exception",
"{",
"//System.out.println(\"readDwgVertex2D executing ...\");",
"int",
"bitPos",
"=",
"offset",
";",
"bitPos",
"=",
"readObjectHeaderV15",
"(",
"data",
",",
"bitPos",
")",
";",
"Vector",
"v",
"=",
"DwgUtil",
".",
"getRawChar",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"int",
"flags",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"intValue",
"(",
")",
";",
"this",
".",
"flags",
"=",
"flags",
";",
"v",
"=",
"DwgUtil",
".",
"getBitDouble",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"double",
"x",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"v",
"=",
"DwgUtil",
".",
"getBitDouble",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"double",
"y",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"v",
"=",
"DwgUtil",
".",
"getBitDouble",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"double",
"z",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"double",
"[",
"]",
"coord",
"=",
"new",
"double",
"[",
"]",
"{",
"x",
",",
"y",
",",
"z",
"}",
";",
"point",
"=",
"new",
"double",
"[",
"]",
"{",
"x",
",",
"y",
",",
"z",
"}",
";",
"v",
"=",
"DwgUtil",
".",
"getBitDouble",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"double",
"sw",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"double",
"ew",
"=",
"0.0",
";",
"if",
"(",
"sw",
"<",
"0.0",
")",
"{",
"ew",
"=",
"Math",
".",
"abs",
"(",
"sw",
")",
";",
"sw",
"=",
"ew",
";",
"}",
"else",
"{",
"v",
"=",
"DwgUtil",
".",
"getBitDouble",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"ew",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"}",
"initWidth",
"=",
"sw",
";",
"endWidth",
"=",
"ew",
";",
"v",
"=",
"DwgUtil",
".",
"getBitDouble",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"double",
"bulge",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"this",
".",
"bulge",
"=",
"bulge",
";",
"v",
"=",
"DwgUtil",
".",
"getBitDouble",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"double",
"tandir",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"tangentDir",
"=",
"tandir",
";",
"bitPos",
"=",
"readObjectTailV15",
"(",
"data",
",",
"bitPos",
")",
";",
"}"
] | Read a Vertex2D in the DWG format Version 15
@param data Array of unsigned bytes obtained from the DWG binary file
@param offset The current bit offset where the value begins
@throws Exception If an unexpected bit value is found in the DWG file. Occurs
when we are looking for LwPolylines. | [
"Read",
"a",
"Vertex2D",
"in",
"the",
"DWG",
"format",
"Version",
"15"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/objects/DwgVertex2D.java#L47-L89 |
137,984 | TheHortonMachine/hortonmachine | gears/src/main/java/oms3/ngmf/util/cosu/Efficiencies.java | Efficiencies.runoffCoefficientError | public static double runoffCoefficientError(double[] obs, double[] sim, double[] precip) {
sameArrayLen(sim, obs, precip);
double mean_pred = Stats.mean(sim);
double mean_val = Stats.mean(obs);
double mean_ppt = Stats.mean(precip);
double error = Math.abs((mean_pred / mean_ppt) - (mean_val / mean_ppt));
return Math.sqrt(error);
} | java | public static double runoffCoefficientError(double[] obs, double[] sim, double[] precip) {
sameArrayLen(sim, obs, precip);
double mean_pred = Stats.mean(sim);
double mean_val = Stats.mean(obs);
double mean_ppt = Stats.mean(precip);
double error = Math.abs((mean_pred / mean_ppt) - (mean_val / mean_ppt));
return Math.sqrt(error);
} | [
"public",
"static",
"double",
"runoffCoefficientError",
"(",
"double",
"[",
"]",
"obs",
",",
"double",
"[",
"]",
"sim",
",",
"double",
"[",
"]",
"precip",
")",
"{",
"sameArrayLen",
"(",
"sim",
",",
"obs",
",",
"precip",
")",
";",
"double",
"mean_pred",
"=",
"Stats",
".",
"mean",
"(",
"sim",
")",
";",
"double",
"mean_val",
"=",
"Stats",
".",
"mean",
"(",
"obs",
")",
";",
"double",
"mean_ppt",
"=",
"Stats",
".",
"mean",
"(",
"precip",
")",
";",
"double",
"error",
"=",
"Math",
".",
"abs",
"(",
"(",
"mean_pred",
"/",
"mean_ppt",
")",
"-",
"(",
"mean_val",
"/",
"mean_ppt",
")",
")",
";",
"return",
"Math",
".",
"sqrt",
"(",
"error",
")",
";",
"}"
] | Runoff coefficient error ROCE
@param obs
@param sim
@param precip
@return | [
"Runoff",
"coefficient",
"error",
"ROCE"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/ngmf/util/cosu/Efficiencies.java#L409-L417 |
137,985 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/optimizers/particleswarm/Particle.java | Particle.update | public double[] update( double w, double c1, double rand1, double c2, double rand2, double[] globalBest ) {
for( int i = 0; i < locations.length; i++ ) {
particleVelocities[i] = w * particleVelocities[i] + //
c1 * rand1 * (particleLocalBests[i] - locations[i]) + //
c2 * rand2 * (globalBest[i] - locations[i]);
double tmpLocation = locations[i] + particleVelocities[i];
/*
* if the location falls outside the ranges, it should
* not be moved.
*/
tmpLocations[i] = tmpLocation;
}
if (!PSEngine.parametersInRange(tmpLocations, ranges)) {
// System.out.println("PRE-TMPLOCATIONS: " + Arrays.toString(tmpLocations));
// System.out.println("LOCATIONS: " + Arrays.toString(locations));
/*
* mirror the value back
*/
for( int i = 0; i < tmpLocations.length; i++ ) {
double min = ranges[i][0];
double max = ranges[i][1];
if (tmpLocations[i] > max) {
double tmp = max - (tmpLocations[i] - max);
if (tmp < min) {
tmp = max;
}
locations[i] = tmp;
} else if (tmpLocations[i] < min) {
double tmp = min + (min - tmpLocations[i]);
if (tmp > max) {
tmp = min;
}
locations[i] = tmp;
} else {
locations[i] = tmpLocations[i];
}
}
// System.out.println("POST-LOCATIONS: " + Arrays.toString(locations));
// System.out.println("VELOCITIES: " + Arrays.toString(particleVelocities));
return null;
} else {
for( int i = 0; i < locations.length; i++ ) {
locations[i] = tmpLocations[i];
}
return locations;
}
} | java | public double[] update( double w, double c1, double rand1, double c2, double rand2, double[] globalBest ) {
for( int i = 0; i < locations.length; i++ ) {
particleVelocities[i] = w * particleVelocities[i] + //
c1 * rand1 * (particleLocalBests[i] - locations[i]) + //
c2 * rand2 * (globalBest[i] - locations[i]);
double tmpLocation = locations[i] + particleVelocities[i];
/*
* if the location falls outside the ranges, it should
* not be moved.
*/
tmpLocations[i] = tmpLocation;
}
if (!PSEngine.parametersInRange(tmpLocations, ranges)) {
// System.out.println("PRE-TMPLOCATIONS: " + Arrays.toString(tmpLocations));
// System.out.println("LOCATIONS: " + Arrays.toString(locations));
/*
* mirror the value back
*/
for( int i = 0; i < tmpLocations.length; i++ ) {
double min = ranges[i][0];
double max = ranges[i][1];
if (tmpLocations[i] > max) {
double tmp = max - (tmpLocations[i] - max);
if (tmp < min) {
tmp = max;
}
locations[i] = tmp;
} else if (tmpLocations[i] < min) {
double tmp = min + (min - tmpLocations[i]);
if (tmp > max) {
tmp = min;
}
locations[i] = tmp;
} else {
locations[i] = tmpLocations[i];
}
}
// System.out.println("POST-LOCATIONS: " + Arrays.toString(locations));
// System.out.println("VELOCITIES: " + Arrays.toString(particleVelocities));
return null;
} else {
for( int i = 0; i < locations.length; i++ ) {
locations[i] = tmpLocations[i];
}
return locations;
}
} | [
"public",
"double",
"[",
"]",
"update",
"(",
"double",
"w",
",",
"double",
"c1",
",",
"double",
"rand1",
",",
"double",
"c2",
",",
"double",
"rand2",
",",
"double",
"[",
"]",
"globalBest",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"locations",
".",
"length",
";",
"i",
"++",
")",
"{",
"particleVelocities",
"[",
"i",
"]",
"=",
"w",
"*",
"particleVelocities",
"[",
"i",
"]",
"+",
"//",
"c1",
"*",
"rand1",
"*",
"(",
"particleLocalBests",
"[",
"i",
"]",
"-",
"locations",
"[",
"i",
"]",
")",
"+",
"//",
"c2",
"*",
"rand2",
"*",
"(",
"globalBest",
"[",
"i",
"]",
"-",
"locations",
"[",
"i",
"]",
")",
";",
"double",
"tmpLocation",
"=",
"locations",
"[",
"i",
"]",
"+",
"particleVelocities",
"[",
"i",
"]",
";",
"/*\n * if the location falls outside the ranges, it should \n * not be moved.\n */",
"tmpLocations",
"[",
"i",
"]",
"=",
"tmpLocation",
";",
"}",
"if",
"(",
"!",
"PSEngine",
".",
"parametersInRange",
"(",
"tmpLocations",
",",
"ranges",
")",
")",
"{",
"// System.out.println(\"PRE-TMPLOCATIONS: \" + Arrays.toString(tmpLocations));",
"// System.out.println(\"LOCATIONS: \" + Arrays.toString(locations));",
"/*\n * mirror the value back\n */",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tmpLocations",
".",
"length",
";",
"i",
"++",
")",
"{",
"double",
"min",
"=",
"ranges",
"[",
"i",
"]",
"[",
"0",
"]",
";",
"double",
"max",
"=",
"ranges",
"[",
"i",
"]",
"[",
"1",
"]",
";",
"if",
"(",
"tmpLocations",
"[",
"i",
"]",
">",
"max",
")",
"{",
"double",
"tmp",
"=",
"max",
"-",
"(",
"tmpLocations",
"[",
"i",
"]",
"-",
"max",
")",
";",
"if",
"(",
"tmp",
"<",
"min",
")",
"{",
"tmp",
"=",
"max",
";",
"}",
"locations",
"[",
"i",
"]",
"=",
"tmp",
";",
"}",
"else",
"if",
"(",
"tmpLocations",
"[",
"i",
"]",
"<",
"min",
")",
"{",
"double",
"tmp",
"=",
"min",
"+",
"(",
"min",
"-",
"tmpLocations",
"[",
"i",
"]",
")",
";",
"if",
"(",
"tmp",
">",
"max",
")",
"{",
"tmp",
"=",
"min",
";",
"}",
"locations",
"[",
"i",
"]",
"=",
"tmp",
";",
"}",
"else",
"{",
"locations",
"[",
"i",
"]",
"=",
"tmpLocations",
"[",
"i",
"]",
";",
"}",
"}",
"// System.out.println(\"POST-LOCATIONS: \" + Arrays.toString(locations));",
"// System.out.println(\"VELOCITIES: \" + Arrays.toString(particleVelocities));",
"return",
"null",
";",
"}",
"else",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"locations",
".",
"length",
";",
"i",
"++",
")",
"{",
"locations",
"[",
"i",
"]",
"=",
"tmpLocations",
"[",
"i",
"]",
";",
"}",
"return",
"locations",
";",
"}",
"}"
] | Particle swarming formula to update positions.
@param w inertia weight (controls the impact of the past velocity of the
particle over the current one).
@param c1 constant weighting the influence of local best
solutions.
@param rand1 random factor introduced in search process.
@param c2 constant weighting the influence of global best
solutions.
@param rand2 random factor introduced in search process.
@param globalBest leader particle (global best) in all dimensions.
@return the updated locations or <code>null</code>, if they are outside the ranges. | [
"Particle",
"swarming",
"formula",
"to",
"update",
"positions",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/optimizers/particleswarm/Particle.java#L122-L173 |
137,986 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/optimizers/particleswarm/Particle.java | Particle.setParticleLocalBeststoCurrent | public void setParticleLocalBeststoCurrent() {
for( int i = 0; i < locations.length; i++ ) {
particleLocalBests[i] = locations[i];
}
} | java | public void setParticleLocalBeststoCurrent() {
for( int i = 0; i < locations.length; i++ ) {
particleLocalBests[i] = locations[i];
}
} | [
"public",
"void",
"setParticleLocalBeststoCurrent",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"locations",
".",
"length",
";",
"i",
"++",
")",
"{",
"particleLocalBests",
"[",
"i",
"]",
"=",
"locations",
"[",
"i",
"]",
";",
"}",
"}"
] | Setter to set the current positions to be the local best positions. | [
"Setter",
"to",
"set",
"the",
"current",
"positions",
"to",
"be",
"the",
"local",
"best",
"positions",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/optimizers/particleswarm/Particle.java#L196-L200 |
137,987 | TheHortonMachine/hortonmachine | gui/src/main/java/org/hortonmachine/gui/utils/GuiUtilities.java | GuiUtilities.getLastFile | public static File getLastFile() {
Preferences preferences = Preferences.userRoot().node(GuiBridgeHandler.PREFS_NODE_NAME);
String userHome = System.getProperty("user.home");
String lastPath = preferences.get(LAST_PATH, userHome);
File file = new File(lastPath);
if (!file.exists()) {
return new File(userHome);
}
return file;
} | java | public static File getLastFile() {
Preferences preferences = Preferences.userRoot().node(GuiBridgeHandler.PREFS_NODE_NAME);
String userHome = System.getProperty("user.home");
String lastPath = preferences.get(LAST_PATH, userHome);
File file = new File(lastPath);
if (!file.exists()) {
return new File(userHome);
}
return file;
} | [
"public",
"static",
"File",
"getLastFile",
"(",
")",
"{",
"Preferences",
"preferences",
"=",
"Preferences",
".",
"userRoot",
"(",
")",
".",
"node",
"(",
"GuiBridgeHandler",
".",
"PREFS_NODE_NAME",
")",
";",
"String",
"userHome",
"=",
"System",
".",
"getProperty",
"(",
"\"user.home\"",
")",
";",
"String",
"lastPath",
"=",
"preferences",
".",
"get",
"(",
"LAST_PATH",
",",
"userHome",
")",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"lastPath",
")",
";",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"return",
"new",
"File",
"(",
"userHome",
")",
";",
"}",
"return",
"file",
";",
"}"
] | Handle the last set path preference.
@return the last set path or the user home. | [
"Handle",
"the",
"last",
"set",
"path",
"preference",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gui/src/main/java/org/hortonmachine/gui/utils/GuiUtilities.java#L115-L125 |
137,988 | TheHortonMachine/hortonmachine | gui/src/main/java/org/hortonmachine/gui/utils/GuiUtilities.java | GuiUtilities.setLastPath | public static void setLastPath( String lastPath ) {
File file = new File(lastPath);
if (!file.isDirectory()) {
lastPath = file.getParentFile().getAbsolutePath();
}
Preferences preferences = Preferences.userRoot().node(GuiBridgeHandler.PREFS_NODE_NAME);
preferences.put(LAST_PATH, lastPath);
} | java | public static void setLastPath( String lastPath ) {
File file = new File(lastPath);
if (!file.isDirectory()) {
lastPath = file.getParentFile().getAbsolutePath();
}
Preferences preferences = Preferences.userRoot().node(GuiBridgeHandler.PREFS_NODE_NAME);
preferences.put(LAST_PATH, lastPath);
} | [
"public",
"static",
"void",
"setLastPath",
"(",
"String",
"lastPath",
")",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"lastPath",
")",
";",
"if",
"(",
"!",
"file",
".",
"isDirectory",
"(",
")",
")",
"{",
"lastPath",
"=",
"file",
".",
"getParentFile",
"(",
")",
".",
"getAbsolutePath",
"(",
")",
";",
"}",
"Preferences",
"preferences",
"=",
"Preferences",
".",
"userRoot",
"(",
")",
".",
"node",
"(",
"GuiBridgeHandler",
".",
"PREFS_NODE_NAME",
")",
";",
"preferences",
".",
"put",
"(",
"LAST_PATH",
",",
"lastPath",
")",
";",
"}"
] | Save the passed path as last path available.
@param lastPath
the last path to save. | [
"Save",
"the",
"passed",
"path",
"as",
"last",
"path",
"available",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gui/src/main/java/org/hortonmachine/gui/utils/GuiUtilities.java#L133-L140 |
137,989 | TheHortonMachine/hortonmachine | gui/src/main/java/org/hortonmachine/gui/utils/GuiUtilities.java | GuiUtilities.setPreference | public static void setPreference( String preferenceKey, String value ) {
if (preferencesDb != null) {
preferencesDb.setPreference(preferenceKey, value);
return;
}
Preferences preferences = Preferences.userRoot().node(GuiBridgeHandler.PREFS_NODE_NAME);
if (value != null) {
preferences.put(preferenceKey, value);
} else {
preferences.remove(preferenceKey);
}
} | java | public static void setPreference( String preferenceKey, String value ) {
if (preferencesDb != null) {
preferencesDb.setPreference(preferenceKey, value);
return;
}
Preferences preferences = Preferences.userRoot().node(GuiBridgeHandler.PREFS_NODE_NAME);
if (value != null) {
preferences.put(preferenceKey, value);
} else {
preferences.remove(preferenceKey);
}
} | [
"public",
"static",
"void",
"setPreference",
"(",
"String",
"preferenceKey",
",",
"String",
"value",
")",
"{",
"if",
"(",
"preferencesDb",
"!=",
"null",
")",
"{",
"preferencesDb",
".",
"setPreference",
"(",
"preferenceKey",
",",
"value",
")",
";",
"return",
";",
"}",
"Preferences",
"preferences",
"=",
"Preferences",
".",
"userRoot",
"(",
")",
".",
"node",
"(",
"GuiBridgeHandler",
".",
"PREFS_NODE_NAME",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"preferences",
".",
"put",
"(",
"preferenceKey",
",",
"value",
")",
";",
"}",
"else",
"{",
"preferences",
".",
"remove",
"(",
"preferenceKey",
")",
";",
"}",
"}"
] | Set a preference.
@param preferenceKey
the preference key.
@param value
the value to set. | [
"Set",
"a",
"preference",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gui/src/main/java/org/hortonmachine/gui/utils/GuiUtilities.java#L187-L199 |
137,990 | TheHortonMachine/hortonmachine | gui/src/main/java/org/hortonmachine/gui/utils/GuiUtilities.java | GuiUtilities.showMultiInputDialog | @SuppressWarnings({"unchecked", "rawtypes"})
public static String[] showMultiInputDialog( Component parentComponent, String title, String[] labels, String[] defaultValues,
HashMap<String, String[]> fields2ValuesMap ) {
Component[] valuesFields = new Component[labels.length];
JPanel panel = new JPanel();
// panel.setPreferredSize(new Dimension(400, 300));
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
String input[] = new String[labels.length];
panel.setLayout(new GridLayout(labels.length, 2, 5, 5));
for( int i = 0; i < labels.length; i++ ) {
panel.add(new JLabel(labels[i]));
boolean doneCombo = false;
if (fields2ValuesMap != null) {
String[] values = fields2ValuesMap.get(labels[i]);
if (values != null) {
JComboBox<String> valuesCombo = new JComboBox<>(values);
valuesFields[i] = valuesCombo;
panel.add(valuesCombo);
if (defaultValues != null) {
valuesCombo.setSelectedItem(defaultValues[i]);
}
doneCombo = true;
}
}
if (!doneCombo) {
valuesFields[i] = new JTextField();
panel.add(valuesFields[i]);
if (defaultValues != null) {
((JTextField) valuesFields[i]).setText(defaultValues[i]);
}
}
}
JScrollPane scrollPane = new JScrollPane(panel);
scrollPane.setPreferredSize(new Dimension(550, 300));
int result = JOptionPane.showConfirmDialog(parentComponent, scrollPane, title, JOptionPane.OK_CANCEL_OPTION);
if (result != JOptionPane.OK_OPTION) {
return null;
}
for( int i = 0; i < labels.length; i++ ) {
if (valuesFields[i] instanceof JTextField) {
JTextField textField = (JTextField) valuesFields[i];
input[i] = textField.getText();
}
if (valuesFields[i] instanceof JComboBox) {
JComboBox<String> combo = (JComboBox) valuesFields[i];
input[i] = combo.getSelectedItem().toString();
}
}
return input;
} | java | @SuppressWarnings({"unchecked", "rawtypes"})
public static String[] showMultiInputDialog( Component parentComponent, String title, String[] labels, String[] defaultValues,
HashMap<String, String[]> fields2ValuesMap ) {
Component[] valuesFields = new Component[labels.length];
JPanel panel = new JPanel();
// panel.setPreferredSize(new Dimension(400, 300));
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
String input[] = new String[labels.length];
panel.setLayout(new GridLayout(labels.length, 2, 5, 5));
for( int i = 0; i < labels.length; i++ ) {
panel.add(new JLabel(labels[i]));
boolean doneCombo = false;
if (fields2ValuesMap != null) {
String[] values = fields2ValuesMap.get(labels[i]);
if (values != null) {
JComboBox<String> valuesCombo = new JComboBox<>(values);
valuesFields[i] = valuesCombo;
panel.add(valuesCombo);
if (defaultValues != null) {
valuesCombo.setSelectedItem(defaultValues[i]);
}
doneCombo = true;
}
}
if (!doneCombo) {
valuesFields[i] = new JTextField();
panel.add(valuesFields[i]);
if (defaultValues != null) {
((JTextField) valuesFields[i]).setText(defaultValues[i]);
}
}
}
JScrollPane scrollPane = new JScrollPane(panel);
scrollPane.setPreferredSize(new Dimension(550, 300));
int result = JOptionPane.showConfirmDialog(parentComponent, scrollPane, title, JOptionPane.OK_CANCEL_OPTION);
if (result != JOptionPane.OK_OPTION) {
return null;
}
for( int i = 0; i < labels.length; i++ ) {
if (valuesFields[i] instanceof JTextField) {
JTextField textField = (JTextField) valuesFields[i];
input[i] = textField.getText();
}
if (valuesFields[i] instanceof JComboBox) {
JComboBox<String> combo = (JComboBox) valuesFields[i];
input[i] = combo.getSelectedItem().toString();
}
}
return input;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"public",
"static",
"String",
"[",
"]",
"showMultiInputDialog",
"(",
"Component",
"parentComponent",
",",
"String",
"title",
",",
"String",
"[",
"]",
"labels",
",",
"String",
"[",
"]",
"defaultValues",
",",
"HashMap",
"<",
"String",
",",
"String",
"[",
"]",
">",
"fields2ValuesMap",
")",
"{",
"Component",
"[",
"]",
"valuesFields",
"=",
"new",
"Component",
"[",
"labels",
".",
"length",
"]",
";",
"JPanel",
"panel",
"=",
"new",
"JPanel",
"(",
")",
";",
"// panel.setPreferredSize(new Dimension(400, 300));",
"panel",
".",
"setBorder",
"(",
"BorderFactory",
".",
"createEmptyBorder",
"(",
"10",
",",
"10",
",",
"10",
",",
"10",
")",
")",
";",
"String",
"input",
"[",
"]",
"=",
"new",
"String",
"[",
"labels",
".",
"length",
"]",
";",
"panel",
".",
"setLayout",
"(",
"new",
"GridLayout",
"(",
"labels",
".",
"length",
",",
"2",
",",
"5",
",",
"5",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"labels",
".",
"length",
";",
"i",
"++",
")",
"{",
"panel",
".",
"add",
"(",
"new",
"JLabel",
"(",
"labels",
"[",
"i",
"]",
")",
")",
";",
"boolean",
"doneCombo",
"=",
"false",
";",
"if",
"(",
"fields2ValuesMap",
"!=",
"null",
")",
"{",
"String",
"[",
"]",
"values",
"=",
"fields2ValuesMap",
".",
"get",
"(",
"labels",
"[",
"i",
"]",
")",
";",
"if",
"(",
"values",
"!=",
"null",
")",
"{",
"JComboBox",
"<",
"String",
">",
"valuesCombo",
"=",
"new",
"JComboBox",
"<>",
"(",
"values",
")",
";",
"valuesFields",
"[",
"i",
"]",
"=",
"valuesCombo",
";",
"panel",
".",
"add",
"(",
"valuesCombo",
")",
";",
"if",
"(",
"defaultValues",
"!=",
"null",
")",
"{",
"valuesCombo",
".",
"setSelectedItem",
"(",
"defaultValues",
"[",
"i",
"]",
")",
";",
"}",
"doneCombo",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"doneCombo",
")",
"{",
"valuesFields",
"[",
"i",
"]",
"=",
"new",
"JTextField",
"(",
")",
";",
"panel",
".",
"add",
"(",
"valuesFields",
"[",
"i",
"]",
")",
";",
"if",
"(",
"defaultValues",
"!=",
"null",
")",
"{",
"(",
"(",
"JTextField",
")",
"valuesFields",
"[",
"i",
"]",
")",
".",
"setText",
"(",
"defaultValues",
"[",
"i",
"]",
")",
";",
"}",
"}",
"}",
"JScrollPane",
"scrollPane",
"=",
"new",
"JScrollPane",
"(",
"panel",
")",
";",
"scrollPane",
".",
"setPreferredSize",
"(",
"new",
"Dimension",
"(",
"550",
",",
"300",
")",
")",
";",
"int",
"result",
"=",
"JOptionPane",
".",
"showConfirmDialog",
"(",
"parentComponent",
",",
"scrollPane",
",",
"title",
",",
"JOptionPane",
".",
"OK_CANCEL_OPTION",
")",
";",
"if",
"(",
"result",
"!=",
"JOptionPane",
".",
"OK_OPTION",
")",
"{",
"return",
"null",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"labels",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"valuesFields",
"[",
"i",
"]",
"instanceof",
"JTextField",
")",
"{",
"JTextField",
"textField",
"=",
"(",
"JTextField",
")",
"valuesFields",
"[",
"i",
"]",
";",
"input",
"[",
"i",
"]",
"=",
"textField",
".",
"getText",
"(",
")",
";",
"}",
"if",
"(",
"valuesFields",
"[",
"i",
"]",
"instanceof",
"JComboBox",
")",
"{",
"JComboBox",
"<",
"String",
">",
"combo",
"=",
"(",
"JComboBox",
")",
"valuesFields",
"[",
"i",
"]",
";",
"input",
"[",
"i",
"]",
"=",
"combo",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
";",
"}",
"}",
"return",
"input",
";",
"}"
] | Create a simple multi input pane, that returns what the use inserts.
@param parentComponent
@param title
the dialog title.
@param labels
the labels to set.
@param defaultValues
a set of default values.
@param fields2ValuesMap a map that allows to set combos for the various options.
@return the result inserted by the user. | [
"Create",
"a",
"simple",
"multi",
"input",
"pane",
"that",
"returns",
"what",
"the",
"use",
"inserts",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gui/src/main/java/org/hortonmachine/gui/utils/GuiUtilities.java#L315-L365 |
137,991 | TheHortonMachine/hortonmachine | gui/src/main/java/org/hortonmachine/gui/utils/GuiUtilities.java | GuiUtilities.colorButton | public static void colorButton( JButton button, Color color, Integer size ) {
if (size == null)
size = 15;
BufferedImage bi = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB);
Graphics2D gr = (Graphics2D) bi.getGraphics();
gr.setColor(color);
gr.fillRect(0, 0, size, size);
gr.dispose();
button.setIcon(new ImageIcon(bi));
} | java | public static void colorButton( JButton button, Color color, Integer size ) {
if (size == null)
size = 15;
BufferedImage bi = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB);
Graphics2D gr = (Graphics2D) bi.getGraphics();
gr.setColor(color);
gr.fillRect(0, 0, size, size);
gr.dispose();
button.setIcon(new ImageIcon(bi));
} | [
"public",
"static",
"void",
"colorButton",
"(",
"JButton",
"button",
",",
"Color",
"color",
",",
"Integer",
"size",
")",
"{",
"if",
"(",
"size",
"==",
"null",
")",
"size",
"=",
"15",
";",
"BufferedImage",
"bi",
"=",
"new",
"BufferedImage",
"(",
"size",
",",
"size",
",",
"BufferedImage",
".",
"TYPE_INT_RGB",
")",
";",
"Graphics2D",
"gr",
"=",
"(",
"Graphics2D",
")",
"bi",
".",
"getGraphics",
"(",
")",
";",
"gr",
".",
"setColor",
"(",
"color",
")",
";",
"gr",
".",
"fillRect",
"(",
"0",
",",
"0",
",",
"size",
",",
"size",
")",
";",
"gr",
".",
"dispose",
"(",
")",
";",
"button",
".",
"setIcon",
"(",
"new",
"ImageIcon",
"(",
"bi",
")",
")",
";",
"}"
] | Create an image to make a color picker button.
@param button the button.
@param color the color to set.
@param size the optional size of the image. | [
"Create",
"an",
"image",
"to",
"make",
"a",
"color",
"picker",
"button",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gui/src/main/java/org/hortonmachine/gui/utils/GuiUtilities.java#L484-L494 |
137,992 | TheHortonMachine/hortonmachine | gui/src/main/java/org/hortonmachine/gui/utils/GuiUtilities.java | GuiUtilities.setFileBrowsingOnWidgets | public static void setFileBrowsingOnWidgets( JTextField pathTextField, JButton browseButton, String[] allowedExtensions,
Runnable postRunnable ) {
FileFilter filter = null;
if (allowedExtensions != null) {
filter = new FileFilter(){
@Override
public String getDescription() {
return Arrays.toString(allowedExtensions);
}
@Override
public boolean accept( File f ) {
if (f.isDirectory()) {
return true;
}
String name = f.getName();
for( String ext : allowedExtensions ) {
if (name.toLowerCase().endsWith(ext.toLowerCase())) {
return true;
}
}
return false;
}
};
}
FileFilter _filter = filter;
browseButton.addActionListener(e -> {
File lastFile = GuiUtilities.getLastFile();
File[] res = showOpenFilesDialog(browseButton, "Select file", false, lastFile, _filter);
if (res != null && res.length == 1) {
String absolutePath = res[0].getAbsolutePath();
pathTextField.setText(absolutePath);
setLastPath(absolutePath);
if (postRunnable != null) {
postRunnable.run();
}
}
});
} | java | public static void setFileBrowsingOnWidgets( JTextField pathTextField, JButton browseButton, String[] allowedExtensions,
Runnable postRunnable ) {
FileFilter filter = null;
if (allowedExtensions != null) {
filter = new FileFilter(){
@Override
public String getDescription() {
return Arrays.toString(allowedExtensions);
}
@Override
public boolean accept( File f ) {
if (f.isDirectory()) {
return true;
}
String name = f.getName();
for( String ext : allowedExtensions ) {
if (name.toLowerCase().endsWith(ext.toLowerCase())) {
return true;
}
}
return false;
}
};
}
FileFilter _filter = filter;
browseButton.addActionListener(e -> {
File lastFile = GuiUtilities.getLastFile();
File[] res = showOpenFilesDialog(browseButton, "Select file", false, lastFile, _filter);
if (res != null && res.length == 1) {
String absolutePath = res[0].getAbsolutePath();
pathTextField.setText(absolutePath);
setLastPath(absolutePath);
if (postRunnable != null) {
postRunnable.run();
}
}
});
} | [
"public",
"static",
"void",
"setFileBrowsingOnWidgets",
"(",
"JTextField",
"pathTextField",
",",
"JButton",
"browseButton",
",",
"String",
"[",
"]",
"allowedExtensions",
",",
"Runnable",
"postRunnable",
")",
"{",
"FileFilter",
"filter",
"=",
"null",
";",
"if",
"(",
"allowedExtensions",
"!=",
"null",
")",
"{",
"filter",
"=",
"new",
"FileFilter",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"getDescription",
"(",
")",
"{",
"return",
"Arrays",
".",
"toString",
"(",
"allowedExtensions",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"accept",
"(",
"File",
"f",
")",
"{",
"if",
"(",
"f",
".",
"isDirectory",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"String",
"name",
"=",
"f",
".",
"getName",
"(",
")",
";",
"for",
"(",
"String",
"ext",
":",
"allowedExtensions",
")",
"{",
"if",
"(",
"name",
".",
"toLowerCase",
"(",
")",
".",
"endsWith",
"(",
"ext",
".",
"toLowerCase",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"}",
";",
"}",
"FileFilter",
"_filter",
"=",
"filter",
";",
"browseButton",
".",
"addActionListener",
"(",
"e",
"->",
"{",
"File",
"lastFile",
"=",
"GuiUtilities",
".",
"getLastFile",
"(",
")",
";",
"File",
"[",
"]",
"res",
"=",
"showOpenFilesDialog",
"(",
"browseButton",
",",
"\"Select file\"",
",",
"false",
",",
"lastFile",
",",
"_filter",
")",
";",
"if",
"(",
"res",
"!=",
"null",
"&&",
"res",
".",
"length",
"==",
"1",
")",
"{",
"String",
"absolutePath",
"=",
"res",
"[",
"0",
"]",
".",
"getAbsolutePath",
"(",
")",
";",
"pathTextField",
".",
"setText",
"(",
"absolutePath",
")",
";",
"setLastPath",
"(",
"absolutePath",
")",
";",
"if",
"(",
"postRunnable",
"!=",
"null",
")",
"{",
"postRunnable",
".",
"run",
"(",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Adds to a textfield and button the necessary to browse for a file.
@param pathTextField
@param browseButton
@param allowedExtensions | [
"Adds",
"to",
"a",
"textfield",
"and",
"button",
"the",
"necessary",
"to",
"browse",
"for",
"a",
"file",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gui/src/main/java/org/hortonmachine/gui/utils/GuiUtilities.java#L503-L542 |
137,993 | TheHortonMachine/hortonmachine | gui/src/main/java/org/hortonmachine/gui/utils/GuiUtilities.java | GuiUtilities.setFolderBrowsingOnWidgets | public static void setFolderBrowsingOnWidgets( JTextField pathTextField, JButton browseButton ) {
browseButton.addActionListener(e -> {
File lastFile = GuiUtilities.getLastFile();
File[] res = showOpenFolderDialog(browseButton, "Select folder", false, lastFile);
if (res != null && res.length == 1) {
String absolutePath = res[0].getAbsolutePath();
pathTextField.setText(absolutePath);
setLastPath(absolutePath);
}
});
} | java | public static void setFolderBrowsingOnWidgets( JTextField pathTextField, JButton browseButton ) {
browseButton.addActionListener(e -> {
File lastFile = GuiUtilities.getLastFile();
File[] res = showOpenFolderDialog(browseButton, "Select folder", false, lastFile);
if (res != null && res.length == 1) {
String absolutePath = res[0].getAbsolutePath();
pathTextField.setText(absolutePath);
setLastPath(absolutePath);
}
});
} | [
"public",
"static",
"void",
"setFolderBrowsingOnWidgets",
"(",
"JTextField",
"pathTextField",
",",
"JButton",
"browseButton",
")",
"{",
"browseButton",
".",
"addActionListener",
"(",
"e",
"->",
"{",
"File",
"lastFile",
"=",
"GuiUtilities",
".",
"getLastFile",
"(",
")",
";",
"File",
"[",
"]",
"res",
"=",
"showOpenFolderDialog",
"(",
"browseButton",
",",
"\"Select folder\"",
",",
"false",
",",
"lastFile",
")",
";",
"if",
"(",
"res",
"!=",
"null",
"&&",
"res",
".",
"length",
"==",
"1",
")",
"{",
"String",
"absolutePath",
"=",
"res",
"[",
"0",
"]",
".",
"getAbsolutePath",
"(",
")",
";",
"pathTextField",
".",
"setText",
"(",
"absolutePath",
")",
";",
"setLastPath",
"(",
"absolutePath",
")",
";",
"}",
"}",
")",
";",
"}"
] | Adds to a textfield and button the necessary to browse for a folder.
@param pathTextField
@param browseButton | [
"Adds",
"to",
"a",
"textfield",
"and",
"button",
"the",
"necessary",
"to",
"browse",
"for",
"a",
"folder",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gui/src/main/java/org/hortonmachine/gui/utils/GuiUtilities.java#L550-L560 |
137,994 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/geomorphology/curvatures/OmsCurvaturesBivariate.java | OmsCurvaturesBivariate.calculateParameters | private static double[] calculateParameters( final double[][] elevationValues ) {
int rows = elevationValues.length;
int cols = elevationValues[0].length;
int pointsNum = rows * cols;
final double[][] xyMatrix = new double[pointsNum][6];
final double[] valueArray = new double[pointsNum];
// TODO check on resolution
int index = 0;
for( int y = 0; y < rows; y++ ) {
for( int x = 0; x < cols; x++ ) {
xyMatrix[index][0] = x * x; // x^2
xyMatrix[index][1] = y * y; // y^2
xyMatrix[index][2] = x * y; // xy
xyMatrix[index][3] = x; // x
xyMatrix[index][4] = y; // y
xyMatrix[index][5] = 1;
valueArray[index] = elevationValues[y][x];
index++;
}
}
RealMatrix A = MatrixUtils.createRealMatrix(xyMatrix);
RealVector z = MatrixUtils.createRealVector(valueArray);
DecompositionSolver solver = new RRQRDecomposition(A).getSolver();
RealVector solution = solver.solve(z);
// start values for a, b, c, d, e, f, all set to 0.0
final double[] parameters = solution.toArray();
return parameters;
} | java | private static double[] calculateParameters( final double[][] elevationValues ) {
int rows = elevationValues.length;
int cols = elevationValues[0].length;
int pointsNum = rows * cols;
final double[][] xyMatrix = new double[pointsNum][6];
final double[] valueArray = new double[pointsNum];
// TODO check on resolution
int index = 0;
for( int y = 0; y < rows; y++ ) {
for( int x = 0; x < cols; x++ ) {
xyMatrix[index][0] = x * x; // x^2
xyMatrix[index][1] = y * y; // y^2
xyMatrix[index][2] = x * y; // xy
xyMatrix[index][3] = x; // x
xyMatrix[index][4] = y; // y
xyMatrix[index][5] = 1;
valueArray[index] = elevationValues[y][x];
index++;
}
}
RealMatrix A = MatrixUtils.createRealMatrix(xyMatrix);
RealVector z = MatrixUtils.createRealVector(valueArray);
DecompositionSolver solver = new RRQRDecomposition(A).getSolver();
RealVector solution = solver.solve(z);
// start values for a, b, c, d, e, f, all set to 0.0
final double[] parameters = solution.toArray();
return parameters;
} | [
"private",
"static",
"double",
"[",
"]",
"calculateParameters",
"(",
"final",
"double",
"[",
"]",
"[",
"]",
"elevationValues",
")",
"{",
"int",
"rows",
"=",
"elevationValues",
".",
"length",
";",
"int",
"cols",
"=",
"elevationValues",
"[",
"0",
"]",
".",
"length",
";",
"int",
"pointsNum",
"=",
"rows",
"*",
"cols",
";",
"final",
"double",
"[",
"]",
"[",
"]",
"xyMatrix",
"=",
"new",
"double",
"[",
"pointsNum",
"]",
"[",
"6",
"]",
";",
"final",
"double",
"[",
"]",
"valueArray",
"=",
"new",
"double",
"[",
"pointsNum",
"]",
";",
"// TODO check on resolution",
"int",
"index",
"=",
"0",
";",
"for",
"(",
"int",
"y",
"=",
"0",
";",
"y",
"<",
"rows",
";",
"y",
"++",
")",
"{",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"cols",
";",
"x",
"++",
")",
"{",
"xyMatrix",
"[",
"index",
"]",
"[",
"0",
"]",
"=",
"x",
"*",
"x",
";",
"// x^2",
"xyMatrix",
"[",
"index",
"]",
"[",
"1",
"]",
"=",
"y",
"*",
"y",
";",
"// y^2",
"xyMatrix",
"[",
"index",
"]",
"[",
"2",
"]",
"=",
"x",
"*",
"y",
";",
"// xy",
"xyMatrix",
"[",
"index",
"]",
"[",
"3",
"]",
"=",
"x",
";",
"// x",
"xyMatrix",
"[",
"index",
"]",
"[",
"4",
"]",
"=",
"y",
";",
"// y",
"xyMatrix",
"[",
"index",
"]",
"[",
"5",
"]",
"=",
"1",
";",
"valueArray",
"[",
"index",
"]",
"=",
"elevationValues",
"[",
"y",
"]",
"[",
"x",
"]",
";",
"index",
"++",
";",
"}",
"}",
"RealMatrix",
"A",
"=",
"MatrixUtils",
".",
"createRealMatrix",
"(",
"xyMatrix",
")",
";",
"RealVector",
"z",
"=",
"MatrixUtils",
".",
"createRealVector",
"(",
"valueArray",
")",
";",
"DecompositionSolver",
"solver",
"=",
"new",
"RRQRDecomposition",
"(",
"A",
")",
".",
"getSolver",
"(",
")",
";",
"RealVector",
"solution",
"=",
"solver",
".",
"solve",
"(",
"z",
")",
";",
"// start values for a, b, c, d, e, f, all set to 0.0",
"final",
"double",
"[",
"]",
"parameters",
"=",
"solution",
".",
"toArray",
"(",
")",
";",
"return",
"parameters",
";",
"}"
] | Calculates the parameters of a bivariate quadratic equation.
@param elevationValues the window of points to use.
@return the parameters of the bivariate quadratic equation as [a, b, c, d, e, f] | [
"Calculates",
"the",
"parameters",
"of",
"a",
"bivariate",
"quadratic",
"equation",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/geomorphology/curvatures/OmsCurvaturesBivariate.java#L230-L262 |
137,995 | TheHortonMachine/hortonmachine | dbs/src/main/java/jsqlite/Stmt.java | Stmt.column | public Object column(int col) throws jsqlite.Exception {
switch (column_type(col)) {
case Constants.SQLITE_INTEGER:
return new Long(column_long(col));
case Constants.SQLITE_FLOAT:
return new Double(column_double(col));
case Constants.SQLITE_BLOB:
return column_bytes(col);
case Constants.SQLITE3_TEXT:
return column_string(col);
}
return null;
} | java | public Object column(int col) throws jsqlite.Exception {
switch (column_type(col)) {
case Constants.SQLITE_INTEGER:
return new Long(column_long(col));
case Constants.SQLITE_FLOAT:
return new Double(column_double(col));
case Constants.SQLITE_BLOB:
return column_bytes(col);
case Constants.SQLITE3_TEXT:
return column_string(col);
}
return null;
} | [
"public",
"Object",
"column",
"(",
"int",
"col",
")",
"throws",
"jsqlite",
".",
"Exception",
"{",
"switch",
"(",
"column_type",
"(",
"col",
")",
")",
"{",
"case",
"Constants",
".",
"SQLITE_INTEGER",
":",
"return",
"new",
"Long",
"(",
"column_long",
"(",
"col",
")",
")",
";",
"case",
"Constants",
".",
"SQLITE_FLOAT",
":",
"return",
"new",
"Double",
"(",
"column_double",
"(",
"col",
")",
")",
";",
"case",
"Constants",
".",
"SQLITE_BLOB",
":",
"return",
"column_bytes",
"(",
"col",
")",
";",
"case",
"Constants",
".",
"SQLITE3_TEXT",
":",
"return",
"column_string",
"(",
"col",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Retrieve column data as object from exec'ed SQLite3 statement.
@param col column number, 0-based
@return Object or null | [
"Retrieve",
"column",
"data",
"as",
"object",
"from",
"exec",
"ed",
"SQLite3",
"statement",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/jsqlite/Stmt.java#L227-L239 |
137,996 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/libs/modules/multiprocessing/GridMultiProcessing.java | GridMultiProcessing.processGrid | protected void processGrid( int cols, int rows, boolean ignoreBorder, Calculator calculator ) throws Exception {
ExecutionPlanner planner = createDefaultPlanner();
planner.setNumberOfTasks(rows * cols);
int startC = 0;
int startR = 0;
int endC = cols;
int endR = rows;
if (ignoreBorder) {
startC = 1;
startR = 1;
endC = cols - 1;
endR = rows - 1;
}
for( int r = startR; r < endR; r++ ) {
for( int c = startC; c < endC; c++ ) {
int _c = c, _r = r;
planner.submit(() -> {
if (!pm.isCanceled()) {
calculator.calculate(_c, _r);
}
});
}
}
planner.join();
} | java | protected void processGrid( int cols, int rows, boolean ignoreBorder, Calculator calculator ) throws Exception {
ExecutionPlanner planner = createDefaultPlanner();
planner.setNumberOfTasks(rows * cols);
int startC = 0;
int startR = 0;
int endC = cols;
int endR = rows;
if (ignoreBorder) {
startC = 1;
startR = 1;
endC = cols - 1;
endR = rows - 1;
}
for( int r = startR; r < endR; r++ ) {
for( int c = startC; c < endC; c++ ) {
int _c = c, _r = r;
planner.submit(() -> {
if (!pm.isCanceled()) {
calculator.calculate(_c, _r);
}
});
}
}
planner.join();
} | [
"protected",
"void",
"processGrid",
"(",
"int",
"cols",
",",
"int",
"rows",
",",
"boolean",
"ignoreBorder",
",",
"Calculator",
"calculator",
")",
"throws",
"Exception",
"{",
"ExecutionPlanner",
"planner",
"=",
"createDefaultPlanner",
"(",
")",
";",
"planner",
".",
"setNumberOfTasks",
"(",
"rows",
"*",
"cols",
")",
";",
"int",
"startC",
"=",
"0",
";",
"int",
"startR",
"=",
"0",
";",
"int",
"endC",
"=",
"cols",
";",
"int",
"endR",
"=",
"rows",
";",
"if",
"(",
"ignoreBorder",
")",
"{",
"startC",
"=",
"1",
";",
"startR",
"=",
"1",
";",
"endC",
"=",
"cols",
"-",
"1",
";",
"endR",
"=",
"rows",
"-",
"1",
";",
"}",
"for",
"(",
"int",
"r",
"=",
"startR",
";",
"r",
"<",
"endR",
";",
"r",
"++",
")",
"{",
"for",
"(",
"int",
"c",
"=",
"startC",
";",
"c",
"<",
"endC",
";",
"c",
"++",
")",
"{",
"int",
"_c",
"=",
"c",
",",
"_r",
"=",
"r",
";",
"planner",
".",
"submit",
"(",
"(",
")",
"->",
"{",
"if",
"(",
"!",
"pm",
".",
"isCanceled",
"(",
")",
")",
"{",
"calculator",
".",
"calculate",
"(",
"_c",
",",
"_r",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
"planner",
".",
"join",
"(",
")",
";",
"}"
] | Loops through all rows and cols of the given grid. | [
"Loops",
"through",
"all",
"rows",
"and",
"cols",
"of",
"the",
"given",
"grid",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/libs/modules/multiprocessing/GridMultiProcessing.java#L33-L58 |
137,997 | TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/hydrogeomorphology/lwrecruitment/NetIndexComparator.java | NetIndexComparator.compare | @Override
public int compare( SimpleFeature f1, SimpleFeature f2 ) {
int linkid1 = (Integer) f1.getAttribute(LINKID);
int linkid2 = (Integer) f2.getAttribute(LINKID);
if (linkid1 < linkid2) {
return -1;
} else if (linkid1 > linkid2) {
return 1;
} else {
return 0;
}
} | java | @Override
public int compare( SimpleFeature f1, SimpleFeature f2 ) {
int linkid1 = (Integer) f1.getAttribute(LINKID);
int linkid2 = (Integer) f2.getAttribute(LINKID);
if (linkid1 < linkid2) {
return -1;
} else if (linkid1 > linkid2) {
return 1;
} else {
return 0;
}
} | [
"@",
"Override",
"public",
"int",
"compare",
"(",
"SimpleFeature",
"f1",
",",
"SimpleFeature",
"f2",
")",
"{",
"int",
"linkid1",
"=",
"(",
"Integer",
")",
"f1",
".",
"getAttribute",
"(",
"LINKID",
")",
";",
"int",
"linkid2",
"=",
"(",
"Integer",
")",
"f2",
".",
"getAttribute",
"(",
"LINKID",
")",
";",
"if",
"(",
"linkid1",
"<",
"linkid2",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"linkid1",
">",
"linkid2",
")",
"{",
"return",
"1",
";",
"}",
"else",
"{",
"return",
"0",
";",
"}",
"}"
] | establish the position of each net point respect to the others | [
"establish",
"the",
"position",
"of",
"each",
"net",
"point",
"respect",
"to",
"the",
"others"
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/hydrogeomorphology/lwrecruitment/NetIndexComparator.java#L28-L40 |
137,998 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/colors/ColorUtilities.java | ColorUtilities.colorFromRbgString | public static Color colorFromRbgString( String rbgString ) {
String[] split = rbgString.split(",");
if (split.length < 3 || split.length > 4) {
throw new IllegalArgumentException("Color string has to be of type r,g,b.");
}
int r = (int) Double.parseDouble(split[0].trim());
int g = (int) Double.parseDouble(split[1].trim());
int b = (int) Double.parseDouble(split[2].trim());
Color c = null;
if (split.length == 4) {
// alpha
int a = (int) Double.parseDouble(split[3].trim());
c = new Color(r, g, b, a);
} else {
c = new Color(r, g, b);
}
return c;
} | java | public static Color colorFromRbgString( String rbgString ) {
String[] split = rbgString.split(",");
if (split.length < 3 || split.length > 4) {
throw new IllegalArgumentException("Color string has to be of type r,g,b.");
}
int r = (int) Double.parseDouble(split[0].trim());
int g = (int) Double.parseDouble(split[1].trim());
int b = (int) Double.parseDouble(split[2].trim());
Color c = null;
if (split.length == 4) {
// alpha
int a = (int) Double.parseDouble(split[3].trim());
c = new Color(r, g, b, a);
} else {
c = new Color(r, g, b);
}
return c;
} | [
"public",
"static",
"Color",
"colorFromRbgString",
"(",
"String",
"rbgString",
")",
"{",
"String",
"[",
"]",
"split",
"=",
"rbgString",
".",
"split",
"(",
"\",\"",
")",
";",
"if",
"(",
"split",
".",
"length",
"<",
"3",
"||",
"split",
".",
"length",
">",
"4",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Color string has to be of type r,g,b.\"",
")",
";",
"}",
"int",
"r",
"=",
"(",
"int",
")",
"Double",
".",
"parseDouble",
"(",
"split",
"[",
"0",
"]",
".",
"trim",
"(",
")",
")",
";",
"int",
"g",
"=",
"(",
"int",
")",
"Double",
".",
"parseDouble",
"(",
"split",
"[",
"1",
"]",
".",
"trim",
"(",
")",
")",
";",
"int",
"b",
"=",
"(",
"int",
")",
"Double",
".",
"parseDouble",
"(",
"split",
"[",
"2",
"]",
".",
"trim",
"(",
")",
")",
";",
"Color",
"c",
"=",
"null",
";",
"if",
"(",
"split",
".",
"length",
"==",
"4",
")",
"{",
"// alpha",
"int",
"a",
"=",
"(",
"int",
")",
"Double",
".",
"parseDouble",
"(",
"split",
"[",
"3",
"]",
".",
"trim",
"(",
")",
")",
";",
"c",
"=",
"new",
"Color",
"(",
"r",
",",
"g",
",",
"b",
",",
"a",
")",
";",
"}",
"else",
"{",
"c",
"=",
"new",
"Color",
"(",
"r",
",",
"g",
",",
"b",
")",
";",
"}",
"return",
"c",
";",
"}"
] | Converts a color string.
@param rbgString the string in the form "r,g,b,a" as integer values between 0 and 255.
@return the {@link Color}. | [
"Converts",
"a",
"color",
"string",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/colors/ColorUtilities.java#L37-L55 |
137,999 | TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/colors/ColorUtilities.java | ColorUtilities.fromHex | public static Color fromHex( String hex ) {
if (hex.startsWith("#")) {
hex = hex.substring(1);
}
int length = hex.length();
int total = 6;
if (length < total) {
// we have a shortened version
String token = hex;
int tokenLength = token.length();
for( int i = 0; i < total; i = i + tokenLength ) {
hex += token;
}
}
int index = 0;
String r = hex.substring(index, index + 2);
String g = hex.substring(index + 2, index + 4);
String b = hex.substring(index + 4, index + total);
return new Color(Integer.valueOf(r, 16), Integer.valueOf(g, 16), Integer.valueOf(b, 16));
} | java | public static Color fromHex( String hex ) {
if (hex.startsWith("#")) {
hex = hex.substring(1);
}
int length = hex.length();
int total = 6;
if (length < total) {
// we have a shortened version
String token = hex;
int tokenLength = token.length();
for( int i = 0; i < total; i = i + tokenLength ) {
hex += token;
}
}
int index = 0;
String r = hex.substring(index, index + 2);
String g = hex.substring(index + 2, index + 4);
String b = hex.substring(index + 4, index + total);
return new Color(Integer.valueOf(r, 16), Integer.valueOf(g, 16), Integer.valueOf(b, 16));
} | [
"public",
"static",
"Color",
"fromHex",
"(",
"String",
"hex",
")",
"{",
"if",
"(",
"hex",
".",
"startsWith",
"(",
"\"#\"",
")",
")",
"{",
"hex",
"=",
"hex",
".",
"substring",
"(",
"1",
")",
";",
"}",
"int",
"length",
"=",
"hex",
".",
"length",
"(",
")",
";",
"int",
"total",
"=",
"6",
";",
"if",
"(",
"length",
"<",
"total",
")",
"{",
"// we have a shortened version",
"String",
"token",
"=",
"hex",
";",
"int",
"tokenLength",
"=",
"token",
".",
"length",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"total",
";",
"i",
"=",
"i",
"+",
"tokenLength",
")",
"{",
"hex",
"+=",
"token",
";",
"}",
"}",
"int",
"index",
"=",
"0",
";",
"String",
"r",
"=",
"hex",
".",
"substring",
"(",
"index",
",",
"index",
"+",
"2",
")",
";",
"String",
"g",
"=",
"hex",
".",
"substring",
"(",
"index",
"+",
"2",
",",
"index",
"+",
"4",
")",
";",
"String",
"b",
"=",
"hex",
".",
"substring",
"(",
"index",
"+",
"4",
",",
"index",
"+",
"total",
")",
";",
"return",
"new",
"Color",
"(",
"Integer",
".",
"valueOf",
"(",
"r",
",",
"16",
")",
",",
"Integer",
".",
"valueOf",
"(",
"g",
",",
"16",
")",
",",
"Integer",
".",
"valueOf",
"(",
"b",
",",
"16",
")",
")",
";",
"}"
] | Convert hex color to Color.
@return the Color object. | [
"Convert",
"hex",
"color",
"to",
"Color",
"."
] | d2b436bbdf951dc1fda56096a42dbc0eae4d35a5 | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/colors/ColorUtilities.java#L93-L113 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.