• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AttributeSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: lookupPrintServices

import javax.print.attribute.AttributeSet; //导入依赖的package包/类
/**
 * Searches print services capable of printing in the given document flavor
 * which supports the specified printing attributes.
 *
 * @param flavor the document flavor to support. If <code>null</code> this
 * constraint is ignored during lookup.
 * @param attributes the printing attributes to support. If
 * <code>null</code> this constraint is ignored during lookup.
 * @return The resulting available print services, or an array of length 0
 * if none is found.
 */
public static final PrintService[] lookupPrintServices(DocFlavor flavor,
  AttributeSet attributes)
{
  ArrayList result = new ArrayList();

  PrintService[] services =
    systemProvider.getPrintServices(flavor, attributes);
  result.addAll(Arrays.asList(services));

  for (Iterator it = printServiceLookups.iterator(); it.hasNext(); )
    {
      PrintServiceLookup lookup = (PrintServiceLookup) it.next();
      services = lookup.getPrintServices(flavor, attributes);
      result.addAll(Arrays.asList(services));
    }

  for (Iterator it = printServices.iterator(); it.hasNext(); )
    {
      PrintService service = (PrintService) it.next();
      if (systemProvider.checkPrintService(flavor, attributes, service))
        result.add(service);
    }

  return (PrintService[]) result.toArray(new PrintService[result.size()]);
}
 
开发者ID:vilie,项目名称:javify,代码行数:37,代码来源:PrintServiceLookup.java


示例2: getMultiDocPrintServices

import javax.print.attribute.AttributeSet; //导入依赖的package包/类
/**
* All printers and printer classes of the CUPS server are checked.
* If flavors or attributes are null the constraint is not used.
*
* @param flavors the document flavors which have to be supported.
* @param attributes the attributes which have to be supported.
*
* @return The multidoc print services of the implementing lookup service
* for the given parameters, or an array of length 0 if none is available.
*/
public MultiDocPrintService[] getMultiDocPrintServices(DocFlavor[] flavors,
    AttributeSet attributes)
{
  ArrayList result = new ArrayList();
  PrintService[] services = getPrintServices();

  for (int i=0; i < services.length; i++)
    {
      if (checkMultiDocPrintService(flavors, attributes, services[i]))
        result.add(services[i]);
    }

  return (MultiDocPrintService[]) result.toArray(
    new MultiDocPrintService[result.size()]);
}
 
开发者ID:vilie,项目名称:javify,代码行数:26,代码来源:CupsPrintServiceLookup.java


示例3: checkPrintService

import javax.print.attribute.AttributeSet; //导入依赖的package包/类
/**
 * Checks the given print service - own method so it can be used also
 * to check application registered print services from PrintServiceLookup.
 *
 * @param flavor the document flavor which has to be supported.
 * @param attributes the attributes which have to be supported.
 * @param service the service to check
 *
 * @return <code>true</code> if all constraints match, <code>false</code>
 * otherwise.
 */
public boolean checkPrintService(DocFlavor flavor, AttributeSet attributes,
  PrintService service)
{
  boolean allAttributesSupported = true;
  if (flavor == null || service.isDocFlavorSupported(flavor))
    {
      if (attributes == null || attributes.size() == 0)
        return allAttributesSupported;

      Attribute[] atts = attributes.toArray();
      for (int i = 0; i < atts.length; i++)
        {
          if (! service.isAttributeCategorySupported(atts[i].getCategory()))
            {
              allAttributesSupported = false;
              break;
            }
        }
      return allAttributesSupported;
    }

  return false;
}
 
开发者ID:vilie,项目名称:javify,代码行数:35,代码来源:CupsPrintServiceLookup.java


示例4: lookupPrintServices

import javax.print.attribute.AttributeSet; //导入依赖的package包/类
/**
 * Searches print services capable of printing in the given document flavor
 * which supports the specified printing attributes.
 * 
 * @param flavor the document flavor to support. If <code>null</code> this 
 * constraint is ignored during lookup.
 * @param attributes the printing attributes to support. If 
 * <code>null</code> this constraint is ignored during lookup.
 * @return The resulting available print services, or an array of length 0 
 * if none is found. 
 */
