當前位置: 首頁>>代碼示例>>Java>>正文


Java MediaSizeName類代碼示例

本文整理匯總了Java中javax.print.attribute.standard.MediaSizeName的典型用法代碼示例。如果您正苦於以下問題:Java MediaSizeName類的具體用法?Java MediaSizeName怎麽用?Java MediaSizeName使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MediaSizeName類屬於javax.print.attribute.standard包,在下文中一共展示了MediaSizeName類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: unMapMedia

import javax.print.attribute.standard.MediaSizeName; //導入依賴的package包/類
public static MediaType unMapMedia(MediaSizeName mSize) {
    MediaType media = null;

    // JAVAXSIZES.length and SIZES.length must be equal!
    // Attempt to recover by getting the smaller size.
    int length = Math.min(SIZES.length, JAVAXSIZES.length);

    for (int i=0; i < length; i++) {
        if (JAVAXSIZES[i] == mSize) {
            if (SIZES[i] != null) {
                media = SIZES[i];
                break;
            }
        }
    }
    return media;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:PrintJob2D.java

示例2: findWin32Media

import javax.print.attribute.standard.MediaSizeName; //導入依賴的package包/類
public MediaSizeName findWin32Media(int dmIndex) {
    if (dmIndex >= 1 && dmIndex <= dmPaperToPrintService.length) {
        return dmPaperToPrintService[dmIndex - 1];
    }
    switch(dmIndex) {
        /* matching media sizes with indices beyond
           dmPaperToPrintService's length */
        case DMPAPER_A2:
            return MediaSizeName.ISO_A2;
        case DMPAPER_A6:
            return MediaSizeName.ISO_A6;
        case DMPAPER_B6_JIS:
            return MediaSizeName.JIS_B6;
        default:
            return null;
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:Win32PrintService.java

示例3: findMatchingMediaSizeNameMM

import javax.print.attribute.standard.MediaSizeName; //導入依賴的package包/類
public MediaSizeName findMatchingMediaSizeNameMM (float w, float h){
    if (predefMedia != null) {
        for (int k=0; k<predefMedia.length;k++) {
            if (predefMedia[k] == null) {
                continue;
            }

            if (isSameSize(predefMedia[k].getX(MediaSize.MM),
                           predefMedia[k].getY(MediaSize.MM),
                           w, h)) {
              return predefMedia[k].getMediaSizeName();
            }
        }
    }
    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:Win32PrintService.java

示例4: getWin32MediaAttrib

import javax.print.attribute.standard.MediaSizeName; //導入依賴的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

示例5: addPaperSize

import javax.print.attribute.standard.MediaSizeName; //導入依賴的package包/類
private void addPaperSize(PrintRequestAttributeSet aset,
                          int dmIndex, int width, int length) {

    if (aset == null) {
        return;
    }
    MediaSizeName msn =
       ((Win32PrintService)myService).findWin32Media(dmIndex);
    if (msn == null) {
        msn = ((Win32PrintService)myService).
            findMatchingMediaSizeNameMM((float)width, (float)length);
    }

    if (msn != null) {
        aset.add(msn);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:WPrinterJob.java

示例6: getAllPrintableAreas

import javax.print.attribute.standard.MediaSizeName; //導入依賴的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

示例7: PrintServiceStub

import javax.print.attribute.standard.MediaSizeName; //導入依賴的package包/類
public PrintServiceStub(String name) {
    _name = name;
    _flavors = new HashSet<DocFlavor>();
    _flavors.add(DocFlavor.SERVICE_FORMATTED.PAGEABLE);
    _flavors.add(DocFlavor.SERVICE_FORMATTED.PRINTABLE);
    _attributes = new HashMap<>();
    _attributes.put(PrinterName.class, new PrinterName(name, null));
    _attributes.put(PrinterState.class, PrinterState.IDLE);
    _attributes.put(PrinterInfo.class, new PrinterInfo("Custom location",
            null));
    _attributes.put(PrinterIsAcceptingJobs.class,
            PrinterIsAcceptingJobs.ACCEPTING_JOBS);
    _attributes.put(PrinterMakeAndModel.class, new PrinterMakeAndModel(
            "Custom printer", null));
    _attributes.put(Media.class, new Media[] { MediaSizeName.ISO_A4 });
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:17,代碼來源:PrintServiceStub.java

示例8: getWin32MediaAttrib

import javax.print.attribute.standard.MediaSizeName; //導入依賴的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

示例9: doTest

import javax.print.attribute.standard.MediaSizeName; //導入依賴的package包/類
private static void doTest() {
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(Chromaticity.MONOCHROME);

    MediaSize isoA5Size = MediaSize.getMediaSizeForName(MediaSizeName.ISO_A5);
    float[] size = isoA5Size.getSize(Size2DSyntax.INCH);
    Paper paper = new Paper();
    paper.setSize(size[0] * 72.0, size[1] * 72.0);
    paper.setImageableArea(0.0, 0.0, size[0] * 72.0, size[1] * 72.0);
    PageFormat pf = new PageFormat();
    pf.setPaper(paper);

    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintable(new WrongPaperPrintingTest(), job.validatePage(pf));
    if (job.printDialog()) {
        try {
            job.print(aset);
        } catch (PrinterException pe) {
            throw new RuntimeException(pe);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:WrongPaperPrintingTest.java

示例10: print

import javax.print.attribute.standard.MediaSizeName; //導入依賴的package包/類
/**
 *
 */
public void print() throws JRException
{
	long start = System.currentTimeMillis();
	PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
	printRequestAttributeSet.add(MediaSizeName.ISO_A4);

	PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
	//printServiceAttributeSet.add(new PrinterName("Epson Stylus 820 ESC/P 2", null));
	//printServiceAttributeSet.add(new PrinterName("hp LaserJet 1320 PCL 6", null));
	//printServiceAttributeSet.add(new PrinterName("PDFCreator", null));
	
	JRPrintServiceExporter exporter = new JRPrintServiceExporter();
	
	exporter.setExporterInput(new SimpleExporterInput("build/reports/PrintServiceReport.jrprint"));
	SimplePrintServiceExporterConfiguration configuration = new SimplePrintServiceExporterConfiguration();
	configuration.setPrintRequestAttributeSet(printRequestAttributeSet);
	configuration.setPrintServiceAttributeSet(printServiceAttributeSet);
	configuration.setDisplayPageDialog(false);
	configuration.setDisplayPrintDialog(true);
	exporter.setConfiguration(configuration);
	exporter.exportReport();

	System.err.println("Printing time : " + (System.currentTimeMillis() - start));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:28,代碼來源:PrintServiceApp.java


注:本文中的javax.print.attribute.standard.MediaSizeName類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。