< prev index next >

src/java.desktop/share/classes/sun/print/PSPrinterJob.java

Print this page




1197                 pos++;
1198             }
1199             char []inArr = str.toCharArray();
1200             char []outArr = new char[inArr.length+count];
1201             pos = 0;
1202             for (int i=0;i<inArr.length;i++) {
1203                 if (inArr[i] == '(' || inArr[i] == ')') {
1204                     outArr[pos++] = '\\';
1205                 }
1206                 outArr[pos++] = inArr[i];
1207             }
1208             return new String(outArr);
1209 
1210         }
1211     }
1212 
1213     /* return of 0 means unsupported. Other return indicates the number
1214      * of distinct PS fonts needed to draw this text. This saves us
1215      * doing this processing one extra time.
1216      */

1217     protected int platformFontCount(Font font, String str) {
1218         if (mFontProps == null) {
1219             return 0;
1220         }
1221         CharsetString[] acs =
1222             ((PlatformFont)(font.getPeer())).makeMultiCharsetString(str,false);
1223         if (acs == null) {
1224             /* AWT can't convert all chars so use 2D path */
1225             return 0;
1226         }
1227         int[] psFonts = getPSFontIndexArray(font, acs);
1228         return (psFonts == null) ? 0 : psFonts.length;
1229     }
1230 

1231      protected boolean textOut(Graphics g, String str, float x, float y,
1232                                Font mLastFont, FontRenderContext frc,
1233                                float width) {
1234         boolean didText = true;
1235 
1236         if (mFontProps == null) {
1237             return false;
1238         } else {
1239             prepDrawing();
1240 
1241             /* On-screen drawString renders most control chars as the missing
1242              * glyph and have the non-zero advance of that glyph.
1243              * Exceptions are \t, \n and \r which are considered zero-width.
1244              * Postscript handles control chars mostly as a missing glyph.
1245              * But we use 'ashow' specifying a width for the string which
1246              * assumes zero-width for those three exceptions, and Postscript
1247              * tries to squeeze the extra char in, with the result that the
1248              * glyphs look compressed or even overlap.
1249              * So exclude those control chars from the string sent to PS.
1250              */


2106      */
2107     public static class PluginPrinter implements Printable {
2108 
2109         private EPSPrinter epsPrinter;
2110         private Component applet;
2111         private PrintStream stream;
2112         private String epsTitle;
2113         private int bx, by, bw, bh;
2114         private int width, height;
2115 
2116         /**
2117          * This is called from the Java Plug-in to print an Applet's
2118          * contents as EPS to a postscript stream provided by the browser.
2119          * @param applet the applet component to print.
2120          * @param stream the print stream provided by the plug-in
2121          * @param x the x location of the applet panel in the browser window
2122          * @param y the y location of the applet panel in the browser window
2123          * @param w the width of the applet panel in the browser window
2124          * @param h the width of the applet panel in the browser window
2125          */

2126         public PluginPrinter(Component applet,
2127                              PrintStream stream,
2128                              int x, int y, int w, int h) {
2129 
2130             this.applet = applet;
2131             this.epsTitle = "Java Plugin Applet";
2132             this.stream = stream;
2133             bx = x;
2134             by = y;
2135             bw = w;
2136             bh = h;
2137             width = applet.size().width;
2138             height = applet.size().height;
2139             epsPrinter = new EPSPrinter(this, epsTitle, stream,
2140                                         0, 0, width, height);
2141         }
2142 
2143         public void printPluginPSHeader() {
2144             stream.println("%%BeginDocument: JavaPluginApplet");
2145         }




1197                 pos++;
1198             }
1199             char []inArr = str.toCharArray();
1200             char []outArr = new char[inArr.length+count];
1201             pos = 0;
1202             for (int i=0;i<inArr.length;i++) {
1203                 if (inArr[i] == '(' || inArr[i] == ')') {
1204                     outArr[pos++] = '\\';
1205                 }
1206                 outArr[pos++] = inArr[i];
1207             }
1208             return new String(outArr);
1209 
1210         }
1211     }
1212 
1213     /* return of 0 means unsupported. Other return indicates the number
1214      * of distinct PS fonts needed to draw this text. This saves us
1215      * doing this processing one extra time.
1216      */
1217     @SuppressWarnings("deprecation")
1218     protected int platformFontCount(Font font, String str) {
1219         if (mFontProps == null) {
1220             return 0;
1221         }
1222         CharsetString[] acs =
1223             ((PlatformFont)(font.getPeer())).makeMultiCharsetString(str,false);
1224         if (acs == null) {
1225             /* AWT can't convert all chars so use 2D path */
1226             return 0;
1227         }
1228         int[] psFonts = getPSFontIndexArray(font, acs);
1229         return (psFonts == null) ? 0 : psFonts.length;
1230     }
1231 
1232     @SuppressWarnings("deprecation")
1233      protected boolean textOut(Graphics g, String str, float x, float y,
1234                                Font mLastFont, FontRenderContext frc,
1235                                float width) {
1236         boolean didText = true;
1237 
1238         if (mFontProps == null) {
1239             return false;
1240         } else {
1241             prepDrawing();
1242 
1243             /* On-screen drawString renders most control chars as the missing
1244              * glyph and have the non-zero advance of that glyph.
1245              * Exceptions are \t, \n and \r which are considered zero-width.
1246              * Postscript handles control chars mostly as a missing glyph.
1247              * But we use 'ashow' specifying a width for the string which
1248              * assumes zero-width for those three exceptions, and Postscript
1249              * tries to squeeze the extra char in, with the result that the
1250              * glyphs look compressed or even overlap.
1251              * So exclude those control chars from the string sent to PS.
1252              */


2108      */
2109     public static class PluginPrinter implements Printable {
2110 
2111         private EPSPrinter epsPrinter;
2112         private Component applet;
2113         private PrintStream stream;
2114         private String epsTitle;
2115         private int bx, by, bw, bh;
2116         private int width, height;
2117 
2118         /**
2119          * This is called from the Java Plug-in to print an Applet's
2120          * contents as EPS to a postscript stream provided by the browser.
2121          * @param applet the applet component to print.
2122          * @param stream the print stream provided by the plug-in
2123          * @param x the x location of the applet panel in the browser window
2124          * @param y the y location of the applet panel in the browser window
2125          * @param w the width of the applet panel in the browser window
2126          * @param h the width of the applet panel in the browser window
2127          */
2128         @SuppressWarnings("deprecation")
2129         public PluginPrinter(Component applet,
2130                              PrintStream stream,
2131                              int x, int y, int w, int h) {
2132 
2133             this.applet = applet;
2134             this.epsTitle = "Java Plugin Applet";
2135             this.stream = stream;
2136             bx = x;
2137             by = y;
2138             bw = w;
2139             bh = h;
2140             width = applet.size().width;
2141             height = applet.size().height;
2142             epsPrinter = new EPSPrinter(this, epsTitle, stream,
2143                                         0, 0, width, height);
2144         }
2145 
2146         public void printPluginPSHeader() {
2147             stream.println("%%BeginDocument: JavaPluginApplet");
2148         }


< prev index next >