From 27bf571d6413c3cc6a5d664b5bddd38d21d7b1cd Mon Sep 17 00:00:00 2001 From: EVE Date: Mon, 13 Mar 2017 16:42:21 -0400 Subject: Formatting --- .../bjc/utils/gui/panels/DropdownListPanel.java | 14 ++--- .../bjc/utils/gui/panels/FormattedInputPanel.java | 20 +++---- .../bjc/utils/gui/panels/HolderOutputPanel.java | 19 +++---- .../bjc/utils/gui/panels/ListParameterPanel.java | 29 ++++------ .../bjc/utils/gui/panels/SimpleInputPanel.java | 12 ++-- .../java/bjc/utils/gui/panels/SimpleListPanel.java | 24 +++----- .../bjc/utils/gui/panels/SimpleSpinnerPanel.java | 12 ++-- .../bjc/utils/gui/panels/SliderInputPanel.java | 65 ++++++++++------------ 8 files changed, 91 insertions(+), 104 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/gui/panels') 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 895faa6..f2d7f7b 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 @@ -26,16 +26,15 @@ public class DropdownListPanel extends JPanel { * Create a new dropdown list panel * * @param - * 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 DropdownListPanel(String type, - DefaultListModel model, IList choices) { + public DropdownListPanel(String type, DefaultListModel model, IList choices) { setLayout(new AutosizeLayout()); JPanel itemInputPanel = new JPanel(); @@ -58,8 +57,7 @@ public class DropdownListPanel extends JPanel { JButton removeItemButton = new JButton("Remove " + type); addItemButton.addActionListener((ev) -> { - model.addElement( - addItemBox.getItemAt(addItemBox.getSelectedIndex())); + model.addElement(addItemBox.getItemAt(addItemBox.getSelectedIndex())); }); removeItemButton.addActionListener((ev) -> { diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/FormattedInputPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/FormattedInputPanel.java index a05c06e..ae62a43 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/FormattedInputPanel.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/FormattedInputPanel.java @@ -15,29 +15,27 @@ import bjc.utils.gui.layout.HLayout; * @author ben * * @param - * The type of value being formatted + * The type of value being formatted */ public class FormattedInputPanel extends JPanel { - private static final long serialVersionUID = 5232016563558588031L; + private static final long serialVersionUID = 5232016563558588031L; - private JFormattedTextField field; + private JFormattedTextField field; /** * 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(String label, int length, - AbstractFormatter formatter, - Consumer reciever) { + public FormattedInputPanel(String label, int length, AbstractFormatter formatter, Consumer reciever) { setLayout(new HLayout(2)); JLabel lab = new JLabel(label); @@ -59,7 +57,7 @@ public class FormattedInputPanel 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(InputVal value) { field.setValue(value); diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/HolderOutputPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/HolderOutputPanel.java index f7f2c26..b6fc807 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/HolderOutputPanel.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/HolderOutputPanel.java @@ -14,25 +14,24 @@ import bjc.utils.gui.layout.HLayout; * */ public class HolderOutputPanel extends JPanel { - private static final long serialVersionUID = 166573313903782080L; + private static final long serialVersionUID = 166573313903782080L; - private Timer updater; - private JLabel value; - private int nDelay; - private IHolder val; + private Timer updater; + private JLabel value; + private int nDelay; + private IHolder val; /** * 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(String lab, IHolder valueHolder, - int nDelay) { + public HolderOutputPanel(String lab, IHolder valueHolder, int nDelay) { this.val = valueHolder; this.nDelay = nDelay; diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/ListParameterPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/ListParameterPanel.java index 088be6c..29ede89 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/ListParameterPanel.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/ListParameterPanel.java @@ -20,7 +20,7 @@ import bjc.utils.gui.layout.VLayout; * @author ben * * @param - * The type of data stored in the list + * The type of data stored in the list */ public class ListParameterPanel extends JPanel { // Version id for serialization @@ -30,14 +30,13 @@ public class ListParameterPanel 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(Supplier add, - Consumer edit, Consumer remove) { + public ListParameterPanel(Supplier add, Consumer edit, Consumer remove) { this(add, edit, remove, null); } @@ -45,17 +44,15 @@ public class ListParameterPanel 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(Supplier add, - Consumer edit, Consumer remove, - IList defaults) { + public ListParameterPanel(Supplier add, Consumer edit, Consumer remove, IList defaults) { setLayout(new VLayout(2)); JList list; @@ -91,8 +88,7 @@ public class ListParameterPanel extends JPanel { if (add != null) { addParam = new JButton("Add..."); addParam.addActionListener((event) -> { - DefaultListModel< - E> model = (DefaultListModel) list.getModel(); + DefaultListModel model = (DefaultListModel) list.getModel(); model.addElement(add.get()); }); @@ -112,8 +108,7 @@ public class ListParameterPanel extends JPanel { if (remove != null) { removeParam = new JButton("Remove..."); removeParam.addActionListener((event) -> { - DefaultListModel< - E> model = (DefaultListModel) list.getModel(); + DefaultListModel model = (DefaultListModel) list.getModel(); remove.accept(model.remove(list.getSelectedIndex())); }); 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 eb900aa..b90e25c 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 @@ -8,21 +8,25 @@ import javax.swing.JTextField; /** * A simple component for text input + * * @author ben * */ public class SimpleInputPanel extends JPanel { - private static final long serialVersionUID = -4734279623645236868L; + private static final long serialVersionUID = -4734279623645236868L; /** * The text field containing the input value */ - public final JTextField inputValue; + 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 + * + * @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 48230dd..11b209f 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 @@ -24,10 +24,8 @@ import bjc.utils.gui.layout.HLayout; public class SimpleListPanel extends JPanel { private static final long serialVersionUID = 2719963952350133541L; - private static void addItem(DefaultListModel model, - Predicate verifier, - Consumer onFailure, - JTextField addItemField) { + private static void addItem(DefaultListModel model, Predicate verifier, + Consumer onFailure, JTextField addItemField) { String potentialItem = addItemField.getText(); if (verifier == null || verifier.test(potentialItem)) { @@ -43,17 +41,15 @@ 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(String type, - DefaultListModel model, - Predicate verifier, + public SimpleListPanel(String type, DefaultListModel model, Predicate verifier, Consumer onFailure) { setLayout(new AutosizeLayout()); @@ -77,13 +73,11 @@ public class SimpleListPanel extends JPanel { JButton removeItemButton = new JButton("Remove " + type); addItemButton.addActionListener((ev) -> { - addItem(model, verifier, onFailure, - addItemField); + addItem(model, verifier, onFailure, addItemField); }); addItemField.addActionListener((ev) -> { - addItem(model, verifier, onFailure, - addItemField); + addItem(model, verifier, onFailure, addItemField); }); removeItemButton.addActionListener((ev) -> { 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 5996b65..e9e94d5 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 @@ -9,21 +9,25 @@ import javax.swing.SpinnerModel; /** * A simple spinner control + * * @author ben * */ public class SimpleSpinnerPanel extends JPanel { - private static final long serialVersionUID = -4734279623645236868L; + private static final long serialVersionUID = -4734279623645236868L; /* * The spinner being used */ - public final JSpinner inputValue; + 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 + * + * @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/gui/panels/SliderInputPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java index 9de4d63..53bff32 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java @@ -11,21 +11,20 @@ import javax.swing.JSlider; import bjc.utils.gui.layout.HLayout; /** - * A simple input panel for a slider-controlled value and a manual-input - * field for setting the slider + * A simple input panel for a slider-controlled value and a manual-input field + * for setting the slider * * @author ben * */ public class SliderInputPanel extends JPanel { - private final class NumberFormatter - extends JFormattedTextField.AbstractFormatter { - private static final long serialVersionUID = -4448291795913908270L; + private final class NumberFormatter extends JFormattedTextField.AbstractFormatter { + private static final long serialVersionUID = -4448291795913908270L; - private int minValue; - private int maxValue; + private int minValue; + private int maxValue; - private int initValue; + private int initValue; public NumberFormatter(SliderSettings settings) { minValue = settings.minValue; @@ -40,17 +39,14 @@ public class SliderInputPanel extends JPanel { int val = Integer.parseInt(text); if (val < minValue) { - throw new ParseException( - "Value must be greater than " + minValue, 0); + throw new ParseException("Value must be greater than " + minValue, 0); } else if (val > maxValue) { - throw new ParseException( - "Value must be smaller than " + maxValue, 0); + throw new ParseException("Value must be smaller than " + maxValue, 0); } else { return val; } } catch (NumberFormatException nfex) { - ParseException pex = new ParseException( - "Value must be a valid integer", 0); + ParseException pex = new ParseException("Value must be a valid integer", 0); pex.initCause(nfex); @@ -78,25 +74,25 @@ public class SliderInputPanel extends JPanel { /** * The minimum value of the slider */ - public final int minValue; + public final int minValue; /** * The maximum value of the slider */ - public final int maxValue; + public final int maxValue; /** * The initial value of the slider */ - public final int initValue; + public final int initValue; /** * Create a new slider settings, with the initial value in the * 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(int min, int max) { this(min, max, (min + max) / 2); @@ -106,11 +102,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(int min, int max, int init) { minValue = min; @@ -120,32 +116,31 @@ public class SliderInputPanel extends JPanel { } } - private static final long serialVersionUID = 2956394160569961404L; - private JSlider slider; - private JFormattedTextField field; + private static final long serialVersionUID = 2956394160569961404L; + private JSlider slider; + private JFormattedTextField field; /** * 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(String lab, SliderSettings settings, - int majorTick, int minorTick, Consumer action) { + public SliderInputPanel(String lab, SliderSettings settings, int majorTick, int minorTick, + Consumer action) { setLayout(new HLayout(3)); JLabel label = new JLabel(lab); - slider = new JSlider(settings.minValue, settings.maxValue, - settings.initValue); + slider = new JSlider(settings.minValue, settings.maxValue, settings.initValue); field = new JFormattedTextField(new NumberFormatter(settings)); slider.setMajorTickSpacing(majorTick); @@ -186,7 +181,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(int value) { slider.setValue(value); -- cgit v1.2.3