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