java.lang.Object
com.marginallyclever.ro3.PanelHelper
PanelHelper is a collection of static methods to help build panels.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddColorChooser(JPanel parent, String title, Supplier<Color> startColor, Consumer<Color> consumer, GridBagConstraints gbc) A convenience method to add a color chooser to a panel.static voidaddLabelAndComponent(JPanel pane, String labelText, JComponent component) A convenience method to add a label and component to a panel that is built withGridLayout.static voidaddLabelAndComponent(JPanel pane, String labelText, JComponent component, GridBagConstraints gbc) A convenience method to add a label and component to a panel that is built withGridBagLayout.static voidaddLimit(JPanel pane, GridBagConstraints gbc, String label, double value, Consumer<Double> consumer, double infinite) A convenience method to add an angle limit to a panel (in degrees).static <T extends Node>
NodeSelector<T> addNodeSelector(JPanel pane, String label, NodePath<T> nodePath, GridBagConstraints gbc) A convenience method to add a label and component to a panel that is expected to be built with GridBagConstraint.static JFormattedTextFieldaddNumberField(String toolTip, double value, NumberFormatter formatter) A convenience method to add a number field to a panel.static JFormattedTextFieldaddNumberFieldDouble(String toolTip, double value) A convenience method to add a number field to a panel.static JFormattedTextFieldaddNumberFieldInt(String toolTip, int value) A convenience method to add a number field to a panel.static voidaddSelector(JPanel pane, GridBagConstraints gbc, String label, NodePath<ODEBody> originalValue, Consumer<ODEBody> consumer) A convenience method to add aNodeSelectorto a panel.createComboBox(String[] options, int type, Consumer<Integer> consumer) static JComponentcreateSlider(double max, double min, double value, Consumer<Double> consumer) Create a range slider with two decimal places that displays the value on the right.static voidenableLimit(boolean isSelected, JSpinner spinner, Consumer<Double> consumer, double infinite)
-
Constructor Details
-
PanelHelper
public PanelHelper()
-
-
Method Details
-
addLabelAndComponent
A convenience method to add a label and component to a panel that is built with
GridLayout.- Parameters:
pane- the panel to add tolabelText- the text for the labelcomponent- the component to add
-
addLabelAndComponent
public static void addLabelAndComponent(JPanel pane, String labelText, JComponent component, GridBagConstraints gbc) A convenience method to add a label and component to a panel that is built with
GridBagLayout.- Parameters:
pane- the panel to add tolabelText- the text for the labelcomponent- the component to addgbc- the GridBagConstraints to use
-
addNodeSelector
public static <T extends Node> NodeSelector<T> addNodeSelector(JPanel pane, String label, NodePath<T> nodePath, GridBagConstraints gbc) A convenience method to add a label and component to a panel that is expected to be built with GridBagConstraint.- Type Parameters:
T- the type filter for theNodeSelector.- Parameters:
pane- the panel to add tolabel- the text for the labelnodePath- the NodePath to usegbc- theGridBagConstraintsto use- Returns:
- the NodeSelector
-
addColorChooser
public static void addColorChooser(JPanel parent, String title, Supplier<Color> startColor, Consumer<Color> consumer, GridBagConstraints gbc) A convenience method to add a color chooser to a panel.
- Parameters:
parent- the parent paneltitle- the title for the color chooserstartColor- the initial colorconsumer- the consumer to accept the colorgbc- theGridBagConstraintsto use
-
addNumberFieldDouble
A convenience method to add a number field to a panel.
- Parameters:
toolTip- the tooltip for the fieldvalue- the initial value- Returns:
- the
JFormattedTextField
-
addNumberFieldInt
A convenience method to add a number field to a panel.
- Parameters:
toolTip- the tooltip for the fieldvalue- the initial value- Returns:
- the
JFormattedTextField
-
addNumberField
public static JFormattedTextField addNumberField(String toolTip, double value, NumberFormatter formatter) A convenience method to add a number field to a panel.
- Parameters:
toolTip- the tooltip for the fieldvalue- the initial valueformatter- theNumberFormatterto use- Returns:
- the
JFormattedTextField
-
addLimit
public static void addLimit(JPanel pane, GridBagConstraints gbc, String label, double value, Consumer<Double> consumer, double infinite) A convenience method to add an angle limit to a panel (in degrees).
- Parameters:
pane- the panel to add togbc- theGridBagConstraintsto uselabel- the label for the limitvalue- the initial valueconsumer- the consumer to accept the valueinfinite- the value to use for infinite (no limit)
-
enableLimit
-
addSelector
public static void addSelector(JPanel pane, GridBagConstraints gbc, String label, NodePath<ODEBody> originalValue, Consumer<ODEBody> consumer) A convenience method to add a
NodeSelectorto a panel.- Parameters:
pane- the panel to add togbc- theGridBagConstraintsto uselabel- the label for the selectororiginalValue- the original valueconsumer- the consumer to accept the value
-
createSlider
public static JComponent createSlider(double max, double min, double value, Consumer<Double> consumer) Create a range slider with two decimal places that displays the value on the right.- Parameters:
max- the maximum valuemin- the minimum valuevalue- the initial valueconsumer- the consumer to accept the value- Returns:
- the
JComponent
-
createComboBox
-