ilog.views.maps.beans
Class IlvMapLayerTreeModel

java.lang.Object
  extended by javax.swing.tree.DefaultTreeModel
      extended by ilog.views.maps.beans.IlvMapLayerTreeModel
All Implemented Interfaces:
IlvPersistentObject, Serializable, TreeModel

public class IlvMapLayerTreeModel
extends DefaultTreeModel
implements IlvPersistentObject

IlvMapLayerTreeModel is a TreeModel that has been specialized to handle IlvMapLayerTreeNode objects. A data source model can be attached to an IlvManager instance through an IlvMapLayerTreeProperty object in order to be saved in an .ivl file. The following code example shows how to retrieve the data source model from an IlvManager object and inserts a data source.

 IlvMapLayerTreeModel model = IlvMapLayerTreeProperty
                .GetMapLayerTreeModel(manager);
 IlvMapLayer layer = new IlvMapLayer();
 IlvMapLayerTreeNode node = new IlvMapLayerTreeNode(layer);
 model.insertNodeInto(node, pnode, pnode.getChildCount());
 

Since:
JViews 7.5
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
 
Constructor Summary
IlvMapLayerTreeModel()
          Constructs an empty IlvMapLayerTreeModel instance.
IlvMapLayerTreeModel(IlvInputStream stream)
          Reads an IlvMapLayerTreeModel object from an IlvInputStream.
 
Method Summary
 void activateListener(boolean activate)
          Activate or deactivates the TreeModelListener.
 void addChild(IlvMapLayer parent, IlvMapLayer layer)
          Adds layer as the last child of parent.
 void addChild(IlvMapLayer parent, IlvMapLayer layer, int idx)
          Adds a child layer to a parent layer.
 void arrangeLayers()
          Arranges the IlvManagerLayer objects in this model so that they match the order returned by calling getEnumeration.
 void clear()
          Clears this model from the root.
 void clearAllObjects()
          Removes all IlvGraphic objects from this model.
 IlvMapLayer findChildLayer(IlvMapLayer parent, String name)
          Returns the child object with a specific name from an IlvMapLayer instance.
protected  void fireTreeNodesChanged(Object source, Object[] path, int[] childIndices, Object[] children)
          
protected  void fireTreeNodesInserted(Object source, Object[] path, int[] childIndices, Object[] children)
          
protected  void fireTreeNodesRemoved(Object source, Object[] path, int[] childIndices, Object[] children)
          
protected  void fireTreeStructureChanged(Object source, Object[] path, int[] childIndices, Object[] children)
          
 Enumeration getCheckedNodes()
          Retrieves an enumeration of all the checked nodes contained in this model.
 Object getChild(Object parent, int index)
          The child object at a specific index in the parent object.
 int getChildCount(Object parent)
          Returns the number of child objects for parent.
 IlvMapLayer[] getChildren(IlvMapLayer layer)
          Returns the array of the children of the specified IlvMapLayer instance.
 Enumeration getEnumeration()
          Retrieves an enumeration of all the nodes contained in this model.
 IlvManager getManager()
          Returns the IlvManager object attached to this model.
 IlvMapLayer getMapLayer(Object o)
          Returns the IlvMapLayer object from the specified IlvMapLayerTreeNode instance.
 IlvMapLayer getParent(IlvMapLayer layer)
          Returns the parent object of the specified layer.
 IlvMapLayerTreeNode getTreeNode(IlvMapLayer layer)
          Returns the IlvMapLayerTreeNode object attached to the specified IlvMapLayer instance.
 boolean isAutoRearrange()
          Returns true if rearrange layers is allowed to change the manager layer order.
 void nodeChanged(IlvMapLayer layer)
          Calls the nodeChanged method of the IlvMapLayerTreeNode object attached to the specified IlvMapLayer instance.
 void nodeStructureChanged(IlvMapLayer layer)
          Calls the nodeStructureChanged method of the IlvMapLayerTreeNode instance attached to the specified IlvMapLayer object.
 void orderLayer(IlvMapLayer l1, IlvMapLayer l2, boolean after)
          Orders the specified IlvMapLayer objects.
 void reload(IlvMapLayer layer)
          Calls the reload method of the IlvMapLayerTreeNode object attached to the specified IlvMapLayer instance.
 boolean removeChild(IlvMapLayer layer)
          Removes the specified child object from its parent.
 void setAutoRearrange(boolean autoRearrange)
          Indicates if rearrange layers is allowed to change the manager layer order.
 void setManager(IlvManager manager)
          Sets the IlvManager object for this model.
 void write(IlvOutputStream stream)
          Write this model to an IlvOutputStream.
 
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvMapLayerTreeModel

public IlvMapLayerTreeModel(IlvInputStream stream)
                     throws IlvReadFileException
Reads an IlvMapLayerTreeModel object from an IlvInputStream.

Parameters:
stream - The stream to read from.
Throws:
IlvReadFileException - if there is a problem reading from stream.

IlvMapLayerTreeModel

public IlvMapLayerTreeModel()
Constructs an empty IlvMapLayerTreeModel instance.

Method Detail

fireTreeNodesInserted

protected void fireTreeNodesInserted(Object source,
                                     Object[] path,
                                     int[] childIndices,
                                     Object[] children)

Overrides:
fireTreeNodesInserted in class DefaultTreeModel
Since:
JViews 8.0

fireTreeNodesChanged

protected void fireTreeNodesChanged(Object source,
                                    Object[] path,
                                    int[] childIndices,
                                    Object[] children)

Overrides:
fireTreeNodesChanged in class DefaultTreeModel
Since:
JViews 8.0

fireTreeNodesRemoved

protected void fireTreeNodesRemoved(Object source,
                                    Object[] path,
                                    int[] childIndices,
                                    Object[] children)

Overrides:
fireTreeNodesRemoved in class DefaultTreeModel
Since:
JViews 8.0

fireTreeStructureChanged

protected void fireTreeStructureChanged(Object source,
                                        Object[] path,
                                        int[] childIndices,
                                        Object[] children)

Overrides:
fireTreeStructureChanged in class DefaultTreeModel
Since:
JViews 8.0

setManager

public void setManager(IlvManager manager)
Sets the IlvManager object for this model.

Parameters:
manager - The manager.

getManager

public IlvManager getManager()
Returns the IlvManager object attached to this model.

Returns:
The IlvManager object attached to this model.

getEnumeration

public Enumeration getEnumeration()
Retrieves an enumeration of all the nodes contained in this model.

Returns:
A preordered Enumeration object from the root.

getCheckedNodes

public Enumeration getCheckedNodes()
Retrieves an enumeration of all the checked nodes contained in this model.

Returns:
A preordered Enumeration object from the root containing all the checked nodes.

nodeChanged

public void nodeChanged(IlvMapLayer layer)
Calls the nodeChanged method of the IlvMapLayerTreeNode object attached to the specified IlvMapLayer instance.

Parameters:
layer - The specified IlvMapLayer instance.

reload

public void reload(IlvMapLayer layer)
Calls the reload method of the IlvMapLayerTreeNode object attached to the specified IlvMapLayer instance.

Parameters:
layer - The specified IlvMapLayer instance.

nodeStructureChanged

public void nodeStructureChanged(IlvMapLayer layer)
Calls the nodeStructureChanged method of the IlvMapLayerTreeNode instance attached to the specified IlvMapLayer object.

Parameters:
layer - The specified IlvMapLayer object.

addChild

public void addChild(IlvMapLayer parent,
                     IlvMapLayer layer)
Adds layer as the last child of parent. If parent is null, the child is added to the root.

Parameters:
parent - The parent to add a child to.
layer - The child to add.

addChild

public void addChild(IlvMapLayer parent,
                     IlvMapLayer layer,
                     int idx)
Adds a child layer to a parent layer. Adds layer as the idxth child of parent. If parent is null, the child is added to the root.

Parameters:
parent - The parent to add a child to.
layer - The child to add.
idx - The index where the layer should be inserted. Set to -1 to insert layer at the end.
Since:
JViews 8.1

removeChild

public boolean removeChild(IlvMapLayer layer)
Removes the specified child object from its parent.

Parameters:
layer - The IlvMapLayer object to detach from its parent.
Returns:
If the operation succeeded, true is returned.

getMapLayer

public IlvMapLayer getMapLayer(Object o)
Returns the IlvMapLayer object from the specified IlvMapLayerTreeNode instance. If o is not an IlvMapLayerTreeNode instance, or if the user object of the IlvMapLayerTreeNode instance is not an IlvMapLayer object, null is returned.

Parameters:
o - The IlvMapLayerTreeNode instance from which to retrieve the layer.
Returns:
The IlvMapLayer object or null.

getChildren

public IlvMapLayer[] getChildren(IlvMapLayer layer)
Returns the array of the children of the specified IlvMapLayer instance.

Parameters:
layer - The layer from which to retrieve the children.
Returns:
An array, possibly empty, of the children of layer.

getParent

public IlvMapLayer getParent(IlvMapLayer layer)
Returns the parent object of the specified layer.

Parameters:
layer - The layer from which to retrieve the parent object.
Returns:
The parent object of the specified layer.

activateListener

public void activateListener(boolean activate)
Activate or deactivates the TreeModelListener.

Parameters:
activate - Set to true to activate the listener.

orderLayer

public void orderLayer(IlvMapLayer l1,
                       IlvMapLayer l2,
                       boolean after)
Orders the specified IlvMapLayer objects.

Parameters:
l1 - The first IlvMapLayer object.
l2 - The second IlvMapLayer object.
after - Specifies if l1 should be placed before or after l2.
Throws:
IllegalArgumentException - if l1 and l2 do not have the same parent object.

clear

public void clear()
Clears this model from the root.


clearAllObjects

public void clearAllObjects()
Removes all IlvGraphic objects from this model.


arrangeLayers

public void arrangeLayers()
Arranges the IlvManagerLayer objects in this model so that they match the order returned by calling getEnumeration.


write

public void write(IlvOutputStream stream)
           throws IOException
Write this model to an IlvOutputStream.

Specified by:
write in interface IlvPersistentObject
Parameters:
stream - The stream to write to.
Throws:
IOException - if there is a problem writing to stream.

getTreeNode

public IlvMapLayerTreeNode getTreeNode(IlvMapLayer layer)
Returns the IlvMapLayerTreeNode object attached to the specified IlvMapLayer instance.

Parameters:
layer - The specified IlvMapLayer instance.
Returns:
The corresponding IlvMapLayerTreeNode object.

findChildLayer

public IlvMapLayer findChildLayer(IlvMapLayer parent,
                                  String name)
Returns the child object with a specific name from an IlvMapLayer instance.

Parameters:
parent - The parent IlvMapLayer object.
name - The name of the layer to find.
Returns:
The IlvMapLayer instance, child of parent, whose name is name.

getChild

public Object getChild(Object parent,
                       int index)
The child object at a specific index in the parent object.

Specified by:
getChild in interface TreeModel
Overrides:
getChild in class DefaultTreeModel
Returns:
The child of parent at index in the parent objects child array.
See Also:
DefaultTreeModel.getChild(java.lang.Object, int)

getChildCount

public int getChildCount(Object parent)
Returns the number of child objects for parent.

Specified by:
getChildCount in interface TreeModel
Overrides:
getChildCount in class DefaultTreeModel
Returns:
The number of child objects for parent.
See Also:
DefaultTreeModel.getChildCount(java.lang.Object)

isAutoRearrange

public boolean isAutoRearrange()
Returns true if rearrange layers is allowed to change the manager layer order.

Returns:
If rearrange layers is allowed to change the manager layer order, true is returned.

setAutoRearrange

public void setAutoRearrange(boolean autoRearrange)
Indicates if rearrange layers is allowed to change the manager layer order. The default value is true.

Note: this property is not persistent.

Parameters:
autoRearrange - Set to false to prevent rearranging of the manager layer order.


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.