| | | | Browse by category |
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 aShape
.
You'll then draw theShape
by usingGraphics2D.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 theShape
by usingGraphics2D.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.