use of org.jfree.chart.labels.ItemLabelPosition in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class ChartFactory method createWaterfallChart.
/**
* Creates a waterfall chart. The chart object returned by this method
* uses a {@link CategoryPlot} instance as the plot, with a
* {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
* range axis, and a {@link WaterfallBarRenderer} as the renderer.
*
* @param title the chart title ({@code null} permitted).
* @param categoryAxisLabel the label for the category axis
* ({@code null} permitted).
* @param valueAxisLabel the label for the value axis ({@code null}
* permitted).
* @param dataset the dataset for the chart ({@code null} permitted).
* @param orientation the plot orientation (horizontal or vertical)
* ({@code null} NOT permitted).
* @param legend a flag specifying whether or not a legend is required.
* @param tooltips configure chart to generate tool tips?
* @param urls configure chart to generate URLs?
*
* @return A waterfall chart.
*/
public static JFreeChart createWaterfallChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {
Args.nullNotPermitted(orientation, "orientation");
CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
categoryAxis.setCategoryMargin(0.0);
ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
WaterfallBarRenderer renderer = new WaterfallBarRenderer();
ItemLabelPosition position = setPosition(orientation);
setItemLabelPosition(renderer, position);
if (tooltips) {
StandardCategoryToolTipGenerator generator = new StandardCategoryToolTipGenerator();
renderer.setDefaultToolTipGenerator(generator);
}
if (urls) {
renderer.setDefaultItemURLGenerator(new StandardCategoryURLGenerator());
}
CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
Marker baseline = new ValueMarker(0.0);
baseline.setPaint(Color.BLACK);
plotFacilitator(plot, baseline, orientation);
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
currentTheme.apply(chart);
return chart;
}
use of org.jfree.chart.labels.ItemLabelPosition in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class AbstractRendererTest method testEquals_ObjectList4.
@Test
public void testEquals_ObjectList4() {
BarRenderer r1 = new BarRenderer();
r1.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
BarRenderer r2 = new BarRenderer();
r2.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
assertEquals(r1, r2);
r2.setSeriesNegativeItemLabelPosition(1, new ItemLabelPosition(ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
assertNotEquals(r1, r2);
}
use of org.jfree.chart.labels.ItemLabelPosition in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class AbstractRendererTest method testEventNotification.
/**
* Tests each setter method to ensure that it sends an event notification.
*/
@Test
public void testEventNotification() {
RendererChangeDetector detector = new RendererChangeDetector();
// have to use a subclass of
BarRenderer r1 = new BarRenderer();
// AbstractRenderer
r1.addChangeListener(detector);
// PAINT
detector.setNotified(false);
r1.setSeriesPaint(0, Color.RED);
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultPaint(Color.RED);
assertTrue(detector.getNotified());
// OUTLINE PAINT
detector.setNotified(false);
r1.setSeriesOutlinePaint(0, Color.RED);
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultOutlinePaint(Color.RED);
assertTrue(detector.getNotified());
// STROKE
detector.setNotified(false);
r1.setSeriesStroke(0, new BasicStroke(1.0f));
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultStroke(new BasicStroke(1.0f));
assertTrue(detector.getNotified());
// OUTLINE STROKE
detector.setNotified(false);
r1.setSeriesOutlineStroke(0, new BasicStroke(1.0f));
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultOutlineStroke(new BasicStroke(1.0f));
assertTrue(detector.getNotified());
// SHAPE
detector.setNotified(false);
r1.setSeriesShape(0, new Rectangle2D.Float());
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultShape(new Rectangle2D.Float());
assertTrue(detector.getNotified());
// ITEM_LABELS_VISIBLE
detector.setNotified(false);
r1.setSeriesItemLabelsVisible(0, Boolean.TRUE);
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultItemLabelsVisible(Boolean.TRUE);
assertTrue(detector.getNotified());
// ITEM_LABEL_FONT
detector.setNotified(false);
r1.setSeriesItemLabelFont(0, new Font("Serif", Font.PLAIN, 12));
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultItemLabelFont(new Font("Serif", Font.PLAIN, 12));
assertTrue(detector.getNotified());
// ITEM_LABEL_PAINT
detector.setNotified(false);
r1.setSeriesItemLabelPaint(0, Color.BLUE);
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultItemLabelPaint(Color.BLUE);
assertTrue(detector.getNotified());
// POSITIVE ITEM LABEL POSITION
detector.setNotified(false);
r1.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
assertTrue(detector.getNotified());
// NEGATIVE ITEM LABEL ANCHOR
detector.setNotified(false);
r1.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
assertTrue(detector.getNotified());
}
use of org.jfree.chart.labels.ItemLabelPosition in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class AbstractRendererTest method testEquals_ObjectList3.
@Test
public void testEquals_ObjectList3() {
BarRenderer r1 = new BarRenderer();
r1.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
BarRenderer r2 = new BarRenderer();
r2.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
assertEquals(r1, r2);
r2.setSeriesPositiveItemLabelPosition(1, new ItemLabelPosition(ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
assertNotEquals(r1, r2);
}
use of org.jfree.chart.labels.ItemLabelPosition in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class XYBarRendererTest method testSerialization2.
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization2() {
XYBarRenderer r1 = new XYBarRenderer();
r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition());
XYBarRenderer r2 = TestUtils.serialised(r1);
assertEquals(r1, r2);
}
Aggregations