Geometry Association

In this section, you will learn how to associate or apply a Geometry to a node or edge. We use the same source code as in the previous example.

Example 5.6. Applying a user-defined geometry

try
{
  GeometryService.loadGeometriesFromResource(
      RESOURCE_PATH + "geometry.xml", this.getClass());
  
  GeometryDescriptor gDesc = 
      GeometryPool.get("AppLabelGeometryDescriptor");
  
  VisualNode visualNode = 
      graphView.getVisualNodeByID(nodeA.getID());
    
  visualNode.getBaseComposite().applyGeometry(gDesc);
}
catch(Exception e)
{
  e.printStackTrace();
}

The source code in bold shows you how to obtain a named GeometryDescriptor instance from the pool and apply that instance to a particular VisualNode via its embedded BaseComposite member. Please see the javadocs for more information about this and other composite interfaces, which are responsible for the runtime graphical representation of all visual elements.