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);
}
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 YIntervalRenderer method drawAdditionalItemLabel.
/**
* Draws an item label.
*
* @param g2 the graphics device.
* @param orientation the orientation.
* @param dataset the dataset.
* @param series the series index (zero-based).
* @param item the item index (zero-based).
* @param x the x coordinate (in Java2D space).
* @param y the y coordinate (in Java2D space).
*/
private void drawAdditionalItemLabel(Graphics2D g2, PlotOrientation orientation, XYDataset dataset, int series, int item, double x, double y) {
if (this.additionalItemLabelGenerator == null) {
return;
}
Font labelFont = getItemLabelFont(series, item);
Paint paint = getItemLabelPaint(series, item);
g2.setFont(labelFont);
g2.setPaint(paint);
String label = this.additionalItemLabelGenerator.generateLabel(dataset, series, item);
ItemLabelPosition position = getNegativeItemLabelPosition(series, item);
Point2D anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), x, y, orientation);
TextUtils.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor());
}
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);
}
Aggregations