当前位置: 首页>>代码示例>>Java>>正文


Java Rectangle.getRotation方法代码示例

本文整理汇总了Java中com.lowagie.text.Rectangle.getRotation方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.getRotation方法的具体用法?Java Rectangle.getRotation怎么用?Java Rectangle.getRotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.lowagie.text.Rectangle的用法示例。


在下文中一共展示了Rectangle.getRotation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startPage

import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
/**
 * Any work to start off printing a page of the document
 * m_currentPage will contain the page being printed, and
 * m_currentTemplatePage will contain the template page number to base this
 * new page on.
 * @throws FormPrintException Thrown if there is any form processing problems
 */
protected void startPage() throws FormPrintException {
    log.debug("startPage: Page=" + getCurrentPage());

    Rectangle r = m_templateReader.getPageSize(getCurrentTemplatePage());
    log.debug( "Page Size      : t="+r.getTop()+",l="+r.getLeft()+",b="+r.getBottom()+",r="+r.getRight()+", rot="+r.getRotation() );
    r = m_templateReader.getPageSizeWithRotation(getCurrentTemplatePage());
    log.debug( "Page Size w/Rot: t="+r.getTop()+",l="+r.getLeft()+",b="+r.getBottom()+",r="+r.getRight()+", rot="+r.getRotation() );

    // Get rotation quadrent 0..3
    int q = (m_templateReader.getPageSizeWithRotation(getCurrentTemplatePage()).getRotation() % 360)/90;
    float tX = (q==2?r.getTop():0)+(q==3?r.getRight():0);
    float tY = (q==1?r.getTop():0)+(q==2?r.getRight():0);
    float sX=1f, sY=1f;
    double angle = -r.getRotation()*(Math.PI/180f);
    double transformA = sX * Math.cos(angle);
    double transformB = sY * Math.sin(angle);
    double transformC = -sX * Math.sin(angle);
    double transformD = sY * Math.cos(angle);
    double transformE = tX;
    double transformF = tY;


    m_generatedDoc.setPageSize(m_templateReader.getPageSizeWithRotation(getCurrentTemplatePage()) );
    //m_generatedDoc.setPageSize(m_templateReader.getPageSize(getCurrentTemplatePage()) );
    /**
     * try {
     * m_generatedDoc.newPage();
     * } catch (DocumentException e) {
     * log.error("Error Creating New Page - " + e.getMessage() ,e);
     * throw new EngineProcessingException("Error Creating New Page - " + e.getMessage());
     * }
     **/
    m_generatedDoc.newPage();

    PdfImportedPage page = m_writer.getImportedPage(m_templateReader, getCurrentTemplatePage() );
    PdfContentByte cb = m_writer.getDirectContent();
    //cb.addTemplate(page, 1f, 0, 0, 1f, 0, 0);
    cb.addTemplate(page, (float)transformA, (float)transformB, (float)transformC,
                         (float)transformD, (float)transformE, (float)transformF);
    log.debug("Matrix = [A=" + transformA +", B=" + transformB +", C=" + transformC +
                      ", D=" + transformD +", E=" + transformE +", F=" + transformF +" ]");
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:50,代码来源:FormPrintEngineIText.java

示例2: applyRotation

import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
void applyRotation(PdfDictionary pageN, ByteBuffer out) {
    if (!cstp.rotateContents)
        return;
    Rectangle page = reader.getPageSizeWithRotation(pageN);
    int rotation = page.getRotation();
    switch (rotation) {
        case 90:
            out.append(PdfContents.ROTATE90);
            out.append(page.getTop());
            out.append(' ').append('0').append(PdfContents.ROTATEFINAL);
            break;
        case 180:
            out.append(PdfContents.ROTATE180);
            out.append(page.getRight());
            out.append(' ');
            out.append(page.getTop());
            out.append(PdfContents.ROTATEFINAL);
            break;
        case 270:
            out.append(PdfContents.ROTATE270);
            out.append('0').append(' ');
            out.append(page.getRight());
            out.append(PdfContents.ROTATEFINAL);
            break;
    }
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:27,代码来源:PdfCopy.java

示例3: rotateAnnotations

import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
public PdfArray rotateAnnotations(PdfWriter writer, Rectangle pageSize) {
    PdfArray array = new PdfArray();
    int rotation = pageSize.getRotation() % 360;
    int currentPage = writer.getCurrentPageNumber();
    for (int k = 0; k < annotations.size(); ++k) {
        PdfAnnotation dic = (PdfAnnotation)annotations.get(k);
        int page = dic.getPlaceInPage();
        if (page > currentPage) {
            delayedAnnotations.add(dic);
            continue;
        }
        if (dic.isForm()) {
            if (!dic.isUsed()) {
                HashMap templates = dic.getTemplates();
                if (templates != null)
                    acroForm.addFieldTemplates(templates);
            }
            PdfFormField field = (PdfFormField)dic;
            if (field.getParent() == null)
                acroForm.addDocumentField(field.getIndirectReference());
        }
        if (dic.isAnnotation()) {
            array.add(dic.getIndirectReference());
            if (!dic.isUsed()) {
                PdfRectangle rect = (PdfRectangle)dic.get(PdfName.RECT);
                if (rect != null) {
                	switch (rotation) {
                    	case 90:
                    		dic.put(PdfName.RECT, new PdfRectangle(
                    				pageSize.getTop() - rect.bottom(),
						rect.left(),
						pageSize.getTop() - rect.top(),
						rect.right()));
                    		break;
                    	case 180:
                    		dic.put(PdfName.RECT, new PdfRectangle(
                    				pageSize.getRight() - rect.left(),
						pageSize.getTop() - rect.bottom(),
						pageSize.getRight() - rect.right(),
						pageSize.getTop() - rect.top()));
                    		break;
                    	case 270:
                    		dic.put(PdfName.RECT, new PdfRectangle(
                    				rect.bottom(),
						pageSize.getRight() - rect.left(),
						rect.top(),
						pageSize.getRight() - rect.right()));
                    		break;
                	}
                }
            }
        }
        if (!dic.isUsed()) {
            dic.setUsed();
            try {
                writer.addToBody(dic, dic.getIndirectReference());
            }
            catch (IOException e) {
                throw new ExceptionConverter(e);
            }
        }
    }
    return array;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:65,代码来源:PdfAnnotationsImp.java

示例4: applyRotation

import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
void applyRotation(PdfDictionary pageN, ByteBuffer out) {
    if (!rotateContents) {
        return;
    }
    Rectangle page = reader.getPageSizeWithRotation(pageN);
    int rotation = page.getRotation();
    switch (rotation) {
        case 90:
            out.append(PdfContents.ROTATE90);
            out.append(page.getTop());
            out.append(' ').append('0').append(PdfContents.ROTATEFINAL);
            break;
        case 180:
            out.append(PdfContents.ROTATE180);
            out.append(page.getRight());
            out.append(' ');
            out.append(page.getTop());
            out.append(PdfContents.ROTATEFINAL);
            break;
        case 270:
            out.append(PdfContents.ROTATE270);
            out.append('0').append(' ');
            out.append(page.getRight());
            out.append(PdfContents.ROTATEFINAL);
            break;
    }
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:28,代码来源:PdfStamperImp.java


注:本文中的com.lowagie.text.Rectangle.getRotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。