Code cleaned (unused imports, formatting, IDE warnings, etc)

This commit is contained in:
skylarmt 2015-01-11 03:39:23 -07:00
parent 629a8d0bc2
commit 9ccf1e3e7e
10 changed files with 46 additions and 50 deletions

View File

@ -32,14 +32,8 @@ import java.awt.Component;
import java.awt.Font; import java.awt.Font;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.PrintStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
@ -63,8 +57,7 @@ public class CodeEditor extends javax.swing.JInternalFrame {
private final JFileChooser fc = new JFileChooser(); private final JFileChooser fc = new JFileChooser();
private boolean isSaved = false; private boolean isSaved = false;
private RSyntaxTextArea codeBox = new RSyntaxTextArea(); private RSyntaxTextArea codeBox = new RSyntaxTextArea();
private RTextScrollPane sp; private final RTextScrollPane sp;
private String lastSaved = "";
private boolean fileChanged = false; private boolean fileChanged = false;
private CompletionProvider jscomp = new CodeCompleter("js").getProvider(); private CompletionProvider jscomp = new CodeCompleter("js").getProvider();
@ -462,7 +455,6 @@ public class CodeEditor extends javax.swing.JInternalFrame {
codeBox.setText(FileUtils.readFile(f.toString())); codeBox.setText(FileUtils.readFile(f.toString()));
isSaved = true; isSaved = true;
filedata = f; filedata = f;
lastSaved = FileUtils.MD5(codeBox.getText());
setTitle("Editor - " + f.getName()); setTitle("Editor - " + f.getName());
} catch (IOException ex) { } catch (IOException ex) {
JOptionPane.showInternalMessageDialog(this, JOptionPane.showInternalMessageDialog(this,

View File

@ -49,6 +49,7 @@ public class Debug {
} }
} }
@SuppressWarnings(value = {"CallToPrintStackTrace"})
public static void stacktrace(Exception e) { public static void stacktrace(Exception e) {
if (DEBUG) { if (DEBUG) {
e.printStackTrace(); e.printStackTrace();

View File

@ -211,7 +211,7 @@ public class FirstRun extends javax.swing.JInternalFrame {
private void contBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_contBtnActionPerformed private void contBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_contBtnActionPerformed
if (noLicSel.isSelected()) { if (noLicSel.isSelected()) {
if (PrefStorage.getSetting("licensetype").equals("demo") if (PrefStorage.getSetting("licensetype").equals("demo")
&& PrefStorage.getSetting("licensedemo").equals("used")) { && PrefStorage.getSetting("licensedemo").equals("used")) {
int ans = JOptionPane.showInternalConfirmDialog(this, int ans = JOptionPane.showInternalConfirmDialog(this,
"You have already used a trial license." "You have already used a trial license."
@ -219,7 +219,7 @@ public class FirstRun extends javax.swing.JInternalFrame {
"Expired", "Expired",
JOptionPane.YES_NO_OPTION); JOptionPane.YES_NO_OPTION);
if (ans == JOptionPane.NO_OPTION) { if (ans == JOptionPane.NO_OPTION) {
} else { } else {
openShop(); openShop();
} }
@ -292,7 +292,7 @@ public class FirstRun extends javax.swing.JInternalFrame {
*/ */
private class CheckThread extends Thread { private class CheckThread extends Thread {
private String email; private final String email;
public CheckThread(String useremail) { public CheckThread(String useremail) {
email = useremail; email = useremail;
@ -303,12 +303,12 @@ public class FirstRun extends javax.swing.JInternalFrame {
try { try {
Debug.println("Checking license..."); Debug.println("Checking license...");
URL url = new URL(API_URL + "liccheck.php?email=" + email); URL url = new URL(API_URL + "liccheck.php?email=" + email);
InputStream is = url.openStream(); String line;
BufferedReader br = new BufferedReader(new InputStreamReader(is)); try (InputStream is = url.openStream();
BufferedReader br
String line = br.readLine(); = new BufferedReader(new InputStreamReader(is))) {
br.close(); line = br.readLine();
is.close(); }
switch (line) { switch (line) {
case "ok:single": case "ok:single":
@ -356,12 +356,13 @@ public class FirstRun extends javax.swing.JInternalFrame {
JOptionPane.QUESTION_MESSAGE); JOptionPane.QUESTION_MESSAGE);
Debug.println("Checking license code (" + code + ")..."); Debug.println("Checking license code (" + code + ")...");
URL url = new URL(API_URL + "emailverify.php?code=" + code + "&email=" + email); URL url = new URL(API_URL + "emailverify.php?code=" + code + "&email=" + email);
InputStream is = url.openStream(); String line;
BufferedReader br = new BufferedReader(new InputStreamReader(is)); try (InputStream is = url.openStream()) {
BufferedReader br
String line = br.readLine(); = new BufferedReader(new InputStreamReader(is));
br.close(); line = br.readLine();
is.close(); br.close();
}
if (code.equals(line)) { if (code.equals(line)) {
success("domain"); success("domain");
} else { } else {

View File

@ -1,7 +1,7 @@
/* /*
* Apocalypse Laboratories * Apocalypse Laboratories
* Open Source License * Open Source License
* *
* Source code can be used for any purpose, as long as: * Source code can be used for any purpose, as long as:
* - Compiled binaries are rebranded and trademarks are not * - Compiled binaries are rebranded and trademarks are not
* visible by the end user at any time, except to give * visible by the end user at any time, except to give
@ -14,7 +14,7 @@
* - and you provide your modified source code for download, * - and you provide your modified source code for download,
* under the terms of the GNU LGPL v3 or a comparable * under the terms of the GNU LGPL v3 or a comparable
* license. * license.
* *
* Compiled binaries cannot be redistributed or mirrored, * Compiled binaries cannot be redistributed or mirrored,
* unless: * unless:
* - You have written permission from Apocalypse Laboratories; * - You have written permission from Apocalypse Laboratories;
@ -22,7 +22,7 @@
* not even behind a paywall or other blocking mechanism; * not even behind a paywall or other blocking mechanism;
* - or you have received a multi-computer license, in which * - or you have received a multi-computer license, in which
* case you should take measures to prevent unauthorized * case you should take measures to prevent unauthorized
* downloads, such as preventing download access from the * downloads, such as preventing download access from the
* Internet. * Internet.
*/ */
package net.apocalypselabs.symat; package net.apocalypselabs.symat;
@ -40,7 +40,7 @@ public class FontOptions extends javax.swing.JPanel {
public FontOptions() { public FontOptions() {
initComponents(); initComponents();
} }
public FontOptions(int size) { public FontOptions(int size) {
this(); this();
jSpinner1.setValue(size); jSpinner1.setValue(size);
@ -104,7 +104,7 @@ public class FontOptions extends javax.swing.JPanel {
public int getResult() { public int getResult() {
return (int) jSpinner1.getValue(); return (int) jSpinner1.getValue();
} }
public boolean isModified() { public boolean isModified() {
return modified; return modified;
} }

View File

@ -1,7 +1,7 @@
/* /*
* Apocalypse Laboratories * Apocalypse Laboratories
* Open Source License * Open Source License
* *
* Source code can be used for any purpose, as long as: * Source code can be used for any purpose, as long as:
* - Compiled binaries are rebranded and trademarks are not * - Compiled binaries are rebranded and trademarks are not
* visible by the end user at any time, except to give * visible by the end user at any time, except to give
@ -14,7 +14,7 @@
* - and you provide your modified source code for download, * - and you provide your modified source code for download,
* under the terms of the GNU LGPL v3 or a comparable * under the terms of the GNU LGPL v3 or a comparable
* license. * license.
* *
* Compiled binaries cannot be redistributed or mirrored, * Compiled binaries cannot be redistributed or mirrored,
* unless: * unless:
* - You have written permission from Apocalypse Laboratories; * - You have written permission from Apocalypse Laboratories;
@ -22,7 +22,7 @@
* not even behind a paywall or other blocking mechanism; * not even behind a paywall or other blocking mechanism;
* - or you have received a multi-computer license, in which * - or you have received a multi-computer license, in which
* case you should take measures to prevent unauthorized * case you should take measures to prevent unauthorized
* downloads, such as preventing download access from the * downloads, such as preventing download access from the
* Internet. * Internet.
*/ */
package net.apocalypselabs.symat; package net.apocalypselabs.symat;
@ -118,7 +118,7 @@ public class Functions {
} }
} }
/* /*
Graphing interfaces Graphing interfaces
*/ */
public void plotrange(double xmin, double xmax) { public void plotrange(double xmin, double xmax) {

View File

@ -1,7 +1,7 @@
/* /*
* Apocalypse Laboratories * Apocalypse Laboratories
* Open Source License * Open Source License
* *
* Source code can be used for any purpose, as long as: * Source code can be used for any purpose, as long as:
* - Compiled binaries are rebranded and trademarks are not * - Compiled binaries are rebranded and trademarks are not
* visible by the end user at any time, except to give * visible by the end user at any time, except to give
@ -14,7 +14,7 @@
* - and you provide your modified source code for download, * - and you provide your modified source code for download,
* under the terms of the GNU LGPL v3 or a comparable * under the terms of the GNU LGPL v3 or a comparable
* license. * license.
* *
* Compiled binaries cannot be redistributed or mirrored, * Compiled binaries cannot be redistributed or mirrored,
* unless: * unless:
* - You have written permission from Apocalypse Laboratories; * - You have written permission from Apocalypse Laboratories;
@ -22,7 +22,7 @@
* not even behind a paywall or other blocking mechanism; * not even behind a paywall or other blocking mechanism;
* - or you have received a multi-computer license, in which * - or you have received a multi-computer license, in which
* case you should take measures to prevent unauthorized * case you should take measures to prevent unauthorized
* downloads, such as preventing download access from the * downloads, such as preventing download access from the
* Internet. * Internet.
*/ */
package net.apocalypselabs.symat; package net.apocalypselabs.symat;
@ -248,7 +248,7 @@ public class Help extends javax.swing.JInternalFrame {
} }
setText(text, "Manual (" + topicList.getSelectedValue().toString() + ")"); setText(text, "Manual (" + topicList.getSelectedValue().toString() + ")");
} catch (Exception e) { } catch (Exception e) {
//JOptionPane.showInternalMessageDialog(MainGUI.mainPane, //JOptionPane.showInternalMessageDialog(MainGUI.mainPane,
//"Error: Cannot load help topic "+name+".\n\n"+e.getMessage()); //"Error: Cannot load help topic "+name+".\n\n"+e.getMessage());
setText("<html><head></head><body><p><b>Error:</b><br>Cannot get help topic \"" setText("<html><head></head><body><p><b>Error:</b><br>Cannot get help topic \""
+ name + "\".<br>(" + e.getMessage() + ")</p></body></html>", "Manual"); + name + "\".<br>(" + e.getMessage() + ")</p></body></html>", "Manual");

View File

@ -31,8 +31,6 @@ import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
@ -412,7 +410,7 @@ public class Interpreter extends javax.swing.JInternalFrame {
false); false);
} catch (IOException ex) { } catch (IOException ex) {
JOptionPane.showInternalMessageDialog(this, JOptionPane.showInternalMessageDialog(this,
"Error saving: "+ex.getMessage(), "Error saving: " + ex.getMessage(),
"Error", "Error",
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
} }
@ -452,7 +450,7 @@ public class Interpreter extends javax.swing.JInternalFrame {
} }
// Implement ans command // Implement ans command
String ansfill = ""; String ansfill;
try { try {
ansfill = String.valueOf(Double.parseDouble(ans.toString())); ansfill = String.valueOf(Double.parseDouble(ans.toString()));
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
@ -463,6 +461,7 @@ public class Interpreter extends javax.swing.JInternalFrame {
} }
@Override @Override
@SuppressWarnings("null")
public void run() { public void run() {
try { try {
if (doSpecialCommands()) { if (doSpecialCommands()) {

View File

@ -29,12 +29,15 @@ package net.apocalypselabs.symat;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
@ -758,7 +761,7 @@ public class MainGUI extends javax.swing.JFrame {
ubuntuRegular = Font.createFont(Font.TRUETYPE_FONT, ubuntuRegular = Font.createFont(Font.TRUETYPE_FONT,
new File(MainGUI.class. new File(MainGUI.class.
getResource("resources/Ubuntu-R.ttf").toURI())); getResource("resources/Ubuntu-R.ttf").toURI()));
} catch (Exception ex) { } catch (URISyntaxException | FontFormatException | IOException ex) {
ubuntuRegular = Font.getFont(Font.SANS_SERIF); ubuntuRegular = Font.getFont(Font.SANS_SERIF);
} }

View File

@ -1,7 +1,7 @@
/* /*
* Apocalypse Laboratories * Apocalypse Laboratories
* Open Source License * Open Source License
* *
* Source code can be used for any purpose, as long as: * Source code can be used for any purpose, as long as:
* - Compiled binaries are rebranded and trademarks are not * - Compiled binaries are rebranded and trademarks are not
* visible by the end user at any time, except to give * visible by the end user at any time, except to give
@ -14,7 +14,7 @@
* - and you provide your modified source code for download, * - and you provide your modified source code for download,
* under the terms of the GNU LGPL v3 or a comparable * under the terms of the GNU LGPL v3 or a comparable
* license. * license.
* *
* Compiled binaries cannot be redistributed or mirrored, * Compiled binaries cannot be redistributed or mirrored,
* unless: * unless:
* - You have written permission from Apocalypse Laboratories; * - You have written permission from Apocalypse Laboratories;
@ -22,7 +22,7 @@
* not even behind a paywall or other blocking mechanism; * not even behind a paywall or other blocking mechanism;
* - or you have received a multi-computer license, in which * - or you have received a multi-computer license, in which
* case you should take measures to prevent unauthorized * case you should take measures to prevent unauthorized
* downloads, such as preventing download access from the * downloads, such as preventing download access from the
* Internet. * Internet.
*/ */
package net.apocalypselabs.symat; package net.apocalypselabs.symat;
@ -45,7 +45,7 @@ public class PrefStorage {
public static boolean isset(String key) { public static boolean isset(String key) {
return !getSetting(key, "NULL").equals("NULL"); return !getSetting(key, "NULL").equals("NULL");
} }
public static void unset(String key) { public static void unset(String key) {
prefs.remove(key); prefs.remove(key);
} }
@ -57,7 +57,7 @@ public class PrefStorage {
public static String getSetting(String key, String emptyResponse) { public static String getSetting(String key, String emptyResponse) {
return prefs.get(key, emptyResponse); return prefs.get(key, emptyResponse);
} }
public static boolean save() { public static boolean save() {
try { try {
prefs.flush(); prefs.flush();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 265 B