|
GLG Toolkit, Java Class Library
Version 4.6
|
This group contains methods for adding and deleting objects from a Container.
These methods may be used to add objects or popup dialogs to the drawing at run time, well as adding points to a polygon.
The Container Methods of the Intermediate API may be used to access elements of a container.
The following files in the GLG installation directory provide examples of using container methods of the Extended API:
Functions | |
| boolean | AddObject (Object object, GlgAccessType access_type, GlgPositionModifier pos_modifier) |
| A generic method for adding an object to the container. More... | |
| boolean | AddObjectAt (Object object, int index) |
| Adds an object at the specified position inside the container. More... | |
| boolean | AddObjectToBottom (Object object) |
| Adds an object at the end of the container. More... | |
| boolean | AddObjectToTop (Object object) |
| Adds an object at the beginning of the container. More... | |
| boolean | DeleteBottomObject () |
| Deletes an object from the bottom of the container. More... | |
| boolean | DeleteObject (GlgAccessType access_type, GlgPositionModifier pos_modifier, boolean replace_element, Object replace_obj) |
| A generic method for deleting an object from the container. More... | |
| boolean | DeleteObject (Object object) |
| Finds and deletes an object from the container. More... | |
| boolean | DeleteObjectAt (int index) |
| Deletes an object from the specified position in the container. More... | |
| boolean | DeleteTopObject () |
| Deletes an object from the beginning of the container. More... | |
| void | Flush (int size) |
| Set the size of the container object. More... | |
| boolean | SetElement (int index, Object new_object) |
| Replaces the object at the specified position in the container. More... | |
| boolean AddObject | ( | Object | object, |
| GlgAccessType | access_type, | ||
| GlgPositionModifier | pos_modifier | ||
| ) |
A generic method for adding an object to the container.
| object | The object to be added. |
| access_type | The position at which the object is inserted:
|
| pos_modifier | Is used only with the CURRENT access type to control where the object is added (use 0 for other access types):
|
A container object keeps an internal current position pointer, which is set by a successful call to a method that accesses an element, such as GetElement, GetIndex, GetNamedObject, GetStringIndex or ContainsObject.
For a call to AddObject immediately following the call to one of the element access methods, the pos_modifier parameter defines where to add the new object: right before or right after the object pointed to by the current position.
The position modifier also defines how the insert position defined by the current position pointer is adjusted after the insertion:
This allows you to call AddObject repeatedly after an initial call to one of the element access methods.
For example, the following sequence of calls adds three objects before the target_object:
The following sequence adds three objects after the target_object:
Note: Any method calls that access, add or delete elements of the container may affect its current position pointer. The current position pointer must be used immediately after the method call that accesses a container's element.
| boolean AddObjectAt | ( | Object | object, |
| int | index | ||
| ) |
Adds an object at the specified position inside the container.
| object | The object to be added. |
| index | The position in a container. |
This method can be used to add objects to the drawing at run time. If the method is invoked on a viewport or a group inside a viewport, you may add any graphical object to it. An attempt to add a non-graphical object to a viewport or a group inside a viewport will generate an error message.
The method can be invoked on a polygon object to add points to it. An attempt to add an object different from a point (an Attribute object of a G (geometrical) data type) to a polygon will generate an error message.
The method can also be invoked on a GIS Object object to add dynamic icons to be displayed on top of the map in lat/lon coordinates.
Objects at the end (the bottom) of the container are drawn last and will appear in front of other objects.
Note: For viewports with integrated scrolling enabled by the viewport's Pan attribute, child viewport objects added to the bottom of the viewport object list will appear in front of the integrated scrollbars until the viewport is reset. Other graphical objects added to the bottom of the container will also appear on top of the integrated scrollbars that use light viewports. Resetting the viewport reorders the scrollbars to be the last in the object list. To achieve proper rendering without resetting the viewport, use AddObjectAt to add the child viewport at a proper position before the integrated scrollbars. If a single X or Y scrollbar is used, the position index will be list_size - 1, where list_size is the number of objects in the viewport. If both X and Y scrollbars are active, list_size - 3 position should be used.
| boolean AddObjectToBottom | ( | Object | object | ) |
Adds an object at the end of the container.
| object | The object to be added. |
This method can be used to add objects to the drawing at run time. If the method is invoked on a viewport or a group inside a viewport, you may add any graphical object to it. An attempt to add a non-graphical object to a viewport or a group inside a viewport will generate an error message.
The method can be invoked on a polygon object to add points to it. An attempt to add an object different from a point (an Attribute object of a G (geometrical) data type) to a polygon will generate an error message.
The method can also be invoked on a GIS Object object to add dynamic icons to be displayed on top of the map in lat/lon coordinates.
Objects at the end (the bottom) of the container are drawn last and will appear in front of other objects.
Note: For viewports with integrated scrolling enabled by the viewport's Pan attribute, child viewport objects added to the bottom of the viewport object list will appear in front of the integrated scrollbars until the viewport is reset. Other graphical objects added to the bottom of the container will also appear on top of the integrated scrollbars that use light viewports. Resetting the viewport reorders the scrollbars to be the last in the object list. To achieve proper rendering without resetting the viewport, use AddObjectAt to add the child viewport at a proper position before the integrated scrollbars. If a single X or Y scrollbar is used, the position index will be list_size - 1, where list_size is the number of objects in the viewport. If both X and Y scrollbars are active, list_size - 3 position should be used.
| boolean AddObjectToTop | ( | Object | object | ) |
Adds an object at the beginning of the container.
| object | The object to be added. |
This method can be used to add objects to the drawing at run time. If the method is invoked on a viewport or a group inside a viewport, you may add any graphical object to it. An attempt to add a non-graphical object to a viewport or a group inside a viewport will generate an error message.
The method can be invoked on a polygon object to add points to it. An attempt to add an object different from a point (an Attribute object of a G (geometrical) data type) to a polygon will generate an error message.
The method can also be invoked on a GIS Object object to add dynamic icons to be displayed on top of the map in lat/lon coordinates.
Objects at the beginning (the top) of the container are drawn first and will appear behind of other objects.
| boolean DeleteBottomObject | ( | ) |
Deletes an object from the bottom of the container.
Note: For viewports with integrated scrolling enabled by the viewport's Pan attribute, the last object in the viewport is one of the integrated scrollbars. Use DeleteObject to avoid interfering with the viewport's integrated scrollbars.
| boolean DeleteObject | ( | GlgAccessType | access_type, |
| GlgPositionModifier | pos_modifier, | ||
| boolean | replace_element, | ||
| Object | replace_obj | ||
| ) |
A generic method for deleting an object from the container.
| access_type | The position of the object to be deleted:
|
| pos_modifier | Is used only with the CURRENT access type to define how to adjust the current position after the delete operation, use 0 for other access types. This parameter allows to use the method repeatedly to delete several objects before or after the object defined by the current position:
|
| replace_element |
|
| replace_obj | The object to replace the targeted element with if replace_element=true. |
A container object keeps an internal current position pointer, which is set by a successful call to a method that accesses an element, such as GetElement, GetIndex, GetNamedObject, GetStringIndex or ContainsObject.
For example, the following sequence of calls deletes target_object and the two objects after it:
The following sequence deletes the target_object and the two objects before it:
Note: Any method calls that access, add or delete elements of the container may affect its current position pointer. The current position pointer must be used immediately after the method call that accesses a container's element.
| boolean DeleteObject | ( | Object | object | ) |
Finds and deletes an object from the container.
| object | An object to be deleted. |
| boolean DeleteObjectAt | ( | int | index | ) |
Deletes an object from the specified position in the container.
| index | An index of the object to be deleted. |
| boolean DeleteTopObject | ( | ) |
Deletes an object from the beginning of the container.
| void Flush | ( | int | size | ) |
Set the size of the container object.
| size | The new size. |
This method sets the container size to the requested size. If the new size is less than the current container size, extra elements are removed. If the new size is greater than the current size, the method adds elements by making a copy of the last element in the container.
The method can only be invoked if the container has not been set up. If the container has been set up (drawn), the method must be surrounded by the SuspendObject and ReleaseObject calls.
| boolean SetElement | ( | int | index, |
| Object | new_object | ||
| ) |
Replaces the object at the specified position in the container.
| index | An index of the element to be modified. |
| new_object | A new element value. |