Outline an IlvLabel

Article ID: 2340
Last updated: 29 May, 2018
Article ID: 2340
Last updated: 29 May, 2018
Revision: 3
Views: 611
Posted: 01 Mar, 2011
by Dean J.
Updated: 29 May, 2018
by Gargani A.

Question

How to add an outline to an IlvLabel?

Answer

Since JViews 8.1, IlvText supports outlined texts. However, if you want to show outlined texts with previous versions of JViews, you need to make some customizations.
By default, IlvLabel does not have any outline mode. 
To enable outline labels, you can either use TextLayout or GlyphVector
The idea is to override the IlvLabel.draw() method to add an outline shape for your label.

  • Using TextLayout: 
    This outline relies on the text layout created from the font to do the rendering and a font context. 
    The text layout will give you the outline of your text as a Shape
    You'll then draw the Shape by using Graphics2D.fill(Shape).
  • Using GlyphVector: 
    This outline relies on the glyphs of the font to do the rendering. 
    The glyphs end up being shapes, one for the label and one for the outline. 
    You'll draw the Shape by using Graphics2D.fill(Shape).

You can download this sample outline_labels.zip that illustrates this mechanism.

Note: In order to run this sample with JViews 8.7 and later, you must call the log.views.util.IlvProductUtil.DeploymentLicenseRequired method with the appropriate argument. See the General information > Deployment licenses > Declaring the use of IBM ILOG JViews services section in the documentation for more information.

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2340
Last updated: 29 May, 2018
Revision: 3
Views: 611
Posted: 01 Mar, 2011 by Dean J.
Updated: 29 May, 2018 by Gargani A.
Attached files

Also listed in


Others in this category