|
GLG Toolkit, JavaScript Library
Version 4.6
|
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... | |
| static GlgObject | CreateObject (GlgObjectType type, Object param1, Object param2, Object param3, Object param4) |
| Creates a GLG object of a specified type. More... | |
| GlgObject CloneObject | ( | GlgCloneType | clone_type | ) |
Creates a specialized copy (clone) of an object.
| clone_type | The type of cloning to perform, as described below. |
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:
| GlgObject CopyObject | ( | ) |
Creates a copy of the object.
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.
|
static |
Creates a GLG object of a specified type.
| type | The type of a GLG object to be created, see GlgObjectType. "" |
| param1,param2,param3,param4 | Parameters which depend on the type of the object to be created, see the table below. Trailing parameters with null values can be omitted. |
Most of the entities in the GLG Toolkit, such as graphical objects, container objects, transformations and even attributes, are objects. The CreateObject method can be used to create any of these objects and is probably the most complex method of the API.
In practice, the GLG Graphics Builder editor provides the most convenient and fast way to create graphical objects, edit their attributes and define their dynamic and interactive behavior. Even applications that need to create objects in the drawing on the fly at run time use prebuilt graphical components instead of creating them from scratch programmatically using CreateObject.
The GLG Graphics Builder is used to create graphical components that will be used as building blocks and saves them, using ether a separate drawing for each component, or a single drawing (used as a component palette) containing all of them. At run time, the application loads the components' drawings and populates the drawing by adding copies of components to the drawing at specified positions.
The GLG Air Traffic and GLG Diagram demos add dynamic objects to the drawing at run time and provide examples of this approach.
Using CreateObject
The type parameter specifies the kind of object to be created. Its possible values and the usage of the accompanying data parameters are outlined in the table below.
The following table summarizes the usage of the data parameters, with a comma-separated list providing parameter description, its type and default value (if any):
| Object Type | data1 | data2 | data3 | data4 |
|---|---|---|---|---|
| Any object type not listed below | null | null | null | null |
| POLYGON | optional number of vertices, int, 2 | null | null | null |
| SPLINE | optional number of vertices, int, 3 | null | null | null |
| PARALLELOGRAM | mandatory subtype, GlgParallType | null | null | null |
| TEXT | optional string, String, empty string | optional text subtype, GlgTextType, FIXED_TEXT | null | null |
| IMAGE | image filename, String, null | optional image subtype, GlgImageType, FIXED_IMAGE | null | null |
| GROUP ARRAY | optional element type, GlgContainerType, GLG_OBJECT | optional initial size, int, 0 | null | null |
| LIST | optional element type, GlgContainerType, GLG_OBJECT | null | null | null |
| VECTOR | optional element type, GlgContainerType, GLG_OBJECT | mandatory size, int | null | null |
| REFERENCE | mandatory template object (null for file references), GlgObject | optional referencing type, GlgReferenceType, SUBDRAWING_REF | null | null |
| SERIES | mandatory template object, GlgObject | optional path transformation of any type, GlgObject, translate xform | null | null |
| SQUARE_SERIES | mandatory template object, GlgObject | null | null | null |
| CONNECTOR | mandatory connector subtype (POLYGON or ARC), GlgObjectType | optional number of points for recta-linear path or 0, int, 2 | null | null |
| FRAME | mandatory frame subtype, GlgFrameType | mandatory frame factor, int | null | null |
| GIS | optional dataset file, String, null | null | null | null |
| DATA | mandatory data type (D, S or G), GlgDataType | optional string value (for S data only), String, null | null | null |
| ATTRIBUTE | mandatory data type (D, S or G), GlgDataType | mandatory attribute role, GlgRole | null | null |
| TAG | optional tag name, String, null | optional tag source, String, null | optional tag comment, String, null | null |
| XFORM | mandatory xform role, GlgRole | mandatory xform subtype, GlgXformType | Xform1 object for CONCATENATE_XF xforms or null, GlgObject, null | Xform2 object for CONCATENATE_XF xforms or null, GlgObject, null |
| ALIAS | optional alias name, String, null | optional resource path, String, null | null | null |
| HISTORY | optional resource name mask, String, null | null | optional entry point data type (D, S or G), GlgDataType, null | null |
| FONTTABLE | optional number of font types, int, Toolkit default | optional number of font sizes, int, Toolkit default | null | null |
| LINE_ATTR | optional line attributes subtype, GlgLineAttrType, LINE_NO_FILL | null | null | null |