public static final PrintService[] lookupPrintServices(DocFlavor flavor,
  AttributeSet attributes)
{   
  ArrayList result = new ArrayList();
  
  PrintService[] services = 
    systemProvider.getPrintServices(flavor, attributes);    
  result.addAll(Arrays.asList(services));
           
  for (Iterator it = printServiceLookups.iterator(); it.hasNext(); )
    {
      PrintServiceLookup lookup = (PrintServiceLookup) it.next();
      services = lookup.getPrintServices(flavor, attributes);   
      result.addAll(Arrays.asList(services));
    }
  
  for (Iterator it = printServices.iterator(); it.hasNext(); )
    {
      PrintService service = (PrintService) it.next();
      if (systemProvider.checkPrintService(flavor, attributes, service)) 
        result.add(service);
    }
  
  return (PrintService[]) result.toArray(new PrintService[result.size()]);
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:37,代码来源:PrintServiceLookup.java


示例5: getMultiDocPrintServices

import javax.print.attribute.AttributeSet; //导入依赖的package包/类
/**
* All printers and printer classes of the CUPS server are checked.
* If flavors or attributes are null the constraint is not used.
* 
* @param flavors the document flavors which have to be supported.
* @param attributes the attributes which have to be supported.
* 
* @return The multidoc print services of the implementing lookup service
* for the given parameters, or an array of length 0 if none is available.
*/
public MultiDocPrintService[] getMultiDocPrintServices(DocFlavor[] flavors,
    AttributeSet attributes)
{
  ArrayList result = new ArrayList();
  PrintService[] services = getPrintServices();   
  
  for (int i=0; i < services.length; i++)
    {
      if (checkMultiDocPrintService(flavors, attributes, services[i]))
        result.add(services[i]);  
    }
  
  return (MultiDocPrintService[]) result.toArray(
    new MultiDocPrintService[result.size()]);
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:26,代码来源:CupsPrintServiceLookup.java


示例6: checkPrintService

import javax.print.attribute.AttributeSet; //导入依赖的package包/类
/**
 * Checks the given print service - own method so it can be used also
 * to check application registered print services from PrintServiceLookup.
 * 
 * @param flavor the document flavor which has to be supported.
 * @param attributes the attributes which have to be supported.
 * @param service the service to check
 * 
 * @return <code>true</code> if all constraints match, <code>false</code> 
 * otherwise.
 */
public boolean checkPrintService(DocFlavor flavor, AttributeSet attributes,
  PrintService service)
{
  boolean allAttributesSupported = true;
  if (flavor == null || service.isDocFlavorSupported(flavor))
    {
      if (attributes == null || attributes.size() == 0)
        return allAttributesSupported;
     
      Attribute[] atts = attributes.toArray();
      for (int i = 0; i < atts.length; i++)
        {
          if (! service.isAttributeCategorySupported(atts[i].getCategory()))
            {
              allAttributesSupported = false;
              break;
            }
        }
      return allAttributesSupported;
    }
  
  return false;
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:35,代码来源:CupsPrintServiceLookup.java


示例7: 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


示例8: 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


示例9: notifyAttrListeners

import javax.print.attribute.AttributeSet; //导入依赖的package包/类
void notifyAttrListeners(final AttributeSet... attrSets) {
    final List<PrintJobAttribute> list = new ArrayList<PrintJobAttribute>();
    final PrintJobAttribute[] attrs;

    for (AttributeSet attrSet : attrSets) {
        if (attrSet != null) {
            for (Attribute attr : attrSet.toArray()) {
                if (attr instanceof PrintJobAttribute) {
                    list.add((PrintJobAttribute) attr);
                }
            }
        }
    }

    attrs = new PrintJobAttribute[list.size()];
    notifyAttrListeners(list.toArray(attrs));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:WinPrintJob.java


示例10: getDocName

import javax.print.attribute.AttributeSet; //导入依赖的package包/类
private String getDocName(final Object doc,
                final AttributeSet... attrSets) {
    Attribute name = getAttribute(DocumentName.class, attrSets);

    if (name == null) {
        name = getAttribute(JobName.class, attrSets);
    }

    if ((name == null) && (doc instanceof Component)) {
        Component c = (Component) doc;

        while (c != null) {
            if (c instanceof Frame) {
                if (((Frame) c).getTitle().length() > 0) {
                    return ((Frame) c).getTitle();
                }
            }
            c = c.getParent();
        }
    }

    return name != null ? ((TextSyntax) name).getValue()
                    : WinPrintService.DEFAULT_JOB_NAME.getValue();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:25,代码来源:WinPrintJob.java


示例11: getPrintServices

import javax.print.attribute.AttributeSet; //导入依赖的package包/类
@Override
public PrintService[] getPrintServices(final DocFlavor flavor,
                final AttributeSet attributes) {
    final PrintService[] matchingServices;
    final PrintService[] allServices = getPrintServices();
    final Vector<PrintService> v = new Vector<PrintService>(
                    allServices.length);

    for (PrintService srv : allServices) {
        if (((flavor == null) || srv.isDocFlavorSupported(flavor))
                        && (srv
                                        .getUnsupportedAttributes(flavor,
                                                        attributes) == null)) {
            v.add(srv);
        }
    }

    matchingServices = new PrintService[v.size()];
    return v.toArray(matchingServices);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:WinPrintServiceLookup.java


示例12: getPrintServices

import javax.print.attribute.AttributeSet; //导入依赖的package包/类
public PrintService[] getPrintServices(DocFlavor flavor,
        AttributeSet attributes) {
    PrintService[] services = getPrintServices();
    if (flavor == null && attributes == null) {
        return services;
    }
    ArrayList requestedServices = new ArrayList();
    for (int i = 0; i < services.length; i++) {
        
        try {
            AttributeSet unsupportedSet =
                services[i].getUnsupportedAttributes(flavor, attributes);
            if (unsupportedSet == null && (flavor == null ||
                    services[i].isDocFlavorSupported(flavor))) {
                requestedServices.add(services[i]);
            }
        } catch (IllegalArgumentException iae) {
            // DocFlavor not supported by service, skiping.
        }
    }
    return (requestedServices.size() == 0) ? new PrintService[0] :
        (PrintService[])requestedServices.toArray(new PrintService[0]);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:Win32PrintServiceProvider.java


示例13: getUnsupportedAttributes

import javax.print.attribute.AttributeSet; //导入依赖的package包/类
public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
        AttributeSet attributes) {
    if (attributes == null) {
        return null;
    }
    if (flavor != null && !isDocFlavorSupported(flavor)) {
        throw new IllegalArgumentException("Flavor " + flavor.getMimeType()
                + " is not supported by print service");
    }
    
    Attribute[] attrs = attributes.toArray();
    HashAttributeSet unsupported = new HashAttributeSet();
    for (int i = 0; i < attrs.length; i++) {
        if (!isAttributeValueSupported(attrs[i], flavor, attributes)) {
            unsupported.add(attrs[i]);
        }
    }
    if (unsupported.size() > 0) {
        return unsupported;
    }
    return null;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:DefaultPrintService.java


示例14: getPrintServices

import javax.print.attribute.AttributeSet; //导入依赖的package包/类
public PrintService[] getPrintServices(DocFlavor flavor,
        AttributeSet attributes) {
    PrintService[] cupsservices = getPrintServices();
    if (flavor == null && attributes == null) {
        return cupsservices;
    }

    ArrayList requestedServices = new ArrayList();
    for (int i = 0; i < cupsservices.length; i++) {
        try {
            AttributeSet unsupportedSet = cupsservices[i]
                    .getUnsupportedAttributes(flavor, attributes);
            if (unsupportedSet == null) {
                requestedServices.add(cupsservices[i]);
            }
        } catch (IllegalArgumentException iae) {
            // DocFlavor not supported by service, skiping.
        }
    }
    return (requestedServices.size() == 0) ? new PrintService[0]
            : (PrintService[]) requestedServices
                    .toArray(new PrintService[0]);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:CUPSPrintServiceProvider.java


示例15: 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


示例16: 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


示例17: getMultiDocPrintServices

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


示例18: 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


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DirectoryScannerConfig类代码示例发布时间:2022-05-21
下一篇:
Java GradientNormalization类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap