Search in sources :

Example 1 with GraphNode

use of org.eclipse.gef4.zest.core.widgets.GraphNode in project netxms by netxms.

the class AbstractNetworkMapView method updateObjectPositions.

/**
 * Update stored object positions with actual positions read from graph control
 */
protected void updateObjectPositions() {
    Graph graph = viewer.getGraphControl();
    List<?> nodes = graph.getNodes();
    for (Object o : nodes) {
        if (o instanceof GraphNode) {
            Object data = ((GraphNode) o).getData();
            if (data instanceof NetworkMapElement) {
                Point loc = ((GraphNode) o).getLocation();
                Dimension size = ((GraphNode) o).getSize();
                ((NetworkMapElement) data).setLocation(loc.x + (size.width + 1) / 2, loc.y + (size.height + 1) / 2);
            }
        }
    }
}
Also used : Graph(org.eclipse.gef4.zest.core.widgets.Graph) NetworkMapElement(org.netxms.client.maps.elements.NetworkMapElement) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) AbstractObject(org.netxms.client.objects.AbstractObject) GraphNode(org.eclipse.gef4.zest.core.widgets.GraphNode) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension)

Aggregations

Dimension (org.eclipse.draw2d.geometry.Dimension)1 Point (org.eclipse.draw2d.geometry.Point)1 Graph (org.eclipse.gef4.zest.core.widgets.Graph)1 GraphNode (org.eclipse.gef4.zest.core.widgets.GraphNode)1 NetworkMapElement (org.netxms.client.maps.elements.NetworkMapElement)1 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)1 AbstractObject (org.netxms.client.objects.AbstractObject)1