Java 类javax.print.attribute.PrintJobAttribute 实例源码

项目:cn1    文件:WinPrintJob.java   
void notifyAttrListeners(final PrintJobAttribute... attrs) {
    final PrintJobAttributeSet attrSet = new HashPrintJobAttributeSet(attrs);
    final PrintJobAttributeEvent event = new PrintJobAttributeEvent(this,
                    attrSet);

    for (PrintJobAttribute attr : attrs) {
        final Class<? extends Attribute> cat = attr.getCategory();

        for (Map.Entry<PrintJobAttributeListener, PrintJobAttributeSet> e : attrListeners
                        .entrySet()) {
            if ((e.getValue() == null) || (e.getValue().containsKey(cat))) {
                e.getKey().attributeUpdate(event);
            }
        }
    }
}
项目:cn1    文件:WinPrintJob.java   
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));
}
项目:freeVM    文件:WinPrintJob.java   
void notifyAttrListeners(final PrintJobAttribute... attrs) {
    final PrintJobAttributeSet attrSet = new HashPrintJobAttributeSet(attrs);
    final PrintJobAttributeEvent event = new PrintJobAttributeEvent(this,
                    attrSet);

    for (PrintJobAttribute attr : attrs) {
        final Class<? extends Attribute> cat = attr.getCategory();

        for (Map.Entry<PrintJobAttributeListener, PrintJobAttributeSet> e : attrListeners
                        .entrySet()) {
            if ((e.getValue() == null) || (e.getValue().containsKey(cat))) {
                e.getKey().attributeUpdate(event);
            }
        }
    }
}
项目:freeVM    文件:WinPrintJob.java   
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));
}
项目:cn1    文件:WinPrintJob.java   
public PrintJobAttributeSet getAttributes() {
    final PrintJobAttributeSet attrs = service.getPrinterProps()
                    .getAttributes(new HashPrintJobAttributeSet());

    for (Attribute attr : attrs.toArray()) {
        if (!(attr instanceof PrintJobAttribute)) {
            attrs.remove(attr);
        }
    }

    return AttributeSetUtilities.unmodifiableView(attrs);
}
项目:freeVM    文件:WinPrintJob.java   
public PrintJobAttributeSet getAttributes() {
    final PrintJobAttributeSet attrs = service.getPrinterProps()
                    .getAttributes(new HashPrintJobAttributeSet());

    for (Attribute attr : attrs.toArray()) {
        if (!(attr instanceof PrintJobAttribute)) {
            attrs.remove(attr);
        }
    }

    return AttributeSetUtilities.unmodifiableView(attrs);
}
项目:cn1    文件:ValueTests.java   
public void testHashPrintJobAttributeSet() {
    startTest("HashPrintJobAttributeSet class testing...");

    PrintJobAttributeSet set1 = new HashPrintJobAttributeSet();
    PrintJobAttributeSet set2 = 
        new HashPrintJobAttributeSet(OrientationRequested.LANDSCAPE);
    PrintJobAttributeSet set3 = new HashPrintJobAttributeSet(set2);
    PrintJobAttribute [] arr = {OrientationRequested.LANDSCAPE,
                                MediaName.NA_LETTER_WHITE};
    PrintJobAttributeSet set4 = new HashPrintJobAttributeSet(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);
}
项目:freeVM    文件:ValueTests.java   
public void testHashPrintJobAttributeSet() {
    startTest("HashPrintJobAttributeSet class testing...");

    PrintJobAttributeSet set1 = new HashPrintJobAttributeSet();
    PrintJobAttributeSet set2 = 
        new HashPrintJobAttributeSet(OrientationRequested.LANDSCAPE);
    PrintJobAttributeSet set3 = new HashPrintJobAttributeSet(set2);
    PrintJobAttribute [] arr = {OrientationRequested.LANDSCAPE,
                                MediaName.NA_LETTER_WHITE};
    PrintJobAttributeSet set4 = new HashPrintJobAttributeSet(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);
}
项目:freeVM    文件:ValueTests.java   
public void testHashPrintJobAttributeSet() {
    startTest("HashPrintJobAttributeSet class testing...");

    PrintJobAttributeSet set1 = new HashPrintJobAttributeSet();
    PrintJobAttributeSet set2 = 
        new HashPrintJobAttributeSet(OrientationRequested.LANDSCAPE);
    PrintJobAttributeSet set3 = new HashPrintJobAttributeSet(set2);
    PrintJobAttribute [] arr = {OrientationRequested.LANDSCAPE,
                                MediaName.NA_LETTER_WHITE};
    PrintJobAttributeSet set4 = new HashPrintJobAttributeSet(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);
}