use of org.jfree.chart.text.TextLine in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class CategoryTickTest method testHashCode.
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashCode() {
Comparable<String> c1 = "C1";
TextBlock tb1 = new TextBlock();
tb1.addLine(new TextLine("Block 1"));
tb1.addLine(new TextLine("Block 2"));
TextBlockAnchor tba1 = TextBlockAnchor.CENTER;
TextAnchor ta1 = TextAnchor.CENTER;
CategoryTick t1 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f);
CategoryTick t2 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f);
assertEquals(t1, t2);
int h1 = t1.hashCode();
int h2 = t2.hashCode();
assertEquals(h1, h2);
}
use of org.jfree.chart.text.TextLine in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class ExtendedCategoryAxis method createLabel.
/**
* Overrides the default behaviour by adding the sublabel to the text
* block that is used for the category label.
*
* @param category the category.
* @param width the width (not used yet).
* @param edge the location of the axis.
* @param g2 the graphics device.
*
* @return A label.
*/
@Override
protected TextBlock createLabel(Comparable category, float width, RectangleEdge edge, Graphics2D g2) {
TextBlock label = super.createLabel(category, width, edge, g2);
String s = (String) this.sublabels.get(category);
if (s != null) {
if (edge == RectangleEdge.TOP || edge == RectangleEdge.BOTTOM) {
TextLine line = new TextLine(s, this.sublabelFont, this.sublabelPaint);
label.addLine(line);
} else if (edge == RectangleEdge.LEFT || edge == RectangleEdge.RIGHT) {
TextLine line = label.getLastLine();
if (line != null) {
line.addFragment(new TextFragment(" " + s, this.sublabelFont, this.sublabelPaint));
}
}
}
return label;
}
use of org.jfree.chart.text.TextLine in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class CategoryTickTest method testEquals.
/**
* Confirm that the equals method can distinguish all the required fields.
*/
@Test
public void testEquals() {
Comparable<String> c1 = "C1";
Comparable<String> c2 = "C2";
TextBlock tb1 = new TextBlock();
tb1.addLine(new TextLine("Block 1"));
TextBlock tb2 = new TextBlock();
tb1.addLine(new TextLine("Block 2"));
TextBlockAnchor tba1 = TextBlockAnchor.CENTER;
TextBlockAnchor tba2 = TextBlockAnchor.BOTTOM_CENTER;
TextAnchor ta1 = TextAnchor.CENTER;
TextAnchor ta2 = TextAnchor.BASELINE_LEFT;
CategoryTick t1 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f);
CategoryTick t2 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f);
assertEquals(t1, t2);
t1 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
assertNotEquals(t1, t2);
t2 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
assertEquals(t1, t2);
t1 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
assertNotEquals(t1, t2);
t2 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
assertEquals(t1, t2);
t1 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
assertNotEquals(t1, t2);
t2 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
assertEquals(t1, t2);
t1 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
assertNotEquals(t1, t2);
t2 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
assertEquals(t1, t2);
t1 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
assertNotEquals(t1, t2);
t2 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
assertEquals(t1, t2);
}
Aggregations