當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。