use of org.jfree.text.TextLine in project SIMVA-SoS by SESoS.
the class CategoryTickTest method testHashCode.
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashCode() {
Comparable 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);
assertTrue(t1.equals(t2));
int h1 = t1.hashCode();
int h2 = t2.hashCode();
assertEquals(h1, h2);
}
use of org.jfree.text.TextLine in project SIMVA-SoS by SESoS.
the class CategoryTickTest method testEquals.
/**
* Confirm that the equals method can distinguish all the required fields.
*/
@Test
public void testEquals() {
Comparable c1 = "C1";
Comparable 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);
assertTrue(t1.equals(t2));
t1 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
assertFalse(t1.equals(t2));
t2 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
assertTrue(t1.equals(t2));
t1 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
assertFalse(t1.equals(t2));
t2 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
assertTrue(t1.equals(t2));
t1 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
assertFalse(t1.equals(t2));
t2 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
assertTrue(t1.equals(t2));
t1 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
assertFalse(t1.equals(t2));
t2 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
assertTrue(t1.equals(t2));
t1 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
assertFalse(t1.equals(t2));
t2 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
assertTrue(t1.equals(t2));
}
use of org.jfree.text.TextLine in project SIMVA-SoS by SESoS.
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;
}
Aggregations