Example usage for com.lowagie.text.pdf PdfTemplate beginLayer

List of usage examples for com.lowagie.text.pdf PdfTemplate beginLayer

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfTemplate beginLayer.

Prototype

public void beginLayer(PdfOCG layer) 

Source Link

Document

Begins a graphic block whose visibility is controlled by the layer.

Usage

From source file:questions.ocg.StatusBars1.java

public Image getImage(PdfContentByte cb, int i) throws BadElementException {
    PdfTemplate tmp = cb.createTemplate(100, 10);
    tmp.setBoundingBox(new Rectangle(-5, -2, 105, 12));
    Rectangle r = new Rectangle(0, 0, 100, 10);
    tmp.rectangle(r);// w w w.  jav  a  2 s  . c  o  m
    r = new Rectangle(0, 0, i, 10);
    tmp.beginLayer(colorLayerColored);
    if (i % 2 == 0)
        r.setBackgroundColor(Color.RED);
    else
        r.setBackgroundColor(Color.GREEN);
    tmp.rectangle(r);
    tmp.endLayer();
    tmp.beginLayer(colorLayerGreyed);
    r = new Rectangle(0, 0, i, 10);
    if (i % 2 == 0)
        r.setBackgroundColor(new GrayColor(10));
    else
        r.setBackgroundColor(new GrayColor(97));
    tmp.rectangle(r);
    tmp.endLayer();
    return Image.getInstance(tmp);
}