Search in sources :

Example 26 with RrdException

use of org.jrobin.core.RrdException in project i2p.i2p by i2p.

the class RrdGraphDefTemplate method resolveLine.

private void resolveLine(Node parentNode) throws RrdException {
    validateTagsOnlyOnce(parentNode, new String[] { "datasource", "color", "legend", "width" });
    String datasource = null, legend = null;
    Paint color = null;
    float width = 1.0F;
    Node[] childNodes = getChildNodes(parentNode);
    for (Node childNode : childNodes) {
        String nodeName = childNode.getNodeName();
        if (nodeName.equals("datasource")) {
            datasource = getValue(childNode);
        } else if (nodeName.equals("color")) {
            color = getValueAsColor(childNode);
        } else if (nodeName.equals("legend")) {
            legend = getValue(childNode);
        } else if (nodeName.equals("width")) {
            width = (float) getValueAsDouble(childNode);
        }
    }
    if (datasource != null) {
        if (color != null) {
            rrdGraphDef.line(datasource, color, legend, width);
        } else {
            rrdGraphDef.line(datasource, BLIND_COLOR, legend, width);
        }
    } else {
        throw new RrdException("Incomplete LINE settings");
    }
}
Also used : Node(org.w3c.dom.Node) RrdException(org.jrobin.core.RrdException)

Example 27 with RrdException

use of org.jrobin.core.RrdException in project i2p.i2p by i2p.

the class RrdGraphDefTemplate method resolvePrint.

private void resolvePrint(Node parentNode, boolean isInGraph) throws RrdException {
    validateTagsOnlyOnce(parentNode, new String[] { "datasource", "cf", "format" });
    String datasource = null, cf = null, format = null;
    Node[] childNodes = getChildNodes(parentNode);
    for (Node childNode : childNodes) {
        String nodeName = childNode.getNodeName();
        if (nodeName.equals("datasource")) {
            datasource = getValue(childNode);
        } else if (nodeName.equals("cf")) {
            cf = getValue(childNode);
        } else if (nodeName.equals("format")) {
            format = getValue(childNode);
        }
    }
    if (datasource != null && cf != null && format != null) {
        if (isInGraph) {
            rrdGraphDef.gprint(datasource, cf, format);
        } else {
            rrdGraphDef.print(datasource, cf, format);
        }
    } else {
        throw new RrdException("Incomplete " + (isInGraph ? "GRPINT" : "PRINT") + " settings");
    }
}
Also used : Node(org.w3c.dom.Node) RrdException(org.jrobin.core.RrdException)

Example 28 with RrdException

use of org.jrobin.core.RrdException in project i2p.i2p by i2p.

the class RrdGraphDefTemplate method resolveSDef.

private void resolveSDef(Node parentNode) throws RrdException {
    validateTagsOnlyOnce(parentNode, new String[] { "name", "source", "cf" });
    String name = null, source = null, cf = null;
    Node[] childNodes = getChildNodes(parentNode);
    for (Node childNode : childNodes) {
        String nodeName = childNode.getNodeName();
        if (nodeName.equals("name")) {
            name = getValue(childNode);
        } else if (nodeName.equals("source")) {
            source = getValue(childNode);
        } else if (nodeName.equals("cf")) {
            cf = getValue(childNode);
        }
    }
    if (name != null && source != null && cf != null) {
        rrdGraphDef.datasource(name, source, cf);
    } else {
        throw new RrdException("Incomplete SDEF settings");
    }
}
Also used : Node(org.w3c.dom.Node) RrdException(org.jrobin.core.RrdException)

Example 29 with RrdException

use of org.jrobin.core.RrdException in project i2p.i2p by i2p.

the class RrdGraphDefTemplate method resolveDef.

private void resolveDef(Node parentNode) throws RrdException {
    validateTagsOnlyOnce(parentNode, new String[] { "name", "rrd", "source", "cf", "backend" });
    String name = null, rrd = null, source = null, cf = null, backend = null;
    Node[] childNodes = getChildNodes(parentNode);
    for (Node childNode : childNodes) {
        String nodeName = childNode.getNodeName();
        if (nodeName.equals("name")) {
            name = getValue(childNode);
        } else if (nodeName.equals("rrd")) {
            rrd = getValue(childNode);
        } else if (nodeName.equals("source")) {
            source = getValue(childNode);
        } else if (nodeName.equals("cf")) {
            cf = getValue(childNode);
        } else if (nodeName.equals("backend")) {
            backend = getValue(childNode);
        }
    }
    if (name != null && rrd != null && source != null && cf != null) {
        rrdGraphDef.datasource(name, rrd, source, cf, backend);
    } else {
        throw new RrdException("Incomplete DEF settings");
    }
}
Also used : Node(org.w3c.dom.Node) RrdException(org.jrobin.core.RrdException)

Example 30 with RrdException

use of org.jrobin.core.RrdException in project i2p.i2p by i2p.

the class RrdGraphDefTemplate method resolveStack.

private void resolveStack(Node parentNode) throws RrdException {
    validateTagsOnlyOnce(parentNode, new String[] { "datasource", "color", "legend" });
    String datasource = null, legend = null;
    Paint color = null;
    Node[] childNodes = getChildNodes(parentNode);
    for (Node childNode : childNodes) {
        String nodeName = childNode.getNodeName();
        if (nodeName.equals("datasource")) {
            datasource = getValue(childNode);
        } else if (nodeName.equals("color")) {
            color = getValueAsColor(childNode);
        } else if (nodeName.equals("legend")) {
            legend = getValue(childNode);
        }
    }
    if (datasource != null) {
        if (color != null) {
            rrdGraphDef.stack(datasource, color, legend);
        } else {
            rrdGraphDef.stack(datasource, BLIND_COLOR, legend);
        }
    } else {
        throw new RrdException("Incomplete STACK settings");
    }
}
Also used : Node(org.w3c.dom.Node) RrdException(org.jrobin.core.RrdException)

Aggregations

RrdException (org.jrobin.core.RrdException)37 Node (org.w3c.dom.Node)13 IOException (java.io.IOException)10 Map (java.util.Map)4 Date (java.util.Date)3 FetchData (org.jrobin.core.FetchData)3 RrdDb (org.jrobin.core.RrdDb)3 FetchResults (org.opennms.netmgt.measurements.api.FetchResults)3 Source (org.opennms.netmgt.measurements.model.Source)3 File (java.io.File)2 Calendar (java.util.Calendar)2 JAXBContext (javax.xml.bind.JAXBContext)2 Unmarshaller (javax.xml.bind.Unmarshaller)2 SAXSource (javax.xml.transform.sax.SAXSource)2 TimeParser (org.jrobin.core.timespec.TimeParser)2 TimeSpec (org.jrobin.core.timespec.TimeSpec)2 Color (java.awt.Color)1 Font (java.awt.Font)1 Graphics (java.awt.Graphics)1 BufferedImage (java.awt.image.BufferedImage)1