How do I add or redefine shapes within ShapeNodeRealizer? |
| Applies to: yFiles 2.4, yFiles 2.3, yFiles 2.2 |
Type: Questions & Answers
Categories this article belongs to:
| yFiles for Java | > yFiles Viewer | > Displaying and Editing Graphs | > Bringing Graph Elements to Life: The Realizer Concept |
Describes how to add custom shapes to the ShapeNodeRealizer
.
To add your own shapes to ShapeNodeRealizer is demonstrated by the yFiles demo demo/view/StateNodeRealizer.java. To redefine the appearance of an already given shape like HEXAGON is done by overriding method setShapeType. Currently both procedures involve the subclassing of ShapeNodeRealizer. Within setShapeType the original HEXAGON shape is constructed this way:
GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD,6); path.moveTo((float)(x),(float)(y+height/2.0)); path.lineTo((float)(x+width*0.1),(float)(y)); path.lineTo((float)(x+width*0.9),(float)(y)); path.lineTo((float)(x+width),(float)(y+height/2.0)); path.lineTo((float)(x+width*0.9),(float)(y+height)); path.lineTo((float)(x+width*0.1),(float)(y+height)); path.closePath(); //assign the hexagonal path to the protected shape attribute shape = path; |
See GenericNodeRealizer
| Keywords: | ShapeNodeRealizer - shape - custom shape - visual appearance - NodeRealizer - GenericNodeRealizer - |


