swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Raster width and height setting problem


From: Tran, Vu Binh
Subject: Raster width and height setting problem
Date: Wed, 18 Jul 2001 15:13:57 +1000

Hi,

I am having problem setting the raster width and height as
well as erasing raster. I am using the sample code from
Marcus G. Daniels TestPixMap. Whenever I call the
r.SetWidth(200) or r.SetHeight(200) or r.setWidth$Height(200, 200)
or r.erase() I always see the Dr. Watson on Windows says access
violation. The code is as follows


import swarm.Globals;
import swarm.simtoolsgui.GUISwarmImpl;
import swarm.gui.PixmapCImpl;
import swarm.gui.PixmapImpl;
import swarm.gui.PixmapC;
import swarm.gui.Pixmap;
import swarm.gui.Raster;
import swarm.gui.RasterImpl;
import swarm.gui.ColormapImpl;
import swarm.gui.Colormap;
import swarm.defobj.Zone;

public class TestPixmap extends GUISwarmImpl {
    static void main (String args[]) {
        Globals.env.initSwarm ("TestCanvas", "0.0", "address@hidden",
                               args);

        TestPixmap testPixmap = new TestPixmap (Globals.env.globalZone);
        //System.out.println(Globals.env.arguments.getAppDataPath ());

        testPixmap.buildObjects ();
        testPixmap.buildActions ();
        testPixmap.activateIn (null);
        testPixmap.go ();
    }

    public TestPixmap (Zone aZone) {
        super (aZone);
    }

    public Object buildObjects () {
        super.buildObjects ();

        Colormap colormap = new ColormapImpl (getZone ());
        colormap.setColor$ToName ((byte) 0, "blue");

        Raster r = new RasterImpl (getZone ());
        r.setWindowTitle ("My raster");

//************************************************************************************
// Problems with these lines
        r.setWidth$Height (200, 200);
        r.setWidth(200);
        r.setHeight(200);
        r.erase ();
//************************************************************************************

        r.setColormap (colormap);
        r.pack ();

        PixmapC pixmapC = new PixmapCImpl (new PixmapImpl ());

        pixmapC.createBegin (getZone ());
        String appDir = Globals.env.arguments.getAppDataPath ();

        pixmapC.setDirectory (appDir);
        pixmapC.setFile ("ant.png");
        Pixmap pixmap = (Pixmap) pixmapC.createEnd ();
        pixmap.setRaster (r);

        pixmap.drawX$Y (50, 50);

        return this;
    }
}

Tran, Vu Binh ================================== Swarm-Support is for discussion of the technical details of the day to day usage of Swarm. For list administration needs (esp. [un]subscribing), please send a message to with "help" in the body of the message.
reply via email to

[Prev in Thread] Current Thread [Next in Thread]