代码片断:
- ...
- CategoryPlot categoryplot = (CategoryPlot)jfreechart.getPlot();
- setBackGroudVerticalGradual(categoryplot);
- ...
- /**
- * vertical gradual color background
- * @param plot
- */
- protected void setBackGroudVerticalGradual(Plot plot){
- GradientPaint gradientpaint =
- new GradientPaint(0.0F, 0.0F, new Color(0xCC, 0xCB, 0xCB), 0.0F, 0.0F, new Color(0xF1, 0xF1, 0xF1));
- plot.setBackgroundPaint(gradientpaint);
- }
-
- /**
- * Horizontal gradual color background
- * @param plot
- */
- protected void setBackGroudHorizotalGradual(Plot plot){
- GradientPaint gradientpaint =
- new GradientPaint(0.0F, 0.0F, new Color(0xCC, 0xCB, 0xCB), chartWidth, chartHeight, new Color(0xF1, 0xF1, 0xF1));
-
- plot.setBackgroundPaint(gradientpaint);
- }
主要是setBackGroudVerticalGradual 和 setBackGroudHorizotalGradual这两个函数,GradientPaint是awt下的一个类专门负责颜色渐变,要了解他的含义可以查阅java API Doc |