use of com.google.code.appengine.awt.font.LineMetrics 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);
}
use of com.google.code.appengine.awt.font.LineMetrics in project activityinfo by bedatadriven.
the class ImageMapRenderer method drawLabel.
private static void drawLabel(Graphics2D g2d, BubbleMapMarker marker) {
Font font = new Font(Font.SANS_SERIF, Font.BOLD, (int) (marker.getRadius() * 2f * 0.8f));
// measure the bounds of the string so we can center it within
// the bubble.
// QUICK FIX: labeling set inappropriately as default for new map layers
// and no method in UI to turn them off.
Rectangle2D rect = font.getStringBounds(marker.getLabel(), g2d.getFontRenderContext());
LineMetrics lm = font.getLineMetrics(marker.getLabel(), g2d.getFontRenderContext());
g2d.setColor(Color.WHITE);
g2d.setFont(font);
g2d.drawString(marker.getLabel(), (int) (marker.getX() - (rect.getWidth() / 2)), (int) (marker.getY() + (lm.getAscent() * 1.25)));
}
Aggregations