Package javax.print.attribute

Examples of javax.print.attribute.HashPrintRequestAttributeSet


public void testPrintJob() {
    startTest("PrintJob class testing...");
    DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
    PrintRequestAttributeSet printRequestSet =
            new HashPrintRequestAttributeSet();
    PrintService service = getPrintService(flavor, printRequestSet);
    if (service != null) {
        DocPrintJob job = service.createPrintJob();
        assertEquals(job.getPrintService(), service);
    } else {
View Full Code Here


public void testHashPrintRequestAttributeSet() {
    startTest("HashPrintRequestAttributeSet class testing...");

    Copies copies = new Copies(2);
    PrintRequestAttributeSet set1 = new HashPrintRequestAttributeSet();
    PrintRequestAttributeSet set2 = new HashPrintRequestAttributeSet(copies);
    PrintRequestAttributeSet set3 = new HashPrintRequestAttributeSet(set2);
    PrintRequestAttribute [] arr = {copies,
                                    MediaName.NA_LETTER_WHITE};
    PrintRequestAttributeSet set4 = new HashPrintRequestAttributeSet(arr);
    Attribute [] attrArr = set1.toArray();

    assertTrue(set1.isEmpty());
    assertFalse(set2.isEmpty());
    assertTrue(set3.equals(set2));
    assertFalse(set3.equals(set1));
    set3.clear();
    assertEquals(set3, set1);
    set3.add(copies);
    set3.add(MediaName.NA_LETTER_WHITE);
    assertTrue(set3.containsKey(copies.getClass()));
    assertFalse(set2.containsKey(MediaName.NA_LETTER_WHITE.getClass()));
    assertTrue(set3.containsValue(copies));
    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(copies.getClass()), copies);
    set1.addAll(set3);
    assertEquals(set3, set1);
    set1.remove(copies.getClass());
    assertEquals(set1.size(), 1);
View Full Code Here

                .println("======= START LookupDefaultPrintServiceTest ======");

        DocFlavor psFlavor = DocFlavor.INPUT_STREAM.GIF;
        PrintService service;
        InputStream fis;
        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        HashDocAttributeSet daset = new HashDocAttributeSet();
        DocPrintJob pj;
        Doc doc;

        aset.add(new Copies(2));
        aset.add(MediaSizeName.ISO_A4);
        daset.add(MediaName.ISO_A4_WHITE);
        daset.add(Sides.TWO_SIDED_LONG_EDGE);

        service = PrintServiceLookup.lookupDefaultPrintService();
        if (service != null) {
View Full Code Here

    private DocFlavor assignDocFlavor() throws Exception {
        return config.getDocFlavor();     
    }   

    private PrintRequestAttributeSet assignPrintAttributes() throws PrintException {
        PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
        if (config.getCopies() >= 1) {
            printRequestAttributeSet.add(new Copies(config.getCopies()));
        } else {
            throw new PrintException("Number of print copies should be greater than zero");
        }
        printRequestAttributeSet.add(config.getMediaSizeName());
        printRequestAttributeSet.add(config.getInternalSides());
       
        return printRequestAttributeSet;
    }
View Full Code Here

        if (printService == null) {
            throw new PrintException("Printer lookup failure. No default printer set up for this host");
        }
        job = printService.createPrintJob();
        flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
        printRequestAttributeSet = new HashPrintRequestAttributeSet();
        printRequestAttributeSet.add(new Copies(1));
        printRequestAttributeSet.add(MediaSizeName.NA_LETTER);
        printRequestAttributeSet.add(Sides.ONE_SIDED);
    }
View Full Code Here

     * @param name The MediaSizeName to check
     */
    private void checkAndAddSize(MediaSizeName name) {

        //Check if available on this printer
        PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
        if (!printService.isAttributeValueSupported(name, new DocFlavor.BYTE_ARRAY(DocFlavor.BYTE_ARRAY.PNG.getMimeType()), attributes))
            return;


        //Get name and lookup in our name map
        Object o = paperNames.get(name.toString());
        String printDescription;
        if (o != null)
            printDescription=o.toString();
        else
            printDescription=name.toString();


        //Get paper size
        MediaSize size = MediaSize.getMediaSizeForName(name);
        double pX = size.getX(MediaSize.MM);
        double pY = size.getY(MediaSize.MM);


        //Get printable area
        attributes.add(name);
        MediaPrintableArea[] area = (MediaPrintableArea[])printService.getSupportedAttributeValues(MediaPrintableArea.class,null,attributes);

        if (area.length==0)
            return;

View Full Code Here

        //On my cheap tesco printer this return null, so accounted for that case.
//        if(area != null) {
//            imagable = area.getPrintableArea(Size2DSyntax.INCH);
//        }
//        else {
          PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
          attributes.add(mediaSizeName);
          MediaPrintableArea areas[] = (MediaPrintableArea[]) printingDevice.getSupportedAttributeValues(MediaPrintableArea.class, null, attributes);
         
          if(testFlag && areas==null)
          System.out.println("Printable Area array is null");
         
View Full Code Here

        {

          exporter = new JRPrintServiceExporter();
          exporter.setExporterInput(new SimpleExporterInput(jasperPrint));

          PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
          printRequestAttributeSet.add(new Copies(mod.getPrintCopies()));


          PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
          printServiceAttributeSet.add(new PrinterName(JPrint.getPrinterServicebyName(printQueue).getName(), Locale.getDefault()));
View Full Code Here

          serviceAttributeSet = new HashPrintServiceAttributeSet();
          serviceAttributeSet.add(new PrinterName(JPrint.getPrinterShortName(JPrint.getPreferredPrinterQueueName()), null));
          exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, serviceAttributeSet);
          exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
          exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, mod.isPrintDialog());
          PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
          printRequestAttributeSet.add(new Copies(mod.getPrintCopies()));
          exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet);
          exporter.exportReport();
         
          /* Alternative method
            exporter = new JRPrintServiceExporter();
View Full Code Here

      //  get format
      if (m_layout == null)
        layout();
      //  print it
      sps.createPrintJob().print(m_layout.getPageable(false),
        new HashPrintRequestAttributeSet());
      //
      os.flush();
      //following 2 line for backward compatibility
      if (os instanceof FileOutputStream)
        ((FileOutputStream)os).close();
View Full Code Here

TOP

Related Classes of javax.print.attribute.HashPrintRequestAttributeSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.