private void parseColors(String[] colorOptions) { if (colorOptions == null) { return; } for (String colorOption : colorOptions) { String[] tokens = colorOption.split("#"); if (tokens.length != 2) { throw new IllegalArgumentException("Invalid COLOR specification: " + colorOption); } String colorName = tokens[0]; Paint paint = Util.parseColor(tokens[1]); gdef.setColor(colorName, paint); } }
public RrdGraphDef getGraphDef( long nowInSeconds, SourceIdentifier sourceIdentifier, boolean showMax) { String absoluteRrdPath = getRrdFile(sourceIdentifier).getAbsolutePath(); RrdGraphDef graphDef = new RrdGraphDef(); graphDef.setColor(RrdGraphConstants.COLOR_CANVAS, new Color(0xcc, 0xcc, 0xcc)); graphDef.setNoMinorGrid(true); graphDef.setShowSignature(false); graphDef.setMinValue(0); graphDef.setAltAutoscaleMax(true); graphDef.setAltYGrid(false); graphDef.setTimeAxis( RrdGraphConstants.HOUR, 1, RrdGraphConstants.HOUR, 6, RrdGraphConstants.DAY, 1, 0, "yyyy-MM-dd"); graphDef.setFilename("-"); graphDef.setImageFormat("PNG"); ConsolFun consolFun; String description; if (showMax) { consolFun = ConsolFun.MAX; description = " (max.)"; } else { consolFun = ConsolFun.AVERAGE; description = " (avg.)"; } graphDef.setVerticalLabel("Events/s" + description); graphDef.datasource( RrdLoggingEventHandler.TRACE, absoluteRrdPath, RrdLoggingEventHandler.TRACE_DS_NAME, consolFun); graphDef.datasource( RrdLoggingEventHandler.DEBUG, absoluteRrdPath, RrdLoggingEventHandler.DEBUG_DS_NAME, consolFun); graphDef.datasource( RrdLoggingEventHandler.INFO, absoluteRrdPath, RrdLoggingEventHandler.INFO_DS_NAME, consolFun); graphDef.datasource( RrdLoggingEventHandler.WARN, absoluteRrdPath, RrdLoggingEventHandler.WARN_DS_NAME, consolFun); graphDef.datasource( RrdLoggingEventHandler.ERROR, absoluteRrdPath, RrdLoggingEventHandler.ERROR_DS_NAME, consolFun); graphDef.area( RrdLoggingEventHandler.TRACE, new Color(0x00, 0x00, 0xff), RrdLoggingEventHandler.TRACE); graphDef.stack( RrdLoggingEventHandler.DEBUG, new Color(0x00, 0xff, 0x00), RrdLoggingEventHandler.DEBUG); graphDef.stack( RrdLoggingEventHandler.INFO, new Color(0xff, 0xff, 0xff), RrdLoggingEventHandler.INFO); graphDef.stack( RrdLoggingEventHandler.WARN, new Color(0xff, 0xff, 0x00), RrdLoggingEventHandler.WARN); graphDef.stack( RrdLoggingEventHandler.ERROR, new Color(0xff, 0x00, 0x00), RrdLoggingEventHandler.ERROR); if (showMax) { graphDef.datasource( RrdLoggingEventHandler.TOTAL, absoluteRrdPath, RrdLoggingEventHandler.TOTAL_DS_NAME, consolFun); graphDef.line(RrdLoggingEventHandler.TOTAL, Color.BLACK, RrdLoggingEventHandler.TOTAL); } graphDef.setAntiAliasing(true); graphDef.setLazy(false); String sourceTitle = createGraphTitle(sourceIdentifier); long before = nowInSeconds - 7 * 24 * 60 * 60; graphDef.setTimeSpan(before, nowInSeconds); graphDef.setTitle(sourceTitle); graphDef.setWidth(graphSize.width); graphDef.setHeight(graphSize.height); return graphDef; }