Fix for nonGUI run

This commit is contained in:
Jindra Petřík
2016-02-27 10:42:35 +01:00
parent a06b7742df
commit 9a6b2a5671
2 changed files with 19 additions and 4 deletions
@@ -189,7 +189,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
Graphics2D g2 = null;
do {
int valid = renderImage.validate(View.conf);
int valid = renderImage.validate(View.getDefaultConfiguration());
if (valid == VolatileImage.IMAGE_INCOMPATIBLE) {
renderImage = View.createRenderImage(getWidth(), getHeight(), Transparency.TRANSLUCENT);
@@ -336,7 +336,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
calcRect();
if (renderImage != null) {
if (renderImage.validate(View.conf) != VolatileImage.IMAGE_OK) {
if (renderImage.validate(View.getDefaultConfiguration()) != VolatileImage.IMAGE_OK) {
renderImage = View.createRenderImage(getWidth(), getHeight(), Transparency.TRANSLUCENT);
render();
}
+17 -2
View File
@@ -728,8 +728,23 @@ public class View {
return table;
}
public static GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
public static GraphicsConfiguration conf = env.getDefaultScreenDevice().getDefaultConfiguration();
private static GraphicsEnvironment env;
public static GraphicsEnvironment getEnv() {
if (env == null) {
env = GraphicsEnvironment.getLocalGraphicsEnvironment();
}
return env;
}
private static GraphicsConfiguration conf;
public static GraphicsConfiguration getDefaultConfiguration() {
if (conf == null) {
conf = getEnv().getDefaultScreenDevice().getDefaultConfiguration();
}
return conf;
}
public static BufferedImage toCompatibleImage(BufferedImage image) {
if (image.getColorModel().equals(conf.getColorModel())) {