本文整理汇总了Java中org.jfree.chart.plot.CategoryPlot.setRenderer方法的典型用法代码示例。如果您正苦于以下问题:Java CategoryPlot.setRenderer方法的具体用法?Java CategoryPlot.setRenderer怎么用?Java CategoryPlot.setRenderer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.plot.CategoryPlot
的用法示例。
在下文中一共展示了CategoryPlot.setRenderer方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test1654215
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
* A test for bug 1654215 (where a renderer is added to the plot without
* a corresponding dataset and it throws an exception at drawing time).
*/
public void test1654215() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y",
dataset, PlotOrientation.VERTICAL, true, false, false);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setRenderer(1, new LineAndShapeRenderer());
boolean success = false;
try {
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
g2.dispose();
success = true;
}
catch (Exception e) {
e.printStackTrace();
success = false;
}
assertTrue(success);
}
示例2: setStackBarRender
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
public static void setStackBarRender(CategoryPlot plot) {
plot.setNoDataMessage(NO_DATA_MSG);
plot.setInsets(new RectangleInsets(10, 10, 5, 10));
StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer();
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
plot.setRenderer(renderer);
setXAixs(plot);
setYAixs(plot);
}
示例3: getChart
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
@Override
public JFreeChart getChart() throws IOException {
final JFreeChart chart = ChartFactory.createLineChart("Time to reach uniform state", "Application State", "Time to reach state (s)", getDataset(), PlotOrientation.VERTICAL, false, false, false);
final CategoryPlot category_plot = chart.getCategoryPlot();
category_plot.setRenderer(new StatisticalBarRenderer());
category_plot.getRangeAxis().setLowerBound(0);
PlainChartTheme.applyTheme(chart);
return chart;
}
示例4: getChart
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
@Override
public JFreeChart getChart() throws IOException {
final DefaultStatisticalCategoryDataset dataset = getDataset();
final JFreeChart chart = ChartFactory.createLineChart(getName(), x_axis_label, "Time to reach " + name + " (s)", dataset, PlotOrientation.VERTICAL, showLegend, false, false);
final StatisticalBarRenderer renderer = new StatisticalBarRenderer();
final CategoryPlot category_plot = chart.getCategoryPlot();
category_plot.setRenderer(renderer);
final ValueAxis range_axis = category_plot.getRangeAxis();
range_axis.setLowerBound(0);
PlainChartTheme.applyTheme(chart);
return chart;
}
示例5: getChart
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
@Override
public JFreeChart getChart() throws IOException {
final DefaultStatisticalCategoryDataset dataset = getDataset();
final JFreeChart chart = ChartFactory.createLineChart(getName(), x_axis_label, y_axis_label, dataset, PlotOrientation.VERTICAL, getDataset().getRowCount() > 1, false, false);
final StatisticalBarRenderer renderer = new StatisticalBarRenderer();
final CategoryPlot category_plot = chart.getCategoryPlot();
category_plot.setRenderer(renderer);
final ValueAxis range_axis = category_plot.getRangeAxis();
range_axis.setLowerBound(0);
PlainChartTheme.applyTheme(chart);
return chart;
}
示例6: createBarChart
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
private static JFreeChart createBarChart(String title,String category,String value, CategoryDataset dataset) {
JFreeChart chart = ChartFactory.createBarChart3D(title, // chart title
category, // domain axis label
value, // range axis label
dataset, // data
PlotOrientation.VERTICAL, // 图标方向
true, // 是否显示legend
true, // 是否显示tooltips
false // 是否显示URLs
);
CategoryPlot plot = chart.getCategoryPlot();//设置图的高级属性
plot.setBackgroundPaint(ChartColor.WHITE);
NumberAxis na= (NumberAxis)plot.getRangeAxis();
// na.setAutoTickUnitSelection(false);//设置小数点位数
na.setNumberFormatOverride(df);
// NumberTickUnit nt=new NumberTickUnit(1.22);
// na.setTickUnit(nt);
// plot.setRangeAxis(na);
BarRenderer3D renderer = new BarRenderer3D();//3D属性修改
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
renderer.setBaseItemLabelsVisible(true);
renderer.setItemLabelAnchorOffset(10);
renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
renderer.setSeriesPaint(0,new Color(34,139,34));
renderer.setSeriesPaint(1,new Color(154,205,50));
renderer.setSeriesPaint(2,new Color(0,255,0));
renderer.setSeriesPaint(3,new Color(127,255,212));
plot.setRenderer(renderer);//将修改后的属性值保存到图中
return chart;
}
示例7: testAxisRange
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
* A test for a bug reported in the forum.
*/
public void testAxisRange() {
DefaultCategoryDataset datasetA = new DefaultCategoryDataset();
DefaultCategoryDataset datasetB = new DefaultCategoryDataset();
datasetB.addValue(50.0, "R1", "C1");
datasetB.addValue(80.0, "R1", "C1");
CategoryPlot plot = new CategoryPlot(
datasetA, new CategoryAxis(null), new NumberAxis(null), new LineAndShapeRenderer()
);
plot.setDataset(1, datasetB);
plot.setRenderer(1, new LineAndShapeRenderer());
Range r = plot.getRangeAxis().getRange();
assertEquals(84.0, r.getUpperBound(), 0.00001);
}
示例8: testAxisRange
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
* A test for a bug reported in the forum.
*/
public void testAxisRange() {
DefaultCategoryDataset datasetA = new DefaultCategoryDataset();
DefaultCategoryDataset datasetB = new DefaultCategoryDataset();
datasetB.addValue(50.0, "R1", "C1");
datasetB.addValue(80.0, "R1", "C1");
CategoryPlot plot = new CategoryPlot(datasetA, new CategoryAxis(null),
new NumberAxis(null), new LineAndShapeRenderer());
plot.setDataset(1, datasetB);
plot.setRenderer(1, new LineAndShapeRenderer());
Range r = plot.getRangeAxis().getRange();
assertEquals(84.0, r.getUpperBound(), 0.00001);
}
示例9: testSetRenderer
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
* A test for a bug where setting the renderer doesn't register the plot
* as a RendererChangeListener.
*/
public void testSetRenderer() {
CategoryPlot plot = new CategoryPlot();
CategoryItemRenderer renderer = new LineAndShapeRenderer();
plot.setRenderer(renderer);
// now make a change to the renderer and see if it triggers a plot
// change event...
MyPlotChangeListener listener = new MyPlotChangeListener();
plot.addChangeListener(listener);
renderer.setSeriesPaint(0, Color.black);
assertTrue(listener.getEvent() != null);
}
示例10: test1169972
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
* A test for bug report 1169972.
*/
public void test1169972() {
CategoryPlot plot = new CategoryPlot(null, null, null, null);
plot.setDomainAxis(new CategoryAxis("C"));
plot.setRangeAxis(new NumberAxis("Y"));
plot.setRenderer(new BarRenderer());
plot.setDataset(new DefaultCategoryDataset());
assertTrue(plot != null);
}
示例11: createNominalChart
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
private JFreeChart createNominalChart() {
JFreeChart chart;
CategoryDataset dataset = createNominalDataSet();
// create the chart...
String domainName = dataTable == null ? MODEL_DOMAIN_AXIS_NAME : dataTable.getColumnName(plotColumn);
chart = ChartFactory.createBarChart(null, // chart title
domainName, // x axis label
RANGE_AXIS_NAME, // y axis label
dataset, // data
PlotOrientation.VERTICAL, true, // include legend
true, // tooltips
false // urls
);
CategoryPlot plot = chart.getCategoryPlot();
BarRenderer renderer = new BarRenderer();
if (dataset.getRowCount() == 1) {
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesFillPaint(0, Color.RED);
} else {
for (int i = 0; i < dataset.getRowCount(); i++) {
Color color = getColorProvider(true).getPointColor((double) i / (double) (dataset.getRowCount() - 1));
renderer.setSeriesPaint(i, color);
renderer.setSeriesFillPaint(i, color);
}
}
renderer.setBarPainter(new RapidBarPainter());
renderer.setDrawBarOutline(true);
plot.setRenderer(renderer);
// rotate labels
if (isLabelRotating()) {
plot.getDomainAxis().setTickLabelsVisible(true);
plot.getDomainAxis().setCategoryLabelPositions(
CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
}
return chart;
}
示例12: createChart
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
private JFreeChart createChart() {
if (data.getItemCount() > 0) {
// get cumulative percentages
KeyedValues cumulative = DataUtilities.getCumulativePercentages(data);
CategoryDataset categoryDataset = DatasetUtilities.createCategoryDataset(
"Count for " + this.dataTable.getColumnName(this.countColumn) + " = " + countValue, data);
// create the chart...
final JFreeChart chart = ChartFactory.createBarChart(null, // chart title
this.dataTable.getColumnName(this.groupByColumn), // domain axis label
"Count", // range axis label
categoryDataset, // data
PlotOrientation.VERTICAL, true, // include legend
true, false);
// set the background color for the chart...
chart.setBackgroundPaint(Color.WHITE);
// get a reference to the plot for further customization...
CategoryPlot plot = chart.getCategoryPlot();
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setLowerMargin(0.02);
domainAxis.setUpperMargin(0.02);
domainAxis.setLabelFont(LABEL_FONT_BOLD);
domainAxis.setTickLabelFont(LABEL_FONT);
// set the range axis to display integers only...
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits(Locale.US));
rangeAxis.setLabelFont(LABEL_FONT_BOLD);
rangeAxis.setTickLabelFont(LABEL_FONT);
// second data set (cumulative percentages)
CategoryDataset dataset2 = DatasetUtilities.createCategoryDataset("Cumulative (Percent)", cumulative);
LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
renderer2.setSeriesPaint(0, SwingTools.VERY_DARK_BLUE.darker());
NumberAxis axis2 = new NumberAxis("Percent of " + countValue);
axis2.setNumberFormatOverride(NumberFormat.getPercentInstance());
axis2.setLabelFont(LABEL_FONT_BOLD);
axis2.setTickLabelFont(LABEL_FONT);
plot.setRangeAxis(1, axis2);
plot.setDataset(1, dataset2);
plot.setRenderer(1, renderer2);
plot.mapDatasetToRangeAxis(1, 1);
axis2.setTickUnit(new NumberTickUnit(0.1));
// show grid lines
plot.setRangeGridlinesVisible(true);
// bring cumulative line to front
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
if (isLabelRotating()) {
domainAxis.setTickLabelsVisible(true);
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
}
return chart;
} else {
return null;
}
}
示例13: init
import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void init() {
CategoryDataset dataset = getDataSet();
JFreeChart chart = ChartFactory.createBarChart3D("Number Ranking", // 图表标题
"Book Types", // 目录轴的显示标签
"The Number of Books", // 数值轴的显示标签
dataset, // 数据集
PlotOrientation.VERTICAL, // 图表方向:水平、垂直
true, false, // 是否生成工具
false // 是否生成URL链接
);
// 从这里开始
CategoryPlot plot = chart.getCategoryPlot();// 获取图表区域对象
BarRenderer3D renderer =new BarRenderer3D();
renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
renderer.setItemLabelFont(new Font("黑体",Font.BOLD,14));//12号黑体加粗
renderer.setItemLabelPaint(Color.black);//字体为黑色
renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.BASELINE_CENTER));
renderer.setItemLabelsVisible(true);
plot.setRenderer(renderer);
CategoryAxis domainAxis = plot.getDomainAxis(); // 水平底部列表
domainAxis.setLabelFont(new Font("黑体", Font.BOLD, 14)); // 水平底部标题
domainAxis.setTickLabelFont(new Font("宋体", Font.BOLD, 12)); // 垂直标题
ValueAxis rangeAxis = plot.getRangeAxis();// 获取柱状
rangeAxis.setUpperMargin(0.1);
rangeAxis.setLabelFont(new Font("黑体", Font.BOLD, 15));
chart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15));
chart.getTitle().setFont(new Font("宋体", Font.BOLD, 20));// 设置标题字体
chartPane = new ChartPanel(chart, true);
// File dir = new File("images\\");
// if (!dir.exists()) {
// dir.mkdir();
// }
// String fName = String.valueOf(System.currentTimeMillis()) + "bar.png";
// File file = new File("images\\", fName);
// try {
// ChartUtilities.saveChartAsPNG(file, chart, 550, 400);
// } catch (IOException e) {
//
// e.printStackTrace();
// }
}