DroidDiagram Programmer's Guide
DiagramItem.query Method
See Also
 






Returns the items that can be reached from this item by following the path specified in the given query expression.

Namespace: com.mindfusion.diagramming
Package: com.mindfusion.diagramming

 Syntax

Java  Copy Code

public DiagramItemList query (
    String query
)

 Parameters

query

A query expression consisting of selectors and boolean predicates.

 Return Value

A DiagramItemList collection of the found items.

 Remarks

The query string consists of selectors, where each selector specifies the next items that should be selected starting from the current one.

The following selectors can be applied to a node:

links

Selects all links connected to the current node

inlinks

Selects the incoming links of the current node

outlinks

Selects the outgoing links of the current node

parent

Selects the parent item of the current node if it is in a group

children

Selects the child nodes of the current node if it is in a group

The following selectors can be applied to a link:

nodes

Selects the two nodes connected by the current link

origin

Selects the Origin node of the current link

destination

Selects the Destination node of the current link

children

Selects the child nodes of the current link if it is in a group.

Selectors must be separated by the / character. The results returned by a selector can be also filtered using a predicate expression, enclosed in square brackets after the selector name. The predicate expression can include C# like boolean and arithmetic operators, and one of the following property identifiers:

tag

Returns the value of the Tag property.

text

Returns the value of the Text property.

weight

Returns the value of the Weight property.

 Example

The following code selects nodes two levels below the current one in a tree or layered graph.

Java  Copy Code

DiagramItemList items = diagram.getActiveItem().query(
    "outlinks/destination/outlinks/destination");
diagram.getSelection().clear();
for (DiagramItem item : items)
    item.setSelected(true);

The following code finds the neighbors of the currently selected node that can be reached from it by following links with Weight greater than 3.

Java  Copy Code

DiagramItemList items = diagram.getActiveItem().query(
 "outlinks[weight>3]/destination");

The following example finds the destination nodes of links labeled "exception" going out of children of the current node's group.

Java  Copy Code
DiagramItemList items = diagram.getActiveItem().query(
    "children/outlinks[text==\"exception\"]/destination");

 See Also

DiagramItem Members
DiagramItem Class
com.mindfusion.diagramming Namespace
getIncomingLinks Method
getOutgoingLinks Method
getMasterGroup Method
getSubordinateGroup Method