本文整理匯總了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();
// }
}