/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
//REMIND: Remove use of this class when IPPPrintService is moved to share directory.
/**
* A class which initiates and executes a PostScript printer job.
*
* @author Richard Blanchard
*/
/* Class Constants */
/**
* Passed to the <code>setFillMode</code>
* method this value forces fills to be
* done using the even-odd fill rule.
*/
/**
* Passed to the <code>setFillMode</code>
* method this value forces fills to be
* done using the non-zero winding rule.
*/
/* PostScript has a 64K maximum on its strings.
*/
private static final byte hexDigits[] = {
(byte)'0', (byte)'1', (byte)'2', (byte)'3',
(byte)'4', (byte)'5', (byte)'6', (byte)'7',
(byte)'8', (byte)'9', (byte)'A', (byte)'B',
(byte)'C', (byte)'D', (byte)'E', (byte)'F'
};
"{currentfile /ASCII85Decode filter /RunLengthDecode filter " +
" imStr readstring pop } def";
+ "1 -1 scale"
+ "0 0 "
+ "0 0]concat";
/**
* The PostScript invocation to fill a path using the
* even-odd rule. (eofill)
*/
/**
* The PostScript invocation to fill a path using the
* non-zero winding rule. (fill)
*/
/**
* The PostScript to set the clip to be the current path
* using the even odd rule. (eoclip)
*/
/**
* The PostScript to set the clip to be the current path
* using the non-zero winding rule. (clip)
*/
/**
* Expecting two numbers on the PostScript stack, this
* invocation moves the current pen position. (moveto)
*/
/**
* Expecting two numbers on the PostScript stack, this
* invocation draws a PS line from the current pen
* position to the point on the stack. (lineto)
*/
/**
* This PostScript operator takes two control points
* and an ending point and using the current pen
* position as a starting point adds a bezier
* curve to the current path. (curveto)
*/
/**
* The PostScript to pop a state off of the printer's
* gstate stack. (grestore)
*/
/**
* The PostScript to push a state on to the printer's
* gstate stack. (gsave)
*/
/**
* Make the current PostScript path an empty path. (newpath)
*/
/**
* Close the current subpath by generating a line segment
* from the current position to the start of the subpath. (closepath)
*/
/**
* Use the three numbers on top of the PS operator
* stack to set the rgb color. (setrgbcolor)
*/
/**
* Use the top number on the stack to set the printer's
* current gray value. (setgray)
*/
/* Instance Variables */
private int mDestType;
private boolean mNoJobSheet = false;
/* non-null if printing EPS for Java Plugin */
/**
* The metrics for the font currently set.
*/
/**
* The output stream to which the generated PostScript
* is written.
*/
/* The temporary file to which we spool before sending to the printer */
/**
* This string holds the PostScript operator to
* be used to fill a path. It can be changed
* by the <code>setFillMode</code> method.
*/
/**
* This string holds the PostScript operator to
* be used to clip to a path. It can be changed
* by the <code>setFillMode</code> method.
*/
/**
* A stack that represents the PostScript gstate stack.
*/
/**
* The x coordinate of the current pen position.
*/
private float mPenX;
/**
* The y coordinate of the current pen position.
*/
private float mPenY;
/**
* The x coordinate of the starting point of
* the current subpath.
*/
private float mStartPathX;
/**
* The y coordinate of the starting point of
* the current subpath.
*/
private float mStartPathY;
/**
* An optional mapping of fonts to PostScript names.
*/
/* Class static initialiser block */
static {
//enable priviledges so initProps can access system properties,
// open the property file, etc.
mFontProps = initProps();
return null;
}
});
}
/*
* Initialize PostScript font properties.
* Copied from PSPrintStream
*/
// search psfont.properties for fonts
// and create and initialize fontProps if it exist.
try {
"psfontj2d.properties." + ulocale);
if (!f.canRead()){
"psfont.properties." + ulocale);
if (!f.canRead()){
if (!f.canRead()){
if (!f.canRead()){
return (Properties)null;
}
}
}
}
// Load property file
return props;
} catch (Exception e){
return (Properties)null;
}
}
return (Properties)null;
}
/* Constructors */
public PSPrinterJob()
{
}
/* Instance Methods */
/**
* Presents the user a dialog for changing properties of the
* print job interactively.
* @returns false if the user cancels the dialog and
* true otherwise.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
*/
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
if (attributes == null) {
attributes = new HashPrintRequestAttributeSet();
}
boolean doPrint = false;
// Remove DialogTypeSelection.NATIVE to prevent infinite loop in
// RasterPrinterJob.
// restore attribute
} else {
}
if (doPrint) {
}
}
try {
} catch (Exception e) {
mDestination = "out.ps";
}
} else {
}
}
}
return doPrint;
}
/**
* Invoked by the RasterPrinterJob super class
* this method is called to mark the start of a
* document.
*/
// A security check has been performed in the
// java.awt.print.printerJob.getPrinterJob method.
// We use an inner class to execute the privilged open operations.
// Note that we only open a file if it has been nominated by
// the end-user in a dialog that we ouselves put up.
if (epsPrinter == null) {
if (getPrintService() instanceof PSStreamPrintService) {
if (sps.isDisposed()) {
throw new PrinterException("service is disposed");
}
throw new PrinterException("Null output stream");
}
} else {
/* REMIND: This needs to be more maintainable */
mNoJobSheet = super.noJobSheet;
if (super.destinationAttr != null) {
mDestination = super.destinationAttr;
}
try {
} catch (IOException ex) {
throw new PrinterIOException(ex);
}
} else {
}
}
}
}
/* The following procedure takes args: string, x, y, desiredWidth.
* It calculates using stringwidth the width of the string in the
* current font and subtracts it from the desiredWidth and divides
* this by stringLen-1. This gives us a per-glyph adjustment in
* the spacing needed (either +ve or -ve) to make the string
* print at the desiredWidth. The ashow procedure call takes this
* per-glyph adjustment as an argument. This is necessary for WYSIWYG
*/
if (mFontProps == null){
} else {
for (int i = 0; i < cnt; i++){
}
}
if (epsPrinter == null) {
// Set Page Size using first page's format.
/* PostScript printers can always generate uncollated copies.
*/
try {
}
} catch (Throwable t) {
}
}
}
);
if (isPS) {
}
}
}
}
}
// Inner class to run "privileged" to open the printer output stream.
try {
/* Write to a temporary file which will be spooled to
* the printer then deleted. In the case that the file
* is not removed for some reason, request that it is
* removed when the VM exits.
*/
return result;
} catch (IOException ex) {
// If there is an IOError we subvert it to a PrinterException.
}
return null;
}
}
// Inner class to run "privileged" to invoke the system print command
}
}
} finally {
}
}
}
return null;
}
try {
/**
* Spool to the printer.
*/
1, fileName);
if (0 != result) {
}
} catch (IOException ex) {
} catch (InterruptedException ie) {
} finally {
}
return null;
}
}
/**
* Invoked if the application cancelled the printjob.
*/
protected void abortDoc() {
}
}
return null;
}
});
}
/**
* Invoked by the RasterPrintJob super class
* this method is called after that last page
* has been imaged.
*/
}
}
if (getPrintService() != null) {
}
}
}
}
/**
* The RasterPrintJob super class calls this method
* at the start of each page.
*/
int index, boolean paperChanged)
throws PrinterException
{
/* Place an initial gstate on to our gstate stack.
* It will have the default PostScript gstate
* attributes.
*/
mGStateStack = new ArrayList();
/* Check current page's pageFormat against the previous pageFormat,
*/
try {
return (Boolean)
}
} catch (Throwable t) {
}
}
}
);
if (isPS) {
}
}
}
/**
* The RastePrintJob super class calls this method
* at the end of each page.
*/
int index)
throws PrinterException
{
}
/**
* Convert the 24 bit BGR image buffer represented by
* <code>image</code> to PostScript. The image is drawn at
* <code>(destX, destY)</code> in device coordinates.
* The image is scaled into a square of size
* specified by <code>destWidth</code> and
* <code>destHeight</code>. The portion of the
* source image copied into that square is specified
* by <code>srcX</code>, <code>srcY</code>,
* <code>srcWidth</code>, and srcHeight.
*/
float destWidth, float destHeight,
int srcBitMapWidth, int srcBitMapHeight) {
/* We draw images at device resolution so we probably need
* to change the current PostScript transform.
*/
setTransform(new AffineTransform());
prepDrawing();
int intSrcWidth = (int) srcWidth;
int intSrcHeight = (int) srcHeight;
/* Create a PS string big enough to hold a row of pixels.
*/
while (psBytesPerRow > MAX_PSSTR) {
psBytesPerRow /= 2;
}
/* Scale and translate the unit image.
*/
+ "0 " + destHeight
+"]concat");
/* Color Image invocation.
*/
+ intSrcWidth + " 0 "
+ "0 " + intSrcHeight
+ " 0 " + 0 + "]"
+ "/imageSrc load false 3 colorimage");
/* Image data.
*/
int index = 0;
try {
/* Skip the parts of the image that are not part
* of the source rectangle.
*/
for(int i = 0; i < intSrcHeight; i++) {
/* Skip the left part of the image that is not
* part of the source rectangle.
*/
}
/*
* If there is an IOError we subvert it to a PrinterException.
* Fix: There has got to be a better way, maybe define
* a PrinterIOException and then throw that?
*/
} catch (IOException e) {
//throw new PrinterException(e.toString());
}
}
/**
* Prints the contents of the array of ints, 'data'
* to the current page. The band is placed at the
* location (x, y) in device coordinates on the
* page. The width and height of the band is
* specified by the caller. Currently the data
* is 24 bits per pixel in BGR format.
*/
throws PrinterException
{
/* Create a PS string big enough to hold a row of pixels.
*/
while (psBytesPerRow > MAX_PSSTR) {
psBytesPerRow /= 2;
}
/* Scale and translate the unit image.
*/
+ "0 " + height
+ " " + x + " " + y
+"]concat");
/* Color Image invocation.
*/
+ width + " 0 "
+ "0 " + -height
+ "/imageSrc load false 3 colorimage");
/* Image data.
*/
int index = 0;
try {
for(int i = 0; i < height; i++) {
}
} catch (IOException e) {
throw new PrinterIOException(e);
}
}
/**
* Examine the metrics captured by the
* <code>PeekGraphics</code> instance and
* if capable of directly converting this
* print job to the printer's control language
* or the native OS's graphics primitives, then
* return a <code>PSPathGraphics</code> to perform
* that conversion. If there is not an object
* capable of the conversion then return
* <code>null</code>. Returning <code>null</code>
* causes the print job to be rasterized.
*/
int pageIndex) {
/* If the application has drawn anything that
* out PathGraphics class can not handle then
* return a null PathGraphics.
*/
if (forcePDL == false && (forceRaster == true
|| metrics.hasNonSolidColors()
|| metrics.hasCompositing())) {
pathGraphics = null;
} else {
}
return pathGraphics;
}
/**
* Intersect the gstate's current path with the
* current clip and make the result the new clip.
*/
protected void selectClipPath() {
}
}
}
/**
* Set the current PostScript font.
* Taken from outFont in PSPrintStream.
*/
return true;
}
/**
* Given an array of CharsetStrings that make up a run
* of text, this routine converts each CharsetString to
* an index into our PostScript font list. If one or more
* CharsetStrings can not be represented by a PostScript
* font, then this routine will return a null array.
*/
if (mFontProps != null) {
}
/* Get the encoding of the run of text.
*/
/*
* sun.awt.Symbol perhaps should return "symbol" for encoding.
* Similarly X11Dingbats should return "dingbats"
*/
charsetName = "symbol";
charsetName = "dingbats";
} else {
}
/* First we map the font name through the properties file.
* This mapping provides alias names for fonts, for example,
* "timesroman" is mapped to "serif".
*/
/* Now map the alias name, character set name, and style
* to a PostScript name.
*/
null);
/* Get the PostScript font index for the PostScript font.
*/
try {
psFont[i] =
/* If there is no PostScript font for this font name,
* then we want to termintate the loop and the method
* indicating our failure. Setting the array to null
* is used to indicate these failures.
*/
} catch(NumberFormatException e){
}
/* There was no PostScript name for the font, character set,
* and style so give up.
*/
} else {
}
}
return psFont;
}
return str;
} else {
int count = 0;
int pos = 0;
count++;
pos++;
}
pos = 0;
count++;
pos++;
}
pos = 0;
}
}
}
}
/* return of 0 means unsupported. Other return indicates the number
* of distinct PS fonts needed to draw this text. This saves us
* doing this processing one extra time.
*/
if (mFontProps == null) {
return 0;
}
CharsetString[] acs =
/* AWT can't convert all chars so use 2D path */
return 0;
}
}
float width) {
boolean didText = true;
if (mFontProps == null) {
return false;
} else {
prepDrawing();
/* On-screen drawString renders most control chars as the missing
* glyph and have the non-zero advance of that glyph.
* Exceptions are \t, \n and \r which are considered zero-width.
* Postscript handles control chars mostly as a missing glyph.
* But we use 'ashow' specifying a width for the string which
* assumes zero-width for those three exceptions, and Postscript
* tries to squeeze the extra char in, with the result that the
* glyphs look compressed or even overlap.
* So exclude those control chars from the string sent to PS.
*/
return true;
}
CharsetString[] acs =
((PlatformFont)
/* AWT can't convert all chars so use 2D path */
return false;
}
/* Get an array of indices into our PostScript name
* table. If all of the runs can not be converted
* to PostScript fonts then null is returned and
* we'll want to fall back to printing the text
* as shapes.
*/
int len = 0;
try {
bb, true);
} catch(IllegalStateException xx){
continue;
} catch(CoderMalfunctionError xx){
continue;
}
/* The width to fit to may either be specified,
* or calculated. Specifying by the caller is only
* valid if the text does not need to be decomposed
* into multiple calls.
*/
float desiredWidth;
} else {
frc);
}
/* unprintable chars had width of 0, causing a PS error
*/
if (desiredWidth == 0) {
return didText;
}
for (int j = 0; j < len; j++){
byte b = strSeg[j];
// to avoid encoding conversion with println()
if (length > 2) {
} else if (length == 1) {
} else if (length == 0) {
hexS = "00";
}
}
/* This comment costs too much in output file size */
// mPSStream.println("% Font[" + mLastFont.getName() + ", " +
// FontConfiguration.getStyleString(mLastFont.getStyle()) + ", "
// + mLastFont.getSize2D() + "]");
// out String
x += desiredWidth;
}
} else {
didText = false;
}
}
return didText;
}
/**
* Set the current path rule to be either
* <code>FILL_EVEN_ODD</code> (using the
* even-odd file rule) or <code>FILL_WINDING</code>
* (using the non-zero winding rule.)
*/
switch (fillRule) {
case FILL_EVEN_ODD:
break;
case FILL_WINDING:
break;
default:
throw new IllegalArgumentException();
}
}
/**
* Set the printer's current color to be that
* defined by <code>color</code>
*/
mLastColor = color;
}
/**
* Fill the current path using the current fill mode
* and color.
*/
protected void fillPath() {
}
/**
* Called to mark the start of a new path.
*/
protected void beginPath() {
prepDrawing();
mPenX = 0;
mPenY = 0;
}
/**
* Close the current subpath by appending a straight
* line from the current point to the subpath's
* starting point.
*/
protected void closeSubpath() {
mPenX = mStartPathX;
mPenY = mStartPathY;
}
/**
* Generate PostScript to move the current pen
* position to <code>(x, y)</code>.
*/
protected void moveTo(float x, float y) {
/* moveto marks the start of a new subpath
* and we need to remember that starting
* position so that we know where the
* pen returns to with a close path.
*/
mStartPathX = x;
mStartPathY = y;
mPenX = x;
mPenY = y;
}
/**
* Generate PostScript to draw a line from the
* current pen position to <code>(x, y)</code>.
*/
protected void lineTo(float x, float y) {
mPenX = x;
mPenY = y;
}
/**
* Add to the current path a bezier curve formed
* by the current pen position and the method parameters
* which are two control points and an ending
* point.
*/
// mPSStream.println(control1x + " " + control1y
// + " " + control2x + " " + control2y
// + " " + endX + " " + endY
// + CURVETO_STR);
+ CURVETO_STR);
}
}
}
/**
* Return the x coordinate of the pen in the
* current path.
*/
protected float getPenX() {
return mPenX;
}
/**
* Return the y coordinate of the pen in the
* current path.
*/
protected float getPenY() {
return mPenY;
}
/**
* Return the x resolution of the coordinates
* to be rendered.
*/
protected double getXRes() {
return PS_XRES;
}
/**
* Return the y resolution of the coordinates
* to be rendered.
*/
protected double getYRes() {
return PS_YRES;
}
/**
* For PostScript the origin is in the upper-left of the
* paper not at the imageable area corner.
*/
return 0;
}
/**
* For PostScript the origin is in the upper-left of the
* paper not at the imageable area corner.
*/
return 0;
}
return p.getImageableWidth();
}
return p.getImageableHeight();
}
return p.getWidth();
}
return p.getHeight();
}
/**
* Returns how many times each page in the book
* should be consecutively printed by PrintJob.
* If the printer makes copies itself then this
* method should return 1.
*/
protected int getNoncollatedCopies() {
return 1;
}
protected int getCollatedCopies() {
return 1;
}
boolean noJobSheet,
int PRINTER = 0x1;
int OPTIONS = 0x2;
int BANNER = 0x4;
int COPIES = 0x8;
int NOSHEET = 0x10;
int pFlags = 0;
int n = 0;
ncomps+=1;
}
ncomps+=1;
}
ncomps+=1;
}
if (copies > 1) {
ncomps+=1;
}
if (noJobSheet) {
ncomps+=1;
}
}
}
}
execCmd[n++] = "-h";
}
}
} else {
}
}
}
execCmd[n++] = "-o nobanner";
}
}
}
return execCmd;
}
int destIndex = 0;
index+=3;
}
return index;
}
/*
* Currently CharToByteConverter.getCharacterEncoding() return values are
* not fixed yet. These are used as the part of the key of
* psfont.propeties. When those name are fixed this routine can
* be erased.
*/
return "latin1";
// same as latin 1 if all chars < 256
if (chs[i] > 255) {
return name.toLowerCase();
}
}
return "latin1";
// same as latin 1 if all chars < 128
if (chs[i] > 127) {
return name.toLowerCase();
}
}
return "latin1";
} else {
return name.toLowerCase();
}
}
private void prepDrawing() {
/* Pop gstates until we can set the needed clip
* and transform or until we are at the outer most
* gstate.
*/
while (isOuterGState() == false
grestore();
}
/* Set the color. This can push the color to the
* outer most gsave which is often a good thing.
*/
/* We do not want to change the outermost
* transform or clip so if we are at the
* outer clip the generate a gsave.
*/
if (isOuterGState()) {
gsave();
}
/* Set the font if we have been asked to. It is
* important that the font is set after the
* transform in order to get the font size
* correct.
*/
// if (g != null) {
// getGState().emitPSFont(g, mLastFont);
// }
}
/**
* Return the GState that is currently on top
* of the GState stack. There should always be
* a GState on top of the stack. If there isn't
* then this method will throw an IndexOutOfBounds
* exception.
*/
}
/**
* Emit a PostScript gsave command and add a
* new GState on to our stack which represents
* the printer's gstate stack.
*/
private void gsave() {
}
/**
* Emit a PostScript grestore command and remove
* a GState from our stack which represents the
* printer's gstate stack.
*/
private void grestore() {
}
/**
* Return true if the current GState is the
* outermost GState and therefore should not
* be restored.
*/
private boolean isOuterGState() {
}
/**
* A stack of GStates is maintained to model the printer's
* gstate stack. Each GState holds information about
* the current graphics attributes.
*/
private class GState{
GState() {
mTransform = new AffineTransform();
}
}
}
/* The clip is a shape and has reset the winding rule state */
}
}
double[] matrix = new double[6];
+ "] concat");
}
}
/* If the color is a gray value then use
* setgray.
*/
/* It's not gray so use setrgbcolor.
*/
} else {
+ SETRGBCOLOR_STR);
}
}
}
}
}
/**
* Given a Java2D <code>PathIterator</code> instance,
* this method translates that into a PostScript path..
*/
float[] segment = new float[6];
int segmentType;
/* Map the PathIterator's fill rule into the PostScript
* fill rule.
*/
int fillRule;
} else {
}
beginPath();
switch (segmentType) {
case PathIterator.SEG_MOVETO:
break;
case PathIterator.SEG_LINETO:
break;
/* Convert the quad path to a bezier.
*/
case PathIterator.SEG_QUADTO:
break;
case PathIterator.SEG_CUBICTO:
break;
case PathIterator.SEG_CLOSE:
closeSubpath();
break;
}
}
}
/*
* Fill the path defined by <code>pathIter</code>
* with the specified color.
* The path is provided in current user space.
*/
/* Specify the path to fill as the clip, this ensures that only
* pixels which are inside the path will be filled, which is
* what the Java 2D APIs specify
*/
fillPath();
}
/*
* Run length encode byte array in a form suitable for decoding
* by the PS Level 2 filter RunLengthDecode.
* Array data to encode is inArr. Encoded data is written to outArr
* outArr must be long enough to hold the encoded data but this
* can't be known ahead of time.
* A safe assumption is to use double the length of the input array.
* This is then copied into a new array of the correct length which
* is returned.
* Algorithm:
* Encoding is a lead byte followed by data bytes.
* Lead byte of 0->127 indicates leadByte + 1 distinct bytes follow
* Lead byte of 129->255 indicates 257 - leadByte is the number of times
* the following byte is repeated in the source.
* 128 is a special lead byte indicating end of data (EOD) and is
* written as the final byte of the returned encoded data.
*/
int inIndex = 0;
int outIndex = 0;
int startIndex = 0;
int runLen = 0;
if (runLen == 0) {
startIndex = inIndex++;
runLen=1;
}
runLen++; // count run of same value
inIndex++;
}
if (runLen > 1) {
runLen = 0;
continue; // back to top of while loop.
}
// if reach here have a run of different values, or at the end.
runLen++; // count run of different values
inIndex++;
}
}
runLen = 0;
}
byte[] encodedData = new byte[outIndex];
return encodedData;
}
/* written acc. to Adobe Spec. "Filtered Files: ASCIIEncode Filter",
* "PS Language Reference Manual, 2nd edition: Section 3.13"
*/
long p1 = 85;
byte pling = '!';
int i = 0;
int olen = 0;
((long)(inArr[i++]&0xff));
if (val == 0) {
} else {
}
}
// input not a multiple of 4 bytes, write partial output.
val = 0;
}
int append = 4 - n;
while (append-- > 0) {
}
byte []c = new byte[5];
for (int b = 0; b < n+1 ; b++) {
}
}
// write EOD marker.
/* The original intention was to insert a newline after every 78 bytes.
* This was mainly intended for legibility but I decided against this
* partially because of the (small) amount of extra space, and
* partially because for line breaks either would have to hardwire
* ascii 10 (newline) or calculate space in bytes to allocate for
* the platform's newline byte sequence. Also need to be careful
* about where its inserted:
* Ascii 85 decoder ignores white space except for one special case:
* you must ensure you do not split the EOD marker across lines.
*/
return retArr;
}
/**
* PluginPrinter generates EPSF wrapped with a header and trailer
* comment. This conforms to the new requirements of Mozilla 1.7
* and FireFox 1.5 and later. Earlier versions of these browsers
* did not support plugin printing in the general sense (not just Java).
* A notable limitation of these browsers is that they handle plugins
* which would span page boundaries by scaling plugin content to fit on a
* single page. This means white space is left at the bottom of the
* previous page and its impossible to print these cases as they appear on
* the web page. This is contrast to how the same browsers behave on
* Windows where it renders as on-screen.
* Cases where the content fits on a single page do work fine, and they
* are the majority of cases.
* The scaling that the browser specifies to make the plugin content fit
* when it is larger than a single page can hold is non-uniform. It
* scales the axis in which the content is too large just enough to
* ensure it fits. For content which is extremely long this could lead
* to noticeable distortion. However that is probably rare enough that
* its not worth compensating for that here, but we can revisit that if
* needed, and compensate by making the scale for the other axis the
* same.
*/
/**
* This is called from the Java Plug-in to print an Applet's
* contents as EPS to a postscript stream provided by the browser.
* @param applet the applet component to print.
* @param stream the print stream provided by the plug-in
* @param x the x location of the applet panel in the browser window
* @param y the y location of the applet panel in the browser window
* @param w the width of the applet panel in the browser window
* @param h the width of the applet panel in the browser window
*/
int x, int y, int w, int h) {
this.epsTitle = "Java Plugin Applet";
bx = x;
by = y;
bw = w;
bh = h;
}
public void printPluginPSHeader() {
}
public void printPluginApplet() {
try {
epsPrinter.print();
} catch (PrinterException e) {
}
}
public void printPluginPSTrailer() {
}
public void printAll() {
}
if (pgIndex > 0) {
return Printable.NO_SUCH_PAGE;
} else {
// "aware" client code can detect that its been passed a
// PrinterGraphics and could theoretically print
// differently. I think this is more likely useful than
// a problem.
return Printable.PAGE_EXISTS;
}
}
}
/*
* This class can take an application-client supplied printable object
* and send the result to a stream.
* The application does not need to send any postscript to this stream
* unless it needs to specify a translation etc.
* It assumes that its importing application obeys all the conventions
* for importation of EPS. See Appendix H - Encapsulated Postscript File
* Format - of the Adobe Postscript Language Reference Manual, 2nd edition.
* This class could be used as the basis for exposing the ability to
* generate EPSF from 2D graphics as a StreamPrintService.
* In that case a MediaPrintableArea attribute could be used to
* communicate the bounding box.
*/
llx = x;
lly = y;
// construct a PageFormat with zero margins representing the
// exact bounds of the applet. ie construct a theoretical
// paper which happens to exactly match applet panel size.
pf = new PageFormat();
}
job = new PSPrinterJob();
try {
} catch (Throwable t) {
if (t instanceof PrinterException) {
throw (PrinterException)t;
} else {
throw new PrinterException(t.toString());
}
} finally {
}
}
public int getNumberOfPages() {
return 1;
}
if (pgIndex > 0) {
throw new IndexOutOfBoundsException("pgIndex");
} else {
return pf;
}
}
if (pgIndex > 0) {
throw new IndexOutOfBoundsException("pgIndex");
} else {
return printable;
}
}
}
}