javax.print.attribute.DocAttributeSet Java Examples
The following examples show how to use
javax.print.attribute.DocAttributeSet.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrintTest.java From spring-boot with Apache License 2.0 | 6 votes |
private void printText2Action() { printStr = area.getText().trim(); if(printStr != null && printStr.length() > 0) { PAGES = getPagesCount(printStr); DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; PrintService printService = PrintServiceLookup.lookupDefaultPrintService(); DocPrintJob job = printService.createPrintJob(); PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); DocAttributeSet das = new HashDocAttributeSet(); Doc doc = new SimpleDoc(this, flavor, das); try { job.print(doc, pras); } catch(PrintException pe) { pe.printStackTrace(); } } else { JOptionPane.showConfirmDialog(null, "Sorry, Printer Job is Empty, Print Cancelled!", "Empty", -1, 2); } }
Example #2
Source File: SimpleDoc.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Constructs a <code>SimpleDoc</code> with the specified * print data, doc flavor and doc attribute set. * @param printData the print data object * @param flavor the <code>DocFlavor</code> object * @param attributes a <code>DocAttributeSet</code>, which can * be <code>null</code> * @throws IllegalArgumentException if <code>flavor</code> or * <code>printData</code> is <code>null</code>, or the * <code>printData</code> does not correspond * to the specified doc flavor--for example, the data is * not of the type specified as the representation in the * <code>DocFlavor</code>. */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #3
Source File: SimpleDoc.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Constructs a {@code SimpleDoc} with the specified print data, doc flavor * and doc attribute set. * * @param printData the print data object * @param flavor the {@code DocFlavor} object * @param attributes a {@code DocAttributeSet}, which can be {@code null} * @throws IllegalArgumentException if {@code flavor} or {@code printData} * is {@code null}, or the {@code printData} does not correspond to * the specified doc flavor--for example, the data is not of the * type specified as the representation in the {@code DocFlavor} */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class<?> repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #4
Source File: SimpleDoc.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a {@code SimpleDoc} with the specified * print data, doc flavor and doc attribute set. * @param printData the print data object * @param flavor the {@code DocFlavor} object * @param attributes a {@code DocAttributeSet}, which can * be {@code null} * @throws IllegalArgumentException if {@code flavor} or * {@code printData} is {@code null}, or the * {@code printData} does not correspond * to the specified doc flavor--for example, the data is * not of the type specified as the representation in the * {@code DocFlavor}. */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class<?> repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #5
Source File: SimpleDoc.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Constructs a <code>SimpleDoc</code> with the specified * print data, doc flavor and doc attribute set. * @param printData the print data object * @param flavor the <code>DocFlavor</code> object * @param attributes a <code>DocAttributeSet</code>, which can * be <code>null</code> * @throws IllegalArgumentException if <code>flavor</code> or * <code>printData</code> is <code>null</code>, or the * <code>printData</code> does not correspond * to the specified doc flavor--for example, the data is * not of the type specified as the representation in the * <code>DocFlavor</code>. */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #6
Source File: SimpleDoc.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Constructs a <code>SimpleDoc</code> with the specified * print data, doc flavor and doc attribute set. * @param printData the print data object * @param flavor the <code>DocFlavor</code> object * @param attributes a <code>DocAttributeSet</code>, which can * be <code>null</code> * @throws IllegalArgumentException if <code>flavor</code> or * <code>printData</code> is <code>null</code>, or the * <code>printData</code> does not correspond * to the specified doc flavor--for example, the data is * not of the type specified as the representation in the * <code>DocFlavor</code>. */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #7
Source File: SimpleDoc.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Constructs a <code>SimpleDoc</code> with the specified * print data, doc flavor and doc attribute set. * @param printData the print data object * @param flavor the <code>DocFlavor</code> object * @param attributes a <code>DocAttributeSet</code>, which can * be <code>null</code> * @throws IllegalArgumentException if <code>flavor</code> or * <code>printData</code> is <code>null</code>, or the * <code>printData</code> does not correspond * to the specified doc flavor--for example, the data is * not of the type specified as the representation in the * <code>DocFlavor</code>. */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #8
Source File: SimpleDoc.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Constructs a <code>SimpleDoc</code> with the specified * print data, doc flavor and doc attribute set. * @param printData the print data object * @param flavor the <code>DocFlavor</code> object * @param attributes a <code>DocAttributeSet</code>, which can * be <code>null</code> * @throws IllegalArgumentException if <code>flavor</code> or * <code>printData</code> is <code>null</code>, or the * <code>printData</code> does not correspond * to the specified doc flavor--for example, the data is * not of the type specified as the representation in the * <code>DocFlavor</code>. */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #9
Source File: SimpleDoc.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Constructs a <code>SimpleDoc</code> with the specified * print data, doc flavor and doc attribute set. * @param printData the print data object * @param flavor the <code>DocFlavor</code> object * @param attributes a <code>DocAttributeSet</code>, which can * be <code>null</code> * @throws IllegalArgumentException if <code>flavor</code> or * <code>printData</code> is <code>null</code>, or the * <code>printData</code> does not correspond * to the specified doc flavor--for example, the data is * not of the type specified as the representation in the * <code>DocFlavor</code>. */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #10
Source File: SimpleDoc.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Constructs a <code>SimpleDoc</code> with the specified * print data, doc flavor and doc attribute set. * @param printData the print data object * @param flavor the <code>DocFlavor</code> object * @param attributes a <code>DocAttributeSet</code>, which can * be <code>null</code> * @throws IllegalArgumentException if <code>flavor</code> or * <code>printData</code> is <code>null</code>, or the * <code>printData</code> does not correspond * to the specified doc flavor--for example, the data is * not of the type specified as the representation in the * <code>DocFlavor</code>. */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #11
Source File: LocatePrint.java From spring-boot with Apache License 2.0 | 5 votes |
public void printContent() { printStr = "打印测试内容";// 获取需要打印的目标文本 if (printStr != null && printStr.length() > 0) // 当打印内容不为空时 { PAGES = 1; // 获取打印总页数 // 指定打印输出格式 DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); // 定位默认的打印服务 PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras); PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService(); // PrintService printService = PrintServiceLookup.lookupDefaultPrintService(); // Toolkit.getDefaultToolkit().getPrintJob // 创建打印作业 PrintService service = ServiceUI.printDialog(null, 200, 200, printService, defaultService, flavor, pras); //PrintService service = ServiceUI.printDialog(null, 200, 200, printService, printService , flavor, pras); //DocPrintJob job = printService.createPrintJob(); DocPrintJob job = service.createPrintJob(); // 设置打印属性 // PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); // 设置纸张大小,也可以新建MediaSize类来自定义大小 pras.add(MediaSizeName.ISO_A4); DocAttributeSet das = new HashDocAttributeSet(); // 指定打印内容 Doc doc = new SimpleDoc(this, flavor, das); // 不显示打印对话框,直接进行打印工作 try { job.print(doc, pras); // 进行每一页的具体打印操作 } catch (PrintException pe) { pe.printStackTrace(); } } else { // 如果打印内容为空时,提示用户打印将取消 JOptionPane.showConfirmDialog(null,"Sorry, Printer Job is Empty, Print Cancelled!", "Empty", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE); } }
Example #12
Source File: SimpleDoc.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Constructs a <code>SimpleDoc</code> with the specified * print data, doc flavor and doc attribute set. * @param printData the print data object * @param flavor the <code>DocFlavor</code> object * @param attributes a <code>DocAttributeSet</code>, which can * be <code>null</code> * @throws IllegalArgumentException if <code>flavor</code> or * <code>printData</code> is <code>null</code>, or the * <code>printData</code> does not correspond * to the specified doc flavor--for example, the data is * not of the type specified as the representation in the * <code>DocFlavor</code>. */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #13
Source File: LocatePrint.java From spring-boot with Apache License 2.0 | 5 votes |
private void printFileAction() { // 构造一个文件选择器,默认为当前目录 JFileChooser fileChooser = new JFileChooser(); int state = fileChooser.showOpenDialog(null);//弹出文件选择对话框 if (state == fileChooser.APPROVE_OPTION)//如果用户选定了文件 { File file = fileChooser.getSelectedFile();//获取选择的文件 //构建打印请求属性集 PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); //设置打印格式,因为未确定文件类型,这里选择AUTOSENSE DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE; //查找所有的可用打印服务 PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras); //定位默认的打印服务 PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService(); //显示打印对话框 PrintService service = ServiceUI.printDialog(null, 200, 200, printService , defaultService, flavor, pras); if (service != null) { try { DocPrintJob job = service.createPrintJob();//创建打印作业 FileInputStream fis = new FileInputStream(file);//构造待打印的文件流 DocAttributeSet das = new HashDocAttributeSet(); Doc doc = new SimpleDoc(fis, flavor, das);//建立打印文件格式 job.print(doc, pras);//进行文件的打印 } catch(Exception e) { e.printStackTrace(); } } } }
Example #14
Source File: PrintTest.java From spring-boot with Apache License 2.0 | 5 votes |
private void printFileAction() { JFileChooser fileChooser = new JFileChooser(System.getProperty("USER_DIR")); // fileChooser.setFileFilter(new JavaFilter()); int state = fileChooser.showOpenDialog(this); if(state == 0) { File file = fileChooser.getSelectedFile(); PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE; PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras); PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService(); PrintService service = ServiceUI.printDialog(null, 200, 200, printService, defaultService, flavor, pras); if(service != null) try { DocPrintJob job = service.createPrintJob(); FileInputStream fis = new FileInputStream(file); DocAttributeSet das = new HashDocAttributeSet(); Doc doc = new SimpleDoc(fis, flavor, das); job.print(doc, pras); } catch(Exception e) { e.printStackTrace(); } } }
Example #15
Source File: SimpleDoc.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a <code>SimpleDoc</code> with the specified * print data, doc flavor and doc attribute set. * @param printData the print data object * @param flavor the <code>DocFlavor</code> object * @param attributes a <code>DocAttributeSet</code>, which can * be <code>null</code> * @throws IllegalArgumentException if <code>flavor</code> or * <code>printData</code> is <code>null</code>, or the * <code>printData</code> does not correspond * to the specified doc flavor--for example, the data is * not of the type specified as the representation in the * <code>DocFlavor</code>. */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #16
Source File: SimpleDoc.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a <code>SimpleDoc</code> with the specified * print data, doc flavor and doc attribute set. * @param printData the print data object * @param flavor the <code>DocFlavor</code> object * @param attributes a <code>DocAttributeSet</code>, which can * be <code>null</code> * @throws IllegalArgumentException if <code>flavor</code> or * <code>printData</code> is <code>null</code>, or the * <code>printData</code> does not correspond * to the specified doc flavor--for example, the data is * not of the type specified as the representation in the * <code>DocFlavor</code>. */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #17
Source File: SimpleDoc.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a <code>SimpleDoc</code> with the specified * print data, doc flavor and doc attribute set. * @param printData the print data object * @param flavor the <code>DocFlavor</code> object * @param attributes a <code>DocAttributeSet</code>, which can * be <code>null</code> * @throws IllegalArgumentException if <code>flavor</code> or * <code>printData</code> is <code>null</code>, or the * <code>printData</code> does not correspond * to the specified doc flavor--for example, the data is * not of the type specified as the representation in the * <code>DocFlavor</code>. */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #18
Source File: SimpleDoc.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Constructs a <code>SimpleDoc</code> with the specified * print data, doc flavor and doc attribute set. * @param printData the print data object * @param flavor the <code>DocFlavor</code> object * @param attributes a <code>DocAttributeSet</code>, which can * be <code>null</code> * @throws IllegalArgumentException if <code>flavor</code> or * <code>printData</code> is <code>null</code>, or the * <code>printData</code> does not correspond * to the specified doc flavor--for example, the data is * not of the type specified as the representation in the * <code>DocFlavor</code>. */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #19
Source File: SimpleDoc.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Constructs a <code>SimpleDoc</code> with the specified * print data, doc flavor and doc attribute set. * @param printData the print data object * @param flavor the <code>DocFlavor</code> object * @param attributes a <code>DocAttributeSet</code>, which can * be <code>null</code> * @throws IllegalArgumentException if <code>flavor</code> or * <code>printData</code> is <code>null</code>, or the * <code>printData</code> does not correspond * to the specified doc flavor--for example, the data is * not of the type specified as the representation in the * <code>DocFlavor</code>. */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #20
Source File: SimpleDoc.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Constructs a <code>SimpleDoc</code> with the specified * print data, doc flavor and doc attribute set. * @param printData the print data object * @param flavor the <code>DocFlavor</code> object * @param attributes a <code>DocAttributeSet</code>, which can * be <code>null</code> * @throws IllegalArgumentException if <code>flavor</code> or * <code>printData</code> is <code>null</code>, or the * <code>printData</code> does not correspond * to the specified doc flavor--for example, the data is * not of the type specified as the representation in the * <code>DocFlavor</code>. */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #21
Source File: SimpleDoc.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Constructs a <code>SimpleDoc</code> with the specified * print data, doc flavor and doc attribute set. * @param printData the print data object * @param flavor the <code>DocFlavor</code> object * @param attributes a <code>DocAttributeSet</code>, which can * be <code>null</code> * @throws IllegalArgumentException if <code>flavor</code> or * <code>printData</code> is <code>null</code>, or the * <code>printData</code> does not correspond * to the specified doc flavor--for example, the data is * not of the type specified as the representation in the * <code>DocFlavor</code>. */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { if (flavor == null || printData == null) { throw new IllegalArgumentException("null argument(s)"); } Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); repClass = Class.forName(className, false, Thread.currentThread().getContextClassLoader()); } catch (Throwable e) { throw new IllegalArgumentException("unknown representation class"); } if (!repClass.isInstance(printData)) { throw new IllegalArgumentException("data is not of declared type"); } this.flavor = flavor; if (attributes != null) { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } this.printData = printData; }
Example #22
Source File: PageableDoc.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #23
Source File: PageableDoc.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #24
Source File: PageableDoc.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #25
Source File: PageableDoc.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #26
Source File: PageableDoc.java From hottub with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #27
Source File: PageableDoc.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #28
Source File: PageableDoc.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #29
Source File: PageableDoc.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #30
Source File: PageableDoc.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }