GLG Toolkit, Java Class Library  Version 4.6
Creating and Copying Objects

Detailed Description

This group contains methods for creating objects at run time, as well as creating copies of an object.

Functions

GlgObject CloneObject (GlgCloneType clone_type)
 Creates a specialized copy (clone) of an object. More...
 
GlgObject CopyObject ()
 Creates a copy of the object. More...
 

Function Documentation

◆ CloneObject()

GlgObject CloneObject ( GlgCloneType  clone_type)

Creates a specialized copy (clone) of an object.

Parameters
clone_typeThe type of cloning to perform, as described below.
Returns
An object's clone.

This method creates a copy of the object according to the specified clone type. There are four different kinds of clones available. The difference between them depends on their treatment of the original object's attributes according to the setting of the Global flag of each attribute. There is also a special shallow clone type which can be applied only to the container objects such as groups and lists.

The following clone types are available:

  • FULL_CLONE - A full clone is a copy of the original object. No attributes of the copy are constrained to the attributes of the original.

  • CONSTRAINED_CLONE - A constrained clone is a copy of the original object all of whose attributes are constrained to the corresponding attributes of the original.
    Exception: The constrained clone does not constrain the attributes that have their Global flag set to UNCONSTRAINED (NONE in the Graphics Builder). This includes the constrained points of the parallelogram, frame and connector objects, the Buffer attribute of the Transfer transformation and some other special attributes.

  • STRONG_CLONE A strong clone is a copy of the original object. Any of the object's attributes that are global or semi-global (have their Global flags set to GLOBAL or SEMI_GLOBAL) will be constrained to the corresponding attribute of the original.

  • WEAK_CLONE - A weak clone interprets SEMI_GLOBAL to mean the same as LOCAL. It is similar to a strong clone, but only the global attributes are constrained.

  • SHALLOW_CLONE A shallow clone is a special clone type that can be applied only to the container objects such as a group (ARRAY) or a list (LIST). When a shallow copy of a group is created, the copy will contain the same objects as the original group, as opposed to the other clone types which clone elements of the group, creating new objects. The shallow clone may be used by a program to create a list of objects in the original group, for example for safe traversing of the list while deleting objects from the original group.

◆ CopyObject()

GlgObject CopyObject ( )

Creates a copy of the object.

Returns
An object's copy.

This method creates and returns a copy of an object. CopyObject is equivalent to using CloneObject with the FULL_CLONE cloning type. Refer to CloneObject for more information on cloning types.

CopyObject may be used to create multiple instances of an object after the object has been created and its attributes have been set to the desired values, which saves repeated calls to the resource-setting methods.