swarm-support
[Top][All Lists]
Advanced

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

Canvas enhancements


From: Marcus G. Daniels
Subject: Canvas enhancements
Date: 19 Apr 2001 11:47:07 -0700
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

Hi Folks,

In today's snapshot, there are two new features courtesy of Jason Alexander:

 1) NodeItems can change their labels.

 2) LinkItems don't need to be directed.

Attached is a test case that demonstrates both new features.

   ftp://ftp.swarm.org/pub/swarm/src/testing/swarm-2001-04-18.tar.gz
   ftp://ftp.swarm.org/pub/swarm/binaries/w32/latest

Thanks, Jason!

import swarm.Globals;
import swarm.simtoolsgui.GUISwarmImpl;
import swarm.defobj.Zone;

import swarm.gui.Canvas;
import swarm.gui.CanvasC;
import swarm.gui.CanvasImpl;
import swarm.gui.CanvasCImpl;
import swarm.gui.RectangleNodeItem;
import swarm.gui.RectangleNodeItemC;
import swarm.gui.RectangleNodeItemCImpl;
import swarm.gui.RectangleNodeItemImpl;
import swarm.gui.OvalNodeItem;
import swarm.gui.OvalNodeItemC;
import swarm.gui.OvalNodeItemS;
import swarm.gui.OvalNodeItemCImpl;
import swarm.gui.OvalNodeItemImpl;
import swarm.gui.LinkItem;
import swarm.gui.LinkItemC;
import swarm.gui.LinkItemImpl;
import swarm.gui.LinkItemCImpl;

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

        TestLink testLink = new TestLink (Globals.env.globalZone);

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

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

    Canvas canvas;

    public Object buildObjects () {
        super.buildObjects ();
        
        CanvasC canvasC = new CanvasCImpl (new CanvasImpl ());
        canvasC.createBegin (getZone ());
        canvas = (Canvas) canvasC.createEnd ();

        canvas.setHeight (500);
        canvas.setWidth (500);
        canvas.setWindowTitle ("Test Nodes and Links");
        canvas.pack ();

        RectangleNodeItemC rectangleC =
            new RectangleNodeItemCImpl (new RectangleNodeItemImpl ());
        rectangleC.createBegin (getZone ());
        rectangleC.setCanvas (canvas);
        rectangleC.setString ("Reset me");
        rectangleC.setX$Y (400, 400);
        RectangleNodeItem rectangle =
            (RectangleNodeItem) rectangleC.createEnd ();

        rectangle.resetString ("Foo");

        OvalNodeItemC ovalC =
            new OvalNodeItemCImpl (new OvalNodeItemImpl ());
        ovalC.createBegin (getZone ());
        ovalC.setCanvas (canvas);
        ovalC.setString ("Bar");
        ovalC.setX$Y (250, 250);
        OvalNodeItem oval = (OvalNodeItem) ovalC.createEnd ();

        LinkItemC linkItemC =
          new LinkItemCImpl (new LinkItemImpl ());
        linkItemC.createBegin (getZone ());
        linkItemC.setDirectedFlag (false);
        linkItemC.setCanvas (canvas);
        linkItemC.setFrom (oval);
        linkItemC.setTo (rectangle);
        linkItemC.createEnd ();

        return this;
    }
}

                  ==================================
   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 <address@hidden>
   with "help" in the body of the message.



reply via email to

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