Fixed rendering.
This commit is contained in:
parent
aaf319e9f4
commit
bbdb394cd2
|
@ -26,6 +26,7 @@ import java.awt.Image;
|
|||
import java.awt.MouseInfo;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.MouseAdapter;
|
||||
|
@ -275,22 +276,18 @@ class NotifyPopup extends JFrame {
|
|||
default:
|
||||
throw new RuntimeException("Unknown position. '" + position + "'");
|
||||
}
|
||||
|
||||
// now we setup the rendering of the image
|
||||
renderBackgroundInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public
|
||||
void paint(Graphics g) {
|
||||
// we cache the text + image (to another image), and then always render the close + progressbar
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
private
|
||||
void renderBackgroundInfo() {
|
||||
cachedImage = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2 = cachedImage.createGraphics();
|
||||
g2.addRenderingHints(new RenderingHints(RenderingHints.KEY_RENDERING,
|
||||
RenderingHints.VALUE_RENDER_QUALITY));
|
||||
|
||||
if (width <= 0 || height <= 0) {
|
||||
return;
|
||||
}
|
||||
if (cachedImage == null) {
|
||||
cachedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||
|
||||
Graphics g2 = cachedImage.createGraphics();
|
||||
try {
|
||||
g2.setColor(panel_BG);
|
||||
g2.fillRect(0, 0, WIDTH, HEIGHT);
|
||||
|
@ -302,7 +299,6 @@ class NotifyPopup extends JFrame {
|
|||
g2.drawString(notification.title, 5, 20);
|
||||
|
||||
|
||||
|
||||
int posX = 10;
|
||||
int textLengthLimit = 108;
|
||||
|
||||
|
@ -353,12 +349,21 @@ class NotifyPopup extends JFrame {
|
|||
} finally {
|
||||
g2.dispose();
|
||||
}
|
||||
|
||||
g.drawImage(cachedImage, 0, 0, null);
|
||||
}
|
||||
else {
|
||||
// use our cached image, so we don't have to re-render text
|
||||
g.drawImage(cachedImage, getX(), getY(), null);
|
||||
|
||||
@Override
|
||||
public
|
||||
void paint(Graphics g) {
|
||||
// we cache the text + image (to another image), and then always render the close + progressbar
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
|
||||
if (width <= 0 || height <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// use our cached image, so we don't have to re-render text/background/etc
|
||||
g.drawImage(cachedImage, 0, 0, null);
|
||||
|
||||
// the progress bar and close button are the only things that can change, so we always draw them
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
|
@ -388,7 +393,6 @@ class NotifyPopup extends JFrame {
|
|||
g2.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
void onClick(final int x, final int y) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user