FAQ - Which should we use: Grouping or Composing Shapes?

Applies to: Nevron Diagram for .NET

Which should we use: Grouping or Composing Shapes?

We often get asked what the difference is between grouping and composing shapes, and which is better to use. Grouping shapes creates a Group which serves as a container for the shapes. This means operations applied to the Group get applied to all of the shapes within it, but the shapes are still separate entities. Thus, you can still access the individual properties of each of the shapes within the group and change them if desired.

However, if you do not require the shapes to be separate entities, then composing is better choice. The Composition operation creates a new Composite Shape which is the composition of the original shapes, but the original shapes are deleted. The Composite Shape has the advantage of being much more efficient and lighter than the Groupe as it only needs to keep properties for itself, and when operations are applied, they are applied to the shape primitives. While a Composite Shape can be decomposed, it will be decomposed into Primitive Shapes, not the original shapes.

Thus, if you need to group shapes but keep them as separate entities, use the Grouping operation. However, if you want the shapes to compose and become a new shape, and you will never need them to be separate entities again, use the Composition operation.


Additional information:
Shapes are aggregate models, which are used to represent objects from the real world, concepts or abstractions. Shapes can be connected with each other and form complex relationships. Shapes are the primary building blocks of diagrams.

Currently there are three distinct NShape class derivates in Nevron Diagram for .NET:

  • Primitive Shapes - these are shapes, which aggregate a single primitive model.
  • Composite Shapes - these are shapes, which aggregate one or more primitive models.
  • Groups - these are shapes, which aggregate other shapes.

Composite Shapes:
Composite shapes are shapes, which aggregate multiple primitive models. You can use any primitive model(s) to represent the geometry of a composite shape. That is why composite shapes are often used for the creation of custom shapes. Composite shapes are by default treated as 2D shapes.

Composition is the process of creating of a new composite shape, which contains clonings of all the primitives contained in other shapes. This operation is primary used for the creation of a custom shape from a set of primitive shapes, but you can generally compose any set of shape - including other composite shapes. Composition preserves the scene transformation of the original primitives. The cloned primitives adopt the style of the shapes, which contained the original primitives. The composed shapes must have a compose permission.

Decomposition is the process of creating of a primitive shape for each primitive model aggregated by a set of shapes. Decomposition preserves the scene transformation of the primitives. If there is a local style applied to a primitive model it will be applied to the created shape. The decomposed shapes must have a decompose permission.

For details on creating a Compostie Shape, take a look at the Help Documentation:
Shapes > Composite Shapes > Creating a custom shape

Groups:
Groups are shapes, which aggregate other shapes. You can construct a group from any types of shapes - including other groups. Groups are by default treated as 2D shapes. Groups support drill down selection, which means that you can select the shapes contained in a group. Groups are created similarly to composite shapes. The difference is that groups can contain only shapes.

Grouping is the process of creating a new group from a set of already existing shapes. The shapes, which must be grouped must have a group permission. When shapes are grouped they are deleted from the current composite in which they reside (a layer or another group) and added to the Shapes collection of the newly created group. The grouped shapes will retain their position and size in scene coordinates.

Ungrouping is the process of destruction of an existing group. The group must have an ungroup permission in order to be ungrouped. You can optionally specify a composite in which the group shapes must be added.

For details on creating a Group, take a look at the Help Documentation:
Shapes > Groups > Creating groups

Article ID: 79, Created On: 10/7/2010, Modified: 12/27/2010