FileDocCategorySizeDatePackage
PlotterAWT.javaAPI DocExample2611Sun Feb 08 21:33:42 GMT 2004None

PlotterAWT

public class PlotterAWT extends Plotter
A Plotter subclass for drawing into an AWT Window. Reflecting back to AWT gives us a "known working" plotter to test on. You can also steal this as a basis for your own plotter driver.
author
Ian Darwin

Fields Summary
Frame
f
PCanvas
p
Graphics
g
Font
font
FontMetrics
fontMetrics
Constructors Summary
PlotterAWT()

		super();
		f = new Frame("Plotter");
		p = new PCanvas(MAXX, MAXY);
		f.add(p);
		f.pack();
		f.setVisible(true);
        f.addWindowListener(new WindowCloser(f, true));
		g = p.getOsGraphics();
	
Methods Summary
public voiddrawBox(int w, int h)

		g.drawRect(curx, cury, w, h);
		p.repaint();
	
voiddrawString(java.lang.String s)

		g.drawString(s, curx, cury);
		curx += fontMetrics.stringWidth(s);
	
public voidmoveTo(int absx, int absy)

		if (!penIsUp)
			g.drawLine(curx, cury, absx, absy);
		curx = absx;
		cury = absy;
	
voidpenColor(int c)

		switch(c) {
		case 0: g.setColor(Color.white); break;
		case 1: g.setColor(Color.black); break;
		case 2: g.setColor(Color.red); break;
		case 3: g.setColor(Color.green); break;
		case 4: g.setColor(Color.blue); break;
		default: g.setColor(new Color(c)); break;
		}
	
voidpenDown()

 penIsUp = false; 
voidpenUp()

 penIsUp = true; 
public voidrmoveTo(int incrx, int incry)

		moveTo(curx += incrx, cury += incry);
	
voidsetFont(java.lang.String fName, int fSize)

		font = new Font(fName, Font.BOLD, fSize);
		fontMetrics = p.getFontMetrics(font);
	
public voidsetdir(float deg)