本文整理汇总了Java中org.jfree.chart.renderer.category.GroupedStackedBarRenderer类的典型用法代码示例。如果您正苦于以下问题:Java GroupedStackedBarRenderer类的具体用法?Java GroupedStackedBarRenderer怎么用?Java GroupedStackedBarRenderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GroupedStackedBarRenderer类属于org.jfree.chart.renderer.category包,在下文中一共展示了GroupedStackedBarRenderer类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEquals
import org.jfree.chart.renderer.category.GroupedStackedBarRenderer; //导入依赖的package包/类
/**
* Test that the equals() method distinguishes all fields.
*/
public void testEquals() {
GroupedStackedBarRenderer r1 = new GroupedStackedBarRenderer();
GroupedStackedBarRenderer r2 = new GroupedStackedBarRenderer();
assertTrue(r1.equals(r2));
assertTrue(r2.equals(r1));
// map
KeyToGroupMap m1 = new KeyToGroupMap("G1");
m1.mapKeyToGroup("S1", "G2");
r1.setSeriesToGroupMap(m1);
assertFalse(r1.equals(r2));
KeyToGroupMap m2 = new KeyToGroupMap("G1");
m2.mapKeyToGroup("S1", "G2");
r2.setSeriesToGroupMap(m2);
assertTrue(r1.equals(r2));
}
示例2: testDrawWithNullInfo
import org.jfree.chart.renderer.category.GroupedStackedBarRenderer; //导入依赖的package包/类
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
public void testDrawWithNullInfo() {
boolean success = false;
try {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(1.0, "S1", "C1");
dataset.addValue(2.0, "S1", "C2");
dataset.addValue(3.0, "S2", "C1");
dataset.addValue(4.0, "S2", "C2");
GroupedStackedBarRenderer renderer
= new GroupedStackedBarRenderer();
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
renderer);
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
success = true;
}
catch (NullPointerException e) {
e.printStackTrace();
success = false;
}
assertTrue(success);
}
示例3: testEquals
import org.jfree.chart.renderer.category.GroupedStackedBarRenderer; //导入依赖的package包/类
/**
* Test that the equals() method distinguishes all fields.
*/
public void testEquals() {
GroupedStackedBarRenderer r1 = new GroupedStackedBarRenderer();
GroupedStackedBarRenderer r2 = new GroupedStackedBarRenderer();
assertTrue(r1.equals(r2));
assertTrue(r2.equals(r1));
// map
KeyToGroupMap m1 = new KeyToGroupMap("G1");
m1.mapKeyToGroup("S1", "G2");
r1.setSeriesToGroupMap(m1);
assertFalse(r1.equals(r2));
KeyToGroupMap m2 = new KeyToGroupMap("G1");
m2.mapKeyToGroup("S1", "G2");
r2.setSeriesToGroupMap(m2);
assertTrue(r1.equals(r2));
}
示例4: testDrawWithNullInfo
import org.jfree.chart.renderer.category.GroupedStackedBarRenderer; //导入依赖的package包/类
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
public void testDrawWithNullInfo() {
boolean success = false;
try {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(1.0, "S1", "C1");
dataset.addValue(2.0, "S1", "C2");
dataset.addValue(3.0, "S2", "C1");
dataset.addValue(4.0, "S2", "C2");
GroupedStackedBarRenderer renderer
= new GroupedStackedBarRenderer();
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
renderer);
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
success = true;
}
catch (NullPointerException e) {
e.printStackTrace();
success = false;
}
assertTrue(success);
}
示例5: customize
import org.jfree.chart.renderer.category.GroupedStackedBarRenderer; //导入依赖的package包/类
@Override
public void customize(JFreeChart chart, ReportParameters reportParameters) {
if (chart.getPlot() instanceof CategoryPlot) {
if (chart.getCategoryPlot().getDataset() != null) {
CategoryDataset dataset;
if (!(chart.getCategoryPlot().getRenderer() instanceof GroupedStackedBarRenderer)) {
dataset = new PercentageCategoryDataset(chart.getCategoryPlot().getDataset());
}
else {
dataset = new PercentageGroupedCategoryDataset(chart.getCategoryPlot().getDataset());
}
chart.getCategoryPlot().setDataset(dataset);
}
if (StringUtils.isBlank(chart.getCategoryPlot().getRangeAxis().getLabel())) {
chart.getCategoryPlot().getRangeAxis().setLabel("%");
}
}
}
示例6: testMap
import org.jfree.chart.renderer.category.GroupedStackedBarRenderer; //导入依赖的package包/类
private void testMap(JFreeChart chart, String ...groups) {
GroupedStackedBarRenderer renderer = (GroupedStackedBarRenderer) chart.getCategoryPlot().getRenderer();
try {
Field field = renderer.getClass().getDeclaredField("seriesToGroupMap");
field.setAccessible(true);
KeyToGroupMap map = (KeyToGroupMap) field.get(renderer);
Assert.assertEquals("map", groups.length, map.getGroupCount());
List<?> groups2 = map.getGroups();
for (int i = 0; i < groups2.size(); i++) {
Assert.assertEquals("map", groups[i], groups2.get(i));
}
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
示例7: testFindRangeBounds
import org.jfree.chart.renderer.category.GroupedStackedBarRenderer; //导入依赖的package包/类
/**
* Some checks for the findRangeBounds() method.
*/
public void testFindRangeBounds() {
GroupedStackedBarRenderer r = new GroupedStackedBarRenderer();
assertNull(r.findRangeBounds(null));
// an empty dataset should return a null range
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
assertNull(r.findRangeBounds(dataset));
dataset.addValue(1.0, "R1", "C1");
assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(-2.0, "R1", "C2");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(null, "R1", "C3");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
KeyToGroupMap m = new KeyToGroupMap("G1");
m.mapKeyToGroup("R1", "G1");
m.mapKeyToGroup("R2", "G1");
m.mapKeyToGroup("R3", "G2");
r.setSeriesToGroupMap(m);
dataset.addValue(0.5, "R3", "C1");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(5.0, "R3", "C2");
assertEquals(new Range(-2.0, 5.0), r.findRangeBounds(dataset));
}
示例8: createChart
import org.jfree.chart.renderer.category.GroupedStackedBarRenderer; //导入依赖的package包/类
public static Drawable createChart(ADCDataset dataset, Dimension dimension) {
final JFreeChart chart = ChartFactory.createBarChart(
dataset.get(Attribute.TITLE), // chart title
dataset.get(Attribute.X_AXIS_LABEL),// domain axis label
dataset.get(Attribute.Y_AXIS_LABEL),// range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
false, // tooltips?
false // URLs?
);
chart.setBackgroundPaint(Color.white);
final CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.white);
plot.setDomainGridlinePaint(Color.lightGray);
plot.setRangeGridlinePaint(Color.lightGray);
GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer();
KeyToGroupMap map = new KeyToGroupMap();
map.mapKeyToGroup(dataset.getRowKey(0), "Y1");
map.mapKeyToGroup(dataset.getRowKey(1), "Y1");
map.mapKeyToGroup(dataset.getRowKey(2), "Y2");
map.mapKeyToGroup(dataset.getRowKey(3), "Y2");
renderer.setSeriesToGroupMap(map);
Colors.setSeriesPaint(renderer, dataset.get(Attribute.SERIES_COLORS));
renderer.setItemMargin(0);
renderer.setBarPainter(new StandardBarPainter());
plot.setRenderer(renderer);
final CategoryAxis cAxis = plot.getDomainAxis();
cAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
chart.getTitle().setFont(cAxis.getLabelFont());
chart.getLegend().setMargin(2, 60, 2, 20);
return new JFreeChartDrawable(chart, dimension);
}
示例9: test
import org.jfree.chart.renderer.category.GroupedStackedBarRenderer; //导入依赖的package包/类
@Override
public void test() {
super.test();
numberOfPagesTest(1);
JFreeChart chart = getChart("summary.chart1", 0);
CategoryPlot categoryPlot = chart.getCategoryPlot();
Assert.assertEquals("renderer", GroupedStackedBarRenderer.class, categoryPlot.getRenderer().getClass());
Assert.assertTrue("show labels", categoryPlot.getRenderer().getBaseItemLabelsVisible());
Assert.assertFalse("show tick labels", categoryPlot.getDomainAxis().isTickLabelsVisible());
Assert.assertFalse("show tick marks", categoryPlot.getDomainAxis().isTickMarksVisible());
chart = getChart("summary.chart2", 0);
Axis axis = chart.getCategoryPlot().getDomainAxis();
Assert.assertEquals("category label", "category", axis.getLabel());
Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.LEFT);
Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle());
Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
chart = getChart("summary.chart3", 0);
axis = chart.getCategoryPlot().getRangeAxis();
Assert.assertEquals("value label", "value", axis.getLabel());
Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}
示例10: createLegend
import org.jfree.chart.renderer.category.GroupedStackedBarRenderer; //导入依赖的package包/类
protected JFreeChart createLegend(CategoryDataset dataset) {
// JFreeChart chart = ChartFactory.createAreaChart(
JFreeChart chart = ChartFactory.createStackedBarChart(
chartTitle, // chart title
domainLabel, // domain axis label
rangeLabel, // range axis label
dataset, // data
PlotOrientation.VERTICAL, // the plot orientation
true, // legend
true, // tooltips
false // urls
);
// NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer();
KeyToGroupMap map = new KeyToGroupMap("G1");
map.mapKeyToGroup("Product 1 (US)", "G1");
map.mapKeyToGroup("Product 1 (Europe)", "G1");
map.mapKeyToGroup("Product 1 (Asia)", "G1");
map.mapKeyToGroup("Product 1 (Middle East)", "G1");
map.mapKeyToGroup("Product 2 (US)", "G2");
map.mapKeyToGroup("Product 2 (Europe)", "G2");
map.mapKeyToGroup("Product 2 (Asia)", "G2");
map.mapKeyToGroup("Product 2 (Middle East)", "G2");
map.mapKeyToGroup("Product 3 (US)", "G3");
map.mapKeyToGroup("Product 3 (Europe)", "G3");
map.mapKeyToGroup("Product 3 (Asia)", "G3");
map.mapKeyToGroup("Product 3 (Middle East)", "G3");
renderer.setSeriesToGroupMap(map);
renderer.setItemMargin(0.10);
renderer.setDrawBarOutline(false);
Paint p1 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF),
0.0f, 0.0f, new Color(0x88, 0x88, 0xFF));
renderer.setSeriesPaint(0, p1);
renderer.setSeriesPaint(4, p1);
renderer.setSeriesPaint(8, p1);
Paint p2 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22),
0.0f, 0.0f, new Color(0x88, 0xFF, 0x88));
renderer.setSeriesPaint(1, p2);
renderer.setSeriesPaint(5, p2);
renderer.setSeriesPaint(9, p2);
Paint p3 = new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22),
0.0f, 0.0f, new Color(0xFF, 0x88, 0x88));
renderer.setSeriesPaint(2, p3);
renderer.setSeriesPaint(6, p3);
renderer.setSeriesPaint(10, p3);
Paint p4 = new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0xFF, 0x22),
0.0f, 0.0f, new Color(0xFF, 0xFF, 0x88));
renderer.setSeriesPaint(3, p4);
renderer.setSeriesPaint(7, p4);
renderer.setSeriesPaint(11, p4);
renderer.setGradientPaintTransformer(
new StandardGradientPaintTransformer(
GradientPaintTransformType.HORIZONTAL));
renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
SubCategoryAxis domainAxis = new SubCategoryAxis("Product / Month");
domainAxis.setCategoryMargin(0.05);
domainAxis.addSubCategory("Product 1");
domainAxis.addSubCategory("Product 2");
domainAxis.addSubCategory("Product 3");
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setDomainAxis(domainAxis);
//plot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
plot.setRenderer(renderer);
return chart;
}
示例11: testPublicCloneable
import org.jfree.chart.renderer.category.GroupedStackedBarRenderer; //导入依赖的package包/类
/**
* Check that this class implements PublicCloneable.
*/
public void testPublicCloneable() {
GroupedStackedBarRenderer r1 = new GroupedStackedBarRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
示例12: createChart
import org.jfree.chart.renderer.category.GroupedStackedBarRenderer; //导入依赖的package包/类
@Override
public Drawable createChart(ADCDataset dataset, Dimension dimension) {
JFreeChart chart = ChartFactory.createStackedBarChart(
dataset.get(Attribute.TITLE), // chart title
"", // domain axis label
"", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // the plot orientation
false, // legend
false, // tooltips
false // urls
);
chart.addLegend(createLegend());
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setBackgroundPaint(Color.white);
plot.setOutlineVisible(false);
plot.setAxisOffset(new RectangleInsets(0,0,0,0));
plot.setDomainGridlinesVisible(false);
plot.setRangeGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.gray);
plot.setRangeGridlineStroke(new BasicStroke(2));
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setAutoTickUnitSelection(true);
rangeAxis.setTickUnit(new NumberTickUnit(0.2, percentFormatter()));
rangeAxis.setAxisLineVisible(true);
rangeAxis.setLabel(dataset.get(Attribute.Y_AXIS_LABEL));
rangeAxis.setAxisLineStroke(new BasicStroke(2));
rangeAxis.setAxisLinePaint(Color.black);
rangeAxis.setTickMarksVisible(false);
rangeAxis.setLabelPaint(AXIS_LABEL_COLOR);
rangeAxis.setLabelFont(AXIS_LABEL_FONT);
rangeAxis.setLabelInsets(new RectangleInsets(0,0,0,0));
rangeAxis.setUpperMargin(0);
rangeAxis.setRange(0, 1);
CategoryAxis cAxis = plot.getDomainAxis();
cAxis.setTickMarksVisible(false);
cAxis.setAxisLinePaint(Color.black);
cAxis.setAxisLineStroke(new BasicStroke(2));
cAxis.setLabel(dataset.get(Attribute.X_AXIS_LABEL));
cAxis.setTickLabelsVisible(false);
cAxis.setCategoryMargin(0.05);
cAxis.setUpperMargin(0.1);
cAxis.setLowerMargin(0);
GroupedStackedBarRenderer renderer = new BarLabelRenderer();
plot.setRenderer(renderer);
for(int i=0;i<seriesPaint.length;i++) {
renderer.setSeriesPaint(i, seriesPaint[i]);
}
renderer.setRenderAsPercentages(true);
renderer.setDrawBarOutline(false);
renderer.setBaseItemLabelsVisible(false);
renderer.setShadowVisible(false);
renderer.setBarPainter(new StandardBarPainter());
renderer.setItemMargin(0.10);
renderer.setSeriesToGroupMap(createKeyToGroupMap(dataset));
return new JFreeChartDrawable(chart, dimension);
}