use of org.jfree.chart.text.TextFragment 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;
}
Aggregations