All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.intelie.pipes.util.SpanReprHelper Maven / Gradle / Ivy

There is a newer version: 0.25.5
Show newest version
package net.intelie.pipes.util;

import net.intelie.pipes.time.TimeSpan;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public abstract class SpanReprHelper {
    public static AutomatonRepr repr(TimeSpan span, long timestamp, String zone, String label, TimeSpan... children) {
        AutomatonRepr auto = new AutomatonRepr("start");

        long start = span.start(timestamp);
        long end = span.end(timestamp);
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.ROOT);
        formatter.setTimeZone(TimeZone.getTimeZone(zone));

        AutomatonRepr.LabelLines lines = new AutomatonRepr.LabelLines();
        lines.addLine(14, label);
        lines.addLine(10, formatter.format(new Date(start)));
        lines.addLine(10, formatter.format(new Date(end)));

        auto.addNode("rectangle", "start", lines);

        for (int i = 0; i < children.length; i++) {
            if (children[i] != null) {
                AutomatonRepr repr = children[i].repr(timestamp, zone);
                if (repr != null)
                    auto.addEdge("start", "s" + (i + 1) + "_", repr, i + 1);
            }
        }
        return auto;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy