本文整理汇总了Java中javax.print.attribute.AttributeSet类的典型用法代码示例。如果您正苦于以下问题:Java AttributeSet类的具体用法?Java AttributeSet怎么用?Java AttributeSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributeSet类属于javax.print.attribute包,在下文中一共展示了AttributeSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()]);
}
示例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()]);
}
示例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;
}
示例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()]);
}
示例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()]);
}
示例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;
}
示例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];
}
}
示例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;
}
示例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));
}
示例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();
}
示例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);
}
示例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]);
}
示例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;
}
示例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]);
}
示例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;
}
}