From 9ccf1e3e7ec01c8791363dd378ca8d284586f7ce Mon Sep 17 00:00:00 2001 From: skylarmt Date: Sun, 11 Jan 2015 03:39:23 -0700 Subject: [PATCH] Code cleaned (unused imports, formatting, IDE warnings, etc) --- src/net/apocalypselabs/symat/CodeEditor.java | 10 +----- src/net/apocalypselabs/symat/Debug.java | 1 + src/net/apocalypselabs/symat/FirstRun.java | 31 +++++++++--------- src/net/apocalypselabs/symat/FontOptions.java | 10 +++--- src/net/apocalypselabs/symat/Functions.java | 10 +++--- src/net/apocalypselabs/symat/Help.java | 10 +++--- src/net/apocalypselabs/symat/Interpreter.java | 7 ++-- src/net/apocalypselabs/symat/MainGUI.java | 5 ++- src/net/apocalypselabs/symat/PrefStorage.java | 12 +++---- src/net/apocalypselabs/symat/menugradient.png | Bin 265 -> 0 bytes 10 files changed, 46 insertions(+), 50 deletions(-) delete mode 100644 src/net/apocalypselabs/symat/menugradient.png diff --git a/src/net/apocalypselabs/symat/CodeEditor.java b/src/net/apocalypselabs/symat/CodeEditor.java index dfb8873..2dbc184 100644 --- a/src/net/apocalypselabs/symat/CodeEditor.java +++ b/src/net/apocalypselabs/symat/CodeEditor.java @@ -32,14 +32,8 @@ import java.awt.Component; import java.awt.Font; import java.io.BufferedReader; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; 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.JOptionPane; import javax.swing.SwingUtilities; @@ -63,8 +57,7 @@ public class CodeEditor extends javax.swing.JInternalFrame { private final JFileChooser fc = new JFileChooser(); private boolean isSaved = false; private RSyntaxTextArea codeBox = new RSyntaxTextArea(); - private RTextScrollPane sp; - private String lastSaved = ""; + private final RTextScrollPane sp; private boolean fileChanged = false; private CompletionProvider jscomp = new CodeCompleter("js").getProvider(); @@ -462,7 +455,6 @@ public class CodeEditor extends javax.swing.JInternalFrame { codeBox.setText(FileUtils.readFile(f.toString())); isSaved = true; filedata = f; - lastSaved = FileUtils.MD5(codeBox.getText()); setTitle("Editor - " + f.getName()); } catch (IOException ex) { JOptionPane.showInternalMessageDialog(this, diff --git a/src/net/apocalypselabs/symat/Debug.java b/src/net/apocalypselabs/symat/Debug.java index 37e97a6..389b1b0 100644 --- a/src/net/apocalypselabs/symat/Debug.java +++ b/src/net/apocalypselabs/symat/Debug.java @@ -49,6 +49,7 @@ public class Debug { } } + @SuppressWarnings(value = {"CallToPrintStackTrace"}) public static void stacktrace(Exception e) { if (DEBUG) { e.printStackTrace(); diff --git a/src/net/apocalypselabs/symat/FirstRun.java b/src/net/apocalypselabs/symat/FirstRun.java index 83dae05..9b499de 100644 --- a/src/net/apocalypselabs/symat/FirstRun.java +++ b/src/net/apocalypselabs/symat/FirstRun.java @@ -211,7 +211,7 @@ public class FirstRun extends javax.swing.JInternalFrame { private void contBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_contBtnActionPerformed if (noLicSel.isSelected()) { - if (PrefStorage.getSetting("licensetype").equals("demo") + if (PrefStorage.getSetting("licensetype").equals("demo") && PrefStorage.getSetting("licensedemo").equals("used")) { int ans = JOptionPane.showInternalConfirmDialog(this, "You have already used a trial license." @@ -219,7 +219,7 @@ public class FirstRun extends javax.swing.JInternalFrame { "Expired", JOptionPane.YES_NO_OPTION); if (ans == JOptionPane.NO_OPTION) { - + } else { openShop(); } @@ -292,7 +292,7 @@ public class FirstRun extends javax.swing.JInternalFrame { */ private class CheckThread extends Thread { - private String email; + private final String email; public CheckThread(String useremail) { email = useremail; @@ -303,12 +303,12 @@ public class FirstRun extends javax.swing.JInternalFrame { try { Debug.println("Checking license..."); URL url = new URL(API_URL + "liccheck.php?email=" + email); - InputStream is = url.openStream(); - BufferedReader br = new BufferedReader(new InputStreamReader(is)); - - String line = br.readLine(); - br.close(); - is.close(); + String line; + try (InputStream is = url.openStream(); + BufferedReader br + = new BufferedReader(new InputStreamReader(is))) { + line = br.readLine(); + } switch (line) { case "ok:single": @@ -356,12 +356,13 @@ public class FirstRun extends javax.swing.JInternalFrame { JOptionPane.QUESTION_MESSAGE); Debug.println("Checking license code (" + code + ")..."); URL url = new URL(API_URL + "emailverify.php?code=" + code + "&email=" + email); - InputStream is = url.openStream(); - BufferedReader br = new BufferedReader(new InputStreamReader(is)); - - String line = br.readLine(); - br.close(); - is.close(); + String line; + try (InputStream is = url.openStream()) { + BufferedReader br + = new BufferedReader(new InputStreamReader(is)); + line = br.readLine(); + br.close(); + } if (code.equals(line)) { success("domain"); } else { diff --git a/src/net/apocalypselabs/symat/FontOptions.java b/src/net/apocalypselabs/symat/FontOptions.java index 88860f3..54334f4 100644 --- a/src/net/apocalypselabs/symat/FontOptions.java +++ b/src/net/apocalypselabs/symat/FontOptions.java @@ -1,7 +1,7 @@ /* * Apocalypse Laboratories * Open Source License - * + * * Source code can be used for any purpose, as long as: * - Compiled binaries are rebranded and trademarks are not * visible by the end user at any time, except to give @@ -14,7 +14,7 @@ * - and you provide your modified source code for download, * under the terms of the GNU LGPL v3 or a comparable * license. - * + * * Compiled binaries cannot be redistributed or mirrored, * unless: * - You have written permission from Apocalypse Laboratories; @@ -22,7 +22,7 @@ * not even behind a paywall or other blocking mechanism; * - or you have received a multi-computer license, in which * 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. */ package net.apocalypselabs.symat; @@ -40,7 +40,7 @@ public class FontOptions extends javax.swing.JPanel { public FontOptions() { initComponents(); } - + public FontOptions(int size) { this(); jSpinner1.setValue(size); @@ -104,7 +104,7 @@ public class FontOptions extends javax.swing.JPanel { public int getResult() { return (int) jSpinner1.getValue(); } - + public boolean isModified() { return modified; } diff --git a/src/net/apocalypselabs/symat/Functions.java b/src/net/apocalypselabs/symat/Functions.java index 5e9d3c3..382477d 100644 --- a/src/net/apocalypselabs/symat/Functions.java +++ b/src/net/apocalypselabs/symat/Functions.java @@ -1,7 +1,7 @@ -/* +/* * Apocalypse Laboratories * Open Source License - * + * * Source code can be used for any purpose, as long as: * - Compiled binaries are rebranded and trademarks are not * visible by the end user at any time, except to give @@ -14,7 +14,7 @@ * - and you provide your modified source code for download, * under the terms of the GNU LGPL v3 or a comparable * license. - * + * * Compiled binaries cannot be redistributed or mirrored, * unless: * - You have written permission from Apocalypse Laboratories; @@ -22,7 +22,7 @@ * not even behind a paywall or other blocking mechanism; * - or you have received a multi-computer license, in which * 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. */ package net.apocalypselabs.symat; @@ -118,7 +118,7 @@ public class Functions { } } - /* + /* Graphing interfaces */ public void plotrange(double xmin, double xmax) { diff --git a/src/net/apocalypselabs/symat/Help.java b/src/net/apocalypselabs/symat/Help.java index c7f1b0b..763b005 100644 --- a/src/net/apocalypselabs/symat/Help.java +++ b/src/net/apocalypselabs/symat/Help.java @@ -1,7 +1,7 @@ -/* +/* * Apocalypse Laboratories * Open Source License - * + * * Source code can be used for any purpose, as long as: * - Compiled binaries are rebranded and trademarks are not * visible by the end user at any time, except to give @@ -14,7 +14,7 @@ * - and you provide your modified source code for download, * under the terms of the GNU LGPL v3 or a comparable * license. - * + * * Compiled binaries cannot be redistributed or mirrored, * unless: * - You have written permission from Apocalypse Laboratories; @@ -22,7 +22,7 @@ * not even behind a paywall or other blocking mechanism; * - or you have received a multi-computer license, in which * 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. */ package net.apocalypselabs.symat; @@ -248,7 +248,7 @@ public class Help extends javax.swing.JInternalFrame { } setText(text, "Manual (" + topicList.getSelectedValue().toString() + ")"); } catch (Exception e) { - //JOptionPane.showInternalMessageDialog(MainGUI.mainPane, + //JOptionPane.showInternalMessageDialog(MainGUI.mainPane, //"Error: Cannot load help topic "+name+".\n\n"+e.getMessage()); setText("

Error:
Cannot get help topic \"" + name + "\".
(" + e.getMessage() + ")

", "Manual"); diff --git a/src/net/apocalypselabs/symat/Interpreter.java b/src/net/apocalypselabs/symat/Interpreter.java index 0235348..d278280 100644 --- a/src/net/apocalypselabs/symat/Interpreter.java +++ b/src/net/apocalypselabs/symat/Interpreter.java @@ -31,8 +31,6 @@ import java.awt.Color; import java.awt.Font; import java.awt.event.KeyEvent; import java.io.IOException; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; @@ -412,7 +410,7 @@ public class Interpreter extends javax.swing.JInternalFrame { false); } catch (IOException ex) { JOptionPane.showInternalMessageDialog(this, - "Error saving: "+ex.getMessage(), + "Error saving: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } @@ -452,7 +450,7 @@ public class Interpreter extends javax.swing.JInternalFrame { } // Implement ans command - String ansfill = ""; + String ansfill; try { ansfill = String.valueOf(Double.parseDouble(ans.toString())); } catch (NumberFormatException ex) { @@ -463,6 +461,7 @@ public class Interpreter extends javax.swing.JInternalFrame { } @Override + @SuppressWarnings("null") public void run() { try { if (doSpecialCommands()) { diff --git a/src/net/apocalypselabs/symat/MainGUI.java b/src/net/apocalypselabs/symat/MainGUI.java index 566d9da..0b4b8b9 100644 --- a/src/net/apocalypselabs/symat/MainGUI.java +++ b/src/net/apocalypselabs/symat/MainGUI.java @@ -29,12 +29,15 @@ package net.apocalypselabs.symat; import java.awt.Color; import java.awt.Font; +import java.awt.FontFormatException; import java.awt.Graphics; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.beans.PropertyVetoException; import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; import java.util.Calendar; import java.util.Date; import javax.swing.ImageIcon; @@ -758,7 +761,7 @@ public class MainGUI extends javax.swing.JFrame { ubuntuRegular = Font.createFont(Font.TRUETYPE_FONT, new File(MainGUI.class. getResource("resources/Ubuntu-R.ttf").toURI())); - } catch (Exception ex) { + } catch (URISyntaxException | FontFormatException | IOException ex) { ubuntuRegular = Font.getFont(Font.SANS_SERIF); } diff --git a/src/net/apocalypselabs/symat/PrefStorage.java b/src/net/apocalypselabs/symat/PrefStorage.java index e5af1ee..4a20b79 100644 --- a/src/net/apocalypselabs/symat/PrefStorage.java +++ b/src/net/apocalypselabs/symat/PrefStorage.java @@ -1,7 +1,7 @@ -/* +/* * Apocalypse Laboratories * Open Source License - * + * * Source code can be used for any purpose, as long as: * - Compiled binaries are rebranded and trademarks are not * visible by the end user at any time, except to give @@ -14,7 +14,7 @@ * - and you provide your modified source code for download, * under the terms of the GNU LGPL v3 or a comparable * license. - * + * * Compiled binaries cannot be redistributed or mirrored, * unless: * - You have written permission from Apocalypse Laboratories; @@ -22,7 +22,7 @@ * not even behind a paywall or other blocking mechanism; * - or you have received a multi-computer license, in which * 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. */ package net.apocalypselabs.symat; @@ -45,7 +45,7 @@ public class PrefStorage { public static boolean isset(String key) { return !getSetting(key, "NULL").equals("NULL"); } - + public static void unset(String key) { prefs.remove(key); } @@ -57,7 +57,7 @@ public class PrefStorage { public static String getSetting(String key, String emptyResponse) { return prefs.get(key, emptyResponse); } - + public static boolean save() { try { prefs.flush(); diff --git a/src/net/apocalypselabs/symat/menugradient.png b/src/net/apocalypselabs/symat/menugradient.png deleted file mode 100644 index c7dea7e66685702fe1d9dd92f5821e73d031365c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 265 zcmeAS@N?(olHy`uVBq!ia0vp^B0y}o)@hB}-f*N`mv#O3D+9QW?t2%k?tzvWt@w3sUv+i_&MmvylQSYV&k) z42fucd(Duq#em1fq6 z>8dMWp7Gv5F=C+$%W}yxGd{7*@)Ryv+rB!eZ4&<