The sim.util package contains classes developed in conjunction with MASON or converted from other packages gathered online.
Bag, IntBag, DoubleBag. Bag is an extensible Object array with public access. Significantly (3-4 times) faster than ArrayList or Vector. Bag is a subclass of Collection. IntBag and DoubleBag are extensible arrays of integers and doubles.
Double2D, Double3D, Int2D, Int3D. Immutable x,y or x,y,z tuples. These classes are used extensively to describe locations of objects. We use them rather than java.awt.Point etc. because you need an immutable class to work properly with a hashtable. Our tuples have better hash algorithms as well.
MutableDouble. A trivial holder for a single, modifiable double value.
Properties, SimpleProperties, CollectionProperties, Proxiable. A small collection of classes for examining and manipulating the Java Beans properties of objects. foo is a Java Beans property if there exists a getFoo() or isFoo() method (and an optional setFoo(val) method). You get the properties from an object with Properties.getProperties(...). Objects can be declared Proxiable, meaning that they offer to the Properties object a proxy to examine instead of the objects themselves.
WordWrap. A small class for doing word wrapping either by number of columns or number of pixels (given font information).
Heap. A simple, fast binary heap class, with longs as keys.
MovieEncoder. A class for generating Quicktime movies from BufferedImages using Sun's Java Media Framework (JMF). Written based largely on code from Sun, portions of which are subject to a mild BSD-like License from Sun.
PNGEncoder. A class for generating PNG Images. Used because Sun's image framework is not available on all platforms (and the encoder works just fine). Distributed with permission from David Eisenberg, under the Artistic License.
AbstractScrollable. An abstract superclass with basic implementation of the javax.swing.Scrollable interface.
LabelledList. A simple class to make it easy to create a 2xN matrix of widgets (often the left column is labels for the right column).
MovieMaker. A GUI front-end for MovieEncoder. Relies on Java's reflection library to tentatively access MovieEncoder; if JMF is not installed on a machine, properly gives a graphical interface warning.
NumberTextField (and various PNG images). A widget for entering, displaying, and filtering a numerical value.
PropertyTextField. A widget for entering, displaying, and filtering a string or boolean value.
SimState. The superclass that you extend to create your simulation model. Contains at least a Schedule and a MersenneTwisterFast.
Schedule. A discrete-event schedule, using heaps and arrays to perform arbitrary schedules and repeated schedules efficiently. Represents time in your model.
Steppable. Something that can be scheduled on the schedule to have its step() method called (to be "stepped").
Stoppable. When a Steppable is scheduled repeating, a Stoppable is returned, with a function called stop() to stop the repeating from continuing on.
Sequence. A Steppable which holds an array of Steppables. When stepped, steps each of the Steppables in turn.
RandomSequence. A Sequence which randomizes the order of its Steppables before stepping them.
ParallelSequence. A Sequence which steps all of its Steppables simultaneously, in different threads.
MultiStep. A Steppable which holds a subsidiary Steppable. Can either call step() N times for each MultiStep.step(), or will call step() once every N MultiStep.step() calls.
WeakStep. A Steppable which only weakly holds an object (letting it GC if desired).
Contains fields, which represent spatial or other neighborhoods. Zero or more fields represent space in your model.
SparseField. An abstract superclass of various sparse fields. A sparse field is one which uses hash tables rather than arrays to store a sparse number of objects spread over a large area.
Contains grids, which are discrete fields. Most grids have a fixed width and height. Grids can be treated toroidally, and 2D grids can be thought of as holding hexagons rather than squares.
Grid2D, Grid3D. Top-level interfaces for all grids. Specify basic grid functions, and toroidal and/or hexagonal conversion functions.
AbstractGrid2D, AbstractGrid3D. Abstract implementations of the Grid2D and Grid3D interfaces. Superclasses of all but the sparse grids (which subclass instead from SparseField).
IntGrid2D, IntGrid3D. Grids of integers. Literally covers for multidimensional Java integer arrays.
DoubleGrid2D, DoubleGrid3D. Grids of doubles. Literally covers for multidimensional Java double arrays.
ObjectGrid2D, ObjectGrid3D. Grids of Objects. Literally covers for multidimensional Java Object arrays.
SparseGrid2D, SparseGrid3D. Sparse grids of Objects. Allow objects to be located anywhere (rather than in a fixed width/height) if necessary, and for multiple Objects to be located at the same location. Implemented with a SparseField. Locations are specified with Int2D and Int3D.
Contains continuous fields which relate Objects to locations defined as tuples of doubles.
Continuous2D, Continuous3D. Associate any number of Objects with 2D or 3D tuples of doubles as locations. Efficient neighborhood lookups are done through discretization of the space. Subclasses of SparseField. Locations are specified with Double2D and Double3D.
Contains networks (directed graphs) which relate Objects to one another via binary relationships.
Edge. A directed relationship between two objects. Edges may be labelled with an "info" object (a weight, a name, etc.).
NetworkField. Defines directed graphs and networks between arbitrary objects. Relationships are defined using Edge objects.
Portrayal. The top-level interface for all portrayals.
Portrayal2D. A Portrayal subinterface. The top interface for all 2D portrayals.
FieldPotrayal. The abstract superclass of all Field Portrayals. Contains facilities for storing SimplePortrayals and relating them with objects in a Field. A Portrayal.
FieldPortrayal2D. The abstract superclass of all 2D Field Portrayals. A FieldPortrayal and a Portrayal2D.
SimplePotrayal2D. The abstract superclass of all 2D Simple Portrayals. A Portrayal2D.
Inspector. The abstract superclass of GUI widgets responsible for allowing the user to view and manipulate the internal parameters of objects and fields.
SimpleInspector. A concrete implementation of Inspector which does so by letting the user have access to the Java Bean properties of objects. This is done using the Properties class and subclasses.
DrawInfo2D. When an object or field needs to be drawn, the scale, location, and clipping information is passed to its portrayal in this wrapper object.
HexaDrawInfo2D. A subclass of DrawInfo2D with additional information for Hexagons to draw themselves prettily.
Portrayals for grids.
ValueGrid2DPortrayal, HexaValueGrid2DPortrayal, FastValueGrid2DPortrayal. Portrayals for IntGrid2D and DoubleGrid2D. ValueGrid2DPortrayal is flexible, while FastValueGrid2DPortrayal is faster. HexaValueGrid2DPortrayal portrays the fields as hexagonal fields.
ObjectGrid2DPortrayal, HexaObjectGrid2DPortrayal. Portrayals for ObjectGrid2D, portraying it in normal fashion or as a hexagonal grid.
SparseGrid2DPortrayal, HexaSparseGrid2DPortrayal. Portrayals for SparseGrid2D, portraying it in normal fashion or as a hexagonal grid.
DrawPolicy. Since multiple objects may hold the same polsition in a SparseGrid2D, its portrayals call this optional object to determine which objects to draw at positions and in which order.
Portrayals for continuous fields.
Continuous2DPortrayal. Portrays a Continuous2D field.
Portrayals for networks.
Network2DPortrayal. Portrays the edges in a NetworkField. The nodes in the field must be also stored in a SparseGrid2D or Continuous2D field, and portrayed with a SparseGrid2DPortrayal or Continuous2DPortrayal respectively.
SpatialNetwork2D. Holds the NetworkField and either a SparseGrid2D or Continuous2D. Used by Network2DPortrayal to know where to draw edges (by querying the right field for the node locations).
SimpleEdgePortrayal2D. A basic SimplePortrayal2D for Edges.
EdgeDrawInfo2D. A subclass of DrawInfo2D which adds additional information for drawing Edges.
Various SimplePortrayal2D's for your enjoyment.
RectanglePortrayal2D. Portrays objects as rectangles (usually squares)
ValuePortrayal2D. Portrays values (from ValueGrid2DPortrayal) as rectangles colored according to the value.
OvalPortrayal2D. Portrays objects as ovals (usually circles).
ImagePortrayal2D. Portrays objects as a provided image.
HexagonalPortrayal2D. Portrays objects as true hexagons.
Controller The abstract superclass of top-level controllers of a simulation.
Console (and various PNG images). An elaborate Controller which presents a window allowing the user to start and stop the simulation, change its parameters, and manage its various windows and inspectors.
Display2D (and various PNG images). A window which allows the user to scroll, scale, take snapshots of, and make moveis of various FieldPortrayal2Ds as they are updated during the course of the simulation run.