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

org.epics.graphene.rrdtool.BubbleUtil Maven / Gradle / Ivy

There is a newer version: 0.5
Show newest version
/**
 * Copyright (C) 2012 University of Michigan
 * All rights reserved. Use is subject to license terms.
 */
package org.epics.graphene.rrdtool;

import java.awt.image.BufferedImage;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import javax.imageio.ImageIO;
import org.epics.graphene.BubbleGraph2DRenderer;
import org.epics.graphene.Point3DWithLabelDataset;
import org.epics.util.time.Timestamp;
import org.epics.util.time.TimestampFormat;

/**
 *
 * @author carcassi
 */
public class BubbleUtil {
    
    private static TimestampFormat format = new TimestampFormat("yyyy/MM/dd HH:mm:ss");
    
    public static void createBubblePlot(String filename, final Point3DWithLabelDataset dataset, final String urlPrototype, String path, String signalX, String signalY, String signalZ, Timestamp time) throws IOException {
        if (dataset.getXStatistics() == null) {
            System.out.println("Found no valid data for x");
            return;
        }
        if (dataset.getYStatistics() == null) {
            System.out.println("Found no valid data for y");
            return;
        }
        if (dataset.getZStatistics() == null) {
            System.out.println("Found no valid data for size");
            return;
        }
        BufferedImage image = new BufferedImage(800, 600, BufferedImage.TYPE_3BYTE_BGR);
        final StringBuilder html = new StringBuilder();
        html.append("\n");

        html.append("\n");
        html.append("    \n");
        html.append("        \n");
        html.append("        \n");
        html.append("    \n");
        html.append("    \n");
        html.append("        

AGLT2 node performance details

\n"); html.append("
\n"); html.append("

" + signalY + "\n"); html.append("
" + signalX + "

\n"); html.append("
\n"); html.append(" \n"); BubbleGraph2DRenderer renderer = new BubbleGraph2DRenderer(800, 600) { { this.bottomAreaMargin = 10; this.topAreaMargin = 10; this.leftAreaMargin = 10; this.rightAreaMargin = 10; } protected void newValue(double x, double y, double size, int i) { String url = urlPrototype.replaceAll("DATASETLABEL", dataset.getLabels().get(i)); html.append(" \""\n"); } }; renderer.draw(image.createGraphics(), dataset); html.append(" \n"); html.append("

Size of the bubble represents bytes_in

\n"); html.append("

Data gathered from directory " + path + ". Data timestamp " + format.format(time) + "

\n"); html.append(" \n"); html.append(" \n"); html.append("\n"); BufferedWriter writer = Files.newBufferedWriter( FileSystems.getDefault().getPath(".", filename + ".html"), Charset.forName("US-ASCII")); writer.write(html.toString()); writer.close(); ImageIO.write(image, "png", new File(filename + ".png")); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy