From f0e585d22c24eec3a723c6f0ea2a18252c570303 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Wed, 16 Nov 2016 11:22:33 -0500 Subject: Documentation update --- .../src/main/java/bjc/utils/funcdata/IList.java | 8 +++++ .../src/main/java/bjc/utils/funcdata/IMap.java | 11 +++++++ .../main/java/bjc/utils/funcutils/ListUtils.java | 23 +++++++++++--- .../java/bjc/utils/gui/SimpleInternalFrame.java | 16 +++++++++- .../java/bjc/utils/gui/TextAreaOutputStream.java | 6 ++++ .../bjc/utils/gui/panels/DropdownListPanel.java | 24 ++++++++++++-- .../bjc/utils/gui/panels/SimpleInputPanel.java | 13 ++++++++ .../java/bjc/utils/gui/panels/SimpleListPanel.java | 20 +++++++++++- .../bjc/utils/gui/panels/SimpleSpinnerPanel.java | 13 ++++++++ .../utils/parserutils/StackBasedConfigReader.java | 37 ---------------------- 10 files changed, 125 insertions(+), 46 deletions(-) delete mode 100644 BJC-Utils2/src/main/java/bjc/utils/parserutils/StackBasedConfigReader.java (limited to 'BJC-Utils2/src/main') diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java index 014c298..037b2b6 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java @@ -28,6 +28,14 @@ public interface IList { */ boolean add(ContainedType item); + /** + * Add all of the elements in the provided list to this list + * + * @param items + * The list of items to add + * @return True if every item was succesfully added to the list, false + * otherwise + */ default boolean addAll(IList items) { return items.map(this::add).anyMatch((bl) -> bl == false); } diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IMap.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IMap.java index 8522058..e69495a 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IMap.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IMap.java @@ -73,6 +73,17 @@ public interface IMap { */ ValueType get(KeyType key); + /** + * Get a value from the map, and return a default value if the key + * doesn't exist + * + * @param key + * The key to attempt to retrieve + * @param defaultValue + * The value to return if the key doesn't exist + * @return The value associated with the key, or the default value if + * the key doesn't exist + */ default ValueType getOrDefault(KeyType key, ValueType defaultValue) { try { return get(key); diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/ListUtils.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/ListUtils.java index cafa80f..94571f5 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/ListUtils.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/ListUtils.java @@ -219,10 +219,8 @@ public class ListUtils { /* * Run up to a certain number of passes */ - for (int numberOfIterations = 0; - numberOfIterations < MAX_NTRIESPART - && !rejectedElements.isEmpty(); - numberOfIterations++) { + for (int numberOfIterations = 0; numberOfIterations < MAX_NTRIESPART + && !rejectedElements.isEmpty(); numberOfIterations++) { input.forEach(new GroupPartIteration<>(returnedList, currentPartition, rejectedElements, numberInCurrentPartition, numberPerPartition, @@ -266,6 +264,23 @@ public class ListUtils { return returnedList; } + /** + * Pad the provided list out to the desired size + * + * @param + * The type of elements in the list + * @param list + * The list to pad out + * @param counter + * The function to count elements with + * @param size + * The desired size of the list + * @param padSource + * The function to get elements to pad with + * @return The list, padded to the desired size + * @throws IllegalArgumentException + * if the list couldn't be padded to the desired size + */ public static IList padList(IList list, Function counter, int size, Supplier padSource) { diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalFrame.java b/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalFrame.java index 61c6702..a7f2183 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalFrame.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalFrame.java @@ -2,13 +2,28 @@ package bjc.utils.gui; import javax.swing.JInternalFrame; +/** + * A simple internal frame class + * + * @author ben + * + */ public class SimpleInternalFrame extends JInternalFrame { private static final long serialVersionUID = -2966801321260716617L; + /** + * Create a new blank internal frame + */ public SimpleInternalFrame() { super(); } + /** + * Create a new blank internal frame with a specific title + * + * @param title + * The title of the internal frame + */ public SimpleInternalFrame(String title) { super(title); } @@ -22,5 +37,4 @@ public class SimpleInternalFrame extends JInternalFrame { setMaximizable(true); setIconifiable(true); } - } \ No newline at end of file diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/TextAreaOutputStream.java b/BJC-Utils2/src/main/java/bjc/utils/gui/TextAreaOutputStream.java index e512d6b..6080462 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gui/TextAreaOutputStream.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gui/TextAreaOutputStream.java @@ -13,6 +13,12 @@ public class TextAreaOutputStream extends OutputStream { private JTextArea textArea; + /** + * Create a new output stream attached to a textarea + * + * @param console + * The textarea to write to + */ public TextAreaOutputStream(JTextArea console) { this.textArea = console; } diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/DropdownListPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/DropdownListPanel.java index 2231760..c98eea3 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/DropdownListPanel.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/DropdownListPanel.java @@ -13,10 +13,27 @@ import bjc.utils.funcdata.IList; import bjc.utils.gui.layout.AutosizeLayout; import bjc.utils.gui.layout.HLayout; +/** + * A panel that allows you to select choices from a dropdown list + * + * @author ben + * + */ public class DropdownListPanel extends JPanel { private static final long serialVersionUID = 2719963952350133541L; - @SuppressWarnings("unchecked") + /** + * Create a new dropdown list panel + * + * @param + * The type of items in the dropdown list + * @param itemType + * The label of the type of items in the list + * @param listModel + * The model to put items into + * @param choices + * The items to choose from + */ public DropdownListPanel(String itemType, DefaultListModel listModel, IList choices) { setLayout(new AutosizeLayout()); @@ -41,7 +58,8 @@ public class DropdownListPanel extends JPanel { JButton removeItemButton = new JButton("Remove " + itemType); addItemButton.addActionListener((ev) -> { - listModel.addElement((T) addItemBox.getSelectedItem()); + listModel.addElement( + addItemBox.getItemAt(addItemBox.getSelectedIndex())); }); removeItemButton.addActionListener((ev) -> { @@ -54,4 +72,4 @@ public class DropdownListPanel extends JPanel { add(itemInputPanel); } -} +} \ No newline at end of file diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleInputPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleInputPanel.java index fd981ec..eb900aa 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleInputPanel.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleInputPanel.java @@ -6,11 +6,24 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +/** + * A simple component for text input + * @author ben + * + */ public class SimpleInputPanel extends JPanel { private static final long serialVersionUID = -4734279623645236868L; + /** + * The text field containing the input value + */ public final JTextField inputValue; + /** + * Create a new input panel + * @param label The label for the field + * @param columns The number of columns of text input to take + */ public SimpleInputPanel(String label, int columns) { setLayout(new BorderLayout()); diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleListPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleListPanel.java index 62aac0d..e034b48 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleListPanel.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleListPanel.java @@ -15,6 +15,12 @@ import javax.swing.ListSelectionModel; import bjc.utils.gui.layout.AutosizeLayout; import bjc.utils.gui.layout.HLayout; +/** + * A simple list of strings + * + * @author ben + * + */ public class SimpleListPanel extends JPanel { private static final long serialVersionUID = 2719963952350133541L; @@ -33,6 +39,18 @@ public class SimpleListPanel extends JPanel { addItemField.setText(""); } + /** + * Create a new list panel + * + * @param itemType + * The type of things in the list + * @param listModel + * The model to put items into + * @param itemVerifier + * The predicate to use to verify items + * @param onVerificationFailure + * The function to call when an item doesn't verify + */ public SimpleListPanel(String itemType, DefaultListModel listModel, Predicate itemVerifier, @@ -78,4 +96,4 @@ public class SimpleListPanel extends JPanel { add(itemInputPanel); } -} +} \ No newline at end of file diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleSpinnerPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleSpinnerPanel.java index 7bbf83e..7b138c5 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleSpinnerPanel.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleSpinnerPanel.java @@ -7,11 +7,24 @@ import javax.swing.JPanel; import javax.swing.JSpinner; import javax.swing.SpinnerModel; +/** + * A simple spinner control + * @author ben + * + */ public class SimpleSpinnerPanel extends JPanel { private static final long serialVersionUID = -4734279623645236868L; + /** + * The spinner being used + */ public final JSpinner inputValue; + /** + * Create a new spinner panel + * @param label The label for the spinner + * @param model The model to attach to the spinner + */ public SimpleSpinnerPanel(String label, SpinnerModel model) { setLayout(new BorderLayout()); diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/StackBasedConfigReader.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/StackBasedConfigReader.java deleted file mode 100644 index 2d15711..0000000 --- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/StackBasedConfigReader.java +++ /dev/null @@ -1,37 +0,0 @@ -package bjc.utils.parserutils; - -/** - * This class parses a config file written in RPN and uses it to construct - * data items - * - * @author ben - * - * TODO implement me - */ -public class StackBasedConfigReader { - public static interface IItem { - public ItemType getType(); - } - - /** - * Represents the types of item that can be found on stacks - * - * @author ben - * - */ - public static enum ItemType { - /** - * Represents an integral number - */ - INTEGER, - /** - * Represents a string of characters - */ - STRING, - /** - * Represents an arbitrary object - */ - OBJECT - } - -} -- cgit v1.2.3