Use of IlvFilterSDMRenderer to set the background of a grapher using a CSS property

Article ID: 2382
Last updated: 29 May, 2018
Article ID: 2382
Last updated: 29 May, 2018
Revision: 3
Views: 514
Posted: 14 Dec, 2010
by Dean J.
Updated: 29 May, 2018
by Gargani A.

Question

How can I set the background of my grapher using a CSS property?

Answer

Create a subclass of IlvFilterSDMRenderer and override the prepareRendering method so that the background is attached to the grapher, as illustrated by the following extract of code (that uses an IVL file as background):

    public class BackgroundRenderer
    extends IlvFilterSDMRenderer {
      private String _backgroundURL;
      public void setParameter(String backgroundURL) {
        _backgroundURL = backgroundURL;
      }
      public String getParameter() {
        return _backgroundURL;
      }
      public void prepareRendering(IlvSDMEngine engine) {
        super.prepareRendering(engine);
        try {
          engine.getGrapher().read(new URL(_backgroundURL));
          IlvManagerView view = engine.getReferenceView();
          if (view != null) {
            view.fitTransformerToContent();
          }
        } catch(Exception ex) {
          ex.printStackTrace();
        }
      }
    }

Then, use this new renderer in the CSS file:

    SDM {
      Renderers:  "Background=BackgroundRenderer";
      Background: "url(background.ivl)";
    }

Note: This feature is implemented in the Decoration renderer since JViews 5.0.

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2382
Last updated: 29 May, 2018
Revision: 3
Views: 514
Posted: 14 Dec, 2010 by Dean J.
Updated: 29 May, 2018 by Gargani A.
Also listed in


Others in this category