Removing some deprecated things

This commit is contained in:
Jindra Petřík
2023-09-28 19:11:51 +02:00
parent 66d5711b0d
commit 7e86723b2e
2 changed files with 18 additions and 23 deletions

View File

@@ -34,8 +34,6 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.Field;
import java.net.URISyntaxException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
@@ -44,6 +42,7 @@ import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
@@ -923,23 +922,15 @@ public final class Configuration {
WINDOWS, OSX, UNIX
}
private static OSId getOSId() {
PrivilegedAction<String> doGetOSName = new PrivilegedAction<String>() {
@Override
public String run() {
return System.getProperty("os.name");
}
};
OSId id = OSId.UNIX;
String osName = AccessController.doPrivileged(doGetOSName);
if (osName != null) {
if (osName.toLowerCase().startsWith("mac os x")) {
id = OSId.OSX;
} else if (osName.contains("Windows")) {
id = OSId.WINDOWS;
}
private static OSId getOSId() {
String OS = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH);
if ((OS.indexOf("mac") >= 0) || (OS.indexOf("darwin") >= 0)) {
return OSId.OSX;
} else if (OS.indexOf("win") >= 0) {
return OSId.WINDOWS;
} else {
return OSId.UNIX;
}
return id;
}
public static String getFFDecHome() {

View File

@@ -39,7 +39,7 @@ public class GraphVizDotCommands {
return true;
}
private static void runCommand(String command) {
private static void runCommand(String[] command) {
try {
Process process = Runtime.getRuntime().exec(command);
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
@@ -52,12 +52,17 @@ public class GraphVizDotCommands {
}
}
private static boolean runDotCommand(String command) {
private static boolean runDotCommand(String[] command) {
String dotLocation = Configuration.graphVizDotLocation.get();
if (dotLocation.isEmpty() && !new File(dotLocation).exists()) {
return false;
}//
runCommand("\"" + dotLocation + "\" " + command);
String[] commandPlusDot = new String[command.length + 1];
commandPlusDot[0] = dotLocation;
for (int i = 0; i < command.length; i++) {
commandPlusDot[1 + i] = command[i];
}
runCommand(commandPlusDot);
return true;
}
@@ -68,8 +73,7 @@ public class GraphVizDotCommands {
PrintWriter pw = new PrintWriter(gvFile);
pw.println(text);
pw.close();
String extraParams = " -Nfontname=times-bold -Nfontsize=12";
if (!runDotCommand("-Tpng" + extraParams + " -o \"" + pngFile.getAbsolutePath() + "\" \"" + gvFile.getAbsolutePath() + "\"")) {
if (!runDotCommand(new String[]{"-Tpng", "-Nfontname=times-bold", "-Nfontsize=12", "-o", pngFile.getAbsolutePath(), gvFile.getAbsolutePath()})) {
gvFile.delete();
return null;
}