The purpose of the manager is to manage a large set of
graphic objects. Each graphic object can be managed by only one manager
at a time, which means that you cannot add the same graphic object
to two different managers.
The following methods allow you to add a graphic object
to a manager.
void addObject(IlvGraphic obj, int layer, boolean redraw)
void addObject(IlvGraphic obj, boolean redraw)
The following example creates a rectangle object and
adds it to a manager:
IlvManager mgr = new IlvManager();
IlvGraphic obj = new IlvRectangle(new IlvRect(10,10,100,100));
mgr.addObject(obj, false);
The second addObject
method
does not specify the layer where the object must be inserted. The
reason for this is that there is a default insertion layer which allows
you to add objects without specifying the layer at every call. The
initial value for the default insertion layer is 0 but it can be modified
using the following methods:
int getInsertionLayer()
void setInsertionLayer(int layer)
Once an object has been added to a manager, you can remove
it with:
void removeObject(IlvGraphic obj, boolean redraw)
You can also remove the objects from the manager or from
a specific layer using one of the following methods:
void deleteAll(boolean redraw)
void deleteAll(int layer, boolean redraw)
The following method can be used to know whether a graphic
object is managed by the current manager:
boolean isManaged(IlvGraphic obj)
You can access all the objects of the manager or of a
specified layer using one of the following methods:
IlvGraphicEnumeration getObjects()
IlvGraphicEnumeration getObjects(int layer)
These methods return an IlvGraphicEnumeration
object
facilitating the enumeration of the contents of the manager (or layer).
You may use it in the following manner:
IlvGraphicEnumeration objects = manager.getObjects();
IlvGraphic obj;
while(objects.hasMoreElements()) {
obj = objects.nextElement();
//perform some action
}
Note
When stepping through the contents of the manager
(or layer) by means of an enumeration, you must not modify the contents
of the manager by adding or removing objects or layers. Doing so may
lead to unpredictable results.
Other useful methods will give you the number of objects
in the manager or in a layer:
int getCardinal()
int getCardinal(int layer)