swarm-support
[Top][All Lists]
Advanced

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

Re: [Swarm-Support] Java Swarm With Graphs


From: Marcus G. Daniels
Subject: Re: [Swarm-Support] Java Swarm With Graphs
Date: Mon, 14 Nov 2005 21:24:45 -0700
User-agent: Mozilla Thunderbird 1.0.5 (Windows/20050711)

durga bhavani wrote:
No I need to add 100 curves each in different time steps.

If you mean: "Can I use I have arbitrary X and Y coordinates?", the answer is yes.
I think Paul's remarks are well taken, though.




import swarm.Globals;
import swarm.simtoolsgui.GUISwarmImpl;
import swarm.defobj.Zone;
import swarm.gui.Graph;
import swarm.gui.GraphElement;
import swarm.gui.GraphImpl;
import swarm.Selector;

public class TestGraph extends GUISwarmImpl {
    TestGraph (Zone aZone) {
        super (aZone);
    }

    public Object buildObjects () {
        super.buildObjects ();
        String colors[] = { "red", "green", "blue" };

        Graph graph = new GraphImpl (getZone ());

        graph.setWindowTitle ("A Graph");
        graph.pack ();

        for (int i = 1; i < 9; i++) { 
          GraphElement ge = graph.createElement ();
        
          ge.setLabel ("#" + i);
          ge.setWidth (1);
          ge.setColor (colors[i % 3]);

          ge.addX$Y ((5 - i) ^ 2, 1 + i);
          ge.addX$Y (i + 9, 10 * Math.sin (Math.PI * i / 10));
        }

        return this;
    }

    public static void main (String []args) {
        Globals.env.initSwarm ("TestGraph", "0.0", "address@hidden",
                               args);
        TestGraph testGraph = new TestGraph (Globals.env.globalZone);

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

reply via email to

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