what the problem? In Opera it show a button. I click ok.
I see a pretty print listing. I have got half of my own working this
afternoon I call JDisplay. It takes a preparsed stream of objects and
renders them, either on a Canvas in colours in monochrome on a
TextArea for copy/paste without needing signing. It distinguishes
between where things are defined and referenced, and uses variable
size bracketing.
It knows the difference between package, variable, method and class
names, and uses slightly different colours and font and sizes.
The paint method is very simple. It just runs down a array of Token
objects that implement the Token interface to compute their fonts and
colours.
You could think of this as like a simple browser's paint method.
/**
* does drawing
*
* @param g where to paint
*/
public void paint ( Graphics g )
{
int x = 0;
int y = Token.LEADING;
// render all the tokens, some may be offscreen, but no matter.
for ( int i=0; i<tokens.length; i++ )
{
Token t = tokens
;
if ( t instanceof NL )
{
// render blank lines compressed.
int lines = ( (NL)t).getCount();
switch ( lines )
{
case 0:
// overwrite
break;
case 1:
// single space
y += Token.LEADING;
break;
case 2:
// 1.5 spacing
y += (Token.LEADING * 15 / 10);
break;
case 3:
default:
// anything bigger, just double space.
y += (Token.LEADING * 2);
break;
}
x = 0;
}
else
{
// render a chunk of text
g.setColor( t.getForeground() );
g.setFont( t.getFont() );
String text = t.getText();
g.drawString( text, x, y );
x += g.getFontMetrics().stringWidth( text );
}
}
} // end paint