Search in sources :

Example 1 with GeneratorStatic

use of de.lmu.ifi.dbs.elki.data.synthetic.bymodel.GeneratorStatic in project elki by elki-project.

the class GeneratorXMLDatabaseConnection method processElementStatic.

/**
 * Process a 'static' cluster Element in the XML stream.
 *
 * @param gen Generator
 * @param cur Current document nod
 */
private void processElementStatic(GeneratorMain gen, Node cur) {
    String name = ((Element) cur).getAttribute(ATTR_NAME);
    if (name == null) {
        throw new AbortException("No cluster name given in specification file.");
    }
    ArrayList<double[]> points = new ArrayList<>();
    // TODO: check for unknown attributes.
    XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild());
    while (iter.hasNext()) {
        Node child = iter.next();
        if (TAG_POINT.equals(child.getNodeName())) {
            processElementPoint(points, child);
        } else if (child.getNodeType() == Node.ELEMENT_NODE) {
            LOG.warning("Unknown element in XML specification file: " + child.getNodeName());
        }
    }
    // *** add new cluster object
    GeneratorStatic cluster = new GeneratorStatic(name, points);
    gen.addCluster(cluster);
    if (LOG.isVerbose()) {
        LOG.verbose("Loaded cluster " + cluster.name + " from specification.");
    }
}
Also used : GeneratorStatic(de.lmu.ifi.dbs.elki.data.synthetic.bymodel.GeneratorStatic) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) AbortException(de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException) XMLNodeIterator(de.lmu.ifi.dbs.elki.utilities.xml.XMLNodeIterator)

Aggregations

GeneratorStatic (de.lmu.ifi.dbs.elki.data.synthetic.bymodel.GeneratorStatic)1 AbortException (de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException)1 XMLNodeIterator (de.lmu.ifi.dbs.elki.utilities.xml.XMLNodeIterator)1 ArrayList (java.util.ArrayList)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1