Class NumberFormField<Type extends Number & Comparable<?>>

java.lang.Object
com.github.tadukoo.view.form.field.FormField<Type>
com.github.tadukoo.view.form.field.number.NumberFormField<Type>
Type Parameters:
Type - The type of Number being stored in the field (used for default, min, max, and step values)
Direct Known Subclasses:
DoubleFormField, FloatFormField, IntFormField, LongFormField, ShortFormField

public abstract class NumberFormField<Type extends Number & Comparable<?>> extends FormField<Type>
Abstract FormField used for Numbers using JSpinner.
Since:
Alpha v.0.2.1
Version:
Alpha v.0.3
Author:
Logan Ferree (Tadukoo)
  • Field Details

    • minValue

      private final Type extends Number & Comparable<?> minValue
      The minimum value allowed for this field
    • maxValue

      private final Type extends Number & Comparable<?> maxValue
      The maximum value allowed for this field
    • stepSize

      private final Type extends Number & Comparable<?> stepSize
      The increment value for the spinner for this field
  • Constructor Details

    • NumberFormField

      protected NumberFormField(FieldType type, String key, Type defaultValue, LabelType labelType, SizablePaint labelForegroundPaint, SizablePaint labelBackgroundPaint, FontFamily labelFontFamily, int labelFontStyle, int labelFontSize, ShapeInfo labelShape, Border labelBorder, int rowPos, int colPos, int rowSpan, int colSpan, boolean logFontResourceLoaderWarnings, com.github.tadukoo.util.logger.EasyLogger logger, GraphicsEnvironment graphEnv, String fontFolder, FontResourceLoader fontResourceLoader, Type minValue, Type maxValue, Type stepSize)
      Creates a new NumberFormField with the given parameters.
      Parameters:
      type - The FieldType of this field
      key - The name of this field (used as a key in Forms)
      defaultValue - The starting value of the field
      labelType - The LabelType to use for this field
      labelForegroundPaint - The SizablePaint for the foreground of the Label
      labelBackgroundPaint - The SizablePaint for the background of the Label
      labelFontFamily - The FontFamily for the Label's font
      labelFontStyle - The font style for the Label
      labelFontSize - The font size for the Label
      labelShape - The ShapeInfo to use for the Label
      labelBorder - The Border to use for the Label
      rowPos - The row position of this field
      colPos - The column position of this field
      rowSpan - The row span of this field
      colSpan - The column span of this field
      logFontResourceLoaderWarnings - Whether to log warnings generated by the FontResourceLoader - can be ignored if you specify your own FontResourceLoader
      logger - An EasyLogger that will be sent to the FontResourceLoader by default - can be ignored if you specify your own FontResourceLoader
      graphEnv - The GraphicsEnvironment to load a font to in the FontResourceLoader - can be ignored if you specify your own FontResourceLoader
      fontFolder - The path to the fonts folder to find font files in if needed in the FontResourceLoader - can be ignored if you specify your own FontResourceLoader
      fontResourceLoader - The FontResourceLoader to use for fonts on this field
      minValue - The minimum value allowed for this field
      maxValue - The maximum value allowed for this field
      stepSize - The increment value for the spinner for this field
  • Method Details

    • getMinValue

      public Type getMinValue()
      Returns:
      The minimum value allowed for this field
    • getMaxValue

      public Type getMaxValue()
      Returns:
      The maximum value allowed for this field
    • getStepSize

      public Type getStepSize()
      Returns:
      The increment value for the spinner for this field
    • getComponent

      public JComponent getComponent()
      Creates the JComponent to be used for this field.
      Specified by:
      getComponent in class FormField<Type extends Number & Comparable<?>>
      Returns:
      A newly created JComponent to use on the form
    • getValue

      public Type getValue(JComponent component)
      Takes in the JComponent for this field and grabs the data off of it, returning it in the proper format for the field to be repopulated on the form.
      Specified by:
      getValue in class FormField<Type extends Number & Comparable<?>>
      Parameters:
      component - The JComponent associated with this field
      Returns:
      The data extracted from the JComponent
    • convertToType

      protected abstract Type convertToType(Number number)
      Used in getValue(JComponent) to convert the Number from the JSpinner into the type used in this particular FormField.
      Parameters:
      number - The Number we got from the JSpinner
      Returns:
      The number in its proper Type