< prev index next >
src/java.desktop/share/classes/sun/awt/image/BufferedImageGraphicsConfig.java
Print this page
*** 43,61 ****
public class BufferedImageGraphicsConfig
extends GraphicsConfiguration
{
private static final int numconfigs = BufferedImage.TYPE_BYTE_BINARY;
! private static BufferedImageGraphicsConfig configs[] =
new BufferedImageGraphicsConfig[numconfigs];
public static BufferedImageGraphicsConfig getConfig(BufferedImage bImg) {
BufferedImageGraphicsConfig ret;
int type = bImg.getType();
if (type > 0 && type < numconfigs) {
ret = configs[type];
! if (ret != null) {
return ret;
}
}
ret = new BufferedImageGraphicsConfig(bImg, null);
if (type > 0 && type < numconfigs) {
--- 43,74 ----
public class BufferedImageGraphicsConfig
extends GraphicsConfiguration
{
private static final int numconfigs = BufferedImage.TYPE_BYTE_BINARY;
! private static BufferedImageGraphicsConfig standardConfigs[] =
! new BufferedImageGraphicsConfig[numconfigs];
! private static BufferedImageGraphicsConfig scaledConfigs[] =
new BufferedImageGraphicsConfig[numconfigs];
public static BufferedImageGraphicsConfig getConfig(BufferedImage bImg) {
+ return getConfig(bImg, 1, 1);
+ }
+
+ public static BufferedImageGraphicsConfig getConfig(BufferedImage bImg,
+ double scaleX,
+ double scaleY)
+ {
BufferedImageGraphicsConfig ret;
int type = bImg.getType();
+
+ BufferedImageGraphicsConfig[] configs = (scaleX == 1 && scaleY == 1)
+ ? standardConfigs : scaledConfigs;
+
if (type > 0 && type < numconfigs) {
ret = configs[type];
! if (ret != null && ret.scaleX == scaleX && ret.scaleY == scaleY) {
return ret;
}
}
ret = new BufferedImageGraphicsConfig(bImg, null);
if (type > 0 && type < numconfigs) {
*** 65,84 ****
--- 78,107 ----
}
GraphicsDevice gd;
ColorModel model;
Raster raster;
+ private final double scaleX;
+ private final double scaleY;
public BufferedImageGraphicsConfig(BufferedImage bufImg, Component comp) {
+ this(bufImg, comp, 1, 1);
+ }
+
+ public BufferedImageGraphicsConfig(BufferedImage bufImg, Component comp,
+ double scaleX, double scaleY)
+ {
if (comp == null) {
this.gd = new BufferedImageDevice(this);
} else {
Graphics2D g2d = (Graphics2D)comp.getGraphics();
this.gd = g2d.getDeviceConfiguration().getDevice();
}
this.model = bufImg.getColorModel();
this.raster = bufImg.getRaster().createCompatibleWritableRaster(1, 1);
+ this.scaleX = scaleX;
+ this.scaleY = scaleY;
}
/**
* Return the graphics device associated with this configuration.
*/
*** 136,146 ****
* the device, with X coordinates
* increasing to the right and Y coordinates increasing downwards.
* For image buffers, this Transform will be the Identity transform.
*/
public AffineTransform getDefaultTransform() {
! return new AffineTransform();
}
/**
*
* Returns a Transform that can be composed with the default Transform
--- 159,169 ----
* the device, with X coordinates
* increasing to the right and Y coordinates increasing downwards.
* For image buffers, this Transform will be the Identity transform.
*/
public AffineTransform getDefaultTransform() {
! return AffineTransform.getScaleInstance(scaleX, scaleY);
}
/**
*
* Returns a Transform that can be composed with the default Transform
< prev index next >