Skip to content
Snippets Groups Projects
Commit 345a0de6 authored by stepan's avatar stepan
Browse files

FastR grid: check AWT support option before creating AWT based devices.

parent 771d10fc
Branches
No related tags found
No related merge requests found
...@@ -96,18 +96,18 @@ public final class GridContext { ...@@ -96,18 +96,18 @@ public final class GridContext {
public void openDefaultDevice() { public void openDefaultDevice() {
String defaultDev = RGridGraphicsAdapter.getDefaultDevice(); String defaultDev = RGridGraphicsAdapter.getDefaultDevice();
if (defaultDev.equals("awt") || defaultDev.startsWith("X11")) { if (defaultDev.equals("awt") || defaultDev.startsWith("X11")) {
if (!FastRConfig.InternalGridAwtSupport) { ensureAwtSupport();
throw awtNotSupported(); setCurrentDevice(defaultDev, WindowDevice.createWindowDevice());
} else {
setCurrentDevice(defaultDev, WindowDevice.createWindowDevice());
}
} else if (defaultDev.equals("svg")) { } else if (defaultDev.equals("svg")) {
setCurrentDevice(defaultDev, new SVGDevice("Rplot.svg", GridDevice.DEFAULT_WIDTH, GridDevice.DEFAULT_HEIGHT)); setCurrentDevice(defaultDev, new SVGDevice("Rplot.svg", GridDevice.DEFAULT_WIDTH, GridDevice.DEFAULT_HEIGHT));
} else if (defaultDev.equals("png")) { } else if (defaultDev.equals("png")) {
ensureAwtSupport();
setCurrentDevice(defaultDev, safeOpenImageDev("Rplot.png", "png")); setCurrentDevice(defaultDev, safeOpenImageDev("Rplot.png", "png"));
} else if (defaultDev.equals("bmp")) { } else if (defaultDev.equals("bmp")) {
ensureAwtSupport();
setCurrentDevice(defaultDev, safeOpenImageDev("Rplot.bmp", "bmp")); setCurrentDevice(defaultDev, safeOpenImageDev("Rplot.bmp", "bmp"));
} else if (defaultDev.equals("jpg") || defaultDev.equals("jpeg")) { } else if (defaultDev.equals("jpg") || defaultDev.equals("jpeg")) {
ensureAwtSupport();
setCurrentDevice("jpeg", safeOpenImageDev("Rplot.jpg", "jpeg")); setCurrentDevice("jpeg", safeOpenImageDev("Rplot.jpg", "jpeg"));
} else { } else {
throw RError.error(RError.NO_CALLER, Message.GENERIC, "FastR does not support device '" + defaultDev + "'."); throw RError.error(RError.NO_CALLER, Message.GENERIC, "FastR does not support device '" + defaultDev + "'.");
...@@ -144,6 +144,12 @@ public final class GridContext { ...@@ -144,6 +144,12 @@ public final class GridContext {
return RContext.getEngine().evalFunction(redrawAll, REnvironment.baseEnv().getFrame(), RCaller.topLevel, true, null, args); return RContext.getEngine().evalFunction(redrawAll, REnvironment.baseEnv().getFrame(), RCaller.topLevel, true, null, args);
} }
private static void ensureAwtSupport() {
if (!FastRConfig.InternalGridAwtSupport) {
throw awtNotSupported();
}
}
private BufferedImageDevice safeOpenImageDev(String filename, String formatName) { private BufferedImageDevice safeOpenImageDev(String filename, String formatName) {
try { try {
return BufferedImageDevice.open(filename, formatName, GridDevice.DEFAULT_WIDTH, GridDevice.DEFAULT_HEIGHT); return BufferedImageDevice.open(filename, formatName, GridDevice.DEFAULT_WIDTH, GridDevice.DEFAULT_HEIGHT);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
package com.oracle.truffle.r.library.fastrGrid.graphics; package com.oracle.truffle.r.library.fastrGrid.graphics;
import com.oracle.truffle.r.library.fastrGrid.FastRGridExternalLookup; import com.oracle.truffle.r.library.fastrGrid.FastRGridExternalLookup;
import com.oracle.truffle.r.runtime.FastRConfig;
import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RError;
import com.oracle.truffle.r.runtime.RError.Message; import com.oracle.truffle.r.runtime.RError.Message;
import com.oracle.truffle.r.runtime.ROptions; import com.oracle.truffle.r.runtime.ROptions;
...@@ -70,7 +71,7 @@ public final class RGridGraphicsAdapter { ...@@ -70,7 +71,7 @@ public final class RGridGraphicsAdapter {
if (options.getValue(DEFAULT_DEVICE_OPTION) != RNull.instance) { if (options.getValue(DEFAULT_DEVICE_OPTION) != RNull.instance) {
return; return;
} }
String defaultDevice = ctx.isInteractive() ? "awt" : "svg"; String defaultDevice = (ctx.isInteractive() && FastRConfig.InternalGridAwtSupport) ? "awt" : "svg";
try { try {
options.setValue(DEFAULT_DEVICE_OPTION, defaultDevice); options.setValue(DEFAULT_DEVICE_OPTION, defaultDevice);
} catch (OptionsException e) { } catch (OptionsException e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment