diff --git a/projects/viztool/src/java/com/samskivert/viztool/Driver.java b/projects/viztool/src/java/com/samskivert/viztool/Driver.java index a1b04bac..57169627 100644 --- a/projects/viztool/src/java/com/samskivert/viztool/Driver.java +++ b/projects/viztool/src/java/com/samskivert/viztool/Driver.java @@ -1,5 +1,5 @@ // -// $Id: Driver.java,v 1.3 2001/07/17 05:21:33 mdb Exp $ +// $Id: Driver.java,v 1.4 2001/07/17 06:01:08 mdb Exp $ package com.samskivert.viztool; @@ -39,6 +39,9 @@ public class Driver System.err.println("Warning: " + warnings[i].reason); } + // initialize the font picker + FontPicker.init(print); + // and finally generate the visualization PackageEnumerator penum = new PackageEnumerator(pkgroot, enum, true); HierarchyVisualizer viz = new HierarchyVisualizer(pkgroot, penum); diff --git a/projects/viztool/src/java/com/samskivert/viztool/hierarchy/CascadingChainVisualizer.java b/projects/viztool/src/java/com/samskivert/viztool/hierarchy/CascadingChainVisualizer.java index 382674ad..d235a936 100644 --- a/projects/viztool/src/java/com/samskivert/viztool/hierarchy/CascadingChainVisualizer.java +++ b/projects/viztool/src/java/com/samskivert/viztool/hierarchy/CascadingChainVisualizer.java @@ -1,5 +1,5 @@ // -// $Id: CascadingChainVisualizer.java,v 1.6 2001/07/17 05:31:37 mdb Exp $ +// $Id: CascadingChainVisualizer.java,v 1.7 2001/07/17 06:01:08 mdb Exp $ package com.samskivert.viztool.viz; @@ -30,7 +30,8 @@ public class CascadingChainVisualizer public void layoutChain (Chain chain, Graphics2D gfx) { // create a text layout based on the current rendering conditions - Font font = chain.getRoot().isInterface() ? _ifaceFont : _classFont; + Font font = chain.getRoot().isInterface() ? + FontPicker.getInterfaceFont() : FontPicker.getClassFont(); TextLayout layout = new TextLayout(chain.getName(), font, gfx.getFontRenderContext()); @@ -70,7 +71,8 @@ public class CascadingChainVisualizer double y = bounds.getY(); // create a text layout based on the current rendering conditions - Font font = chain.getRoot().isInterface() ? _ifaceFont : _classFont; + Font font = chain.getRoot().isInterface() ? + FontPicker.getInterfaceFont() : FontPicker.getClassFont(); TextLayout layout = new TextLayout(chain.getName(), font, gfx.getFontRenderContext()); @@ -137,7 +139,4 @@ public class CascadingChainVisualizer * The number of points of spacing between each child chain. */ protected static final double GAP = 4; - - protected static Font _classFont = new Font("Helvetica", Font.PLAIN, 8); - protected static Font _ifaceFont = new Font("Helvetica", Font.ITALIC, 8); } diff --git a/projects/viztool/src/java/com/samskivert/viztool/hierarchy/ChainGroup.java b/projects/viztool/src/java/com/samskivert/viztool/hierarchy/ChainGroup.java index 7f8fe5f5..bfad782f 100644 --- a/projects/viztool/src/java/com/samskivert/viztool/hierarchy/ChainGroup.java +++ b/projects/viztool/src/java/com/samskivert/viztool/hierarchy/ChainGroup.java @@ -1,5 +1,5 @@ // -// $Id: ChainGroup.java,v 1.5 2001/07/17 05:28:46 mdb Exp $ +// $Id: ChainGroup.java,v 1.6 2001/07/17 06:01:08 mdb Exp $ package com.samskivert.viztool.viz; @@ -44,7 +44,7 @@ public class ChainGroup } // we'll need room to incorporate our title - TextLayout layout = new TextLayout(_pkg, _titleFont, + TextLayout layout = new TextLayout(_pkg, FontPicker.getTitleFont(), gfx.getFontRenderContext()); // we let the title stick halfway up out of our rectangular @@ -82,7 +82,7 @@ public class ChainGroup */ public void render (Graphics2D gfx, double x, double y) { - TextLayout layout = new TextLayout(_pkg, _titleFont, + TextLayout layout = new TextLayout(_pkg, FontPicker.getTitleFont(), gfx.getFontRenderContext()); // we let the title stick halfway up out of our rectangular @@ -137,6 +137,4 @@ public class ChainGroup protected Rectangle2D _size; protected static final double BORDER = 72/8; - - protected static Font _titleFont = new Font("Helvetica", Font.BOLD, 8); } diff --git a/projects/viztool/src/java/com/samskivert/viztool/util/FontPicker.java b/projects/viztool/src/java/com/samskivert/viztool/util/FontPicker.java new file mode 100644 index 00000000..ba678be2 --- /dev/null +++ b/projects/viztool/src/java/com/samskivert/viztool/util/FontPicker.java @@ -0,0 +1,58 @@ +// +// $Id: FontPicker.java,v 1.1 2001/07/17 06:01:08 mdb Exp $ + +package com.samskivert.viztool.viz; + +import java.awt.Font; + +/** + * The font picker provides the proper font based on operating condtions. + */ +public class FontPicker +{ + /** + * Instructs the font picker to choose fonts for printing or fonts for + * displaying on the screen based on the value of the + * printing argument. + */ + public static void init (boolean printing) + { + int size = printing ? 8 : 10; + _titleFont = new Font("Helvetica", Font.BOLD, size); + _classFont = new Font("Helvetica", Font.PLAIN, size); + _ifaceFont = new Font("Helvetica", Font.ITALIC, size); + _implsFont = new Font("Helvetica", Font.ITALIC, size-2); + _declsFont = new Font("Helvetica", Font.PLAIN, size-2); + } + + public static Font getTitleFont () + { + return _titleFont; + } + + public static Font getClassFont () + { + return _classFont; + } + + public static Font getInterfaceFont () + { + return _ifaceFont; + } + + public static Font getImplementsFont () + { + return _implsFont; + } + + public static Font getDeclaresFont () + { + return _declsFont; + } + + protected static Font _titleFont; + protected static Font _classFont; + protected static Font _ifaceFont; + protected static Font _implsFont; + protected static Font _declsFont; +}