本文整理汇总了Java中javax.print.attribute.HashAttributeSet类的典型用法代码示例。如果您正苦于以下问题:Java HashAttributeSet类的具体用法?Java HashAttributeSet怎么用?Java HashAttributeSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HashAttributeSet类属于javax.print.attribute包,在下文中一共展示了HashAttributeSet类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import javax.print.attribute.HashAttributeSet; //导入依赖的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];
}
}
示例2: getUnsupportedAttributes
import javax.print.attribute.HashAttributeSet; //导入依赖的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;
}
示例3: getUnsupportedAttributes
import javax.print.attribute.HashAttributeSet; //导入依赖的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;
}
示例4: testMediaCategory
import javax.print.attribute.HashAttributeSet; //导入依赖的package包/类
public final void testMediaCategory() {
HashAttributeSet aset = new HashAttributeSet();
MediaSizeName msn = MediaSizeName.ISO_A3;
aset.add(msn);
assertEquals(msn, aset.get(Media.class));
assertNull(aset.get(MediaSizeName.class));
MediaTray mt = MediaTray.BOTTOM;
aset.add(mt);
assertEquals(mt, aset.get(Media.class));
assertNull(aset.get(MediaTray.class));
MediaName mn = MediaName.ISO_A4_WHITE;
aset.add(mn);
assertEquals(mn, aset.get(Media.class));
assertNull(aset.get(MediaName.class));
}
示例5: getUnsupportedAttributes
import javax.print.attribute.HashAttributeSet; //导入依赖的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;
}
}
示例6: getUnsupportedAttributes
import javax.print.attribute.HashAttributeSet; //导入依赖的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;
}
}
示例7: getUnsupportedAttributes
import javax.print.attribute.HashAttributeSet; //导入依赖的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;
}
}
示例8: lookupByName
import javax.print.attribute.HashAttributeSet; //导入依赖的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;
}
示例9: getUnsupportedAttributes
import javax.print.attribute.HashAttributeSet; //导入依赖的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;
}
}
示例10: lookupByName
import javax.print.attribute.HashAttributeSet; //导入依赖的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;
}