itexttotalwrapper.java

来自「一个完整的表格展示数据查询的工具,可以直接在eclipse中编辑使用.」· Java 代码 · 共 82 行

JAVA
82
字号
// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov  Date: 2008-6-14 13:30:33
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   ItextTotalWrapper.java

package org.displaytag.sample.decorators;

import com.lowagie.text.*;
import org.displaytag.render.ItextTableWriter;

// Referenced classes of package org.displaytag.sample.decorators:
//            TotalWrapperTemplate

public class ItextTotalWrapper extends TotalWrapperTemplate
    implements org.displaytag.render.ItextTableWriter.ItextDecorator
{

    public ItextTotalWrapper()
    {
    }

    public void setTable(Table table)
    {
        this.table = table;
    }

    public void setFont(Font font)
    {
        this.font = font;
    }

    public String startRow()
    {
        table.setDefaultCellBorder(2);
        return null;
    }

    protected void writeCityTotal(String city, double total)
    {
        writeTotal(city, total);
    }

    protected void writeGrandTotal(double total)
    {
        writeTotal("Grand", total);
    }

    private void writeTotal(String value, double total)
    {
        if(assertRequiredState())
            try
            {
                font = FontFactory.getFont(font.getFamilyname(), font.size(), 1, font.color());
                table.addCell(getCell(""));
                table.addCell(getCell(""));
                table.addCell(getCell("-------------"));
                table.addCell(getCell(""));
                table.addCell(getCell(""));
                table.addCell(getCell(value + " Total:"));
                table.addCell(getCell(total + ""));
                table.addCell(getCell(""));
            }
            catch(BadElementException e) { }
    }

    private Cell getCell(String value)
        throws BadElementException
    {
        Cell cell = new Cell(new Chunk(value, font));
        cell.setLeading(8F);
        cell.setHorizontalAlignment(0);
        return cell;
    }

    private boolean assertRequiredState()
    {
        return table != null && font != null;
    }

    private Table table;
    private Font font;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?