Adding a label to graphic object

Article ID: 2187
Last updated: 28 May, 2018
Article ID: 2187
Last updated: 28 May, 2018
Revision: 3
Views: 744
Posted: 02 Nov, 2007
by Dean J.
Updated: 28 May, 2018
by Gargani A.

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.

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2187
Last updated: 28 May, 2018
Revision: 3
Views: 744
Posted: 02 Nov, 2007 by Dean J.
Updated: 28 May, 2018 by Gargani A.
Also listed in


Others in this category