6804454: RFE: Provide a way to control the printing dpi resolution from MSIE browser print. See also 6801859

Reviewed-by: igor, prr
This commit is contained in:
Jennifer Godinez 2010-10-15 11:20:31 -07:00
parent cd9f7232bb
commit 1ff2431b71

View File

@ -33,6 +33,7 @@ import java.util.*;
import java.awt.color.*; import java.awt.color.*;
import java.awt.image.*; import java.awt.image.*;
import sun.awt.image.ByteInterleavedRaster; import sun.awt.image.ByteInterleavedRaster;
import sun.security.action.GetPropertyAction;
import java.lang.reflect.*; import java.lang.reflect.*;
public class WEmbeddedFrame extends EmbeddedFrame { public class WEmbeddedFrame extends EmbeddedFrame {
@ -48,8 +49,12 @@ public class WEmbeddedFrame extends EmbeddedFrame {
private int imgWid = 0; private int imgWid = 0;
private int imgHgt = 0; private int imgHgt = 0;
private static int pScale = 0;
private static final int MAX_BAND_SIZE = (1024*30); private static final int MAX_BAND_SIZE = (1024*30);
private static String printScale = (String) java.security.AccessController
.doPrivileged(new GetPropertyAction("sun.java2d.print.pluginscalefactor"));
public WEmbeddedFrame() { public WEmbeddedFrame() {
this((long)0); this((long)0);
} }
@ -114,8 +119,7 @@ public class WEmbeddedFrame extends EmbeddedFrame {
* real resolution of the destination so * real resolution of the destination so
*/ */
if (isPrinterDC(hdc)) { if (isPrinterDC(hdc)) {
xscale = 4; xscale = yscale = getPrintScaleFactor();
yscale = 4;
} }
int frameHeight = getHeight(); int frameHeight = getHeight();
@ -168,6 +172,37 @@ public class WEmbeddedFrame extends EmbeddedFrame {
} }
} }
protected static int getPrintScaleFactor() {
// check if value is already cached
if (pScale != 0)
return pScale;
if (printScale == null) {
// if no system property is specified,
// check for environment setting
printScale = (String) java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
return System.getenv("JAVA2D_PLUGIN_PRINT_SCALE");
}
}
);
}
int default_printDC_scale = 4;
int scale = default_printDC_scale;
if (printScale != null) {
try {
scale = Integer.parseInt(printScale);
if (scale > 8 || scale < 1) {
scale = default_printDC_scale;
}
} catch (NumberFormatException nfe) {
}
}
pScale = scale;
return pScale;
}
protected native boolean isPrinterDC(long hdc); protected native boolean isPrinterDC(long hdc);
protected native void printBand(long hdc, byte[] data, int offset, protected native void printBand(long hdc, byte[] data, int offset,