Skip to content

Commit cfc269c

Browse files
committed
Fix some warnings
Fix some warnings new Integer(integer) getRotationElevation --> getRotationElevationRadians etc.
1 parent a130876 commit cfc269c

22 files changed

Lines changed: 161 additions & 106 deletions

src/main/java/com/neuronrobotics/bowlerstudio/BowlerStudioMenu.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import eu.mihosoft.vrl.v3d.CSG;
2626
import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase;
27+
2728
import javafx.collections.ObservableList;
2829
import javafx.event.ActionEvent;
2930
import javafx.event.Event;
@@ -34,6 +35,8 @@
3435
import javafx.scene.control.Alert.AlertType;
3536
import javafx.stage.FileChooser.ExtensionFilter;
3637
import javafx.stage.Stage;
38+
import javafx.scene.layout.*;
39+
3740
import org.eclipse.jgit.api.errors.GitAPIException;
3841
import org.eclipse.jgit.api.errors.NoHeadException;
3942
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
@@ -59,10 +62,6 @@
5962
import java.util.function.Consumer;
6063
import java.util.regex.Pattern;
6164
import java.util.stream.Collectors;
62-
import javafx.scene.layout.*;
63-
import javafx.event.ActionEvent;
64-
import javafx.event.EventHandler;
65-
import javafx.scene.control.*;
6665

