FileDocCategorySizeDatePackage
GWorldToPict.javaAPI DocExample3558Wed Nov 10 12:38:08 GMT 2004com.oreilly.qtjnotebook.ch05

GWorldToPict

public class GWorldToPict extends Object implements QDDrawer

Fields Summary
Constructors Summary
public GWorldToPict()

        try {
            QTSessionCheck.check();
            QDRect bounds = new QDRect (0, 0, 200, 250);
            ImageDescription imgDesc =
                new ImageDescription(QDConstants.k32RGBAPixelFormat);
            imgDesc.setHeight (bounds.getHeight());
            imgDesc.setWidth (bounds.getWidth());
            QDGraphics gw = new QDGraphics (imgDesc, 0);
            System.out.println ("GWorld created: " + gw);
            
            OpenCPicParams params = new OpenCPicParams(bounds);

            Pict pict = Pict.open (gw, params);
            gw.beginDraw (this);

            pict.close();

            try {
                pict.writeToFile (new java.io.File ("gworld.pict"));
            } catch (java.io.IOException ioe) {
                ioe.printStackTrace();
            }
        } catch (QTException qte) {
            qte.printStackTrace();
        }
        System.exit(0);

    
Methods Summary
public voiddraw(QDGraphics gw)

        System.out.println ("draw() called with GWorld " + gw);
        QDRect bounds = gw.getBounds();
        System.out.println ("bounds: " + bounds);
        // clear drawing surface, set up colors
        gw.setBackColor (QDColor.lightGray);
        gw.eraseRect (bounds);
        // draw some shapes
        gw.penSize (2, 2);
        gw.moveTo (20,20);
        gw.setForeColor (QDColor.green);
        gw.line (30, 100);
        gw.moveTo (20,20);
        gw.setForeColor (QDColor.blue);
        gw.lineTo (30, 100);

        // draw some text
        gw.setForeColor (QDColor.red);
        gw.textSize (24);
        gw.moveTo (10, 150);
        gw.drawText ("QDGraphics", 0, 10);

        // draw some shapes
        gw.setForeColor (QDColor.magenta);
        QDRect rect = new QDRect (0, 170, 40, 30);
        gw.paintRoundRect (rect, 0, 0);
        QDRect roundRect = new QDRect (50, 170, 40, 30);
        gw.paintRoundRect (roundRect, 10, 10);
        QDRect ovalRect = new QDRect (100, 170, 40, 30);
        gw.paintOval (ovalRect);
        QDRect arcRect = new QDRect (150, 170, 40, 30);
        gw.paintArc (arcRect, 15, 215);
    
public static voidmain(java.lang.String[] args)

        new GWorldToPict();