|
GLG Toolkit, JavaScript Library
Version 4.6
|
This group contains miscellaneous utility methods. More...
This group contains miscellaneous utility methods.
Functions | |
| static void | Bell () |
| Emits an audio beep. More... | |
| static void | BellExt (double volume, double frequency, double duration) |
| Emits a beeping sound with the specified parameters. More... | |
| static String | ConcatResNames (String resource_name1, String resource_name2) |
| Creates a composite resource path from two components. More... | |
| static String | CreateIndexedName (String template_name, int resource_index) |
| Creates a string with a name of an enumerated resource. More... | |
| static boolean | EnableTimerXforms (boolean state) |
| ADVANCED: Enables or disables all timer transformations defined inside GLG drawings. More... | |
| boolean | Equals (GlgObject object) |
| Performs equality comparison between the object passed as the method parameter and the object the method is invoked on. More... | |
| static String | GetLibraryVersion () |
| Returns GLG API library version as a string. More... | |
| static boolean | GetModifierState (GlgModifierType modifier) |
| Returns the current state of a modifier. More... | |
| Object | GetNativeComponent (String resource_name, GlgComponentQueryType type) |
| ADVANCED: Returns a native component used to render the viewport. More... | |
| static GlgObject | GetReference (GlgObject object) |
| Creates a reference to a GlgObject that may be used outside of a callback function. More... | |
| static String | GetStackTraceAsString () |
| Returns current stack trace as a string. More... | |
| static boolean | IsDemo () |
| Queries the type of the GLG library. More... | |
| static boolean | ObjectsEqual (GlgObject object1, GlgObject object2) |
| Performs equality comparison between two GLG objects. More... | |
| static String | PrintfD (String format, double value) |
| C-style printf method for formatting double values. More... | |
| static String | PrintfI (String format, int value) |
| C-style printf method for formatting integer values. More... | |
| static String | PrintfS (String format, String value) |
| C-style printf method for formatting strings. More... | |
| static double | Rand (double low, double high) |
| Returns a random number in the specified range. More... | |
| static | ReleaseToCache (Object object) |
| ADVANCED: Releases an object to a cache for reuse, minimizing garbage collection. More... | |
| boolean | SetCursorType (String resource_name, GlgCursorType cursor_type) |
| Sets cursor for the viewport's drawing or one of its child viewports. More... | |
| void | SetFocus (String resource_name) |
| Sets the keyboard focus to the object's viewport. More... | |
| static void | ThrowExceptionOnError (boolean user_error, boolean internal_error, boolean detect_null_strings) |
| Controls throwing an exception on an error to assist debugging. More... | |
|
static |
Emits an audio beep.
See BellExt for more control over the audio beep parameters.
|
static |
Emits a beeping sound with the specified parameters.
The Bell method uses this method with the following parameters:
| volume | The sound volume. |
| frequency | The sound frequency. |
| duration | The sound duration in seconds. |
|
static |
Creates a composite resource path from two components.
This method is provided to mimic C/C++ API in cases when the C/C++ GLG code is converted to JavaScript.
| resource_name1 | Specifies the first resource path component. |
| resource_name2 | Specifies the second resource path component. |
This method creates and returns a resource path formed by concatenating the two components with the / character between them. The method checks if a trailing / separator is already present in the first string, and adds it only if the separator is not present.
Either argument may be null, in which case the returned string will precisely equal the input value of the other argument.
Examples
The following code:
produces the following output:
Multiple calls to ConcatResNames may be used to create composite paths from more than two components:
producing the following output:
|
static |
Creates a string with a name of an enumerated resource.
This method is provided to mimic C/C++ API in cases when the C/C++ GLG code is converted to JavaScript.
| template_name | A character string containing the template name to be expanded. This name uses the % character to define the expansion position. |
| resource_index | Specifies the number to use for expanding the % character in the template name. |
This method creates and returns a resource name by replacing the first (leftmost) occurrence of the % expansion character within the template name with the number corresponding to the resource_index parameter. If the template name does not contain the expansion character, the number is added to the end of the name.
Examples
The following code:
produces the following output:
CreateIndexedName may be used repeatedly if a template name has more than one expansion character. For example, the following code:
produces the following output:
|
static |
ADVANCED: Enables or disables all timer transformations defined inside GLG drawings.
This method may be used to temporarily disable time transformation in some advanced usage scenarios.
| state | The new enabled state. |
| boolean Equals | ( | GlgObject | object | ) |
Performs equality comparison between the object passed as the method parameter and the object the method is invoked on.
| object | The GlgObject to compare with. |
|
static |
Returns GLG API library version as a string.
The string uses the "N1.N2" format, where N1 is replaced with MAJOR_VERSION and N2 is replaced with MINOR_VERSION, for example, "4.5".
|
static |
Returns the current state of a modifier.
| modifier | Specifies the modifier to query, may be one of the following constants: |
| Object GetNativeComponent | ( | String | resource_name, |
| GlgComponentQueryType | type | ||
| ) |
ADVANCED: Returns a native component used to render the viewport.
The method provides an access to native components used to render the viewport, making it possible to set their native properties.
| resource_name | A resource path of a child viewport, or null to query the viewport the method is invoked on. The resource path is relative to the invoking object. |
| type | The type of a component to retrieve:
|
Creates a reference to a GlgObject that may be used outside of a callback function.
| object | GlgObject to reference. |
Any object obtained inside a callback without a call to a GLG method that returns an object is not valid outside of a callback. GetReference method should be used to assign such an object to a variable used outside the callback, as shown in the below example:
Note: The only exception from the above rule is a load callback: the loaded object is owned by the application code and can be stored in a variable that is used outside the callback.
|
static |
Returns current stack trace as a string.
|
static |
Queries the type of the GLG library.
Performs equality comparison between two GLG objects.
| object1 | The first object to check, may be null. |
| object2 | The second object to check, may be null. |
|
static |
C-style printf method for formatting double values.
| format | C-style format string. |
| value | Double value to be formatted. |
|
static |
C-style printf method for formatting integer values.
| format | C-style format string. |
| value | Integer value to be formatted. |
|
static |
C-style printf method for formatting strings.
| format | C-style format string. |
| value | String value to be formatted. |
|
static |
Returns a random number in the specified range.
| low | The low limit. |
| high | The high limit. |
|
static |
ADVANCED: Releases an object to a cache for reuse, minimizing garbage collection.
| object | An object to be released to the cache, must be an instance of GlgObject, GlgPoint, GlgCube, GlgInteger, GlgMatrixData, or GlgMinMax objects. |
The method can be used with any GlgObject, GlgPoint, GlgCube, GlgInteger, GlgMatrixData, or GlgMinMax objects that were obtained by a call to a GLG API method. It cannot be used with objects obtained inside callbacks and stored using an assignment operator without a call to a GLG method.
The method can yield performance improvements for applications with loops that invoke a large number of GLG methods returning GLG objects.
Since all GLG objects are wrappers around the internal representation of the GLG objects, releasing an instance of a wrapper to a cache does not affect the internal GLG object the wrapper represents.
The following examples demonstrate correct uses of the method:
The example below shows both valid and invalid uses of the method:
| boolean SetCursorType | ( | String | resource_name, |
| GlgCursorType | cursor_type | ||
| ) |
Sets cursor for the viewport's drawing or one of its child viewports.
| resource_name | A resource path of a child viewport, or null to set cursor for the viewport the method is invoked on. The resource path is relative to the invoking object. |
| cursor_type | One of the system cursor types to be used: |
The specified cursor will be used when the mouse moves inside the viewport the cursor is assigned to. The drawing's hierarchy must be set up in order to set cursor type.
| void SetFocus | ( | String | resource_name | ) |
Sets the keyboard focus to the object's viewport.
If the target object is a viewport, the focus is set to this viewport, otherwise the focus is set to the target object's parent viewport.
| resource_name | A resource path of a target child object, or null to use the object the method is invoked on. The resource path is relative to the invoking object. |
|
static |
Controls throwing an exception on an error to assist debugging.
| user_error | Set to true to throw exceptions on application errors, such as "Can't find resource". |
| internal_error | Set to true to throw exceptions on internal GLG errors. |
| detect_null_strings | Set to true to detect null strings being used as values of resources that are GLG data objects of S (String) type. Setting values of these attributes to null strings causes exceptions much later, when the objects are drawn. Setting this parameter to true makes it possible to detect such errors right at the line of code where the resource value is set. |