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

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

Introduction

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

Prototype

public void endLayer() 

Source Link

Document

Ends a layer controlled graphic block.

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);//from   ww  w  .ja  v a2  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);
}