📄 rrdgraphdeftemplate.java
字号:
boolean antiAliasing = getValueAsBoolean(optionNode);
rrdGraphDef.setAntiAliasing(antiAliasing);
}
// ARROW COLOR
else if(option.equals("arrow_color")) {
String colorStr = getValue(optionNode);
rrdGraphDef.setArrowColor(Color.decode(colorStr));
}
// AXIS COLOR
else if(option.equals("axis_color")) {
String colorStr = getValue(optionNode);
rrdGraphDef.setAxisColor(Color.decode(colorStr));
}
// BACK COLOR
else if(option.equals("back_color")) {
String colorStr = getValue(optionNode);
rrdGraphDef.setBackColor(Color.decode(colorStr));
}
// BACKGROUND
else if(option.equals("background")) {
String backgroundFile = getValue(optionNode);
rrdGraphDef.setBackground(backgroundFile);
}
// BASE VALUE
else if(option.equals("base_value")) {
double baseValue = getValueAsDouble(optionNode);
rrdGraphDef.setBaseValue(baseValue);
}
// CANVAS
else if(option.equals("canvas")) {
String colorStr = getValue(optionNode);
rrdGraphDef.setCanvasColor(Color.decode(colorStr));
}
// LEFT PADDING
else if(option.equals("left_padding")) {
int padding = getValueAsInt(optionNode);
rrdGraphDef.setChartLeftPadding(padding);
}
// DEFAULT FONT
else if(option.equals("default_font")) {
Font f = resolveFont(optionNode);
rrdGraphDef.setDefaultFont(f);
}
// DEFAULT FONT COLOR
else if(option.equals("default_font_color")) {
String colorStr = getValue(optionNode);
rrdGraphDef.setDefaultFontColor(Color.decode(colorStr));
}
// FRAME COLOR
else if(option.equals("frame_color")) {
String colorStr = getValue(optionNode);
rrdGraphDef.setFrameColor(Color.decode(colorStr));
}
// FRONT GRID
else if(option.equals("front_grid")) {
boolean frontGrid = getValueAsBoolean(optionNode);
rrdGraphDef.setFrontGrid(frontGrid);
}
// GRID RANGE
else if(option.equals("grid_range")) {
validateTagsOnlyOnce(optionNode, new String[] { "lower", "upper", "rigid" });
double lower = getChildValueAsDouble(optionNode, "lower");
double upper = getChildValueAsDouble(optionNode, "upper");
boolean rigid = getChildValueAsBoolean(optionNode, "rigid");
rrdGraphDef.setGridRange(lower, upper, rigid);
}
// LOWER LIMIT
else if(option.equals("lower_limit")) {
double lower = getValueAsDouble(optionNode);
rrdGraphDef.setLowerLimit( lower );
}
// GRID X?
else if(option.equals("grid_x")) {
boolean gx = getValueAsBoolean(optionNode);
rrdGraphDef.setGridX(gx);
}
// GRID Y?
else if(option.equals("grid_y")) {
boolean gy = getValueAsBoolean(optionNode);
rrdGraphDef.setGridY(gy);
}
// BORDER
else if(option.equals("border")) {
validateTagsOnlyOnce(optionNode, new String[] {"color", "width"});
String colorStr = getChildValue(optionNode, "color");
int width = getChildValueAsInt(optionNode, "width");
rrdGraphDef.setImageBorder(Color.decode(colorStr), width);
}
// MAJOR GRID COLOR
else if(option.equals("major_grid_color")) {
String colorStr = getValue(optionNode);
rrdGraphDef.setMajorGridColor(Color.decode(colorStr));
}
// MAJOR GRID X?
else if(option.equals("major_grid_x")) {
boolean gx = getValueAsBoolean(optionNode);
rrdGraphDef.setMajorGridX(gx);
}
// MAJOR GRID Y?
else if(option.equals("major_grid_y")) {
boolean gy = getValueAsBoolean(optionNode);
rrdGraphDef.setMajorGridY(gy);
}
// MINOR GRID COLOR
else if(option.equals("minor_grid_color")) {
String colorStr = getValue(optionNode);
rrdGraphDef.setMinorGridColor(Color.decode(colorStr));
}
// MINOR GRID X?
else if(option.equals("minor_grid_x")) {
boolean gx = getValueAsBoolean(optionNode);
rrdGraphDef.setMinorGridX(gx);
}
// MINOR GRID Y?
else if(option.equals("minor_grid_y")) {
boolean gy = getValueAsBoolean(optionNode);
rrdGraphDef.setMinorGridY(gy);
}
// OVERLAY
else if(option.equals("overlay")) {
String overlay = getValue(optionNode);
rrdGraphDef.setOverlay(overlay);
}
// SHOW LEGEND?
else if(option.equals("show_legend")) {
boolean show = getValueAsBoolean(optionNode);
rrdGraphDef.setShowLegend(show);
}
// SHOW SIGNATURE?
else if(option.equals("show_signature")) {
boolean show = getValueAsBoolean(optionNode);
rrdGraphDef.setShowSignature(show);
}
// TIME AXIS
else if(option.equals("time_axis")) {
validateTagsOnlyOnce(optionNode, new String[] {
"min_grid_time_unit", "min_grid_unit_steps", "maj_grid_time_unit",
"maj_grid_unit_steps", "date_format", "center_labels", "first_day_of_week"
});
if ( hasChildNode( optionNode, "min_grid_time_unit" ) )
{
int unit1 = resolveUnit(getChildValue(optionNode, "min_grid_time_unit"));
int step1 = getChildValueAsInt(optionNode, "min_grid_unit_steps");
int unit2 = resolveUnit(getChildValue(optionNode, "maj_grid_time_unit"));
int step2 = getChildValueAsInt(optionNode, "maj_grid_unit_steps");
String format = getChildValue(optionNode, "date_format");
boolean center = getChildValueAsBoolean(optionNode, "center_labels");
rrdGraphDef.setTimeAxis(unit1, step1, unit2, step2, format, center);
}
// Determine first day of the week
if ( hasChildNode( optionNode, "first_day_of_week" ) )
{
int dow = resolveDayUnit( getChildValue(optionNode, "first_day_of_week") );
rrdGraphDef.setFirstDayOfWeek( dow );
}
}
// TIME AXIS LABEL
else if(option.equals("time_axis_label")) {
String label = getValue(optionNode);
rrdGraphDef.setTimeAxisLabel(label);
}
// TITLE
else if(option.equals("title")) {
String title = getValue(optionNode);
rrdGraphDef.setTitle(title);
}
// TITLE FONT
else if(option.equals("title_font")) {
Font f = resolveFont(optionNode);
rrdGraphDef.setTitleFont(f);
}
// TITLE FONT COLOR
else if(option.equals("title_font_color")) {
String colorStr = getValue(optionNode);
rrdGraphDef.setTitleFontColor(Color.decode(colorStr));
}
// UNITS EXPONENT
else if(option.equals("units_exponent")) {
int exp = getValueAsInt(optionNode);
rrdGraphDef.setUnitsExponent(exp);
}
// VALUE AXIS
else if(option.equals("value_axis")) {
validateTagsOnlyOnce(optionNode, new String[] {"grid_step", "label_step"});
double gridStep = getChildValueAsDouble(optionNode, "grid_step");
double labelStep = getChildValueAsDouble(optionNode, "label_step");
rrdGraphDef.setValueAxis(gridStep, labelStep);
}
// VERTICAL LABEL
else if(option.equals("vertical_label")) {
String label = getValue(optionNode);
rrdGraphDef.setVerticalLabel(label);
}
// STRICT EXPORT
else if(option.equals("strict_export")) {
rrdGraphDef.setStrictExport( getValueAsBoolean(optionNode) );
}
// RESOLUTION
else if(option.equals("resolution")) {
rrdGraphDef.setResolution( getValueAsInt(optionNode) );
}
}
}
private int resolveUnit(String unit) {
if(unit.equalsIgnoreCase("second")) {
return TimeAxisUnit.SECOND;
}
else if(unit.equalsIgnoreCase("minute")) {
return TimeAxisUnit.MINUTE;
}
else if(unit.equalsIgnoreCase("hour")) {
return TimeAxisUnit.HOUR;
}
else if(unit.equalsIgnoreCase("day")) {
return TimeAxisUnit.DAY;
}
else if(unit.equalsIgnoreCase("week")) {
return TimeAxisUnit.WEEK;
}
else if(unit.equalsIgnoreCase("month")) {
return TimeAxisUnit.MONTH;
}
else if(unit.equalsIgnoreCase("year")) {
return TimeAxisUnit.YEAR;
}
else {
throw new IllegalArgumentException("Invalid unit specified: " + unit);
}
}
private int resolveDayUnit( String unit ) {
if ( unit.equalsIgnoreCase("monday") ) {
return TimeAxisUnit.MONDAY;
}
else if ( unit.equalsIgnoreCase("tuesday") ) {
return TimeAxisUnit.TUESDAY;
}
else if ( unit.equalsIgnoreCase("wednesday") ) {
return TimeAxisUnit.WEDNESDAY;
}
else if ( unit.equalsIgnoreCase("thursday") ) {
return TimeAxisUnit.THURSDAY;
}
else if ( unit.equalsIgnoreCase("friday") ) {
return TimeAxisUnit.FRIDAY;
}
else if ( unit.equalsIgnoreCase("saturday") ) {
return TimeAxisUnit.SATURDAY;
}
else if ( unit.equalsIgnoreCase("sunday") ) {
return TimeAxisUnit.SUNDAY;
}
else {
throw new IllegalArgumentException( "Invalid day unit specified: " + unit );
}
}
private void resolveSpan(Node spanNode) throws RrdException {
validateTagsOnlyOnce(spanNode, new String[] {"start", "end"});
String startStr = getChildValue(spanNode, "start");
String endStr = getChildValue(spanNode, "end");
GregorianCalendar gc1 = Util.getGregorianCalendar(startStr);
GregorianCalendar gc2 = Util.getGregorianCalendar(endStr);
rrdGraphDef.setTimePeriod(gc1, gc2);
}
private Font resolveFont(Node fontNode) throws RrdException {
validateTagsOnlyOnce(fontNode, new String[] {"name", "style", "size"});
String name = getChildValue(fontNode, "name");
String style = getChildValue(fontNode, "style");
int size = getChildValueAsInt(fontNode, "size");
int stl = Font.PLAIN;
if(style.equalsIgnoreCase("BOLD")) {
stl = Font.BOLD;
}
else if(style.equalsIgnoreCase("ITALIC")) {
stl = Font.ITALIC;
}
else if(style.equalsIgnoreCase("BOLDITALIC") ||
style.equalsIgnoreCase("ITALICBOLD") ||
style.equalsIgnoreCase("BOLD ITALIC") ||
style.equalsIgnoreCase("ITALIC BOLD")) {
stl = Font.ITALIC + Font.BOLD;
}
return new Font(name, stl, size);
}
/*
public static void main(String[] args) throws IOException, RrdException {
File fileTemplate = new File("work/test2.xml");
RrdGraphDefTemplate template = new RrdGraphDefTemplate(fileTemplate);
template.setVariable("comment1", "[comment 1]");
template.setVariable("comment2", "[comment 2]");
System.out.println(template.getRrdGraphDef().exportXmlTemplate());
}
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -