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


Java Attribute类代码示例

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


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

示例1: isAttributeCategorySupported

import javax.print.attribute.Attribute; //导入依赖的package包/类
public boolean
    isAttributeCategorySupported(Class<? extends Attribute> category)
{
    if (category == null) {
        throw new NullPointerException("null category");
    }
    if (!(Attribute.class.isAssignableFrom(category))) {
        throw new IllegalArgumentException(category +
                                         " is not an Attribute");
    }

    for (int i=0;i<otherAttrCats.length;i++) {
        if (category == otherAttrCats[i]) {
            return true;
        }
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:UnixPrintService.java

示例2: isAttributeCategorySupported

import javax.print.attribute.Attribute; //导入依赖的package包/类
public boolean
    isAttributeCategorySupported(Class<? extends Attribute> category)
{

    if (category == null) {
        throw new NullPointerException("null category");
    }

    if (!(Attribute.class.isAssignableFrom(category))) {
        throw new IllegalArgumentException(category +
                                           " is not an Attribute");
    }

    Class[] classList = getSupportedAttributeCategories();
    for (int i = 0; i < classList.length; i++) {
        if (category.equals(classList[i])) {
            return true;
        }
    }

    return false;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:Win32PrintService.java

示例3: setMediaTrayAttrib

import javax.print.attribute.Attribute; //导入依赖的package包/类
private void setMediaTrayAttrib(Attribute attr) {
    if (attr == MediaTray.BOTTOM) {
        mAttMediaTray = 2;    // DMBIN_LOWER
    } else if (attr == MediaTray.ENVELOPE) {
        mAttMediaTray = 5;    // DMBIN_ENVELOPE
    } else if (attr == MediaTray.LARGE_CAPACITY) {
        mAttMediaTray = 11;      // DMBIN_LARGECAPACITY
    } else if (attr == MediaTray.MAIN) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else if (attr == MediaTray.MANUAL) {
        mAttMediaTray = 4;              // DMBIN_MANUAL
    } else if (attr == MediaTray.MIDDLE) {
        mAttMediaTray = 3;              // DMBIN_MIDDLE
    } else if (attr == MediaTray.SIDE) {
        // no equivalent predefined value
        mAttMediaTray = 7;              // DMBIN_AUTO
    } else if (attr == MediaTray.TOP) {
        mAttMediaTray = 1;              // DMBIN_UPPER
    } else {
        if (attr instanceof Win32MediaTray) {
            mAttMediaTray = ((Win32MediaTray)attr).winID;
        } else {
            mAttMediaTray = 1;  // default
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:WPrinterJob.java

示例4: getUpdatedAttributes

import javax.print.attribute.Attribute; //导入依赖的package包/类
public PrintServiceAttributeSet getUpdatedAttributes() {
    PrintServiceAttributeSet currSet = getDynamicAttributes();
    if (lastSet == null) {
        lastSet = currSet;
        return AttributeSetUtilities.unmodifiableView(currSet);
    } else {
        PrintServiceAttributeSet updates =
            new HashPrintServiceAttributeSet();
        Attribute []attrs = currSet.toArray();
        Attribute attr;
        for (int i=0; i<attrs.length; i++) {
            attr = attrs[i];
            if (!lastSet.containsValue(attr)) {
                updates.add(attr);
            }
        }
        lastSet = currSet;
        return AttributeSetUtilities.unmodifiableView(updates);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:UnixPrintService.java

示例5: getUpdatedAttributes

import javax.print.attribute.Attribute; //导入依赖的package包/类
public PrintServiceAttributeSet getUpdatedAttributes() {
    PrintServiceAttributeSet currSet = getDynamicAttributes();
    if (lastSet == null) {
        lastSet = currSet;
        return AttributeSetUtilities.unmodifiableView(currSet);
    } else {
        PrintServiceAttributeSet updates =
            new HashPrintServiceAttributeSet();
        Attribute []attrs =  currSet.toArray();
        for (int i=0; i<attrs.length; i++) {
            Attribute attr = attrs[i];
            if (!lastSet.containsValue(attr)) {
                updates.add(attr);
            }
        }
        lastSet = currSet;
        return AttributeSetUtilities.unmodifiableView(updates);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:Win32PrintService.java

示例6: isSupportedValue

import javax.print.attribute.Attribute; //导入依赖的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

示例7: getUnsupportedValues

import javax.print.attribute.Attribute; //导入依赖的package包/类
public Attribute[] getUnsupportedValues() {
    if (attr == null) {
        return null;
    } else {
        Attribute [] attrs = { attr};
        return attrs;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:PrintJobAttributeException.java

示例8: getUnsupportedAttributes

import javax.print.attribute.Attribute; //导入依赖的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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:UnixPrintService.java

示例9: printTest

import javax.print.attribute.Attribute; //导入依赖的package包/类
private static void printTest() {
    ServiceDlgSheetCollateTest pd = new ServiceDlgSheetCollateTest();
    DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG;
    //DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
    PrintService defService = null, service[] = null;
    defService = PrintServiceLookup.lookupDefaultPrintService();
    service = PrintServiceLookup.lookupPrintServices(flavor, null);

    if ((service == null) || (service.length == 0)) {
        throw new RuntimeException("No Printer services found");
    }
    if (defService != null) {
        System.out.println("\nDefault print service: " + service );
        System.out.println("is flavor: "+flavor+" supported? "+
                        defService.isDocFlavorSupported(flavor));
        System.out.println("is SheetCollate category supported? "+
              defService.isAttributeCategorySupported(SheetCollate.class));
        System.out.println("is SheetCollate.COLLATED value supported ? "+
              defService.isAttributeValueSupported(SheetCollate.COLLATED,
                                                        flavor, null));
    }
    HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
    try {
        PrintService selService = ServiceUI.printDialog(null, 200, 200, service, defService, flavor, prSet);
    } catch (IllegalArgumentException ia) {
        System.out.println("Exception thrown : " + ia);
    }

    System.out.println("\nSelected Values\n");
    Attribute attr[] = prSet.toArray();
    for (int x = 0; x < attr.length; x ++) {
        System.out.println("Attribute: " + attr[x].getName() + " Value: " + attr[x]);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:ServiceDlgSheetCollateTest.java

示例10: matchesAttributes

import javax.print.attribute.Attribute; //导入依赖的package包/类
private boolean matchesAttributes(PrintService service,
                                  PrintServiceAttributeSet attributes) {

    Attribute [] attrs =  attributes.toArray();
    Attribute serviceAttr;
    for (int i=0; i<attrs.length; i++) {
        serviceAttr
            = service.getAttribute((Class<PrintServiceAttribute>)attrs[i].getCategory());
        if (serviceAttr == null || !serviceAttr.equals(attrs[i])) {
            return false;
        }
    }
    return true;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:UnixPrintServiceLookup.java

示例11: setSidesAttrib

import javax.print.attribute.Attribute; //导入依赖的package包/类
private void setSidesAttrib(Attribute attr) {
    if (attr == Sides.TWO_SIDED_LONG_EDGE) {
        mAttSides = 2; // DMDUP_VERTICAL
    } else if (attr == Sides.TWO_SIDED_SHORT_EDGE) {
        mAttSides = 3; // DMDUP_HORIZONTAL
    } else { // Sides.ONE_SIDED
        mAttSides = 1;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:WPrinterJob.java

示例12: setQualityAttrib

import javax.print.attribute.Attribute; //导入依赖的package包/类
private void setQualityAttrib(Attribute attr) {
    if (attr == PrintQuality.HIGH) {
        mAttQuality = -4; // DMRES_HIGH
    } else if (attr == PrintQuality.NORMAL) {
        mAttQuality = -3; // DMRES_MEDIUM
    } else {
        mAttQuality = -2; // DMRES_LOW
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:WPrinterJob.java

示例13: setColorAttrib

import javax.print.attribute.Attribute; //导入依赖的package包/类
private void setColorAttrib(Attribute attr) {
    if (attr == Chromaticity.COLOR) {
        mAttChromaticity = 2; // DMCOLOR_COLOR
    } else {
        mAttChromaticity = 1; // DMCOLOR_MONOCHROME
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:WPrinterJob.java

示例14: setCollateAttrib

import javax.print.attribute.Attribute; //导入依赖的package包/类
private void setCollateAttrib(Attribute attr) {
    if (attr == SheetCollate.COLLATED) {
        mAttCollate = 1; // DMCOLLATE_TRUE
    } else {
        mAttCollate = 0; // DMCOLLATE_FALSE
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:WPrinterJob.java

示例15: getUnsupportedAttributes

import javax.print.attribute.Attribute; //导入依赖的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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:PSStreamPrintService.java


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