use of com.google.code.appengine.awt.Font in project activityinfo by bedatadriven.
the class PolygonLegendRenderer method createImage.
public ItextGraphic createImage(ImageCreator creator) {
ItextGraphic result = creator.create(width, height);
Graphics2D g2d = result.getGraphics();
int y = 0;
for (PolygonLegend.ColorClass clazz : legend.getClasses()) {
y += PADDING;
g2d.setColor(ColorUtil.colorFromString(clazz.getColor()));
g2d.fillRect(PADDING, y, SWATCH_WIDTH, SWATCH_HEIGHT);
g2d.setColor(Color.BLACK);
g2d.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, LABEL_HEIGHT));
g2d.drawString(formatLabel(clazz), PADDING + SWATCH_WIDTH + PADDING, y + SWATCH_HEIGHT - (LABEL_HEIGHT / 2));
y += SWATCH_HEIGHT;
}
return result;
}
use of com.google.code.appengine.awt.Font in project activityinfo by bedatadriven.
the class BubbleLegendRenderer method drawBubbleLegendLabel.
private void drawBubbleLegendLabel(Graphics2D g2d, int x, int y, double value) {
Font font = new Font(Font.SANS_SERIF, Font.PLAIN, 10);
String label = labelFormat.format(value);
LineMetrics metrics = font.getLineMetrics(label, g2d.getFontRenderContext());
Rectangle2D bounds = font.getStringBounds(label, g2d.getFontRenderContext());
x -= bounds.getWidth() / 2d;
y += metrics.getAscent();
g2d.setColor(Color.BLACK);
g2d.setFont(font);
g2d.drawString(label, x, y);
}
Aggregations