Print

Print


Hi

We were not 100% sure what you meant in your first mail (for instance,
there are nodes in java3D, which we use to render 3d stuff).

For graphs (networks)

NetworkPortrayal2D draws edges between the locations of nodes; the
locations of nodes is specified by a SpatialNetwork2D object.

A SpactialNetwork2d is "A wrapper used by NetworkPortrayal2D to hold a
Network and EITHER a Continuous2D OR a SparseGrid2D. The
Continuous2D/SparseGrid2D specifies the spatial location of the
nodes; the Network specifies the edges connecting those nodes."

Here's how I did it in my traffic application to draw a Manhattan style
grid of roads and intersections:

GridCity gridCity = (GridCity) ((TrafficSim)state).roadNet;
//this is the network object!

GridNode[][] grid = gridCity.grid;
//my intersections (network nodes) also reside in a grid

SparseGrid2D map = new SparseGrid2D(gridCity.width, gridCity.height);
for(int x=0; x<gridCity.width;x++)
	for(int y=0;y<gridCity.height;y++)
		map.setObjectLocation(grid[y][x], x, y);
//load the map
roadPortrayal.setField(new SpatialNetwork2D(map, gridCity));
//set it
roadPortrayal.setPortrayalForAll(new SegmentPortrayal2D(true, SegmentPortrayal2D.RIGHT_HAND_SIDE_OF_ROAD));

I plug the whole thing in in "init(Controller)"

display.attach(roadPortrayal, "roads");

Similarly for nodes: I build a SparseGridPortrayal2D, set its field to
"map" (see above), set its portrayal[forAll], then attach it to the
display.


If your nodes don't have an underlying spatial layout (sometimes a graph
is just a graph), you coudl spread out your nodes on a circle.

Gabriel


On Tue, 25 Mar 2008, MASON-INTEREST-L automatic digest system wrote:

> There is 1 message totalling 17 lines in this issue.
>
> Topics of the day:
>
>   1. Moving Agents
>
> ----------------------------------------------------------------------
>
> Date:    Mon, 24 Mar 2008 18:59:49 -0400
> From:    Sandhya Arunachalam <[log in to unmask]>
> Subject: Moving Agents
>
> Hi all
>
> I want to create agents that move between nodes through an edge .And I
> need some way to show that they have moved from node A to node B. Please
> help me .I am very new to MASON but I need to do this real fast.So far I
> have created only the nodes with edges connecting them.
>
> Thanks
>
> Sandhya
>
> ------------------------------
>
> End of MASON-INTEREST-L Digest - 23 Mar 2008 to 24 Mar 2008 (#2008-11)
> **********************************************************************
>