You can create your own item types by deriving the DiagramNode and DiagramLink classes or their successors such as TableNode, ContainerNode and so on. Thus, you can add custom data fields to the diagram items, and implement custom visualization and interaction functionality.
If you add custom fields to your item class, you will probably want their values saved when saving diagram files, and restored when loading files. To enable this, override the writeExternal and readExternal methods of the DiagramItem class, which let you use ObjectOutputStream and ObjectInputStream objects to implement binary serialization. To implement XML serialization, you must override the saveToXml and loadFromXml methods, and use the registerItemClass method to associate an element name with your class.
You must implement the clone method in order to enable copyToClipboard and pasteFromClipboard to work with your custom item type. If clone is not implemented, you will get an instance of the base class created for the pasted item, and this could lead to an exception when the base class deserialization code tries to load the item state from a data stream created by the derived class. If your class has any custom fields, it must also implement the writeExternal and readExternal methods for proper serialization.
If you need to provide custom rendering for your items, override the drawLocal and drawShadowLocal methods. They receive as an argument a Graphics2D object, which provides methods for drawing vector graphics, text and images. The specified Graphics2D in drawLocal has a rotation transform applied to it to match the node's RotationAngle, and a translation transform to match the node's position, so that the coordinate system origin (0,0) is at the node's top-left corner. Alternatively, override the draw method to receive a Graphics2D without any local transformations applied to it.
Apart from drawing on screen via Java's Graphics2D objects, JDiagram provides PdfGraphics2D and SvgGraphics2D implementations of that interface, which are used when exporting to PDF and to SVG. That lets you use the same code regardless of where the item should draw itself.
To allow the user to draw items from a custom class, set the Behavior of the diagram view to Custom, and call the setCustomNodeType and/or setCustomLinkType method with the Class object that corresponds to your type. If you need to change how items handle user interaction while they are being initially created, implement the startCreate, updateCreate and completeCreate methods. In order to change how items respond to user interaction while they are being modified, implement the startModify, updateModify and completeModify methods.