6766
public class BowlerStudioMenu implements MenuRefreshEvent, INewVitaminCallback {
6867

@@ -277,7 +276,7 @@ private void openFilesInUI() {
277276
ArrayList<String> repoFile = (ArrayList<String>) ConfigurationDatabase.getObject(key, s,
278277
new ArrayList<>());
279278
File f = ScriptingEngine.fileFromGit(repoFile.get(0), repoFile.get(1));
280-
if (!f.exists() || BowlerStudio.createFileTab(f) == null) {
279+
if (!f.exists() || (BowlerStudio.createFileTab(f) == null)) {
281280
ConfigurationDatabase.removeObject(key, s);
282281
System.err.println("Removing missing " + s);
283282
}
@@ -295,7 +294,7 @@ private void openFilesInUI() {
295294
String repoFile = (String) ConfigurationDatabase.getObject(webKey, s, null);
296295
if (repoFile != null)
297296
try {
298-
bowlerStudioModularFrame.openUrlInNewTab(new URL(repoFile));
297+
bowlerStudioModularFrame.openUrlInNewTab(new URI(repoFile).toURL());
299298
} catch (Exception e) {
300299
exp.uncaughtException(Thread.currentThread(), e);
301300
}
@@ -1235,8 +1234,8 @@ public void onCreatenewGist(ActionEvent event) {
12351234
public void onOpenGitter(ActionEvent event) {
12361235
String url = "https://gitter.im";
12371236
try {
1238-
BowlerStudio.openUrlInNewTab(new URL(url));
1239-
} catch (MalformedURLException e) {
1237+
BowlerStudio.openUrlInNewTab(new URI(url).toURL());
1238+
} catch (MalformedURLException | URISyntaxException e) {
12401239
exp.uncaughtException(Thread.currentThread(), e);
12411240
}
12421241
}

src/main/java/com/neuronrobotics/bowlerstudio/ConnectionManager.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
import com.neuronrobotics.sdk.serial.SerialConnection;
1818
import com.neuronrobotics.sdk.ui.AbstractConnectionPanel;
1919
import com.neuronrobotics.sdk.wireless.bluetooth.BluetoothSerialConnection;
20+
2021
import gnu.io.NRSerialPort;
22+
2123
import javafx.event.ActionEvent;
2224
import javafx.event.EventHandler;
2325
import javafx.scene.Node;
@@ -33,8 +35,11 @@
3335
import javafx.stage.Stage;
3436

3537
import java.io.File;
38+
3639
import java.net.MalformedURLException;
40+
import java.net.URISyntaxException;
3741
import java.net.URL;
42+
import java.net.URI;
3843
import java.util.ArrayList;
3944
import java.util.List;
4045
import java.util.Optional;
@@ -283,32 +288,35 @@ public static void onConnectFileSourceCamera() {
283288
}
284289

285290
public static void onConnectURLSourceCamera() {
291+
286292
TextInputDialog alert = new TextInputDialog("http://neuronrobotics.com/img/AndrewHarrington/2014-09-15-86.jpg");
287293
alert.setTitle("URL Image Source");
288294
alert.setHeaderText("This url will be loaded each capture.");
289295
alert.setContentText("URL ");
290296
Node root = alert.getDialogPane();
291297
Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
292298
stage.setOnCloseRequest(ev -> alert.hide());
299+
293300
FontSizeManager.addListener(fontNum -> {
294301
int tmp = fontNum - 10;
295302
if (tmp < 12)
296303
tmp = 12;
304+
297305
root.setStyle("-fx-font-size: " + tmp + "pt");
298306
alert.getDialogPane().applyCss();
299307
alert.getDialogPane().layout();
300308
stage.sizeToScene();
301309
});
310+
302311
// Traditional way to get the response value.
303312
Optional<String> result = alert.showAndWait();
304313
if (result.isPresent()) {
305314
URLImageProvider p;
306315
try {
307-
p = new URLImageProvider(new URL(result.get()));
316+
p = new URLImageProvider(new URI(result.get()).toURL());
308317
String name = "url";
309318
addConnection(p, name);
310-
} catch (MalformedURLException e) {
311-
// Auto-generated catch block
319+
} catch (MalformedURLException | URISyntaxException e) {
312320
e.printStackTrace();
313321
}
314322
}

src/main/java/com/neuronrobotics/bowlerstudio/DeviceSupportPluginMap.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ public AbstractBowlerStudioTab generateNewPlugin()
5858
throws ClassNotFoundException, InstantiationException, IllegalAccessException {
5959
if (factory != null)
6060
return factory.generateNewPlugin();
61-
return (AbstractBowlerStudioTab) Class.forName(plugin.getName()).cast(plugin.newInstance()// This is where the
62-
// new tab
63-
// allocation is
64-
// called
61+
62+
// This is where the new tab allocation is called
63+
return (AbstractBowlerStudioTab) Class.forName(plugin.getName()).cast(plugin.newInstance()
6564
);
6665
}
6766
}

src/main/java/com/neuronrobotics/bowlerstudio/creature/TransformWidget.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ public TransformWidget(String title, TransformNR is, IOnTransformChange onChange
8585
}
8686
double e = 0;
8787
try {
88-
e = Math.toDegrees(storeRotation.getRotationElevation());
88+
e = Math.toDegrees(storeRotation.getRotationElevationRadians());
8989
} catch (Exception ex) {
9090
ex.printStackTrace();
9191
}
9292
double a = 0;
9393
try {
94-
a = Math.toDegrees(storeRotation.getRotationAzimuth());
94+
a = Math.toDegrees(storeRotation.getRotationAzimuthRadians());
9595
} catch (Exception ex) {
9696
ex.printStackTrace();
9797
}
@@ -297,13 +297,13 @@ public void updatePose(TransformNR p) {
297297
}
298298
double e = 0;
299299
try {
300-
e = Math.toDegrees(rot.getRotationElevation());
300+
e = Math.toDegrees(rot.getRotationElevationRadians());
301301
} catch (Exception ex) {
302302
ex.printStackTrace();
303303
}
304304
double a = 0;
305305
try {
306-
a = Math.toDegrees(rot.getRotationAzimuth());
306+
a = Math.toDegrees(rot.getRotationAzimuthRadians());
307307
} catch (Exception ex) {
308308
ex.printStackTrace();
309309
}

src/main/java/com/neuronrobotics/bowlerstudio/scripting/external/ArduinoExternalEditor.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import java.io.File;
66
import java.net.MalformedURLException;
77
import java.net.URL;
8+
import java.net.URI;
9+
import java.net.URISyntaxException;
810
import java.util.Arrays;
911
import java.util.List;
1012

@@ -63,7 +65,11 @@ public String nameOfEditor() {
6365

6466
@Override
6567
public URL getInstallURL() throws MalformedURLException {
66-
return new URL("https://github.com/WPIRoboticsEngineering/RobotInterfaceBoard/blob/master/InstallEclipse.md");
68+
try {
69+
return new URI("https://github.com/WPIRoboticsEngineering/RobotInterfaceBoard/blob/master/InstallEclipse.md").toURL();
70+
} catch (URISyntaxException e) {
71+
throw new MalformedURLException(e.getMessage());
72+
}
6773
}
6874

6975
@Override

src/main/java/com/neuronrobotics/bowlerstudio/scripting/external/BlenderExternalEditor.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import java.io.IOException;
77
import java.net.MalformedURLException;
88
import java.net.URL;
9+
import java.net.URI;
10+
import java.net.URISyntaxException;
911
import java.util.Arrays;
1012
import java.util.List;
1113

@@ -91,7 +93,11 @@ public void onProcessExit(int ev) {
9193

9294
@Override
9395
public URL getInstallURL() throws MalformedURLException {
94-
return new URL("https://www.blender.org/download/release/Blender4.1/blender-4.1.1-linux-x64.tar.xz/");
96+
try {
97+
return new URI("https://www.blender.org/download/release/Blender4.1/blender-4.1.1-linux-x64.tar.xz/").toURL();
98+
} catch (URISyntaxException e) {
99+
throw new MalformedURLException(e.getMessage());
100+
}
95101
}
96102

97103
@Override

src/main/java/com/neuronrobotics/bowlerstudio/scripting/external/CaDoodleExternalEditor.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import java.io.IOException;
77
import java.net.MalformedURLException;
88
import java.net.URL;
9+
import java.net.URI;
10+
import java.net.URISyntaxException;
911
import java.util.Arrays;
1012
import java.util.HashMap;
1113
import java.util.List;
@@ -66,8 +68,13 @@ public void onProcessExit(int ev) {
6668

6769
}
6870

71+
@Override
6972
public URL getInstallURL() throws MalformedURLException {
70-
return new URL("https://github.com/CommonWealthRobotics/CaDoodle/blob/main/README.md");
73+
try {
74+
return new URI("https://github.com/CommonWealthRobotics/CaDoodle/blob/main/README.md").toURL();
75+
} catch (URISyntaxException e) {
76+
throw new MalformedURLException(e.getMessage());
77+
}
7178
}
7279

7380
public String nameOfEditor() {

src/main/java/com/neuronrobotics/bowlerstudio/scripting/external/EclipseExternalEditor.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import java.io.Reader;
1010
import java.net.MalformedURLException;
1111
import java.net.URL;
12+
import java.net.URI;
13+
import java.net.URISyntaxException;
1214
import java.nio.channels.FileLock;
1315
import java.nio.charset.StandardCharsets;
1416
import java.nio.file.Files;
@@ -122,7 +124,7 @@ public void launch(File file, Button advanced, Runnable OnComplete) {
122124
OutputStream out = null;
123125
try {
124126
out = FileUtils.openOutputStream(desired, false);
125-
IOUtils.write(content, out);
127+
IOUtils.write(content, out, "UTF-8");
126128
out.close(); // don't swallow close Exception if copy completes
127129
// normally
128130
} finally {
@@ -265,7 +267,11 @@ public String nameOfEditor() {
265267

266268
@Override
267269
public URL getInstallURL() throws MalformedURLException {
268-
return new URL("https://github.com/CommonWealthRobotics/ESP32ArduinoEclipseInstaller/blob/master/README.md");
270+
try {
271+
return new URI("https://github.com/CommonWealthRobotics/ESP32ArduinoEclipseInstaller/blob/master/README.md").toURL();
272+
} catch (URISyntaxException e) {
273+
throw new MalformedURLException(e.getMessage());
274+
}
269275
}
270276

271277
}

src/main/java/com/neuronrobotics/bowlerstudio/scripting/external/OpenSCADExternalEditor.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import java.io.IOException;
77
import java.net.MalformedURLException;
88
import java.net.URL;
9+
import java.net.URI;
10+
import java.net.URISyntaxException;
911
import java.util.Arrays;
1012
import java.util.List;
1113

@@ -60,7 +62,11 @@ public void onProcessExit(int ev) {
6062

6163
@Override
6264
public URL getInstallURL() throws MalformedURLException {
63-
return new URL("https://openscad.org/downloads.html");
65+
try {
66+
return new URI("https://openscad.org/downloads.html").toURL();
67+
} catch (URISyntaxException e) {
68+
throw new MalformedURLException(e.getMessage());
69+
}
6470
}
6571

6672
@Override

src/main/java/com/neuronrobotics/bowlerstudio/scripting/external/SVGExternalEditor.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import java.io.IOException;
77
import java.net.MalformedURLException;
88
import java.net.URL;
9+
import java.net.URI;
10+
import java.net.URISyntaxException;
911
import java.util.Arrays;
1012
import java.util.List;
1113

@@ -65,7 +67,11 @@ public void onProcessExit(int ev) {
6567

6668
@Override
6769
public URL getInstallURL() throws MalformedURLException {
68-
return new URL("https://inkscape.org/release/");
70+
try {
71+
return new URI("https://inkscape.org/release/").toURL();
72+
} catch (URISyntaxException e) {
73+
throw new MalformedURLException(e.getMessage());
74+
}
6975
}
7076

7177
@Override

0 commit comments

Comments
 (0)