]> git.gag.com Git - debian/openrocket/blob - src/net/sf/openrocket/gui/print/PDFPrintStreamDoc.java
DGP - 1st printing
[debian/openrocket] / src / net / sf / openrocket / gui / print / PDFPrintStreamDoc.java
1 /*
2  * PDFPrintStreamDoc.java
3  */
4 package net.sf.openrocket.gui.print;
5
6 import javax.print.Doc;
7 import javax.print.DocFlavor;
8 import javax.print.attribute.AttributeSetUtilities;
9 import javax.print.attribute.DocAttributeSet;
10 import java.io.ByteArrayInputStream;
11 import java.io.ByteArrayOutputStream;
12 import java.io.IOException;
13 import java.io.InputStream;
14 import java.io.Reader;
15
16 /**
17  */
18 public class PDFPrintStreamDoc implements Doc {
19
20     private InputStream stream;
21     private DocAttributeSet attributeSet;
22
23     public PDFPrintStreamDoc (ByteArrayOutputStream ostream, DocAttributeSet attributes) {
24         stream = new ByteArrayInputStream(ostream.toByteArray());
25         if (attributes != null) {
26             attributeSet = AttributeSetUtilities.unmodifiableView(attributes);
27         }
28     }
29
30     public DocFlavor getDocFlavor () {
31         return DocFlavor.INPUT_STREAM.PDF;
32     }
33
34     public DocAttributeSet getAttributes () {
35         return attributeSet;
36     }
37
38     /* Since the data is to be supplied as an InputStream delegate to
39      * getStreamForBytes().
40      */
41
42     public Object getPrintData () throws IOException {
43         return getStreamForBytes();
44     }
45
46     public Reader getReaderForText () {
47         return null;
48     }
49
50     /* Return the print data as an InputStream.
51      * Always return the same instance.
52      */
53
54     public InputStream getStreamForBytes () throws IOException {
55         return stream;
56     }
57 }