Hiding the label of IlvGeneralLink

Article ID: 2397
Last updated: 29 May, 2018
Article ID: 2397
Last updated: 29 May, 2018
Revision: 3
Views: 501
Posted: 31 Mar, 2011
by Dean J.
Updated: 29 May, 2018
by Gargani A.

Question

How to hide and show the label of IlvGeneralLink?

Answer

You can achieve this in two ways:

  • Through API:
    • By default, IlvGeneralLink's label is represented by an IlvZoomableLabel at the first slot of the decoration list. You can remove or add the label decoration to hide or show the label.
    • Alternatively, you can hide the label by using the fully transparent color at the label graphic object. Something like the following:

      IlvGeneralLink linkGraphic = ...;

      IlvGraphic label = linkGraphic.getDecorations(0);

      boolean isVisible = label.isVisible();

      if( isVisible){

      // make label invisible

      label.setForeground(new java.awt.Color(0,0,0,0));

      }

      else {

      // make label visible

      label.setForeground(new java.awt.Color(0,0,0,255));

      }

      label.setVisible(!isVisible);

      linkGraphic.reDraw(); // important to force a refraw here

  • Through CSS:

    You need to subclass the IlvGeneralLink and store the label internally. In your subclass, you need to provide a getter and setter for labelVisible property. When this property is set to true in the CSS file, you can set the label value to the parent class in order to add the label as a decoration.

    Then in the CSS file, you can configure the label and its visibility like the following:
    link {

    class : "MyGeneralLink";

    // replace labelValue with the appropriate model attribute name

    label : "@labelValue" ;

    // this is new property available in the MyGeneralLink class

    labelVisible : "true";

    }

    This will enable you to toggle the label's visibility via CSS while maintains the label value at the graphic level.

Attached is the sample that demonstrates both approaches.

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

Also listed in


Others in this category