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


Java MediaSize.getY方法代码示例

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


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

示例1: getWin32MediaAttrib

import javax.print.attribute.standard.MediaSize; //导入方法依赖的package包/类
/** MediaSizeName / dmPaper */
private final int[] getWin32MediaAttrib() {
    int wid_ht[] = {0, 0};
    if (attributes != null) {
        Media media = (Media)attributes.get(Media.class);
        if (media instanceof MediaSizeName) {
            MediaSizeName msn = (MediaSizeName)media;
            MediaSize ms = MediaSize.getMediaSizeForName(msn);
            if (ms != null) {
                wid_ht[0] = (int)(ms.getX(MediaSize.INCH) * 72.0);
                wid_ht[1] = (int)(ms.getY(MediaSize.INCH) * 72.0);
            }
        }
    }
    return wid_ht;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:WPrinterJob.java

示例2: getAllPrintableAreas

import javax.print.attribute.standard.MediaSize; //导入方法依赖的package包/类
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:UnixPrintService.java

示例3: getWin32MediaAttrib

import javax.print.attribute.standard.MediaSize; //导入方法依赖的package包/类
/** MediaSizeName / dmPaper */
private int[] getWin32MediaAttrib() {
    int wid_ht[] = {0, 0};
    if (attributes != null) {
        Media media = (Media)attributes.get(Media.class);
        if (media instanceof MediaSizeName) {
            MediaSizeName msn = (MediaSizeName)media;
            MediaSize ms = MediaSize.getMediaSizeForName(msn);
            if (ms != null) {
                wid_ht[0] = (int)(ms.getX(MediaSize.INCH) * 72.0);
                wid_ht[1] = (int)(ms.getY(MediaSize.INCH) * 72.0);
            }
        }
    }
    return wid_ht;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:WPrinterJob.java

示例4: savePrinterProperties

import javax.print.attribute.standard.MediaSize; //导入方法依赖的package包/类
/**
 * Utility that tries to save the state of the currently set MediaSize.
 * The width height and unit values are written to the the propertiesManager.
 * When the Viewer RI is exited the properites file is wrtten to disk.
 *
 * @param printHelper instance of the open documents print helper.
 */
private void savePrinterProperties(PrintHelper printHelper) {
    PrintRequestAttributeSet printRequestAttributeSet =
            printHelper.getPrintRequestAttributeSet();

    Object printAttributeSet = printRequestAttributeSet.get(Media.class);

    if (propertiesManager != null &&
            printAttributeSet instanceof MediaSizeName) {
        MediaSizeName paper = (MediaSizeName) printAttributeSet;
        MediaSize mediaSize = MediaSize.getMediaSizeForName(paper);
        // write out the new page size property values.
        int printMediaUnit = MediaSize.MM;
        propertiesManager.set(
                PropertiesManager.PROPERTY_PRINT_MEDIA_SIZE_UNIT,
                String.valueOf(printMediaUnit));
        double printMediaWidth = mediaSize.getX(printMediaUnit);
        propertiesManager.set(
                PropertiesManager.PROPERTY_PRINT_MEDIA_SIZE_WIDTH,
                String.valueOf(printMediaWidth));
        double printMediaHeight = mediaSize.getY(printMediaUnit);
        propertiesManager.set(
                PropertiesManager.PROPERTY_PRINT_MEDIA_SIZE_HEIGHT,
                String.valueOf(printMediaHeight));
    }
}
 
开发者ID:pdf4j,项目名称:icepdf,代码行数:33,代码来源:SwingController.java

示例5: CustomMediaSizeName

import javax.print.attribute.standard.MediaSize; //导入方法依赖的package包/类
public CustomMediaSizeName(String name, String choice,
                           float width, float length) {
    super(nextValue(name));
    choiceName = choice;
    customEnumTable.add(this);
    mediaName = null;
    try {
        mediaName = MediaSize.findMedia(width, length,
                                        MediaSize.INCH);
    } catch (IllegalArgumentException iae) {
    }
    // The public API method finds a closest match even if it not
    // all that close. Here we want to be sure its *really* close.
    if (mediaName != null) {
        MediaSize sz = MediaSize.getMediaSizeForName(mediaName);
        if (sz == null) {
            mediaName = null;
        } else {
            float w = sz.getX(MediaSize.INCH);
            float h = sz.getY(MediaSize.INCH);
            float dw = Math.abs(w - width);
            float dh = Math.abs(h - length);
            if (dw > 0.1 || dh > 0.1) {
                mediaName = null;
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:CustomMediaSizeName.java

示例6: getMediaPrintableArea

import javax.print.attribute.standard.MediaSize; //导入方法依赖的package包/类
public MediaPrintableArea getMediaPrintableArea(MediaSize size) {
    return new MediaPrintableArea(getX1(MM), 
                                  getY1(MM),
                                  size.getX(MM) - getX1(MM) - getX2(MM),
                                  size.getY(MM) - getY1(MM) - getY2(MM),
                                  MM);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:8,代码来源:MediaMargins.java

示例7: patchMedia

import javax.print.attribute.standard.MediaSize; //导入方法依赖的package包/类
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,代码行数:69,代码来源:Win32PrintJob.java

示例8: updateMargins

import javax.print.attribute.standard.MediaSize; //导入方法依赖的package包/类
private boolean updateMargins() {
    float x1;
    float y1;
    float x2; 
    float y2;    
    NumberFormatter format = getFloatFormatter();

    if (!leftTxt.isEnabled()) {
        removeAttribute(MediaPrintableArea.class);
        removeAttribute(MediaMargins.class);
        return true;
    }

    try {
        x1 = ((Float) format.stringToValue(leftTxt.getText())).floatValue();
        x2 = ((Float) format.stringToValue(rightTxt.getText())).floatValue();
        y1 = ((Float) format.stringToValue(topTxt.getText())).floatValue();
        y2 = ((Float) format.stringToValue(bottomTxt.getText())).floatValue();
    } catch(ParseException e) {
        return false;
    }

    if (sizeBox.isEnabled() 
         && (sizeBox.getSelectedItem() instanceof MediaSizeName) 
         && myService.isAttributeCategorySupported(MediaPrintableArea.class)) {
        MediaSize mediaSize = MediaSize.getMediaSizeForName(
                (MediaSizeName) sizeBox.getSelectedItem());
        float paperWidth = mediaSize.getX(Size2DSyntax.MM);
        float paperHeight = mediaSize.getY(Size2DSyntax.MM);
        if ((x1 + x2 >= paperWidth) || (y1 + y2 >= paperHeight)) {
            return false;
        }
        newAttrs.add(new MediaPrintableArea(x1, 
                                            y1, 
                                            paperWidth - x1 - x2,
                                            paperHeight - y1 - y2, 
                                            MediaPrintableArea.MM));
    } else {
        removeAttribute(MediaPrintableArea.class);
    }

    if (myService.isAttributeCategorySupported(MediaMargins.class)) {
        newAttrs.add(new MediaMargins(x1, y1, x2, y2, MediaMargins.MM));
    } else {
        removeAttribute(MediaMargins.class);
    }
    return true;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:49,代码来源:ServiceUIDialog.java


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