Font metrics used for batch mode layout (without X11 connection).
authorberghofe
Tue, 16 Oct 2001 16:48:30 +0200
changeset 11799 533a95523f61
parent 11798 fbab70de9b0d
child 11800 5f84c687ba06
Font metrics used for batch mode layout (without X11 connection).
lib/browser/GraphBrowser/DefaultFontMetrics.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/browser/GraphBrowser/DefaultFontMetrics.java	Tue Oct 16 16:48:30 2001 +0200
@@ -0,0 +1,33 @@
+/***************************************************************************
+  Title:      GraphBrowser/DefaultFontMetrics.java
+  ID:         $Id$
+  Author:     Stefan Berghofer, TU Muenchen
+  License:    GPL (GNU GENERAL PUBLIC LICENSE)
+
+  Default font metrics which is used when no graphics context
+  is available.
+***************************************************************************/
+
+package GraphBrowser;
+
+import java.awt.*;
+
+public class DefaultFontMetrics extends FontMetrics
+{
+	public DefaultFontMetrics(Font f)
+	{ super(f); }
+
+	// note : values are rather inaccurate !
+
+	public int getLeading()
+	{ return 1; }
+
+	public int getAscent()
+	{ return (int)(Math.round(font.getSize()*5.0/6.0)); }
+
+	public int getDescent()
+	{ return (int)(Math.round(font.getSize()/6.0)); }
+
+	public int stringWidth(String s)
+	{ return (int)(Math.round(s.length()*font.getSize()/2.0)); }
+}