summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/gui
diff options
context:
space:
mode:
Diffstat (limited to 'base/src/main/java/bjc/utils/gui')
-rw-r--r--base/src/main/java/bjc/utils/gui/ExtensionFileFilter.java6
-rw-r--r--base/src/main/java/bjc/utils/gui/SimpleDialogs.java108
-rw-r--r--base/src/main/java/bjc/utils/gui/SimpleFileChooser.java60
-rw-r--r--base/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java92
-rw-r--r--base/src/main/java/bjc/utils/gui/SimpleInternalFrame.java2
-rw-r--r--base/src/main/java/bjc/utils/gui/SimpleJList.java12
-rw-r--r--base/src/main/java/bjc/utils/gui/SimpleTitledBorder.java2
-rw-r--r--base/src/main/java/bjc/utils/gui/TextAreaOutputStream.java4
-rw-r--r--base/src/main/java/bjc/utils/gui/awt/ExtensionFileFilter.java6
-rw-r--r--base/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java67
-rw-r--r--base/src/main/java/bjc/utils/gui/layout/HLayout.java2
-rw-r--r--base/src/main/java/bjc/utils/gui/layout/VLayout.java2
-rw-r--r--base/src/main/java/bjc/utils/gui/panels/DropdownListPanel.java8
-rw-r--r--base/src/main/java/bjc/utils/gui/panels/FormattedInputPanel.java12
-rw-r--r--base/src/main/java/bjc/utils/gui/panels/HolderOutputPanel.java6
-rw-r--r--base/src/main/java/bjc/utils/gui/panels/ListParameterPanel.java36
-rw-r--r--base/src/main/java/bjc/utils/gui/panels/SimpleInputPanel.java6
-rw-r--r--base/src/main/java/bjc/utils/gui/panels/SimpleListPanel.java10
-rw-r--r--base/src/main/java/bjc/utils/gui/panels/SimpleSpinnerPanel.java4
-rw-r--r--base/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java37
20 files changed, 238 insertions, 244 deletions
diff --git a/base/src/main/java/bjc/utils/gui/ExtensionFileFilter.java b/base/src/main/java/bjc/utils/gui/ExtensionFileFilter.java
index 7c487eb..6696c92 100644
--- a/base/src/main/java/bjc/utils/gui/ExtensionFileFilter.java
+++ b/base/src/main/java/bjc/utils/gui/ExtensionFileFilter.java
@@ -26,7 +26,7 @@ public class ExtensionFileFilter extends FileFilter {
* Create a new filter only showing files with the specified extensions.
*
* @param exts
- * The extensions to show in this filter.
+ * The extensions to show in this filter.
*/
public ExtensionFileFilter(final List<String> exts) {
extensions = new FunctionalList<>(exts);
@@ -36,7 +36,7 @@ public class ExtensionFileFilter extends FileFilter {
* Create a new filter only showing files with the specified extensions.
*
* @param exts
- * The extensions to show in this filter.
+ * The extensions to show in this filter.
*/
public ExtensionFileFilter(final String... exts) {
extensions = new FunctionalList<>(exts);
@@ -44,7 +44,7 @@ public class ExtensionFileFilter extends FileFilter {
@Override
public boolean accept(final File pathname) {
- if (pathname == null) throw new NullPointerException("Pathname must not be null");
+ if(pathname == null) throw new NullPointerException("Pathname must not be null");
return extensions.anyMatch(pathname.getName()::endsWith);
}
diff --git a/base/src/main/java/bjc/utils/gui/SimpleDialogs.java b/base/src/main/java/bjc/utils/gui/SimpleDialogs.java
index 59eb1c3..b7763a2 100644
--- a/base/src/main/java/bjc/utils/gui/SimpleDialogs.java
+++ b/base/src/main/java/bjc/utils/gui/SimpleDialogs.java
@@ -25,15 +25,15 @@ public class SimpleDialogs {
* Get a bounded integer from the user.
*
* @param parent
- * The parent component for the dialogs.
+ * The parent component for the dialogs.
* @param title
- * The title for the dialogs.
+ * The title for the dialogs.
* @param prompt
- * The prompt to tell the user what to enter.
+ * The prompt to tell the user what to enter.
* @param lowerBound
- * The lower integer bound to accept.
+ * The lower integer bound to accept.
* @param upperBound
- * The upper integer bound to accept.
+ * The upper integer bound to accept.
* @return A int within the specified bounds.
*/
public static int getBoundedInt(final Component parent, final String title, final String prompt,
@@ -43,7 +43,7 @@ public class SimpleDialogs {
final int value = Integer.parseInt(strang);
return value < upperBound && value > lowerBound;
- } catch (final NumberFormatException nfex) {
+ } catch(final NumberFormatException nfex) {
// We don't care about the specifics of the
// exception, just
// that this value isn't good
@@ -56,26 +56,26 @@ public class SimpleDialogs {
* Asks the user to pick an option from a series of choices.
*
* @param <E>
- * The type of choices for the user to pick
+ * The type of choices for the user to pick
*
* @param parent
- * The parent frame for this dialog
+ * The parent frame for this dialog
* @param title
- * The title of this dialog
+ * The title of this dialog
* @param question
- * The question being asked
+ * The question being asked
* @param choices
- * The available choices for the question
+ * The available choices for the question
* @return The choice the user picked, or null if they didn't pick one
*/
@SuppressWarnings("unchecked")
public static <E> E getChoice(final Frame parent, final String title, final String question,
final E... choices) {
- if (parent == null)
+ if(parent == null)
throw new NullPointerException("Parent must not be null");
- else if (title == null)
+ else if(title == null)
throw new NullPointerException("Title must not be null");
- else if (question == null) throw new NullPointerException("Question must not be null");
+ else if(question == null) throw new NullPointerException("Question must not be null");
final JDialog chooser = new JDialog(parent, title, true);
chooser.setLayout(new VLayout(2));
@@ -112,11 +112,11 @@ public class SimpleDialogs {
* Get a integer from the user
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for dialogs.
+ * The title for dialogs.
* @param prompt
- * The prompt to tell the user what to enter.
+ * The prompt to tell the user what to enter.
* @return A int.
*/
public static int getInt(final Component parent, final String title, final String prompt) {
@@ -124,7 +124,7 @@ public class SimpleDialogs {
try {
Integer.parseInt(strang);
return true;
- } catch (final NumberFormatException nfex) {
+ } catch(final NumberFormatException nfex) {
// We don't care about this exception, just mark
// the value
// as not good
@@ -137,19 +137,19 @@ public class SimpleDialogs {
* Get a string from the user
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for the dialogs.
+ * The title for the dialogs.
* @param prompt
- * The prompt to tell the user what to enter.
+ * The prompt to tell the user what to enter.
* @return A string.
*/
public static String getString(final Component parent, final String title, final String prompt) {
- if (parent == null)
+ if(parent == null)
throw new NullPointerException("Parent must not be null");
- else if (title == null)
+ else if(title == null)
throw new NullPointerException("Title must not be null");
- else if (prompt == null) throw new NullPointerException("Prompt must not be null");
+ else if(prompt == null) throw new NullPointerException("Prompt must not be null");
return JOptionPane.showInputDialog(parent, prompt, title, JOptionPane.QUESTION_MESSAGE);
}
@@ -158,29 +158,29 @@ public class SimpleDialogs {
* Get a value parsable from a string from the user.
*
* @param <E>
- * The type of the value parsed from the string
+ * The type of the value parsed from the string
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for dialogs.
+ * The title for dialogs.
* @param prompt
- * The prompt to tell the user what to enter.
+ * The prompt to tell the user what to enter.
* @param validator
- * A predicate to determine if a input is valid.
+ * A predicate to determine if a input is valid.
* @param transformer
- * The function to transform the string into a value.
+ * The function to transform the string into a value.
* @return The value parsed from a string.
*/
public static <E> E getValue(final Component parent, final String title, final String prompt,
final Predicate<String> validator, final Function<String, E> transformer) {
- if (validator == null)
+ if(validator == null)
throw new NullPointerException("Validator must not be null");
- else if (transformer == null) throw new NullPointerException("Transformer must not be null");
+ else if(transformer == null) throw new NullPointerException("Transformer must not be null");
String input = getString(parent, title, prompt);
- while (!validator.test(input)) {
+ while(!validator.test(input)) {
showError(parent, "I/O Error", "Please enter a valid value");
input = getString(parent, title, prompt);
@@ -193,11 +193,11 @@ public class SimpleDialogs {
* Get a whole number from the user.
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for dialogs.
+ * The title for dialogs.
* @param prompt
- * The prompt to tell the user what to enter.
+ * The prompt to tell the user what to enter.
* @return A whole number.
*/
public static int getWhole(final Component parent, final String title, final String prompt) {
@@ -208,19 +208,19 @@ public class SimpleDialogs {
* Ask the user a Yes/No question.
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for dialogs.
+ * The title for dialogs.
* @param question
- * The question to ask the user.
+ * The question to ask the user.
* @return True if the user said yes, false otherwise.
*/
public static boolean getYesNo(final Component parent, final String title, final String question) {
- if (parent == null)
+ if(parent == null)
throw new NullPointerException("Parent must not be null");
- else if (title == null)
+ else if(title == null)
throw new NullPointerException("Title must not be null");
- else if (question == null) throw new NullPointerException("Question must not be null");
+ else if(question == null) throw new NullPointerException("Question must not be null");
final int result = JOptionPane.showConfirmDialog(parent, question, title, JOptionPane.YES_NO_OPTION);
@@ -231,18 +231,18 @@ public class SimpleDialogs {
* Show a error message to the user
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for dialogs.
+ * The title for dialogs.
* @param message
- * The error to show the user.
+ * The error to show the user.
*/
public static void showError(final Component parent, final String title, final String message) {
- if (parent == null)
+ if(parent == null)
throw new NullPointerException("Parent must not be null");
- else if (title == null)
+ else if(title == null)
throw new NullPointerException("Title must not be null");
- else if (message == null) throw new NullPointerException("Error message must not be null");
+ else if(message == null) throw new NullPointerException("Error message must not be null");
JOptionPane.showMessageDialog(parent, message, title, JOptionPane.ERROR_MESSAGE);
}
@@ -251,18 +251,18 @@ public class SimpleDialogs {
* Show an informative message to the user
*
* @param parent
- * The parent for this dialog
+ * The parent for this dialog
* @param title
- * Show the title for this dialog
+ * Show the title for this dialog
* @param message
- * Show the message for this dialog
+ * Show the message for this dialog
*/
public static void showMessage(final Component parent, final String title, final String message) {
- if (parent == null)
+ if(parent == null)
throw new NullPointerException("Parent must not be null");
- else if (title == null)
+ else if(title == null)
throw new NullPointerException("Title must not be null");
- else if (message == null) throw new NullPointerException("Message must not be null");
+ else if(message == null) throw new NullPointerException("Message must not be null");
JOptionPane.showMessageDialog(parent, title, message, JOptionPane.INFORMATION_MESSAGE);
}
diff --git a/base/src/main/java/bjc/utils/gui/SimpleFileChooser.java b/base/src/main/java/bjc/utils/gui/SimpleFileChooser.java
index 7da0bd8..2bdd792 100644
--- a/base/src/main/java/bjc/utils/gui/SimpleFileChooser.java
+++ b/base/src/main/java/bjc/utils/gui/SimpleFileChooser.java
@@ -17,18 +17,18 @@ import bjc.utils.exceptions.FileNotChosenException;
*/
public class SimpleFileChooser {
private static File doOpenFile(final Component parent, final String title, final JFileChooser files) {
- if (title == null) throw new NullPointerException("Title must not be null");
+ if(title == null) throw new NullPointerException("Title must not be null");
files.setDialogTitle(title);
boolean success = false;
- while (!success) {
+ while(!success) {
try {
maybeDoOpenFile(parent, files);
success = true;
- } catch (final FileNotChosenException fncx) {
+ } catch(final FileNotChosenException fncx) {
// We don't care about specifics
SimpleDialogs.showError(parent, "I/O Error", "Please pick a file to open");
}
@@ -38,18 +38,18 @@ public class SimpleFileChooser {
}
private static File doSaveFile(final Component parent, final String title, final JFileChooser files) {
- if (title == null) throw new NullPointerException("Title must not be null");
+ if(title == null) throw new NullPointerException("Title must not be null");
files.setDialogTitle(title);
final boolean success = false;
- while (!success) {
+ while(!success) {
try {
maybeDoSaveFile(parent, files);
return files.getSelectedFile();
- } catch (final FileNotChosenException fncex) {
+ } catch(final FileNotChosenException fncex) {
// We don't care about specifics
SimpleDialogs.showError(parent, "I/O Error", "Please pick a file to save to");
}
@@ -61,9 +61,9 @@ public class SimpleFileChooser {
* until they pick a file.
*
* @param parent
- * The component to use as the parent for the dialog.
+ * The component to use as the parent for the dialog.
* @param title
- * The title of the dialog to prompt with.
+ * The title of the dialog to prompt with.
* @return The file the user has chosen.
*/
public static File getOpenFile(final Component parent, final String title) {
@@ -77,11 +77,11 @@ public class SimpleFileChooser {
* until they pick a file.
*
* @param parent
- * The component to use as the parent for the dialog.
+ * The component to use as the parent for the dialog.
* @param title
- * The title of the dialog to prompt with.
+ * The title of the dialog to prompt with.
* @param extensions
- * The list of file extensions the file should have.
+ * The list of file extensions the file should have.
* @return The file the user has chosen.
*/
public static File getOpenFile(final Component parent, final String title, final String... extensions) {
@@ -96,9 +96,9 @@ public class SimpleFileChooser {
* Prompt the user with a "Save File..." dialog.
*
* @param parent
- * The component to use as the parent for the dialog.
+ * The component to use as the parent for the dialog.
* @param title
- * The title of the dialog to prompt with.
+ * The title of the dialog to prompt with.
* @return The file the user chose.
*/
public static File getSaveFile(final Component parent, final String title) {
@@ -111,11 +111,11 @@ public class SimpleFileChooser {
* Prompt the user with a "Save File..." dialog.
*
* @param parent
- * The component to use as the parent for the dialog.
+ * The component to use as the parent for the dialog.
* @param title
- * The title of the dialog to prompt with.
+ * The title of the dialog to prompt with.
* @param extensions
- * The extensions of the files the user can choose.
+ * The extensions of the files the user can choose.
* @return The file the user chose.
*/
public static File getSaveFile(final Component parent, final String title, final String... extensions) {
@@ -128,44 +128,44 @@ public class SimpleFileChooser {
private static void maybeDoOpenFile(final Component parent, final JFileChooser files)
throws FileNotChosenException {
- if (parent == null)
+ if(parent == null)
throw new NullPointerException("Parent must not be null");
- else if (files == null) throw new NullPointerException("File chooser must not be null");
+ else if(files == null) throw new NullPointerException("File chooser must not be null");
final int result = files.showSaveDialog(parent);
- if (result != JFileChooser.APPROVE_OPTION) throw new FileNotChosenException();
+ if(result != JFileChooser.APPROVE_OPTION) throw new FileNotChosenException();
}
private static void maybeDoSaveFile(final Component parent, final JFileChooser files)
throws FileNotChosenException {
- if (parent == null)
+ if(parent == null)
throw new NullPointerException("Parent must not be null");
- else if (files == null) throw new NullPointerException("File chooser must not be null");
+ else if(files == null) throw new NullPointerException("File chooser must not be null");
final int result = files.showSaveDialog(parent);
- if (result != JFileChooser.APPROVE_OPTION) throw new FileNotChosenException();
+ if(result != JFileChooser.APPROVE_OPTION) throw new FileNotChosenException();
}
/**
* Prompt the user with a "Open File..." dialog.
*
* @param parent
- * The component to use as the parent for the dialog.
+ * The component to use as the parent for the dialog.
* @param title
- * The title of the dialog to prompt with.
+ * The title of the dialog to prompt with.
* @return The file if the user chose one or null if they didn't.
*/
public static File maybeOpenFile(final Component parent, final String title) {
- if (title == null) throw new NullPointerException("Title must not be null");
+ if(title == null) throw new NullPointerException("Title must not be null");
final JFileChooser files = new JFileChooser();
files.setDialogTitle(title);
try {
maybeDoOpenFile(parent, files);
- } catch (final FileNotChosenException fncex) {
+ } catch(final FileNotChosenException fncex) {
// We don't care about specifics
}
@@ -176,20 +176,20 @@ public class SimpleFileChooser {
* Prompt the user with a "Save File..." dialog.
*
* @param parent
- * The component to use as the parent for the dialog.
+ * The component to use as the parent for the dialog.
* @param title
- * The title of the dialog to prompt with.
+ * The title of the dialog to prompt with.
* @return The file if the user chose one or null if they didn't.
*/
public static File maybeSaveFile(final Component parent, final String title) {
- if (title == null) throw new NullPointerException("Title must not be null");
+ if(title == null) throw new NullPointerException("Title must not be null");
final JFileChooser files = new JFileChooser();
files.setDialogTitle(title);
try {
maybeDoSaveFile(parent, files);
- } catch (final FileNotChosenException fncex) {
+ } catch(final FileNotChosenException fncex) {
// We don't care about specifics
}
diff --git a/base/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java b/base/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java
index 5237557..ef56011 100644
--- a/base/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java
+++ b/base/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java
@@ -19,15 +19,15 @@ public class SimpleInternalDialogs {
* Get a bounded integer from the user.
*
* @param parent
- * The parent component for the dialogs.
+ * The parent component for the dialogs.
* @param title
- * The title for the dialogs.
+ * The title for the dialogs.
* @param prompt
- * The prompt to tell the user what to enter.
+ * The prompt to tell the user what to enter.
* @param lowerBound
- * The lower integer bound to accept.
+ * The lower integer bound to accept.
* @param upperBound
- * The upper integer bound to accept.
+ * The upper integer bound to accept.
* @return A int within the specified bounds.
*/
public static int getBoundedInt(final Component parent, final String title, final String prompt,
@@ -37,7 +37,7 @@ public class SimpleInternalDialogs {
final int value = Integer.parseInt(strang);
return value < upperBound && value > lowerBound;
- } catch (final NumberFormatException nfex) {
+ } catch(final NumberFormatException nfex) {
// We don't care about the specifics of the
// exception, just
// that this value isn't good
@@ -50,11 +50,11 @@ public class SimpleInternalDialogs {
* Get a integer from the user
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for dialogs.
+ * The title for dialogs.
* @param prompt
- * The prompt to tell the user what to enter.
+ * The prompt to tell the user what to enter.
* @return A int.
*/
public static int getInt(final Component parent, final String title, final String prompt) {
@@ -62,7 +62,7 @@ public class SimpleInternalDialogs {
try {
Integer.parseInt(strang);
return true;
- } catch (final NumberFormatException nfex) {
+ } catch(final NumberFormatException nfex) {
// We don't care about this exception, just mark
// the value
// as not good
@@ -75,19 +75,19 @@ public class SimpleInternalDialogs {
* Get a string from the user
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for the dialogs.
+ * The title for the dialogs.
* @param prompt
- * The prompt to tell the user what to enter.
+ * The prompt to tell the user what to enter.
* @return A string.
*/
public static String getString(final Component parent, final String title, final String prompt) {
- if (parent == null)
+ if(parent == null)
throw new NullPointerException("Parent must not be null");
- else if (title == null)
+ else if(title == null)
throw new NullPointerException("Title must not be null");
- else if (prompt == null) throw new NullPointerException("Prompt must not be null");
+ else if(prompt == null) throw new NullPointerException("Prompt must not be null");
return JOptionPane.showInternalInputDialog(parent, prompt, title, JOptionPane.QUESTION_MESSAGE);
}
@@ -96,29 +96,29 @@ public class SimpleInternalDialogs {
* Get a value parsable from a string from the user.
*
* @param <E>
- * The type of the value parsed from the string
+ * The type of the value parsed from the string
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for dialogs.
+ * The title for dialogs.
* @param prompt
- * The prompt to tell the user what to enter.
+ * The prompt to tell the user what to enter.
* @param validator
- * A predicate to determine if a input is valid.
+ * A predicate to determine if a input is valid.
* @param transformer
- * The function to transform the string into a value.
+ * The function to transform the string into a value.
* @return The value parsed from a string.
*/
public static <E> E getValue(final Component parent, final String title, final String prompt,
final Predicate<String> validator, final Function<String, E> transformer) {
- if (validator == null)
+ if(validator == null)
throw new NullPointerException("Validator must not be null");
- else if (transformer == null) throw new NullPointerException("Transformer must not be null");
+ else if(transformer == null) throw new NullPointerException("Transformer must not be null");
String strang = getString(parent, title, prompt);
- while (!validator.test(strang)) {
+ while(!validator.test(strang)) {
showError(parent, "I/O Error", "Please enter a valid value");
strang = getString(parent, title, prompt);
@@ -131,11 +131,11 @@ public class SimpleInternalDialogs {
* Get a whole number from the user.
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for dialogs.
+ * The title for dialogs.
* @param prompt
- * The prompt to tell the user what to enter.
+ * The prompt to tell the user what to enter.
* @return A whole number.
*/
public static int getWhole(final Component parent, final String title, final String prompt) {
@@ -146,19 +146,19 @@ public class SimpleInternalDialogs {
* Ask the user a Yes/No question.
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for dialogs.
+ * The title for dialogs.
* @param question
- * The question to ask the user.
+ * The question to ask the user.
* @return True if the user said yes, false otherwise.
*/
public static boolean getYesNo(final Component parent, final String title, final String question) {
- if (parent == null)
+ if(parent == null)
throw new NullPointerException("Parent must not be null");
- else if (title == null)
+ else if(title == null)
throw new NullPointerException("Title must not be null");
- else if (question == null) throw new NullPointerException("Question must not be null");
+ else if(question == null) throw new NullPointerException("Question must not be null");
final int result = JOptionPane.showInternalConfirmDialog(parent, question, title,
JOptionPane.YES_NO_OPTION);
@@ -170,18 +170,18 @@ public class SimpleInternalDialogs {
* Show a error message to the user
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for dialogs.
+ * The title for dialogs.
* @param message
- * The error to show the user.
+ * The error to show the user.
*/
public static void showError(final Component parent, final String title, final String message) {
- if (parent == null)
+ if(parent == null)
throw new NullPointerException("Parent must not be null");
- else if (title == null)
+ else if(title == null)
throw new NullPointerException("Title must not be null");
- else if (message == null) throw new NullPointerException("Error message must not be null");
+ else if(message == null) throw new NullPointerException("Error message must not be null");
JOptionPane.showInternalMessageDialog(parent, message, title, JOptionPane.ERROR_MESSAGE);
}
@@ -190,18 +190,18 @@ public class SimpleInternalDialogs {
* Show an informative message to the user
*
* @param parent
- * The parent for this dialog
+ * The parent for this dialog
* @param title
- * Show the title for this dialog
+ * Show the title for this dialog
* @param message
- * Show the message for this dialog
+ * Show the message for this dialog
*/
public static void showMessage(final Component parent, final String title, final String message) {
- if (parent == null)
+ if(parent == null)
throw new NullPointerException("Parent must not be null");
- else if (title == null)
+ else if(title == null)
throw new NullPointerException("Title must not be null");
- else if (message == null) throw new NullPointerException("Message must not be null");
+ else if(message == null) throw new NullPointerException("Message must not be null");
JOptionPane.showInternalMessageDialog(parent, title, message, JOptionPane.INFORMATION_MESSAGE);
}
diff --git a/base/src/main/java/bjc/utils/gui/SimpleInternalFrame.java b/base/src/main/java/bjc/utils/gui/SimpleInternalFrame.java
index afb498e..5c7983c 100644
--- a/base/src/main/java/bjc/utils/gui/SimpleInternalFrame.java
+++ b/base/src/main/java/bjc/utils/gui/SimpleInternalFrame.java
@@ -22,7 +22,7 @@ public class SimpleInternalFrame extends JInternalFrame {
* Create a new blank internal frame with a specific title
*
* @param title
- * The title of the internal frame
+ * The title of the internal frame
*/
public SimpleInternalFrame(final String title) {
super(title);
diff --git a/base/src/main/java/bjc/utils/gui/SimpleJList.java b/base/src/main/java/bjc/utils/gui/SimpleJList.java
index 411d0db..31c995c 100644
--- a/base/src/main/java/bjc/utils/gui/SimpleJList.java
+++ b/base/src/main/java/bjc/utils/gui/SimpleJList.java
@@ -15,14 +15,14 @@ public class SimpleJList {
* Create a new JList from a given list.
*
* @param <E>
- * The type of data in the JList
+ * The type of data in the JList
*
* @param source
- * The list to populate the JList with.
+ * The list to populate the JList with.
* @return A JList populated with the elements from ls.
*/
public static <E> JList<E> buildFromList(final Iterable<E> source) {
- if (source == null) throw new NullPointerException("Source must not be null");
+ if(source == null) throw new NullPointerException("Source must not be null");
return new JList<>(buildModel(source));
}
@@ -31,14 +31,14 @@ public class SimpleJList {
* Create a new list model from a given list.
*
* @param <E>
- * The type of data in the list model
+ * The type of data in the list model
*
* @param source
- * The list to fill the list model from.
+ * The list to fill the list model from.
* @return A list model populated with the elements from ls.
*/
public static <E> ListModel<E> buildModel(final Iterable<E> source) {
- if (source == null) throw new NullPointerException("Source must not be null");
+ if(source == null) throw new NullPointerException("Source must not be null");
final DefaultListModel<E> defaultModel = new DefaultListModel<>();
diff --git a/base/src/main/java/bjc/utils/gui/SimpleTitledBorder.java b/base/src/main/java/bjc/utils/gui/SimpleTitledBorder.java
index 9b01507..bddb564 100644
--- a/base/src/main/java/bjc/utils/gui/SimpleTitledBorder.java
+++ b/base/src/main/java/bjc/utils/gui/SimpleTitledBorder.java
@@ -17,7 +17,7 @@ public class SimpleTitledBorder extends TitledBorder {
* Create a new border with the specified title.
*
* @param title
- * The title for the border.
+ * The title for the border.
*/
public SimpleTitledBorder(final String title) {
super(new EtchedBorder(), title);
diff --git a/base/src/main/java/bjc/utils/gui/TextAreaOutputStream.java b/base/src/main/java/bjc/utils/gui/TextAreaOutputStream.java
index fbc58ed..0beb1e2 100644
--- a/base/src/main/java/bjc/utils/gui/TextAreaOutputStream.java
+++ b/base/src/main/java/bjc/utils/gui/TextAreaOutputStream.java
@@ -18,7 +18,7 @@ public class TextAreaOutputStream extends OutputStream {
* Create a new output stream attached to a textarea
*
* @param console
- * The textarea to write to
+ * The textarea to write to
*/
public TextAreaOutputStream(final JTextArea console) {
this.textArea = console;
@@ -28,7 +28,7 @@ public class TextAreaOutputStream extends OutputStream {
public void write(final int b) throws IOException {
textArea.append("" + (char) b);
- if (b == '\n') {
+ if(b == '\n') {
textArea.repaint();
}
}
diff --git a/base/src/main/java/bjc/utils/gui/awt/ExtensionFileFilter.java b/base/src/main/java/bjc/utils/gui/awt/ExtensionFileFilter.java
index 5998345..ae424b4 100644
--- a/base/src/main/java/bjc/utils/gui/awt/ExtensionFileFilter.java
+++ b/base/src/main/java/bjc/utils/gui/awt/ExtensionFileFilter.java
@@ -22,10 +22,10 @@ public class ExtensionFileFilter implements FilenameFilter {
* Create a new filter only showing files with the specified extensions.
*
* @param exts
- * The extensions to show in this filter.
+ * The extensions to show in this filter.
*/
public ExtensionFileFilter(final List<String> exts) {
- if (exts == null) throw new NullPointerException("Extensions must not be null");
+ if(exts == null) throw new NullPointerException("Extensions must not be null");
extensions = new FunctionalList<>(exts);
}
@@ -34,7 +34,7 @@ public class ExtensionFileFilter implements FilenameFilter {
* Create a new filter only showing files with the specified extensions.
*
* @param exts
- * The extensions to show in this filter.
+ * The extensions to show in this filter.
*/
public ExtensionFileFilter(final String... exts) {
extensions = new FunctionalList<>(exts);
diff --git a/base/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java b/base/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java
index e9236fe..daea7cd 100644
--- a/base/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java
+++ b/base/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java
@@ -19,13 +19,12 @@ public class SimpleFileDialog {
* Prompt the user to pick a file to open.
*
* @param parent
- * The parent of the file picker.
+ * The parent of the file picker.
*
* @param title
- * The title of the file picker.
+ * The title of the file picker.
*
- * @return
- * The file the user picked.
+ * @return The file the user picked.
*/
public static File getOpenFile(final Frame parent, final String title) {
return getOpenFile(parent, title, (String[]) null);
@@ -35,34 +34,33 @@ public class SimpleFileDialog {
* Prompt the user to pick a file to open.
*
* @param parent
- * The parent of the file picker.
+ * The parent of the file picker.
*
* @param title
- * The title of the file picker.
+ * The title of the file picker.
*
* @param extensions
- * The extensions to accept as valid.
+ * The extensions to accept as valid.
*
- * @return
- * The file the user picked.
+ * @return The file the user picked.
*/
public static File getOpenFile(final Frame parent, final String title, final String... extensions) {
- if (parent == null) {
+ if(parent == null) {
throw new NullPointerException("Parent must not be null");
- } else if (title == null) {
+ } else if(title == null) {
throw new NullPointerException("Title must not be null");
}
final FileDialog chooser = new FileDialog(parent, title, FileDialog.LOAD);
- if (extensions != null) {
+ if(extensions != null) {
final FilenameFilter filter = new ExtensionFileFilter(extensions);
chooser.setFilenameFilter(filter);
}
chooser.setVisible(true);
- while (chooser.getFile() == null) {
+ while(chooser.getFile() == null) {
SimpleDialogs.showError(parent, "File I/O Error", "Please choose a file to open.");
chooser.setVisible(true);
}
@@ -74,26 +72,24 @@ public class SimpleFileDialog {
* Prompt the user to pick a file to open.
*
* @param parent
- * The parent of the file picker.
+ * The parent of the file picker.
*
* @param title
- * The title of the file picker.
+ * The title of the file picker.
*
* @param extensions
- * The extensions to accept as valid.
+ * The extensions to accept as valid.
*
- * @return
- * The file the user picked.
+ * @return The file the user picked.
*/
public static File[] getOpenFiles(final Frame parent, final String title, final String... extensions) {
- if (parent == null)
+ if(parent == null)
throw new NullPointerException("Parent must not be null");
- else if (title == null)
- throw new NullPointerException("Title must not be null");
+ else if(title == null) throw new NullPointerException("Title must not be null");
final FileDialog chooser = new FileDialog(parent, title, FileDialog.LOAD);
- if (extensions != null) {
+ if(extensions != null) {
final FilenameFilter filter = new ExtensionFileFilter(extensions);
chooser.setFilenameFilter(filter);
}
@@ -101,7 +97,7 @@ public class SimpleFileDialog {
chooser.setMultipleMode(true);
chooser.setVisible(true);
- while (chooser.getFile() == null) {
+ while(chooser.getFile() == null) {
SimpleDialogs.showError(parent, "File I/O Error", "Please choose a file to open.");
chooser.setVisible(true);
}
@@ -113,13 +109,12 @@ public class SimpleFileDialog {
* Prompt the user to pick a file to save
*
* @param parent
- * The parent of the file picker
+ * The parent of the file picker
*
* @param title
- * The title of the file picker
+ * The title of the file picker
*
- * @return
- * The file the user picked
+ * @return The file the user picked
*/
public static File getSaveFile(final Frame parent, final String title) {
return getSaveFile(parent, title, (String[]) null);
@@ -129,33 +124,31 @@ public class SimpleFileDialog {
* Prompt the user to pick a file to save
*
* @param parent
- * The parent of the file picker
+ * The parent of the file picker
*
* @param title
- * The title of the file picker
+ * The title of the file picker
*
* @param extensions
- * The extensions to accept as valid
+ * The extensions to accept as valid
*
- * @return
- * The file the user picked
+ * @return The file the user picked
*/
public static File getSaveFile(final Frame parent, final String title, final String... extensions) {
- if (parent == null)
+ if(parent == null)
throw new NullPointerException("Parent must not be null");
- else if (title == null)
- throw new NullPointerException("Title must not be null");
+ else if(title == null) throw new NullPointerException("Title must not be null");
final FileDialog chooser = new FileDialog(parent, title, FileDialog.SAVE);
- if (extensions != null) {
+ if(extensions != null) {
final FilenameFilter filter = new ExtensionFileFilter(extensions);
chooser.setFilenameFilter(filter);
}
chooser.setVisible(true);
- while (chooser.getFile() == null) {
+ while(chooser.getFile() == null) {
SimpleDialogs.showError(parent, "File I/O Error", "Please choose a file to save to.");
chooser.setVisible(true);
}
diff --git a/base/src/main/java/bjc/utils/gui/layout/HLayout.java b/base/src/main/java/bjc/utils/gui/layout/HLayout.java
index 6e4f878..c2caa01 100644
--- a/base/src/main/java/bjc/utils/gui/layout/HLayout.java
+++ b/base/src/main/java/bjc/utils/gui/layout/HLayout.java
@@ -16,7 +16,7 @@ public class HLayout extends GridLayout {
* Create a new horizontal layout with the specified number of columns.
*
* @param columns
- * The number of columns in this layout.
+ * The number of columns in this layout.
*/
public HLayout(final int columns) {
super(1, columns);
diff --git a/base/src/main/java/bjc/utils/gui/layout/VLayout.java b/base/src/main/java/bjc/utils/gui/layout/VLayout.java
index 6993365..d0f0503 100644
--- a/base/src/main/java/bjc/utils/gui/layout/VLayout.java
+++ b/base/src/main/java/bjc/utils/gui/layout/VLayout.java
@@ -17,7 +17,7 @@ public class VLayout extends GridLayout {
* Create a new vertical layout with the specified number of rows.
*
* @param rows
- * The number of rows.
+ * The number of rows.
*/
public VLayout(final int rows) {
super(rows, 1);
diff --git a/base/src/main/java/bjc/utils/gui/panels/DropdownListPanel.java b/base/src/main/java/bjc/utils/gui/panels/DropdownListPanel.java
index 4f71d38..6c57c5a 100644
--- a/base/src/main/java/bjc/utils/gui/panels/DropdownListPanel.java
+++ b/base/src/main/java/bjc/utils/gui/panels/DropdownListPanel.java
@@ -26,13 +26,13 @@ public class DropdownListPanel extends JPanel {
* Create a new dropdown list panel
*
* @param <T>
- * The type of items in the dropdown list
+ * The type of items in the dropdown list
* @param type
- * The label of the type of items in the list
+ * The label of the type of items in the list
* @param model
- * The model to put items into
+ * The model to put items into
* @param choices
- * The items to choose from
+ * The items to choose from
*/
public <T> DropdownListPanel(final String type, final DefaultListModel<T> model, final IList<T> choices) {
setLayout(new AutosizeLayout());
diff --git a/base/src/main/java/bjc/utils/gui/panels/FormattedInputPanel.java b/base/src/main/java/bjc/utils/gui/panels/FormattedInputPanel.java
index 2cecf0c..96f0487 100644
--- a/base/src/main/java/bjc/utils/gui/panels/FormattedInputPanel.java
+++ b/base/src/main/java/bjc/utils/gui/panels/FormattedInputPanel.java
@@ -15,7 +15,7 @@ import bjc.utils.gui.layout.HLayout;
* @author ben
*
* @param <InputVal>
- * The type of value being formatted
+ * The type of value being formatted
*/
public class FormattedInputPanel<InputVal> extends JPanel {
private static final long serialVersionUID = 5232016563558588031L;
@@ -26,13 +26,13 @@ public class FormattedInputPanel<InputVal> extends JPanel {
* Create a new formatted input panel
*
* @param label
- * The label for this panel
+ * The label for this panel
* @param length
- * The length of this panel
+ * The length of this panel
* @param formatter
- * The formatter to use for input
+ * The formatter to use for input
* @param reciever
- * The action to call whenever the value changes
+ * The action to call whenever the value changes
*/
@SuppressWarnings("unchecked")
public FormattedInputPanel(final String label, final int length, final AbstractFormatter formatter,
@@ -58,7 +58,7 @@ public class FormattedInputPanel<InputVal> extends JPanel {
* Reset the value in this panel to a specified value
*
* @param value
- * The value to set the panel to
+ * The value to set the panel to
*/
public void resetValues(final InputVal value) {
field.setValue(value);
diff --git a/base/src/main/java/bjc/utils/gui/panels/HolderOutputPanel.java b/base/src/main/java/bjc/utils/gui/panels/HolderOutputPanel.java
index 653dace..1cf3d88 100644
--- a/base/src/main/java/bjc/utils/gui/panels/HolderOutputPanel.java
+++ b/base/src/main/java/bjc/utils/gui/panels/HolderOutputPanel.java
@@ -25,11 +25,11 @@ public class HolderOutputPanel extends JPanel {
* Create a new display panel, backed by a holder
*
* @param lab
- * The label to attach to this field
+ * The label to attach to this field
* @param valueHolder
- * The holder to get the value from
+ * The holder to get the value from
* @param nDelay
- * The delay in ms between value updates
+ * The delay in ms between value updates
*/
public HolderOutputPanel(final String lab, final IHolder<String> valueHolder, final int nDelay) {
this.val = valueHolder;
diff --git a/base/src/main/java/bjc/utils/gui/panels/ListParameterPanel.java b/base/src/main/java/bjc/utils/gui/panels/ListParameterPanel.java
index cca73d5..f8d9b72 100644
--- a/base/src/main/java/bjc/utils/gui/panels/ListParameterPanel.java
+++ b/base/src/main/java/bjc/utils/gui/panels/ListParameterPanel.java
@@ -20,7 +20,7 @@ import bjc.utils.gui.layout.VLayout;
* @author ben
*
* @param <E>
- * The type of data stored in the list
+ * The type of data stored in the list
*/
public class ListParameterPanel<E> extends JPanel {
// Version id for serialization
@@ -30,11 +30,11 @@ public class ListParameterPanel<E> extends JPanel {
* Create a new panel using the specified actions for doing things
*
* @param add
- * The action that provides items
+ * The action that provides items
* @param edit
- * The action that edits items
+ * The action that edits items
* @param remove
- * The action that removes items
+ * The action that removes items
*/
public ListParameterPanel(final Supplier<E> add, final Consumer<E> edit, final Consumer<E> remove) {
this(add, edit, remove, null);
@@ -44,13 +44,13 @@ public class ListParameterPanel<E> extends JPanel {
* Create a new panel using the specified actions for doing things
*
* @param add
- * The action that provides items
+ * The action that provides items
* @param edit
- * The action that edits items
+ * The action that edits items
* @param remove
- * The action that removes items
+ * The action that removes items
* @param defaults
- * The default values to put in the list
+ * The default values to put in the list
*/
public ListParameterPanel(final Supplier<E> add, final Consumer<E> edit, final Consumer<E> remove,
final IList<E> defaults) {
@@ -58,7 +58,7 @@ public class ListParameterPanel<E> extends JPanel {
JList<E> list;
- if (defaults != null) {
+ if(defaults != null) {
list = SimpleJList.buildFromList(defaults.toIterable());
} else {
list = new JList<>(new DefaultListModel<>());
@@ -70,15 +70,15 @@ public class ListParameterPanel<E> extends JPanel {
int numButtons = 0;
- if (add != null) {
+ if(add != null) {
numButtons++;
}
- if (edit != null) {
+ if(edit != null) {
numButtons++;
}
- if (remove != null) {
+ if(remove != null) {
numButtons++;
}
@@ -86,7 +86,7 @@ public class ListParameterPanel<E> extends JPanel {
JButton addParam = null;
- if (add != null) {
+ if(add != null) {
addParam = new JButton("Add...");
addParam.addActionListener((event) -> {
final DefaultListModel<E> model = (DefaultListModel<E>) list.getModel();
@@ -97,7 +97,7 @@ public class ListParameterPanel<E> extends JPanel {
JButton editParam = null;
- if (edit != null) {
+ if(edit != null) {
editParam = new JButton("Edit...");
editParam.addActionListener((event) -> {
edit.accept(list.getSelectedValue());
@@ -106,7 +106,7 @@ public class ListParameterPanel<E> extends JPanel {
JButton removeParam = null;
- if (remove != null) {
+ if(remove != null) {
removeParam = new JButton("Remove...");
removeParam.addActionListener((event) -> {
final DefaultListModel<E> model = (DefaultListModel<E>) list.getModel();
@@ -115,15 +115,15 @@ public class ListParameterPanel<E> extends JPanel {
});
}
- if (add != null) {
+ if(add != null) {
buttonPanel.add(addParam);
}
- if (edit != null) {
+ if(edit != null) {
buttonPanel.add(editParam);
}
- if (remove != null) {
+ if(remove != null) {
buttonPanel.add(removeParam);
}
diff --git a/base/src/main/java/bjc/utils/gui/panels/SimpleInputPanel.java b/base/src/main/java/bjc/utils/gui/panels/SimpleInputPanel.java
index 65c533d..301a183 100644
--- a/base/src/main/java/bjc/utils/gui/panels/SimpleInputPanel.java
+++ b/base/src/main/java/bjc/utils/gui/panels/SimpleInputPanel.java
@@ -24,16 +24,16 @@ public class SimpleInputPanel extends JPanel {
* Create a new input panel
*
* @param label
- * The label for the field
+ * The label for the field
* @param columns
- * The number of columns of text input to take
+ * The number of columns of text input to take
*/
public SimpleInputPanel(final String label, final int columns) {
setLayout(new BorderLayout());
final JLabel inputLabel = new JLabel(label);
- if (columns < 1) {
+ if(columns < 1) {
inputValue = new JTextField();
} else {
inputValue = new JTextField(columns);
diff --git a/base/src/main/java/bjc/utils/gui/panels/SimpleListPanel.java b/base/src/main/java/bjc/utils/gui/panels/SimpleListPanel.java
index edc1797..628d146 100644
--- a/base/src/main/java/bjc/utils/gui/panels/SimpleListPanel.java
+++ b/base/src/main/java/bjc/utils/gui/panels/SimpleListPanel.java
@@ -28,7 +28,7 @@ public class SimpleListPanel extends JPanel {
final Consumer<String> onFailure, final JTextField addItemField) {
final String potentialItem = addItemField.getText();
- if (verifier == null || verifier.test(potentialItem)) {
+ if(verifier == null || verifier.test(potentialItem)) {
model.addElement(potentialItem);
} else {
onFailure.accept(potentialItem);
@@ -41,13 +41,13 @@ public class SimpleListPanel extends JPanel {
* Create a new list panel
*
* @param type
- * The type of things in the list
+ * The type of things in the list
* @param model
- * The model to put items into
+ * The model to put items into
* @param verifier
- * The predicate to use to verify items
+ * The predicate to use to verify items
* @param onFailure
- * The function to call when an item doesn't verify
+ * The function to call when an item doesn't verify
*/
public SimpleListPanel(final String type, final DefaultListModel<String> model,
final Predicate<String> verifier, final Consumer<String> onFailure) {
diff --git a/base/src/main/java/bjc/utils/gui/panels/SimpleSpinnerPanel.java b/base/src/main/java/bjc/utils/gui/panels/SimpleSpinnerPanel.java
index 6106182..2628c39 100644
--- a/base/src/main/java/bjc/utils/gui/panels/SimpleSpinnerPanel.java
+++ b/base/src/main/java/bjc/utils/gui/panels/SimpleSpinnerPanel.java
@@ -25,9 +25,9 @@ public class SimpleSpinnerPanel extends JPanel {
* Create a new spinner panel
*
* @param label
- * The label for the spinner
+ * The label for the spinner
* @param model
- * The model to attach to the spinner
+ * The model to attach to the spinner
*/
public SimpleSpinnerPanel(final String label, final SpinnerModel model) {
setLayout(new BorderLayout());
diff --git a/base/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java b/base/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java
index e6a6da4..ff4c161 100644
--- a/base/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java
+++ b/base/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java
@@ -38,12 +38,13 @@ public class SliderInputPanel extends JPanel {
try {
final int val = Integer.parseInt(text);
- if (val < minValue)
+ if(val < minValue)
throw new ParseException("Value must be greater than " + minValue, 0);
- else if (val > maxValue)
+ else if(val > maxValue)
throw new ParseException("Value must be smaller than " + maxValue, 0);
- else return val;
- } catch (final NumberFormatException nfex) {
+ else
+ return val;
+ } catch(final NumberFormatException nfex) {
final ParseException pex = new ParseException("Value must be a valid integer", 0);
pex.initCause(nfex);
@@ -54,7 +55,7 @@ public class SliderInputPanel extends JPanel {
@Override
public String valueToString(final Object value) throws ParseException {
- if (value == null) return Integer.toString(initValue);
+ if(value == null) return Integer.toString(initValue);
return Integer.toString((Integer) value);
}
@@ -86,9 +87,9 @@ public class SliderInputPanel extends JPanel {
* middle
*
* @param min
- * The minimum value of the slider
+ * The minimum value of the slider
* @param max
- * The maximum value of the slider
+ * The maximum value of the slider
*/
public SliderSettings(final int min, final int max) {
this(min, max, (min + max) / 2);
@@ -98,11 +99,11 @@ public class SliderInputPanel extends JPanel {
* Create a new set of slider sttings
*
* @param min
- * The minimum slider value
+ * The minimum slider value
* @param max
- * The maximum slider value
+ * The maximum slider value
* @param init
- * Th initial slider value
+ * Th initial slider value
*/
public SliderSettings(final int min, final int max, final int init) {
minValue = min;
@@ -120,15 +121,15 @@ public class SliderInputPanel extends JPanel {
* Create a new slider input panel
*
* @param lab
- * The label for the field
+ * The label for the field
* @param settings
- * The settings for slider values
+ * The settings for slider values
* @param majorTick
- * The setting for where to place big ticks
+ * The setting for where to place big ticks
* @param minorTick
- * The setting for where to place small ticks
+ * The setting for where to place small ticks
* @param action
- * The action to execute for a given value
+ * The action to execute for a given value
*/
public SliderInputPanel(final String lab, final SliderSettings settings, final int majorTick,
final int minorTick, final Consumer<Integer> action) {
@@ -145,7 +146,7 @@ public class SliderInputPanel extends JPanel {
slider.setPaintLabels(true);
slider.addChangeListener((event) -> {
- if (slider.getValueIsAdjusting()) {
+ if(slider.getValueIsAdjusting()) {
// Do nothing
} else {
final int val = slider.getValue();
@@ -161,7 +162,7 @@ public class SliderInputPanel extends JPanel {
field.addPropertyChangeListener("value", (event) -> {
final Object value = field.getValue();
- if (value == null) {
+ if(value == null) {
// Do nothing
} else {
slider.setValue((Integer) value);
@@ -177,7 +178,7 @@ public class SliderInputPanel extends JPanel {
* Reset the values in this panel to a specified value
*
* @param value
- * The value to reset the fields to
+ * The value to reset the fields to
*/
public void resetValues(final int value) {
slider.setValue(value);