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


Java AttributeSet.add方法代码示例

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


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

示例1: create

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
@Override
public void create(String filename) {
	// find the printing service
	//http://www.coderanch.com/t/385989/java/java/send-raw-data-printer
	AttributeSet attributeSet = new HashAttributeSet();  
	attributeSet.add(new PrinterName(filename, null));
	PrintService[] services = PrintServiceLookup.lookupPrintServices(null, attributeSet);
	if(services.length > 0){
		if(printFile != null){
			printFile.deleteOnExit();
			printFile = null;
		}
		try {
			printFile = File.createTempFile("printer_"+name,".redirect");
		} catch (IOException e) {
			e.printStackTrace();
		}
		printService = services[0];
	}
	
}
 
开发者ID:thshdw,项目名称:lixia-javardp,代码行数:22,代码来源:Printer.java

示例2: getUnsupportedAttributes

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

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

    final AttributeSet result = new HashAttributeSet();

    for (Attribute attr : attributes.toArray()) {
        if (!isAttributeValueSupported(attr, flavor, attributes)) {
            result.add(attr);
        }
    }

    return result.size() > 0 ? result : null;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:WinPrintService.java

示例3: getUnsupportedAttributes

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

示例4: removeUnsupportedAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
 * Removes any attributes from the given AttributeSet that are
 * unsupported by the given PrintService/DocFlavor combination.
 */
private static void removeUnsupportedAttributes(PrintService ps,
                                                DocFlavor flavor,
                                                AttributeSet aset)
{
    AttributeSet asUnsupported = ps.getUnsupportedAttributes(flavor,
                                                             aset);

    if (asUnsupported != null) {
        Attribute[] usAttrs = asUnsupported.toArray();

        for (int i=0; i<usAttrs.length; i++) {
            Class category = usAttrs[i].getCategory();

            if (ps.isAttributeCategorySupported(category)) {
                Attribute attr =
                    (Attribute)ps.getDefaultAttributeValue(category);

                if (attr != null) {
                    aset.add(attr);
                } else {
                    aset.remove(category);
                }
            } else {
                aset.remove(category);
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:ServiceUI.java

示例5: getUnsupportedAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的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,代码来源:Win32PrintService.java

示例6: getUnsupportedAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的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,代码来源:UnixPrintService.java

示例7: lookupByName

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
private static PrintService lookupByName(String name) {
  AttributeSet attributes = new HashAttributeSet();
  attributes.add(new PrinterName(name, null));
  for (PrintService service : PrintServiceLookup.lookupPrintServices(null, attributes)) {
    return service;
  }
  return null;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:GetPrintServices.java

示例8: removeUnsupportedAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
 * Removes any attributes from the given {@code AttributeSet} that are
 * unsupported by the given {@code PrintService/DocFlavor} combination.
 */
private static void removeUnsupportedAttributes(PrintService ps,
                                                DocFlavor flavor,
                                                AttributeSet aset)
{
    AttributeSet asUnsupported = ps.getUnsupportedAttributes(flavor,
                                                             aset);

    if (asUnsupported != null) {
        Attribute[] usAttrs = asUnsupported.toArray();

        for (int i=0; i<usAttrs.length; i++) {
            Class<? extends Attribute> category = usAttrs[i].getCategory();

            if (ps.isAttributeCategorySupported(category)) {
                Attribute attr =
                    (Attribute)ps.getDefaultAttributeValue(category);

                if (attr != null) {
                    aset.add(attr);
                } else {
                    aset.remove(category);
                }
            } else {
                aset.remove(category);
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:ServiceUI.java

示例9: getUnsupportedAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:Win32PrintService.java

示例10: lookupByName

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
private static PrintService lookupByName(String name) {
    AttributeSet attributes = new HashAttributeSet();
    attributes.add(new PrinterName(name, null));
    for (PrintService service :
         PrintServiceLookup.lookupPrintServices(null, attributes)) {
        return service;
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:GetPrintServices.java

示例11: removeUnsupportedAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
 * Removes any attributes from the given AttributeSet that are
 * unsupported by the given PrintService/DocFlavor combination.
 */
private static void removeUnsupportedAttributes(PrintService ps,
                                                DocFlavor flavor,
                                                AttributeSet aset)
{
    AttributeSet asUnsupported = ps.getUnsupportedAttributes(flavor,
                                                             aset);

    if (asUnsupported != null) {
        Attribute[] usAttrs = asUnsupported.toArray();

        for (int i=0; i<usAttrs.length; i++) {
            Class<? extends Attribute> category = usAttrs[i].getCategory();

            if (ps.isAttributeCategorySupported(category)) {
                Attribute attr =
                    (Attribute)ps.getDefaultAttributeValue(category);

                if (attr != null) {
                    aset.add(attr);
                } else {
                    aset.remove(category);
                }
            } else {
                aset.remove(category);
            }
        }
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:33,代码来源:ServiceUI.java

示例12: testIsAttributeValueSupported

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
public void testIsAttributeValueSupported() throws Exception {
    System.out
            .println("============= START GetUnsupportedAttributesTest ================");

    PrintService[] services;
    DocFlavor[] flavors = new DocFlavor[] { DocFlavor.INPUT_STREAM.GIF,
            DocFlavor.INPUT_STREAM.POSTSCRIPT,
            DocFlavor.INPUT_STREAM.TEXT_PLAIN_US_ASCII };

    services = PrintServiceLookup.lookupPrintServices(null, null);
    TestUtil.checkServices(services);
    if (services.length > 0) {
        for (int i = 0, ii = services.length; i < ii; i++) {
            System.out.println("----------- " + services[i].getName()
                    + "----------");

            URI uri = null;
            try {
                uri = new URI("file:///c:/no/such/dir/print.out");
                //uri = File.createTempFile("xxx", null).toURI();
            } catch (URISyntaxException e) {
                fail();
            }

            AttributeSet attrs = new HashAttributeSet();
            attrs.add(Finishings.EDGE_STITCH);
            attrs.add(MediaSizeName.JAPANESE_DOUBLE_POSTCARD);
            attrs.add(new Destination(uri));
            attrs.add(new DocumentName("Doc X", Locale.US));
            attrs.add(new JobName("Job Y", Locale.US));
            attrs.add(new RequestingUserName("User Z", Locale.US));

            for (int j = 0; j < flavors.length; j++) {
                if (services[i].isDocFlavorSupported(flavors[j])) {
                    AttributeSet aset = services[i]
                            .getUnsupportedAttributes(flavors[j], attrs);
                    if (aset == null) {
                        fail("At least one attribute is unsupported");
                    }
                    if (aset != null) {
                        Attribute[] aarr = aset.toArray();
                        System.out
                                .println("Usupported attributes fo DocFlavor "
                                        + flavors[j]);
                        for (int k = 0, kk = aarr.length; k < kk; k++) {
                            System.out.println("\t" + aarr[k]);
                        }
                    }
                }
            }
        }
    }

    System.out
            .println("============= END GetUnsupportedAttributesTest ================");
}
 
开发者ID:shannah,项目名称:cn1,代码行数:57,代码来源:GetUnsupportedAttributesTest.java


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