Java examples for 2D Graphics:Dimension
get Max Line Height
import org.apache.log4j.Logger; import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Point; import java.awt.font.FontRenderContext; import java.awt.font.LineMetrics; import java.util.*; import java.util.regex.Pattern; public class Main{ public static final float getMaxLineHeight(Graphics2D g, Map<String, Font> values) { float max = 0; FontRenderContext context = g.getFontRenderContext(); for (String each : values.keySet()) { float height = values.get(each).getLineMetrics(each, context) .getHeight();/*from w w w.ja v a 2s .c om*/ max = Math.max(max, height); } return max; } public static final float getMaxLineHeight(Graphics2D g, Font font, String... strings) { float max = 0; FontRenderContext context = g.getFontRenderContext(); for (String each : strings) { max = Math.max(max, font.getLineMetrics(each, context) .getHeight()); } return max; } }