本文整理汇总了Java中javax.print.attribute.DocAttributeSet.add方法的典型用法代码示例。如果您正苦于以下问题:Java DocAttributeSet.add方法的具体用法?Java DocAttributeSet.add怎么用?Java DocAttributeSet.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.print.attribute.DocAttributeSet
的用法示例。
在下文中一共展示了DocAttributeSet.add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSimpleDoc
import javax.print.attribute.DocAttributeSet; //导入方法依赖的package包/类
public void testSimpleDoc() {
startTest("SimpleDoc class testing...");
DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
InputStream reader =
getClass().getResourceAsStream("/Resources/picture.gif");
if (reader == null) {
fail("/Resources/picture.gif resource is not found!");
}
DocAttributeSet aSet = new HashDocAttributeSet();
Doc doc = new SimpleDoc(reader, flavor, aSet);
assertEquals(doc.getAttributes(), aSet);
aSet.add(OrientationRequested.LANDSCAPE);
aSet.add(MediaName.NA_LETTER_WHITE);
assertEquals(doc.getAttributes(), aSet);
assertEquals(doc.getDocFlavor(), DocFlavor.INPUT_STREAM.GIF);
try {
assertTrue(doc.getPrintData() instanceof java.io.InputStream);
assertNull(doc.getReaderForText());
assertEquals(doc.getStreamForBytes(), reader);
} catch(Exception e) {
e.printStackTrace();
fail("Exception found: "+e);
}
}
示例2: testHashDocAttributeSet
import javax.print.attribute.DocAttributeSet; //导入方法依赖的package包/类
public void testHashDocAttributeSet() {
startTest("HashDocAttributeSet class testing...");
DocAttributeSet set1 = new HashDocAttributeSet();
DocAttributeSet set2 =
new HashDocAttributeSet(OrientationRequested.LANDSCAPE);
DocAttributeSet set3 = new HashDocAttributeSet(set2);
DocAttribute [] arr = {OrientationRequested.LANDSCAPE,
MediaName.NA_LETTER_WHITE};
DocAttributeSet set4 = new HashDocAttributeSet(arr);
Attribute [] attrArr;
assertTrue(set1.isEmpty());
assertFalse(set2.isEmpty());
assertTrue(set3.equals(set2));
assertFalse(set3.equals(set1));
set3.clear();
assertEquals(set3, set1);
set3.add(OrientationRequested.LANDSCAPE);
set3.add(MediaName.NA_LETTER_WHITE);
assertTrue(set3.containsKey(OrientationRequested.LANDSCAPE.getClass()));
assertFalse(set2.containsKey(MediaName.NA_LETTER_WHITE.getClass()));
assertTrue(set3.containsValue(OrientationRequested.LANDSCAPE));
assertFalse(set3.containsValue(OrientationRequested.PORTRAIT));
assertFalse(set3.containsValue(PrintQuality.DRAFT));
assertEquals(set1.size(), 0);
assertEquals(set2.size(), 1);
assertEquals(set3.size(), 2);
assertTrue(set4.equals(set3));
assertEquals(set3.get(OrientationRequested.PORTRAIT.getClass()),
OrientationRequested.LANDSCAPE);
assertFalse((set3.get(OrientationRequested.PORTRAIT.getClass()))
.equals(OrientationRequested.PORTRAIT));
set1.addAll(set3);
assertEquals(set3, set1);
set1.remove(OrientationRequested.PORTRAIT.getClass());
assertEquals(set1.size(), 1);
attrArr = set1.toArray();
assertEquals(attrArr.length, 1);
assertEquals(attrArr[0], MediaName.NA_LETTER_WHITE);
}