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


Java PageFormat.PORTRAIT属性代码示例

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


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

示例1: setPageFormat

public static void setPageFormat(String name, PageFormat pageFormat) {
    Properties properties = getProperties(name);
    switch (pageFormat.getOrientation()) {
        case PageFormat.LANDSCAPE:
            properties.setProperty(ORIENTATION, LANDSCAPE);
            break;
        case PageFormat.PORTRAIT:
            properties.setProperty(ORIENTATION, PORTRAIT);
            break;
        case PageFormat.REVERSE_LANDSCAPE:
            properties.setProperty(ORIENTATION, REVERSE_LANDSCAPE);
            break;
        default:
            properties.setProperty(ORIENTATION, "EMPTY");
    }
    ;
    final Paper paper = pageFormat.getPaper();
    properties.setProperty(PAPER_IMAGEABLE_HEIGHT, Double.toString(paper
            .getImageableHeight()));
    properties.setProperty(PAPER_IMAGEABLE_WIDTH, Double.toString(paper
            .getImageableWidth()));
    properties.setProperty(PAPER_IMAGEABLE_X, Double.toString(paper
            .getImageableX()));
    properties.setProperty(PAPER_IMAGEABLE_Y, Double.toString(paper
            .getImageableY()));
    properties
            .setProperty(PAPER_HEIGHT, Double.toString(paper.getHeight()));
    properties.setProperty(PAPER_WIDTH, Double.toString(paper.getWidth()));
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:29,代码来源:Options.java

示例2: getPageCount

public int getPageCount() {
    int res = 0;
    for (int index = 0; index < painters.length; index++) {
        PIDEF0painter painter = getPainter(index);
        res += painter.hPageCount;
    }
    if (getPageFormat().getOrientation() == PageFormat.PORTRAIT)
        res = (int) Math.ceil((double) res / 2.d);
    return res;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:10,代码来源:IDEF0Printable.java

示例3: patchMedia

private Pageable patchMedia( Pageable pageable ){
	/* OpenBook is used internally only when app uses Printable.
     * This is the case when we use the values from the attribute set.
     */
    Media media = (Media)reqAttrSet.get(Media.class);
    OrientationRequested orientReq = (OrientationRequested)reqAttrSet.get(OrientationRequested.class);
    MediaPrintableArea mpa = (MediaPrintableArea)reqAttrSet.get(MediaPrintableArea.class);

    if ((orientReq != null || media != null || mpa != null) && pageable instanceof OpenBook) {

        /* We could almost(!) use PrinterJob.getPageFormat() except
         * here we need to start with the PageFormat from the OpenBook :
         */
        Printable printable = pageable.getPrintable(0);
        PageFormat pf = (PageFormat)pageable.getPageFormat(0).clone();
        Paper paper = pf.getPaper();

        /* If there's a media but no media printable area, we can try
         * to retrieve the default value for mpa and use that.
         */
        if (mpa == null && media != null && service.isAttributeCategorySupported(MediaPrintableArea.class)) {
            Object mpaVals = service. getSupportedAttributeValues(MediaPrintableArea.class, null, reqAttrSet);
            if (mpaVals instanceof MediaPrintableArea[] && ((MediaPrintableArea[])mpaVals).length > 0) {
                mpa = ((MediaPrintableArea[])mpaVals)[0];
            }
        }

        if (isSupportedValue(orientReq, reqAttrSet) || (!fidelity && orientReq != null)) {
            int orient;
            if (orientReq.equals(OrientationRequested.REVERSE_LANDSCAPE)) {
                orient = PageFormat.REVERSE_LANDSCAPE;
            } else if (orientReq.equals(OrientationRequested.LANDSCAPE)) {
                orient = PageFormat.LANDSCAPE;
            } else {
                orient = PageFormat.PORTRAIT;
            }
            pf.setOrientation(orient);
        }

        if (isSupportedValue(media, reqAttrSet) || (!fidelity && media != null)) {
            if (media instanceof MediaSizeName) {
                MediaSizeName msn = (MediaSizeName)media;
                MediaSize msz = MediaSize.getMediaSizeForName(msn);
                if (msz != null) {
                    float paperWid =  msz.getX(MediaSize.INCH) * 72.0f;
                    float paperHgt =  msz.getY(MediaSize.INCH) * 72.0f;
                    paper.setSize(paperWid, paperHgt);
                    if (mpa == null) {
                        paper.setImageableArea(72.0, 72.0, paperWid-144.0, paperHgt-144.0);
                    }
                }
            }
        }

        if (isSupportedValue(mpa, reqAttrSet) || (!fidelity && mpa != null)) {
            float [] printableArea = mpa.getPrintableArea(MediaPrintableArea.INCH);
            for (int i=0; i < printableArea.length; i++) {
                printableArea[i] = printableArea[i]*72.0f;
            }
            paper.setImageableArea(printableArea[0], printableArea[1], printableArea[2], printableArea[3]);
        }

        pf.setPaper(paper);
        pf = validatePage(pf);
        return new OpenBook(pf, printable);
    }
    return pageable;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:68,代码来源:Win32PrintJob.java


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