| | | | Browse by category |
Question
How can I add a label to my graphic object?
Answer
Some graphic objects already support additional labels (for instance IlvGeneralNode
of JViews Diagrammer). If you want to do it yourself, there are several solutions. The easiest and fastest (to code) way is to use an IlvCompositeGraphic
or an IlvGraphicSet
containing your graphic object, and an Ilv(Zoomable)Label
.
Another solution, longer but more efficient if you have a lot of these objects, is to create your own IlvGraphic
subclass. This subclass should be able to handle both the drawing of your original design and the label. Bear in mind that zoomable labels only appear with Java 2, and that you should pay attention to the way you define the boundingBox()
, applyTransform()
, and draw()
methods to take into account the label bounding box.