当前位置: 首页>>代码示例>>Java>>正文


Java RrdGraphDef类代码示例

本文整理汇总了Java中org.jrobin.graph.RrdGraphDef的典型用法代码示例。如果您正苦于以下问题:Java RrdGraphDef类的具体用法?Java RrdGraphDef怎么用?Java RrdGraphDef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RrdGraphDef类属于org.jrobin.graph包,在下文中一共展示了RrdGraphDef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initGraphSource

import org.jrobin.graph.RrdGraphDef; //导入依赖的package包/类
private void initGraphSource(RrdGraphDef graphDef, int height, boolean maxHidden) {
	final String dataSourceName = getDataSourceName();
	final String average = "average";
	graphDef.datasource(average, rrdFileName, dataSourceName, ConsolFuns.CF_AVERAGE);
	graphDef.setMinValue(0);
	final String moyenneLabel = I18N.getString("Moyenne");
	graphDef.area(average, getPaint(height), moyenneLabel);
	graphDef.gprint(average, ConsolFuns.CF_AVERAGE, moyenneLabel + ": %9.0f %S\\r");
	//graphDef.gprint(average, ConsolFuns.CF_MIN, "Minimum: %9.0f %S\\r");
	if (!maxHidden) {
		final String max = "max";
		graphDef.datasource(max, rrdFileName, dataSourceName, "MAX");
		final String maximumLabel = I18N.getString("Maximum");
		graphDef.line(max, Color.BLUE, maximumLabel);
		graphDef.gprint(max, ConsolFuns.CF_MAX, maximumLabel + ": %9.0f %S\\r");
	}
	// graphDef.comment("JRobin :: RRDTool Choice for the Java World");
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:19,代码来源:JRobin.java

示例2: setGraphStartEndTime

import org.jrobin.graph.RrdGraphDef; //导入依赖的package包/类
private static void setGraphStartEndTime(RrdGraphDef graphDef, Range range) {
  long endTime; // Current timestamp or custom end-date
  long startTime; // Depending on the range and end-date
  if (range.getPeriod().equals(Period.CUSTOM)) {
    // Custom period:
    endTime = Math.min(range.getEndDate().getTime() / 1000, Util.getTime());
    startTime = range.getStartDate().getTime() / 1000;
  }
  else {
    endTime = Util.getTime();
    startTime = endTime - range.getPeriod().getDurationSeconds();
  }
  graphDef.setStartTime(startTime);
  graphDef.setEndTime(endTime);
  graphDef.setFirstDayOfWeek(Calendar.getInstance().getFirstDayOfWeek());
}
 
开发者ID:purej,项目名称:purej-vminspect,代码行数:17,代码来源:Statistics.java

示例3: cfgBaseGraphDef

import org.jrobin.graph.RrdGraphDef; //导入依赖的package包/类
private static RrdGraphDef cfgBaseGraphDef() {
	RrdGraphDef rgdef = new RrdGraphDef();
	rgdef.setSignature("www.micmiu.com");
	rgdef.setAntiAliasing(false);
	rgdef.setImageFormat("PNG");
	rgdef.setSmallFont(new Font("Monospaced", Font.PLAIN, 11));
	rgdef.setLargeFont(new Font("SansSerif", Font.BOLD, 14));
	// rgdef

	rgdef.setTitle("JRobin Graph Demo for micmiu.com");
	rgdef.setBase(1024);
	rgdef.setWidth(500);
	rgdef.setHeight(200);
	rgdef.setVerticalLabel("transfer speed [bps]");

	return rgdef;
}
 
开发者ID:micmiu,项目名称:snmp-tutorial,代码行数:18,代码来源:GraphDemoHandler.java

示例4: graphByDef

import org.jrobin.graph.RrdGraphDef; //导入依赖的package包/类
public static void graphByDef(RrdGraphDef rgdef) {
	try {

		RrdGraph graph = new RrdGraph(rgdef);
		System.out.println("[rrd graph info:]"
				+ graph.getRrdGraphInfo().dump());

		// 如果filename没有设置,只是在内存中,可以调用下面的方法再次生成图片文件
		if ("-".equals(graph.getRrdGraphInfo().getFilename())) {
			createImgFile(graph, "jrobin-graph.jpg");
		}
		System.out.println("[Jrobin graph by RrdGraphDef success.]");
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:micmiu,项目名称:snmp-tutorial,代码行数:17,代码来源:GraphDemoHandler.java

示例5: createGraphDefByTemplate

import org.jrobin.graph.RrdGraphDef; //导入依赖的package包/类
/**
 * 根据定义的XML文件创建画图模板
 *
 * @param startTime
 * @param endTime
 * @param templateName
 * @param rrdName
 * @param imgFile
 * @return
 */
public static RrdGraphDef createGraphDefByTemplate(long startTime, long endTime, String templateName, String rrdName, String imgFile) {
	try {
		System.out
				.println("[GraphDef create by xml template file start...]");
		RrdGraphDefTemplate defTemplate = new RrdGraphDefTemplate(
				new InputSource(templateName));
		// setVariable 设置XML template的变量
		defTemplate.setVariable("startTime", startTime);
		defTemplate.setVariable("endTime", endTime);
		defTemplate.setVariable("img_file", imgFile);
		defTemplate.setVariable("rrd_file", rrdName);
		return defTemplate.getRrdGraphDef();

	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:micmiu,项目名称:snmp-tutorial,代码行数:29,代码来源:GraphDemoHandler.java

示例6: addVdefDs

import org.jrobin.graph.RrdGraphDef; //导入依赖的package包/类
protected void addVdefDs(RrdGraphDef graphDef, String sourceName, String[] rhs, double start, double end, Map<String,List<String>> defs) throws RrdException {
    if (rhs.length == 2) {
        graphDef.datasource(sourceName, rhs[0], rhs[1]);
    } else if (rhs.length == 3 && "PERCENT".equals(rhs[2])) {
        // Is there a better way to do this than with a separate DataProcessor?
        double pctRank = Double.valueOf(rhs[1]);
        DataProcessor dataProcessor = new DataProcessor((int)start, (int)end);
        for (String dsName : defs.keySet()) {
            List<String> thisDef = defs.get(dsName);
            if (thisDef.size() == 3) {
                dataProcessor.addDatasource(dsName, thisDef.get(0), thisDef.get(1), thisDef.get(2));
            } else if (thisDef.size() == 1) {
                dataProcessor.addDatasource(dsName, thisDef.get(0));
            }
        }
        try {
            dataProcessor.processData();
        } catch (IOException e) {
            throw new RrdException("Caught IOException: " + e.getMessage());
        }
        
        double result = dataProcessor.getPercentile(rhs[0], pctRank);
        ConstantStaticDef csDef = new ConstantStaticDef((long)start, (long)end, result);
        graphDef.datasource(sourceName, csDef);
    } 
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:27,代码来源:JRobinRrdStrategy.java

示例7: testPrint

import org.jrobin.graph.RrdGraphDef; //导入依赖的package包/类
@Test
public void testPrint() throws Exception {
    long end = System.currentTimeMillis();
    long start = end - (24 * 60 * 60 * 1000);
    String[] command = new String[] {
            "--start=" + start,
            "--end=" + end,
            "CDEF:something=1",
            "PRINT:something:AVERAGE:\"%le\""
    };

    RrdGraphDef graphDef = ((JRobinRrdStrategy)m_strategy).createGraphDef(new File(""), command);
    RrdGraph graph = new RrdGraph(graphDef);
    assertNotNull("graph object", graph);
    
    RrdGraphInfo info = graph.getRrdGraphInfo();
    assertNotNull("graph info object", info);
    
    String[] printLines = info.getPrintLines();
    assertNotNull("graph printLines", printLines);
    assertEquals("graph printLines size", 1, printLines.length);
    assertEquals("graph printLines item 0", "1.000000e+00", printLines[0]);
    double d = Double.parseDouble(printLines[0]);
    assertEquals("graph printLines item 0 as a double", 1.0, d, 0.0);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:26,代码来源:JRobinRrdStrategyTest.java

示例8: parseVDef

import org.jrobin.graph.RrdGraphDef; //导入依赖的package包/类
private void parseVDef(RrdGraphDef graphDef, String word) throws RrdException {
	String[] tokens1 = new ColonSplitter(word).split();
	if (tokens1.length != 2) {
		throw new RrdException("Invalid VDEF specification: " + word);
	}
	String[] tokens2 = tokens1[1].split("=");
	if (tokens2.length != 2) {
		throw new RrdException("Invalid DEF specification: " + word);
	}
               String[] tokens3 = tokens2[1].split(",");
               if (tokens3.length == 2)  {
                   graphDef.datasource(tokens2[0], tokens3[0], tokens3[1]);
               } else {
                   graphDef.datasource(tokens2[0], tokens3[0], Double.parseDouble(tokens3[1]), tokens3[2].equals("PERCENT"));
               }
}
 
开发者ID:OpenNMS,项目名称:jrobin,代码行数:17,代码来源:RrdGraphCmd.java

示例9: parseYGrid

import org.jrobin.graph.RrdGraphDef; //导入依赖的package包/类
private void parseYGrid(RrdGraphDef graphDef, String ygrid) throws RrdException {
	if (ygrid == null) {
		return;
	}
	if (ygrid.equalsIgnoreCase("none")) {
		graphDef.setDrawYGrid(false);
		return;
	}
	String[] tokens = new ColonSplitter(ygrid).split();
	if (tokens.length != 2) {
		throw new RrdException("Invalid YGRID settings: " + ygrid);
	}
	double gridStep = parseDouble(tokens[0]);
	int labelFactor = parseInt(tokens[1]);
	graphDef.setValueAxis(gridStep, labelFactor);
}
 
开发者ID:OpenNMS,项目名称:jrobin,代码行数:17,代码来源:RrdGraphCmd.java

示例10: parseXGrid

import org.jrobin.graph.RrdGraphDef; //导入依赖的package包/类
private void parseXGrid(RrdGraphDef graphDef, String xgrid) throws RrdException {
	if (xgrid == null) {
		return;
	}
	if (xgrid.equalsIgnoreCase("none")) {
		graphDef.setDrawXGrid(false);
		return;
	}
	String[] tokens = new ColonSplitter(xgrid).split();
	if (tokens.length != 8) {
		throw new RrdException("Invalid XGRID settings: " + xgrid);
	}
	int minorUnit = resolveUnit(tokens[0]), majorUnit = resolveUnit(tokens[2]),
			labelUnit = resolveUnit(tokens[4]);
	int minorUnitCount = parseInt(tokens[1]), majorUnitCount = parseInt(tokens[3]),
			labelUnitCount = parseInt(tokens[5]);
	int labelSpan = parseInt(tokens[6]);
	String fmt = tokens[7];
	graphDef.setTimeAxis(minorUnit, minorUnitCount, majorUnit, majorUnitCount,
			labelUnit, labelUnitCount, labelSpan, fmt);
}
 
开发者ID:OpenNMS,项目名称:jrobin,代码行数:22,代码来源:RrdGraphCmd.java

示例11: processRrdFontArgument

import org.jrobin.graph.RrdGraphDef; //导入依赖的package包/类
private void processRrdFontArgument(RrdGraphDef graphDef, String argParm) {
	/*
	String[] argValue = tokenize(argParm, ":", true);
	if (argValue[0].equals("DEFAULT")) {
		int newPointSize = Integer.parseInt(argValue[1]);
		graphDef.setSmallFont(graphDef.getSmallFont().deriveFont(newPointSize));
	} else if (argValue[0].equals("TITLE")) {
		int newPointSize = Integer.parseInt(argValue[1]);
		graphDef.setLargeFont(graphDef.getLargeFont().deriveFont(newPointSize));
	} else {
		try {
			Font font = Font.createFont(Font.TRUETYPE_FONT, new File(argValue[0]));
		} catch (Throwable e) {
			// oh well, fall back to existing font stuff
			log().warn("unable to create font from font argument " + argParm, e);
		}
	}
	*/
}
 
开发者ID:vishwaabhinav,项目名称:OpenNMS,代码行数:20,代码来源:JRobinRrdStrategy.java

示例12: graph

import org.jrobin.graph.RrdGraphDef; //导入依赖的package包/类
public byte[] graph(Range range, int width, int height, boolean maxHidden) throws IOException {
	// static init of the AppContext ClassLoader
	AppContextClassLoaderLeakPrevention.dummy();

	try {
		// Rq : il pourrait être envisagé de récupérer les données dans les fichiers rrd ou autre stockage
		// puis de faire des courbes en sparklines html (écrites dans la page html) ou jfreechart

		// create common part of graph definition
		final RrdGraphDef graphDef = new RrdGraphDef();
		if (Locale.CHINESE.getLanguage()
				.equals(I18N.getResourceBundle().getLocale().getLanguage())) {
			graphDef.setSmallFont(new Font(Font.MONOSPACED, Font.PLAIN, 10));
			graphDef.setLargeFont(new Font(Font.MONOSPACED, Font.BOLD, 12));
		}

		initGraphSource(graphDef, height, maxHidden);

		initGraphPeriodAndSize(range, width, height, graphDef);

		graphDef.setImageFormat("png");
		graphDef.setFilename("-");
		// il faut utiliser le pool pour les performances
		// et pour éviter des erreurs d'accès concurrents sur les fichiers
		// entre différentes générations de graphs et aussi avec l'écriture des données
		graphDef.setPoolUsed(true);
		return new RrdGraph(graphDef).getRrdGraphInfo().getBytes();
	} catch (final RrdException e) {
		throw createIOException(e);
	}
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:32,代码来源:JRobin.java

示例13: createGraph

import org.jrobin.graph.RrdGraphDef; //导入依赖的package包/类
/**
 * Creates a graphics binary of this statistics in PNG format.
 *
 * @param range the range to be shown
 * @param width the width of the created PNG
 * @param height the height of the created PNG
 * @return the created binary image data
 * @throws IOException if image creation failed
 */
public byte[] createGraph(Range range, int width, int height) throws IOException {
  try {
    // Create the graph definition:
    RrdGraphDef graphDef = new RrdGraphDef();
    graphDef.setPoolUsed(true);
    graphDef.setFilename("-"); // Important for in-memory generation!

    // Set datasources:
    graphDef.datasource("average", _rrdPath, _name, FUNCTION_AVG, _rrdBackendFactory.getFactoryName());
    graphDef.datasource("max", _rrdPath, _name, FUNCTION_MAX, _rrdBackendFactory.getFactoryName());
    graphDef.setMinValue(0);

    // Set graphics stuff:
    graphDef.setImageFormat("png");
    graphDef.area("average", new GradientPaint(0, 0, Color.RED, 0, height, Color.GREEN, false), "Mean");
    graphDef.line("max", Color.BLUE, "Maximum");
    graphDef.gprint("average", FUNCTION_AVG, "Mean: %9.0f " + _unit + "\\r");
    graphDef.gprint("max", FUNCTION_MAX, "Maximum: %9.0f " + _unit + "\\r");
    graphDef.setWidth(width);
    graphDef.setHeight(height);

    setGraphStartEndTime(graphDef, range);
    setGraphTitle(graphDef, _label, range, width);

    return new RrdGraph(graphDef).getRrdGraphInfo().getBytes();
  }
  catch (final RrdException e) {
    throw new IOException(e);
  }
}
 
开发者ID:purej,项目名称:purej-vminspect,代码行数:40,代码来源:Statistics.java

示例14: setGraphTitle

import org.jrobin.graph.RrdGraphDef; //导入依赖的package包/类
private static void setGraphTitle(RrdGraphDef graphDef, String label, Range range, int width) {
  String titleStart = label + " - " + range.getPeriod().getLabel();
  String titleEnd = "";
  if (width > 400) {
    if (range.getPeriod().equals(Period.CUSTOM)) {
      titleEnd = " - " + Utils.formatDate(range.getStartDate()) + " - " + Utils.formatDate(range.getEndDate());
    }
    else {
      titleEnd = " - " + Utils.formatDate(new Date());
    }
  }
  graphDef.setTitle(titleStart + titleEnd);
}
 
开发者ID:purej,项目名称:purej-vminspect,代码行数:14,代码来源:Statistics.java

示例15: graphDef4Demo

import org.jrobin.graph.RrdGraphDef; //导入依赖的package包/类
/**
 * 自定义画图模板
 *
 * @param startTime
 * @param endTime
 * @param rrdName
 * @param imgFileName
 * @return
 */
public static RrdGraphDef graphDef4Demo(long startTime, long endTime,
										String rrdName, String imgFileName) {
	RrdGraphDef rgdef = null;
	try {
		System.out.println("[rrd graph by RrdGraphDef start...]");
		rgdef = cfgBaseGraphDef();

		rgdef.setFilename(imgFileName);
		rgdef.setStartTime(startTime);
		rgdef.setEndTime(endTime);

		rgdef.datasource("port", rrdName, "flow", "AVERAGE");
		rgdef.datasource("line_data", "port,8,*");
		rgdef.line("line_data", Color.BLUE, "test flow\\l");

		// \\l->左对齐 \\c->中间对齐 \\r->右对齐 \\j->自适应
		// \\s-> \\g->glue \\J->
		rgdef.gprint("line_data", "MAX", "速率最大值=%.2f %sbps");
		rgdef.gprint("line_data", "AVERAGE", "速率平均值=%.2f %sbps\\l");
		rgdef.gprint("line_data", "TOTAL", "总流量=%.2f %sb\\l");
		rgdef.comment("More info see : www.micmiu.com");

		return rgdef;
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:micmiu,项目名称:snmp-tutorial,代码行数:38,代码来源:GraphDemoHandler.java


注:本文中的org.jrobin.graph.RrdGraphDef类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。