use of org.jfree.chart.plot.CategoryPlot in project SIMVA-SoS by SESoS.
the class GroupedStackedBarRendererTest method testDrawWithNullInfo.
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
@Test
public void testDrawWithNullInfo() {
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);
} catch (NullPointerException e) {
fail("No exception should be thrown.");
}
}
use of org.jfree.chart.plot.CategoryPlot in project SIMVA-SoS by SESoS.
the class LayeredBarRendererTest method testDrawWithNullInfo.
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
@Test
public void testDrawWithNullInfo() {
try {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(1.0, "S1", "C1");
CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new LayeredBarRenderer());
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */
chart.createBufferedImage(300, 200, null);
} catch (NullPointerException e) {
fail("No exception should be thrown.");
}
}
use of org.jfree.chart.plot.CategoryPlot in project SIMVA-SoS by SESoS.
the class CategoryAxis3D method getCategoryJava2DCoordinate.
/**
* Returns the Java 2D coordinate for a category.
*
* @param anchor the anchor point.
* @param category the category index.
* @param categoryCount the category count.
* @param area the data area.
* @param edge the location of the axis.
*
* @return The coordinate.
*/
@Override
public double getCategoryJava2DCoordinate(CategoryAnchor anchor, int category, int categoryCount, Rectangle2D area, RectangleEdge edge) {
double result = 0.0;
Rectangle2D adjustedArea = area;
CategoryPlot plot = (CategoryPlot) getPlot();
CategoryItemRenderer renderer = plot.getRenderer();
if (renderer instanceof Effect3D) {
Effect3D e3D = (Effect3D) renderer;
double adjustedX = area.getMinX();
double adjustedY = area.getMinY();
double adjustedW = area.getWidth() - e3D.getXOffset();
double adjustedH = area.getHeight() - e3D.getYOffset();
if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) {
adjustedY += e3D.getYOffset();
} else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) {
adjustedX += e3D.getXOffset();
}
adjustedArea = new Rectangle2D.Double(adjustedX, adjustedY, adjustedW, adjustedH);
}
if (anchor == CategoryAnchor.START) {
result = getCategoryStart(category, categoryCount, adjustedArea, edge);
} else if (anchor == CategoryAnchor.MIDDLE) {
result = getCategoryMiddle(category, categoryCount, adjustedArea, edge);
} else if (anchor == CategoryAnchor.END) {
result = getCategoryEnd(category, categoryCount, adjustedArea, edge);
}
return result;
}
use of org.jfree.chart.plot.CategoryPlot in project SIMVA-SoS by SESoS.
the class GanttChartTest method testDrawWithNullInfo2.
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (a problem that was occurring at one point).
*/
@Test
public void testDrawWithNullInfo2() {
JFreeChart chart = createGanttChart();
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setDataset(createDataset());
/* BufferedImage img =*/
chart.createBufferedImage(300, 200, null);
// FIXME we should really assert a value
}
use of org.jfree.chart.plot.CategoryPlot in project SIMVA-SoS by SESoS.
the class GanttChartTest method testReplaceDataset.
/**
* Replaces the chart's dataset and then checks that the new dataset is OK.
*/
@Test
public void testReplaceDataset() {
LocalListener l = new LocalListener();
this.chart.addChangeListener(l);
CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
plot.setDataset(null);
assertEquals(true, l.flag);
}
Aggregations