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


Java DocFlavor类代码示例

本文整理汇总了Java中javax.print.DocFlavor的典型用法代码示例。如果您正苦于以下问题:Java DocFlavor类的具体用法?Java DocFlavor怎么用?Java DocFlavor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: lookupDefaultPrintService

import javax.print.DocFlavor; //导入依赖的package包/类
protected static PrintService lookupDefaultPrintService() {
    PrintService service = PrintServiceLookup.lookupDefaultPrintService();

    /* Pageable implies Printable so checking both isn't strictly needed */
    if (service != null &&
        service.isDocFlavorSupported(
                            DocFlavor.SERVICE_FORMATTED.PAGEABLE) &&
        service.isDocFlavorSupported(
                            DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
        return service;
    } else {
       PrintService []services =
         PrintServiceLookup.lookupPrintServices(
                            DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
       if (services.length > 0) {
           return services[0];
       }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:RasterPrinterJob.java

示例2: getFactories

import javax.print.DocFlavor; //导入依赖的package包/类
private static ArrayList getFactories(DocFlavor flavor, String outType) {

        if (flavor == null && outType == null) {
            return getAllFactories();
        }

        ArrayList list = new ArrayList();
        Iterator iterator = getAllFactories().iterator();
        while (iterator.hasNext()) {
            StreamPrintServiceFactory factory =
                (StreamPrintServiceFactory)iterator.next();
            if ((outType == null ||
                 outType.equalsIgnoreCase(factory.getOutputFormat())) &&
                (flavor == null ||
                 isMember(flavor, factory.getSupportedDocFlavors()))) {
                list.add(factory);
            }
        }

        return list;
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:StreamPrintServiceFactory.java

示例3: getSupportedDocFlavors

import javax.print.DocFlavor; //导入依赖的package包/类
public DocFlavor[] getSupportedDocFlavors() {
    int len = supportedFlavors.length;
    DocFlavor[] supportedDocFlavors;
    int caps = getPrinterCapabilities();
    // doc flavors supported
    // if PostScript is supported
    if ((caps & DEVCAP_POSTSCRIPT) != 0) {
        supportedDocFlavors = new DocFlavor[len+3];
        System.arraycopy(supportedFlavors, 0, supportedDocFlavors, 0, len);
        supportedDocFlavors[len] = DocFlavor.BYTE_ARRAY.POSTSCRIPT;
        supportedDocFlavors[len+1] = DocFlavor.INPUT_STREAM.POSTSCRIPT;
        supportedDocFlavors[len+2] = DocFlavor.URL.POSTSCRIPT;
    } else {
        supportedDocFlavors = new DocFlavor[len];
        System.arraycopy(supportedFlavors, 0, supportedDocFlavors, 0, len);
    }
    return supportedDocFlavors;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:Win32PrintService.java

示例4: initSupportedDocFlavors

import javax.print.DocFlavor; //导入依赖的package包/类
private void initSupportedDocFlavors() {
    String hostEnc = DocFlavor.hostEncoding.toLowerCase(Locale.ENGLISH);
    if (!hostEnc.equals("utf-8") && !hostEnc.equals("utf-16") &&
        !hostEnc.equals("utf-16be") && !hostEnc.equals("utf-16le") &&
        !hostEnc.equals("us-ascii")) {

        int len = supportedDocFlavorsInit.length;
        DocFlavor[] flavors =
            new DocFlavor[len + supportedHostDocFlavors.length];
        // copy host encoding flavors
        System.arraycopy(supportedHostDocFlavors, 0, flavors,
                         len, supportedHostDocFlavors.length);
        System.arraycopy(supportedDocFlavorsInit, 0, flavors, 0, len);

        supportedDocFlavors = flavors;
    } else {
        supportedDocFlavors = supportedDocFlavorsInit;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:UnixPrintService.java

示例5: isDocFlavorSupported

import javax.print.DocFlavor; //导入依赖的package包/类
public boolean isDocFlavorSupported(DocFlavor flavor) {
    /* To avoid a native query which may be time-consuming
     * do not invoke native unless postscript support is being queried.
     * Instead just check the ones we 'always' support
     */
    DocFlavor[] supportedDocFlavors;
    if (isPostScriptFlavor(flavor)) {
        supportedDocFlavors = getSupportedDocFlavors();
    } else {
        supportedDocFlavors = supportedFlavors;
    }
    for (int f=0; f<supportedDocFlavors.length; f++) {
        if (flavor.equals(supportedDocFlavors[f])) {
            return true;
        }
    }
    return false;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:Win32PrintService.java

示例6: actionPerformed

import javax.print.DocFlavor; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e)
{
    try {
        if (selectedDriver == null)
            return;

        PrintService ps = (PrintService)printers.getSelectedItem();
        PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();

        attr.add(new Copies(1));
        attr.add((Media)ps.getDefaultAttributeValue(Media.class)); // set to default paper from printer
        attr.add(OrientationRequested.LANDSCAPE);

        SimpleDoc doc = new SimpleDoc(activeLabel, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
        ps.createPrintJob().print(doc, attr);
    }  catch (PrintException ex) {
        log.log(Level.SEVERE, "\bBarcode print failed: " + ex.getMessage(), ex);
    }
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:21,代码来源:EntryPanel.java

示例7: main

import javax.print.DocFlavor; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        GraphicsEnvironment.getLocalGraphicsEnvironment();

        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
        String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();

        StreamPrintServiceFactory[] factories =
                StreamPrintServiceFactory.
                        lookupStreamPrintServiceFactories(flavor, mime);
        if (factories.length == 0) {
            System.out.println("No print service found.");
            return;
        }

        FileOutputStream output = new FileOutputStream("out.ps");
        StreamPrintService service = factories[0].getPrintService(output);

        SimpleDoc doc =
             new SimpleDoc(new PrintSEUmlauts(),
                           DocFlavor.SERVICE_FORMATTED.PRINTABLE,
                           new HashDocAttributeSet());
        DocPrintJob job = service.createPrintJob();
        job.addPrintJobListener(new PrintJobAdapter() {
            @Override
            public void printJobCompleted(PrintJobEvent pje) {
                testPrintAndExit();
            }
        });

        job.print(doc, new HashPrintRequestAttributeSet());
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:33,代码来源:PrintSEUmlauts.java

示例8: getMediaTray

import javax.print.DocFlavor; //导入依赖的package包/类
static MediaTray getMediaTray( PrintService ps, String name) {
     Media[] media  = (Media[])ps.getSupportedAttributeValues( Media.class,
             DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);

    for (Media m : media) {
        if ( m instanceof MediaTray) {
            System.out.println("MediaTray=" + m.toString() );
            if ( m.toString().trim().indexOf( name ) > -1 ) {
                return (MediaTray)m;
            }
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:TestMediaTraySelection.java

示例9: setPrintService

import javax.print.DocFlavor; //导入依赖的package包/类
/**
 * Associate this PrinterJob with a new PrintService.
 *
 * Throws <code>PrinterException</code> if the specified service
 * cannot support the <code>Pageable</code> and
 * <code>Printable</code> interfaces necessary to support 2D printing.
 * @param a print service which supports 2D printing.
 *
 * @throws PrinterException if the specified service does not support
 * 2D printing or no longer available.
 */
public void setPrintService(PrintService service)
    throws PrinterException {
    if (service == null) {
        throw new PrinterException("Service cannot be null");
    } else if (!(service instanceof StreamPrintService) &&
               service.getName() == null) {
        throw new PrinterException("Null PrintService name.");
    } else {
        // Check the list of services.  This service may have been
        // deleted already
        PrinterState prnState = (PrinterState)service.getAttribute(
                                              PrinterState.class);
        if (prnState == PrinterState.STOPPED) {
            PrinterStateReasons prnStateReasons =
                (PrinterStateReasons)service.getAttribute(
                                             PrinterStateReasons.class);
            if ((prnStateReasons != null) &&
                (prnStateReasons.containsKey(PrinterStateReason.SHUTDOWN)))
            {
                throw new PrinterException("PrintService is no longer available.");
            }
        }


        if (service.isDocFlavorSupported(
                                         DocFlavor.SERVICE_FORMATTED.PAGEABLE) &&
            service.isDocFlavorSupported(
                                         DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
            myService = service;
        } else {
            throw new PrinterException("Not a 2D print service: " + service);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:46,代码来源:RasterPrinterJob.java

示例10: isSupportedValue

import javax.print.DocFlavor; //导入依赖的package包/类
protected boolean isSupportedValue(Attribute attrval,
                                 PrintRequestAttributeSet attrset) {
    PrintService ps = getPrintService();
    return
        (attrval != null && ps != null &&
         ps.isAttributeValueSupported(attrval,
                                      DocFlavor.SERVICE_FORMATTED.PAGEABLE,
                                      attrset));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:RasterPrinterJob.java

示例11: isDocFlavorSupported

import javax.print.DocFlavor; //导入依赖的package包/类
public boolean isDocFlavorSupported(DocFlavor flavor) {
    if (supportedDocFlavors == null) {
        getSupportedDocFlavors();
    }
    if (supportedDocFlavors != null) {
        for (int f=0; f<supportedDocFlavors.length; f++) {
            if (flavor.equals(supportedDocFlavors[f])) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:IPPPrintService.java

示例12: isDocFlavorSupported

import javax.print.DocFlavor; //导入依赖的package包/类
public boolean isDocFlavorSupported(DocFlavor flavor) {
    DocFlavor [] flavors = getSupportedDocFlavors();
    for (int f=0; f<flavors.length; f++) {
        if (flavor.equals(flavors[f])) {
            return true;
        }
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:PSStreamPrintService.java

示例13: getUnsupportedAttributes

import javax.print.DocFlavor; //导入依赖的package包/类
public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
                                             AttributeSet attributes) {

    if (flavor != null && !isDocFlavorSupported(flavor)) {
        throw new IllegalArgumentException("flavor " + flavor +
                                           "is not supported");
    }

    if (attributes == null) {
        return null;
    }

    Attribute attr;
    AttributeSet unsupp = new HashAttributeSet();
    Attribute[] attrs = attributes.toArray();
    for (int i=0; i<attrs.length; i++) {
        try {
            attr = attrs[i];
            if (!isAttributeCategorySupported(attr.getCategory())) {
                unsupp.add(attr);
            } else if (!isAttributeValueSupported(attr, flavor,
                                                  attributes)) {
                unsupp.add(attr);
            }
        } catch (ClassCastException e) {
        }
    }
    if (unsupp.isEmpty()) {
        return null;
    } else {
        return unsupp;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:PSStreamPrintService.java

示例14: isMember

import javax.print.DocFlavor; //导入依赖的package包/类
private static boolean isMember(DocFlavor flavor, DocFlavor[] flavors) {
    for (int f=0; f<flavors.length; f++ ) {
        if (flavor.equals(flavors[f])) {
            return true;
        }
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:StreamPrintServiceFactory.java

示例15: getMultiDocPrintServices

import javax.print.DocFlavor; //导入依赖的package包/类
public MultiDocPrintService[]
    getMultiDocPrintServices(DocFlavor[] flavors,
                             AttributeSet attributes) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
      security.checkPrintJobAccess();
    }
    return new MultiDocPrintService[0];
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:Win32PrintServiceLookup.java


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