public class IlvManagerLayer extends IlvIndexedSet implements IlvPersistentObject
IlvManagerLayer
is a storage class for graphic objects;
an IlvManager
instance is composed of several layers.
Objects stored in a higher screen layer are displayed in front of objects in lower layers, that is, a layer with the number N is placed in front of layers with numbers from N-1 to zero.
Each graphic object stored in a layer is unique to that layer and can be stored only in that layer. Each layer, as well as its graphic objects, is unique to a single manager and can only be controlled by this manager.
Note: manipulation of layers and the graphic objects
they contain is normally done through IlvManager
and
IlvManagerView
instances.
You control the visibility and selection for all objects contained
in a layer by calling
setVisible
and setSelectable
. Objects
that cannot be selected cannot be modified.
A visible layer can be temporarily hidden depending on specific conditions
such as the zoom factor. This is done using an
IlvLayerVisibilityFilter
instance that is called when the
IlvManager
containing this layer needs to redraw a layer.
To be active, this filter must be registered by calling
addVisibilityFilter
.
Layers are controlled by the manager or manager view that contains them.
To add new layers to a manager, call
addObject
and specify the layer in which you want to place the graphic object.
By default, a manager has one layer only, using addObject
new
layers are added automatically when a new graphic object is added to a layer
that does not currently exist.
IlvGraphic obj; IlvManager manager = new IlvManager(); ... obj = new IlvRectangle(new IlvRect(70,40,50,50), false, true); // Add obj to layer six and redraw the manager. // New layers are added automatically. manager.addObject(obj, 6, true); IlvManagerView view = new IlvManagerView(manager); view.setBackground(Color.RED); JFrame frame = new JFrame("IlvManagerExample"); frame.getContentPane().add(view); ...The visibility of all objects in a manager layer for a specific view is controlled by calling
IlvManager.setVisible
.
manager.setVisible(view,2,false,true);
One use of layers is to display a static background on top of
which "live" graphic objects are drawn and manipulated by the user.
Using triple buffering, background layers are drawn in an additional
off-screen image, this image is used instead of redrawing the background
graphic objects to speed up your application. Triple buffering is activated
by calling
setTripleBufferedLayerCount(int)
.
Constructor and Description |
---|
IlvManagerLayer()
Creates a new layer.
|
IlvManagerLayer(IlvInputStream stream)
Reads the layer from an
IlvInputStream . |
IlvManagerLayer(int maxInNode,
int maxInList)
Creates a new layer.
|
Modifier and Type | Method and Description |
---|---|
void |
addVisibilityFilter(IlvLayerVisibilityFilter filter)
Adds a visibility filter.
|
IlvRect |
computeBBox(IlvTransformer t)
Returns the bounding rectangle of the layer when
it is drawn with the specified transformer.
|
protected void |
draw(Graphics dst,
IlvManagerView view)
Draws the layer in a view of a manager.
|
protected void |
drawImpl(Graphics dst,
IlvManagerView view)
Draws the layer in a view of a manager.
|
float |
getAlpha()
Returns the alpha value of this layer.
|
int |
getIndex()
Returns the index of the layer in the manager.
|
IlvManager |
getManager()
Returns the manager to which this layer belongs.
|
String |
getName()
Returns the name of the layer.
|
IlvNamedProperty |
getNamedProperty(String name)
Returns the named property associated with this layer having
the specified name.
|
Object |
getProperty(String key)
Returns the value of a property.
|
Enumeration |
getVisibilityFilters()
Returns an enumeration of all installed
visibility filters.
|
boolean |
isSelectable()
Returns
true if the layer is selectable. |
protected boolean |
isTemporarilyHidden(IlvManagerView view) |
boolean |
isVisible()
Returns
true if the layer is visible in the manager. |
boolean |
isVisible(IlvManagerView view)
Returns
true if the layer is visible in the specified view. |
void |
print(Graphics dst,
IlvRect area,
IlvTransformer t)
Prints the layer with a specified transformer.
|
void |
removeNamedProperty(String name)
Removes the named property associated with this layer having
the specified name.
|
void |
removeVisibilityFilter(IlvLayerVisibilityFilter filter)
Removes an installed visibility filter.
|
void |
setAlpha(float alpha)
Changes the alpha value of this layer.
|
protected void |
setManager(IlvManager manager)
Sets the manager to which this layer will belong.
|
void |
setName(String name)
Sets the name of the layer.
|
IlvNamedProperty |
setNamedProperty(IlvNamedProperty property)
Associates a named property with the layer.
|
void |
setProperty(String key,
Object value)
Sets the value of a property.
|
void |
write(IlvOutputStream stream)
Writes the layer to an output stream.
|
void |
writeIt(IlvOutputStream stream)
Stores the content of the manager layer
to an
IlvOutputStream . |
addObject, afterUpdate, beforeUpdate, collectObjects, collectSelectableObjects, deleteAll, getCardinal, getElements, getIndex, getManagers, getManagersCount, getObject, getObject, getSelectableObject, getSubsequentRemoveThreshold, isQuadtreeEnabled, isZOrdering, map, mapInside, mapInside, mapIntersects, mapIntersects, removeObject, setIndex, SetInitialNumberOfNonZoomablesCapacity, SetInitialNumberOfObjectsCapacity, setQuadtreeEnabled, setSubsequentRemoveThreshold, setZOrdering
public IlvManagerLayer()
IlvManager.addLayer
method to
add it in the manager.public IlvManagerLayer(int maxInNode, int maxInList)
IlvManager.addLayer
method to
add it in the manager.maxInNode
- The maximum number of objects in a
quadtree node before the quadtree node divides itself
into 4 quadrants.maxInList
- The maximum number of objects in the layer
before the layer starts using a quadtree for the storage of
objects.IlvManager.addLayer(ilog.views.IlvManagerLayer, int)
public IlvManagerLayer(IlvInputStream stream) throws IlvReadFileException
IlvInputStream
.
You should use this constructor only when defining a
new class of layer. The default implementation does nothing.stream
- The input stream.IlvReadFileException
- if the format is not correct.public final IlvManager getManager()
null
if this layer has not been added to a manager.protected void setManager(IlvManager manager)
manager
- The manager to which this layer will belong.public final int getIndex()
public final boolean isSelectable()
true
if the layer is selectable.
The graphic objects contained in a non-selectable layer:
IlvSelectInteractor
.
IlvMakeRectangleInteractor
and
IlvMakeArcInteractor
in
the ilog.views.interactor
package.
public void setAlpha(float alpha)
alpha
- The new transparency level in the range [0.0, 1.0].getAlpha()
public float getAlpha()
setAlpha(float)
public final void addVisibilityFilter(IlvLayerVisibilityFilter filter)
public final void removeVisibilityFilter(IlvLayerVisibilityFilter filter)
public final Enumeration getVisibilityFilters()
IlvLayerVisibilityFilter
.addVisibilityFilter(ilog.views.IlvLayerVisibilityFilter)
,
removeVisibilityFilter(ilog.views.IlvLayerVisibilityFilter)
public final boolean isVisible()
true
if the layer is visible in the manager.
Note that even if this method returns true
,
the layer may not appear in a view. The layer can be
set invisible for a particular view.isVisible(ilog.views.IlvManagerView)
public boolean isVisible(IlvManagerView view)
true
if the layer is visible in the specified view.
This method checks the visibility of the layer itself, the visibility of
the layer for the specified view, and then calls the visibility filters.view
- The view of the manager.public final void setProperty(String key, Object value)
value
is null
, the property is removed.
Otherwise the property value is set to value
.key
- The key string for this property.value
- The new value of this property.public final Object getProperty(String key)
null
if the property does not exist.public void print(Graphics dst, IlvRect area, IlvTransformer t)
dst
- The graphics.area
- The rectangle of the layer to print in the manager
coordinate system.t
- The transformer used to print the content.protected final boolean isTemporarilyHidden(IlvManagerView view)
protected void draw(Graphics dst, IlvManagerView view)
The actual method that draws the layer content is
drawImpl(Graphics, IlvManagerView)
. Subclasses can override
this method to implement a specialized drawing for the layer.
dst
- The Graphics
to draw.view
- The view of the manager.IlvManagerView.setLayerCached(int, boolean)
protected void drawImpl(Graphics dst, IlvManagerView view)
draw(Graphics, IlvManagerView)
.
Subclasses can override this method to implement a specialized
drawing for the layer.dst
- The destination with or without the clip being set.view
- The manager view.draw(Graphics, IlvManagerView)
public IlvRect computeBBox(IlvTransformer t)
isVisible()
),
the method returns an empty rectangle (x
,
y
, width
, and height
equal to 0
).computeBBox
in class IlvIndexedSet
t
- The transformer.public void setName(String name)
name
- The name of the layer.getName()
public String getName()
setName(java.lang.String)
public final IlvNamedProperty setNamedProperty(IlvNamedProperty property)
property
- The named property to associate.null
otherwise.public final IlvNamedProperty getNamedProperty(String name)
null
if no such property
exists.name
- The name of property.public final void removeNamedProperty(String name)
name
- The name of the property.public void write(IlvOutputStream stream) throws IOException
IlvManagerLayer
to store your
own information. If you override the method, you
may call super.write(stream)
after
your own saving instructions. Calling the superclass method
will dump the graphic objects stored in the layer.write
in interface IlvPersistentObject
stream
- the output streamIOException
- thrown when an exception occurs during
the write operation for this object.public final void writeIt(IlvOutputStream stream) throws IOException
IlvOutputStream
.
You should not call this method directly.
This method is public for implementation purposes.IOException
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.