use of de.lmu.ifi.dbs.elki.utilities.xml.XMLNodeIterator in project elki by elki-project.
the class GeneratorXMLDatabaseConnection method processElementUniform.
/**
* Process a 'uniform' Element in the XML stream.
*
* @param cluster
* @param cur Current document nod
*/
private void processElementUniform(GeneratorSingleCluster cluster, Node cur) {
double min = 0.0;
double max = 1.0;
String minstr = ((Element) cur).getAttribute(ATTR_MIN);
if (minstr != null && minstr.length() > 0) {
min = ParseUtil.parseDouble(minstr);
}
String maxstr = ((Element) cur).getAttribute(ATTR_MAX);
if (maxstr != null && maxstr.length() > 0) {
max = ParseUtil.parseDouble(maxstr);
}
// *** new uniform generator
Random random = cluster.getNewRandomGenerator();
Distribution generator = new UniformDistribution(min, max, random);
cluster.addGenerator(generator);
// TODO: check for unknown attributes.
XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild());
while (iter.hasNext()) {
Node child = iter.next();
if (child.getNodeType() == Node.ELEMENT_NODE) {
LOG.warning("Unknown element in XML specification file: " + child.getNodeName());
}
}
}
use of de.lmu.ifi.dbs.elki.utilities.xml.XMLNodeIterator in project elki by elki-project.
the class GeneratorXMLDatabaseConnection method processElementClipping.
/**
* Process a 'clipping' Element in the XML stream.
*
* @param cluster
* @param cur Current document nod
*/
private void processElementClipping(GeneratorSingleCluster cluster, Node cur) {
double[] cmin = null, cmax = null;
String minstr = ((Element) cur).getAttribute(ATTR_MIN);
if (minstr != null && minstr.length() > 0) {
cmin = parseVector(minstr);
}
String maxstr = ((Element) cur).getAttribute(ATTR_MAX);
if (maxstr != null && maxstr.length() > 0) {
cmax = parseVector(maxstr);
}
if (cmin == null || cmax == null) {
throw new AbortException("No or incomplete clipping vectors given.");
}
// *** set clipping
cluster.setClipping(cmin, cmax);
// TODO: check for unknown attributes.
XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild());
while (iter.hasNext()) {
Node child = iter.next();
if (child.getNodeType() == Node.ELEMENT_NODE) {
LOG.warning("Unknown element in XML specification file: " + child.getNodeName());
}
}
}
use of de.lmu.ifi.dbs.elki.utilities.xml.XMLNodeIterator in project elki by elki-project.
the class GeneratorXMLDatabaseConnection method processElementTranslate.
/**
* Process a 'translate' Element in the XML stream.
*
* @param cluster
* @param cur Current document nod
*/
private void processElementTranslate(GeneratorSingleCluster cluster, Node cur) {
double[] offset = null;
String vstr = ((Element) cur).getAttribute(ATTR_VECTOR);
if (vstr != null && vstr.length() > 0) {
offset = parseVector(vstr);
}
if (offset == null) {
throw new AbortException("No translation vector given.");
}
// *** add new translation
cluster.addTranslation(offset);
// TODO: check for unknown attributes.
XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild());
while (iter.hasNext()) {
Node child = iter.next();
if (child.getNodeType() == Node.ELEMENT_NODE) {
LOG.warning("Unknown element in XML specification file: " + child.getNodeName());
}
}
}
use of de.lmu.ifi.dbs.elki.utilities.xml.XMLNodeIterator in project elki by elki-project.
the class GeneratorXMLDatabaseConnection method processElementGamma.
/**
* Process a 'gamma' Element in the XML stream.
*
* @param cluster
* @param cur Current document nod
*/
private void processElementGamma(GeneratorSingleCluster cluster, Node cur) {
double k = 1.0;
double theta = 1.0;
String kstr = ((Element) cur).getAttribute(ATTR_K);
if (kstr != null && kstr.length() > 0) {
k = ParseUtil.parseDouble(kstr);
}
String thetastr = ((Element) cur).getAttribute(ATTR_THETA);
if (thetastr != null && thetastr.length() > 0) {
theta = ParseUtil.parseDouble(thetastr);
}
// *** New normal distribution generator
Random random = cluster.getNewRandomGenerator();
Distribution generator = new GammaDistribution(k, theta, random);
cluster.addGenerator(generator);
// TODO: check for unknown attributes.
XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild());
while (iter.hasNext()) {
Node child = iter.next();
if (child.getNodeType() == Node.ELEMENT_NODE) {
LOG.warning("Unknown element in XML specification file: " + child.getNodeName());
}
}
}
use of de.lmu.ifi.dbs.elki.utilities.xml.XMLNodeIterator in project elki by elki-project.
the class GeneratorXMLDatabaseConnection method processElementHalton.
/**
* Process a 'halton' Element in the XML stream.
*
* @param cluster
* @param cur Current document nod
*/
private void processElementHalton(GeneratorSingleCluster cluster, Node cur) {
double min = 0.0;
double max = 1.0;
String minstr = ((Element) cur).getAttribute(ATTR_MIN);
if (minstr != null && minstr.length() > 0) {
min = ParseUtil.parseDouble(minstr);
}
String maxstr = ((Element) cur).getAttribute(ATTR_MAX);
if (maxstr != null && maxstr.length() > 0) {
max = ParseUtil.parseDouble(maxstr);
}
// *** new uniform generator
Random random = cluster.getNewRandomGenerator();
Distribution generator = new HaltonUniformDistribution(min, max, random);
cluster.addGenerator(generator);
// TODO: check for unknown attributes.
XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild());
while (iter.hasNext()) {
Node child = iter.next();
if (child.getNodeType() == Node.ELEMENT_NODE) {
LOG.warning("Unknown element in XML specification file: " + child.getNodeName());
}
}
}
Aggregations