Recent Changes - Search:

Information

Installation

Documentation

 

 « Trace | Sitemap | Sets of shapes » 

Sets of 2D elements

A set of elements is a collection of EJS elements of the same type. Technically they are stored in an array, which means that each element has an index number between 0 and n-1. The total number n of elements in a set would be the dimension of that array. Most of the properties of the individual elements of a set - such as their positions or colours - can be specified by providing either a single value (which is then applied to all elements of the set) or an array of the same or larger dimension. In this latter case, each entry of the array is applied to the corresponding element of the set. Unless the dimension is very small (say, 2 or 3, where you could type something like new double[] {0,1,0}), you cannot fill in multiple values into a single input field of the set’s property dialogue, and you need to declare and fill in the value of arrays of the right dimension in the model variables.

 


Defining 3-dimensional arrays color, x, and y for e.g. a set of three 2D-shapes.

 

Once the property arrays are defined they can be manipulated e.g. in for-loops during initialization and evolution:
  for(int i = 0; i < y.length; i++) {         // Loop i from 0 to n-1
    y[i] = y[i] + dy[i];                      // manipulate element with index i
  }

 

The array variables can be used to define the view properties of a set of elements:

 


Use array variables for properties of e.g. SegmentSet2D.

 

Available sets for 2D elements

  • Shape set. A set of shapes such as ellipses, rectangles…

 

 

 

 

  • Image set. Add a new set of 2D image or a animated GIF image.

 

  • Text set. Include a 2D interactive text field set.

 

 

 

  • Group. Define a 2D elements group.

 



 « Trace | Sitemap | Sets of shapes » 

Edit - History - Print - Recent Changes - Search
Page last modified on November 08, 2010, at 02:01 AM