private void doGraph(GraphNode gn, Renderer r, ParamsBean params, JrdsJSONWriter w) throws IOException { jrds.Graph graph = gn.getGraph(); if (graph == null) { return; } params.configureGraph(graph); Map<String, Object> imgProps = new HashMap<String, Object>(); r.render(graph); Probe<?, ?> p = gn.getProbe(); imgProps.put("probename", p.getName()); imgProps.put("qualifiedname", graph.getQualifiedName()); Dimension d = graph.getDimension(); if(d != null) { imgProps.put("height", d.height); imgProps.put("width", d.width); } imgProps.put("graph", params.doArgsMap(graph, true)); imgProps.put("history", params.doArgsMap(graph, false)); imgProps.put("probe", params.doArgsMap(p, true)); imgProps.put("graphnode", params.doArgsMap(gn, true)); doTree(w, graph.getQualifiedName(), gn.hashCode(), "graph", null, imgProps); }
int wh = graph.getDimension().height; int rh = graph.getRrdGraph().getRrdGraphInfo().getHeight(); logger.trace("Delta height:" + (rh - wh) + " for " + node.getGraphDesc());
@Test public void create() throws Exception { @SuppressWarnings("unchecked") Probe<String, Number> p = GenerateProbe.quickProbe(testFolder); p.setPd(Full.getPd()); File rrdFile = new File(p.getMainStore().getPath()); Assert.assertTrue("Failed to create probe " + rrdFile.getAbsolutePath(), p.checkStore()); logger.debug("Created " + p + " stored in " + p.getMainStore().getStoreObject()); long endSec = Full.fill(p); logger.debug("fill time: " + endSec); logger.debug(p.getLastUpdate()); Period pr = Full.getPeriod(p, endSec); Graphics2D g2d = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB).createGraphics(); GraphDesc gd = Full.getGd(); gd.initializeLimits(g2d); GraphNode gn = new GraphNode(p, gd); Graph g = new Graph(gn); g.setPeriod(pr); int h = g.getDimension().height; int w = g.getDimension().width; File outputFile = testFolder.newFile(); OutputStream out = new FileOutputStream(outputFile); g.writePng(out); BufferedImage img = ImageIO.read(outputFile); Assert.assertEquals(h, img.getHeight()); Assert.assertEquals(w, img.getWidth()); Assert.assertTrue(rrdFile.exists()); Assert.assertTrue(rrdFile.length() > 0); }