Pick fonts based on whether we're printing or displaying on screen.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@192 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2001-07-17 06:01:08 +00:00
parent 8efe315270
commit c695cdeb41
4 changed files with 70 additions and 12 deletions
@@ -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);
@@ -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);
}
@@ -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);
}
@@ -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
* <code>printing</code> 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;
}