下面列出了怎么用sun.awt.image.ImageCache的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Paints a native control, which identified by its size and a set of
* additional arguments using a cached image.
*
* @param g Graphics to draw the control
* @param control the reference to the native control
* @param controlState the state of the native control
* @param bounds the rectangle where the native part should be drawn.
* Note: the focus can/will be drawn outside of this bounds.
*/
static void paintFromSingleCachedImage(final Graphics2D g,
final JRSUIControl control,
final JRSUIState controlState,
final Rectangle bounds) {
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
int focus = 0;
if (controlState.is(JRSUIConstants.Focused.YES)) {
focus = JRSUIConstants.FOCUS_SIZE;
}
final int imgX = bounds.x - focus;
final int imgY = bounds.y - focus;
final int imgW = bounds.width + (focus << 1);
final int imgH = bounds.height + (focus << 1);
final GraphicsConfiguration config = g.getDeviceConfiguration();
final ImageCache cache = ImageCache.getInstance();
final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
bounds, controlState);
Image img = cache.getImage(key);
if (img == null) {
img = new MultiResolutionCachedImage(imgW, imgH,
(rvWidth, rvHeight) -> createImage(imgX, imgY,
rvWidth, rvHeight, bounds, control, controlState));
if (!controlState.is(JRSUIConstants.Animating.YES)) {
cache.setImage(key, img);
}
}
g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
/**
* Paints a native control, which identified by its size and a set of
* additional arguments using a cached image.
*
* @param g Graphics to draw the control
* @param control the reference to the native control
* @param controlState the state of the native control
* @param bounds the rectangle where the native part should be drawn.
* Note: the focus can/will be drawn outside of this bounds.
*/
static void paintFromSingleCachedImage(final Graphics2D g,
final JRSUIControl control,
final JRSUIState controlState,
final Rectangle bounds) {
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
int focus = 0;
if (controlState.is(JRSUIConstants.Focused.YES)) {
focus = JRSUIConstants.FOCUS_SIZE;
}
final int imgX = bounds.x - focus;
final int imgY = bounds.y - focus;
final int imgW = bounds.width + (focus << 1);
final int imgH = bounds.height + (focus << 1);
final GraphicsConfiguration config = g.getDeviceConfiguration();
final ImageCache cache = ImageCache.getInstance();
final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
bounds, controlState);
Image img = cache.getImage(key);
if (img == null) {
img = new MultiResolutionCachedImage(imgW, imgH,
(rvWidth, rvHeight) -> createImage(imgX, imgY,
rvWidth, rvHeight, bounds, control, controlState));
if (!controlState.is(JRSUIConstants.Animating.YES)) {
cache.setImage(key, img);
}
}
g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
/**
* Paints a native control, which identified by its size and a set of
* additional arguments using a cached image.
*
* @param g Graphics to draw the control
* @param control the reference to the native control
* @param controlState the state of the native control
* @param bounds the rectangle where the native part should be drawn.
* Note: the focus can/will be drawn outside of this bounds.
*/
static void paintFromSingleCachedImage(final Graphics2D g,
final JRSUIControl control,
final JRSUIState controlState,
final Rectangle bounds) {
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
int focus = 0;
if (controlState.is(JRSUIConstants.Focused.YES)) {
focus = JRSUIConstants.FOCUS_SIZE;
}
final int imgX = bounds.x - focus;
final int imgY = bounds.y - focus;
final int imgW = bounds.width + (focus << 1);
final int imgH = bounds.height + (focus << 1);
final GraphicsConfiguration config = g.getDeviceConfiguration();
final ImageCache cache = ImageCache.getInstance();
final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
bounds, controlState);
Image img = cache.getImage(key);
if (img == null) {
img = new MultiResolutionCachedImage(imgW, imgH,
(rvWidth, rvHeight) -> createImage(imgX, imgY,
rvWidth, rvHeight, bounds, control, controlState));
if (!controlState.is(JRSUIConstants.Animating.YES)) {
cache.setImage(key, img);
}
}
g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
/**
* Paints a native control, which identified by its size and a set of
* additional arguments using a cached image.
*
* @param g Graphics to draw the control
* @param control the reference to the native control
* @param controlState the state of the native control
* @param bounds the rectangle where the native part should be drawn.
* Note: the focus can/will be drawn outside of this bounds.
*/
static void paintFromSingleCachedImage(final Graphics2D g,
final JRSUIControl control,
final JRSUIState controlState,
final Rectangle bounds) {
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
int focus = 0;
if (controlState.is(JRSUIConstants.Focused.YES)) {
focus = JRSUIConstants.FOCUS_SIZE;
}
final int imgX = bounds.x - focus;
final int imgY = bounds.y - focus;
final int imgW = bounds.width + (focus << 1);
final int imgH = bounds.height + (focus << 1);
final GraphicsConfiguration config = g.getDeviceConfiguration();
final ImageCache cache = ImageCache.getInstance();
final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
bounds, controlState);
Image img = cache.getImage(key);
if (img == null) {
img = new MultiResolutionCachedImage(imgW, imgH,
(rvWidth, rvHeight) -> createImage(imgX, imgY,
rvWidth, rvHeight, bounds, control, controlState));
if (!controlState.is(JRSUIConstants.Animating.YES)) {
cache.setImage(key, img);
}
}
g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
/**
* Paints a native control, which identified by its size and a set of
* additional arguments using a cached image.
*
* @param g Graphics to draw the control
* @param control the reference to the native control
* @param controlState the state of the native control
* @param bounds the rectangle where the native part should be drawn.
* Note: the focus can/will be drawn outside of this bounds.
*/
static void paintFromSingleCachedImage(final Graphics2D g,
final JRSUIControl control,
final JRSUIState controlState,
final Rectangle bounds) {
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
int focus = 0;
if (controlState.is(JRSUIConstants.Focused.YES)) {
focus = JRSUIConstants.FOCUS_SIZE;
}
final int imgX = bounds.x - focus;
final int imgY = bounds.y - focus;
final int imgW = bounds.width + (focus << 1);
final int imgH = bounds.height + (focus << 1);
final GraphicsConfiguration config = g.getDeviceConfiguration();
final ImageCache cache = ImageCache.getInstance();
final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
bounds, controlState);
Image img = cache.getImage(key);
if (img == null) {
img = new MultiResolutionCachedImage(imgW, imgH,
(rvWidth, rvHeight) -> createImage(imgX, imgY,
rvWidth, rvHeight, bounds, control, controlState));
if (!controlState.is(JRSUIConstants.Animating.YES)) {
cache.setImage(key, img);
}
}
g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
/**
* Paints a native control, which identified by its size and a set of
* additional arguments using a cached image.
*
* @param g Graphics to draw the control
* @param control the reference to the native control
* @param controlState the state of the native control
* @param bounds the rectangle where the native part should be drawn.
* Note: the focus can/will be drawn outside of this bounds.
*/
static void paintFromSingleCachedImage(final Graphics2D g,
final JRSUIControl control,
final JRSUIState controlState,
final Rectangle bounds) {
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
int focus = 0;
if (controlState.is(JRSUIConstants.Focused.YES)) {
focus = JRSUIConstants.FOCUS_SIZE;
}
final int imgX = bounds.x - focus;
final int imgY = bounds.y - focus;
final int imgW = bounds.width + (focus << 1);
final int imgH = bounds.height + (focus << 1);
final GraphicsConfiguration config = g.getDeviceConfiguration();
final ImageCache cache = ImageCache.getInstance();
final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
bounds, controlState);
Image img = cache.getImage(key);
if (img == null) {
img = new MultiResolutionCachedImage(imgW, imgH,
(rvWidth, rvHeight) -> createImage(imgX, imgY,
rvWidth, rvHeight, bounds, control, controlState));
if (!controlState.is(JRSUIConstants.Animating.YES)) {
cache.setImage(key, img);
}
}
g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
/**
* Paints a native control, which identified by its size and a set of
* additional arguments using a cached image.
*
* @param g Graphics to draw the control
* @param control the reference to the native control
* @param controlState the state of the native control
* @param bounds the rectangle where the native part should be drawn.
* Note: the focus can/will be drawn outside of this bounds.
*/
static void paintFromSingleCachedImage(final Graphics2D g,
final JRSUIControl control,
final JRSUIState controlState,
final Rectangle bounds) {
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
int focus = 0;
if (controlState.is(JRSUIConstants.Focused.YES)) {
focus = JRSUIConstants.FOCUS_SIZE;
}
final int imgX = bounds.x - focus;
final int imgY = bounds.y - focus;
final int imgW = bounds.width + (focus << 1);
final int imgH = bounds.height + (focus << 1);
final GraphicsConfiguration config = g.getDeviceConfiguration();
final ImageCache cache = ImageCache.getInstance();
final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
bounds, controlState);
Image img = cache.getImage(key);
if (img == null) {
img = new MultiResolutionCachedImage(imgW, imgH,
(rvWidth, rvHeight) -> createImage(imgX, imgY,
rvWidth, rvHeight, bounds, control, controlState));
if (!controlState.is(JRSUIConstants.Animating.YES)) {
cache.setImage(key, img);
}
}
g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
/**
* Paints a native control, which identified by its size and a set of
* additional arguments using a cached image.
*
* @param g Graphics to draw the control
* @param control the reference to the native control
* @param controlState the state of the native control
* @param bounds the rectangle where the native part should be drawn.
* Note: the focus can/will be drawn outside of this bounds.
*/
static void paintFromSingleCachedImage(final Graphics2D g,
final JRSUIControl control,
final JRSUIState controlState,
final Rectangle bounds) {
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
int focus = 0;
if (controlState.is(JRSUIConstants.Focused.YES)) {
focus = JRSUIConstants.FOCUS_SIZE;
}
final int imgX = bounds.x - focus;
final int imgY = bounds.y - focus;
final int imgW = bounds.width + (focus << 1);
final int imgH = bounds.height + (focus << 1);
final GraphicsConfiguration config = g.getDeviceConfiguration();
final ImageCache cache = ImageCache.getInstance();
final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
bounds, controlState);
Image img = cache.getImage(key);
if (img == null) {
img = new MultiResolutionCachedImage(imgW, imgH,
(rvWidth, rvHeight) -> createImage(imgX, imgY,
rvWidth, rvHeight, bounds, control, controlState));
if (!controlState.is(JRSUIConstants.Animating.YES)) {
cache.setImage(key, img);
}
}
g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
/**
* Paints a native control, which identified by its size and a set of
* additional arguments using a cached image.
*
* @param g Graphics to draw the control
* @param control the reference to the native control
* @param controlState the state of the native control
* @param bounds the rectangle where the native part should be drawn.
* Note: the focus can/will be drawn outside of this bounds.
*/
static void paintFromSingleCachedImage(final Graphics2D g,
final JRSUIControl control,
final JRSUIState controlState,
final Rectangle bounds) {
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
int focus = 0;
if (controlState.is(JRSUIConstants.Focused.YES)) {
focus = JRSUIConstants.FOCUS_SIZE;
}
final int imgX = bounds.x - focus;
final int imgY = bounds.y - focus;
final int imgW = bounds.width + (focus << 1);
final int imgH = bounds.height + (focus << 1);
final GraphicsConfiguration config = g.getDeviceConfiguration();
final ImageCache cache = ImageCache.getInstance();
final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
bounds, controlState);
Image img = cache.getImage(key);
if (img == null) {
img = new MultiResolutionCachedImage(imgW, imgH,
(rvWidth, rvHeight) -> createImage(imgX, imgY,
rvWidth, rvHeight, bounds, control, controlState));
if (!controlState.is(JRSUIConstants.Animating.YES)) {
cache.setImage(key, img);
}
}
g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
/**
* Paints a native control, which identified by its size and a set of
* additional arguments using a cached image.
*
* @param g Graphics to draw the control
* @param control the reference to the native control
* @param controlState the state of the native control
* @param bounds the rectangle where the native part should be drawn.
* Note: the focus can/will be drawn outside of this bounds.
*/
static void paintFromSingleCachedImage(final Graphics2D g,
final JRSUIControl control,
final JRSUIState controlState,
final Rectangle bounds) {
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
int focus = 0;
if (controlState.is(JRSUIConstants.Focused.YES)) {
focus = JRSUIConstants.FOCUS_SIZE;
}
final int imgX = bounds.x - focus;
final int imgY = bounds.y - focus;
final int imgW = bounds.width + (focus << 1);
final int imgH = bounds.height + (focus << 1);
final GraphicsConfiguration config = g.getDeviceConfiguration();
final ImageCache cache = ImageCache.getInstance();
final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
bounds, controlState);
Image img = cache.getImage(key);
if (img == null) {
img = new MultiResolutionCachedImage(imgW, imgH,
(rvWidth, rvHeight) -> createImage(imgX, imgY,
rvWidth, rvHeight, bounds, control, controlState));
if (!controlState.is(JRSUIConstants.Animating.YES)) {
cache.setImage(key, img);
}
}
g.drawImage(img, imgX, imgY, imgW, imgH, null);
}
/**
* Paints a native control, which identified by its size and a set of
* additional arguments using a cached image.
*
* @param g Graphics to draw the control
* @param control the reference to the native control
* @param controlState the state of the native control
* @param bounds the rectangle where the native part should be drawn.
* Note: the focus can/will be drawn outside of this bounds.
*/
static void paintFromSingleCachedImage(final Graphics2D g,
final JRSUIControl control,
final JRSUIState controlState,
final Rectangle bounds) {
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
int focus = 0;
if (controlState.is(JRSUIConstants.Focused.YES)) {
focus = JRSUIConstants.FOCUS_SIZE;
}
final int imgX = bounds.x - focus;
final int imgY = bounds.y - focus;
final int imgW = bounds.width + (focus << 1);
final int imgH = bounds.height + (focus << 1);
final GraphicsConfiguration config = g.getDeviceConfiguration();
final ImageCache cache = ImageCache.getInstance();
final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
bounds, controlState);
Image img = cache.getImage(key);
if (img == null) {
img = new MultiResolutionCachedImage(imgW, imgH,
(rvWidth, rvHeight) -> createImage(imgX, imgY,
rvWidth, rvHeight, bounds, control, controlState));
if (!controlState.is(JRSUIConstants.Animating.YES)) {
cache.setImage(key, img);
}
}
g.drawImage(img, imgX, imgY, imgW, imgH, null);
}