Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/exports/DiagramAttributes.java @ 7044:6ab1464021ae generator-refactoring
Add DiagramGenerator which should mainly replace xygenerator
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Wed, 18 Sep 2013 17:13:17 +0200 |
parents | 599d3c48474c |
children | a43137dfdcac |
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.exports; import java.util.ArrayList; import java.util.List; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.dive4elements.river.exports.process.Processor; import org.apache.log4j.Logger; public class DiagramAttributes { private static Logger log = Logger.getLogger(DiagramAttributes.class); public class AxisAttributes { // TODO: More Attributes private String name; public AxisAttributes() { } public AxisAttributes(String name) { this.name = name; } public String getName() { return name; } } // class AxisAttributes public class AxisProcessor { private Processor processor; private String axisName; public AxisProcessor() { } public AxisProcessor(Processor processor, String axisName) { this.processor = processor; this.axisName = axisName; } public Processor getProcessor() { return processor; } public String getAxisName() { return axisName; } } // class AxisProcessor private List<AxisAttributes> axesAttrs; private List<AxisProcessor> axesProcessors; public DiagramAttributes() { axesAttrs = new ArrayList<AxisAttributes>(5); axesProcessors = new ArrayList<AxisProcessor>(5); } public DiagramAttributes(Element config) { this(); parseAxis(config); parseProcessors(config); } private void parseAxis(Element config) { NodeList axisNodes = config.getElementsByTagName("axis"); for (int i = 0, N = axisNodes.getLength(); i < N; ++i) { Element axisElement = (Element)axisNodes.item(i); String name = axisElement.getAttribute("name").trim(); if (!name.isEmpty()) { axesAttrs.add(new AxisAttributes(name)); } } } public List<AxisProcessor> getAxesProcessors() { return axesProcessors; } private void parseProcessors(Element config) { NodeList processorNodes = config.getElementsByTagName("processor"); for (int i = 0, N = processorNodes.getLength(); i < N; ++i) { Element processorElement = (Element)processorNodes.item(i); String className = processorElement.getAttribute("class").trim(); String axisName = processorElement.getAttribute("axis").trim(); if (className.isEmpty() || axisName.isEmpty()) { continue; } try { Processor processor = (Processor)Class.forName(className).newInstance(); axesProcessors.add(new AxisProcessor(processor, axisName)); } catch (ClassNotFoundException cnfe) { log.error(cnfe, cnfe); } catch (InstantiationException ie) { log.error(ie, ie); } catch (IllegalAccessException ia) { log.error(ia, ia); } catch (ClassCastException cce) { log.error(cce, cce); } } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :