AllFontspublic class AllFonts extends AnimatingControlsSurface Scrolling text of fonts returned from GraphicsEnvironment.getAllFonts(). |
Fields Summary |
---|
private static Vector | fonts | private int | nStrs | private int | strH | private int | fi | protected int | fsize | protected Vector | v |
Constructors Summary |
---|
public AllFonts()
setBackground(Color.white);
setSleepAmount(500);
setControls(new Component[] { new DemoControls(this) });
|
Methods Summary |
---|
public void | handleThread(int state)
| public static void | main(java.lang.String[] argv)
createDemoFrame(new AllFonts());
| public void | render(int w, int h, java.awt.Graphics2D g2)
g2.setColor(Color.black);
int yy = (fi >= fonts.size()) ? 0 : h - v.size() * strH - strH/2;
for (int i = 0; i < v.size(); i++) {
Font f = (Font) v.get(i);
int sw = getFontMetrics(f).stringWidth(f.getName());
g2.setFont(f);
g2.drawString(f.getName(), (int) (w/2-sw/2),yy += strH);
}
| public void | reset(int w, int h)
v.clear();
Font f = ((Font) fonts.get(0)).deriveFont(Font.PLAIN,fsize);
FontMetrics fm = getFontMetrics(f);
strH = (int) (fm.getAscent()+fm.getDescent());
nStrs = h/strH + 1;
fi = 0;
| public void | step(int w, int h)
if (fi < fonts.size()) {
v.addElement(((Font) fonts.get(fi)).deriveFont(Font.PLAIN,fsize));
}
if (v.size() == nStrs && v.size() != 0 || fi > fonts.size()) {
v.removeElementAt(0);
}
fi = (v.size() == 0) ? 0 : ++fi;
|
|