Class ComboBoxSpecifier<V>
- java.lang.Object
-
- uk.ac.starlink.ttools.plot2.config.SpecifierPanel<V>
-
- uk.ac.starlink.ttools.plot2.config.ComboBoxSpecifier<V>
-
- All Implemented Interfaces:
Specifier<V>
public class ComboBoxSpecifier<V> extends SpecifierPanel<V>
Typed specifier for selecting options from a combo box.- Since:
- 5 Mar 2013
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description ComboBoxSpecifier(java.lang.Class<V> clazz, java.util.Collection<V> options)Constructs a specifier selecting from a given collection of options.ComboBoxSpecifier(java.lang.Class<V> clazz, javax.swing.JComboBox comboBox)Constructs a specifier with a given combo box and default options.ComboBoxSpecifier(java.lang.Class<V> clazz, javax.swing.JComboBox comboBox, boolean customStringify, boolean allowAny)Constructs a specifier with a given combo box, and optional custom labelling and setting restrictions.ComboBoxSpecifier(V[] options)Constructs a specifier selecting from a given array of options.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.swing.JComponentcreateComponent()Abstract method called lazily duringgetComponentto obtain the graphical component used by this specifier.javax.swing.JComboBoxgetComboBox()Returns this specifier's combo box.VgetSpecifiedValue()Returns the typed value currently specified by the graphical component.voidsetSpecifiedValue(V value)Sets the typed value represented by the graphical component.java.lang.Stringstringify(V value)May be used to turn typed values into text labels for the combo box.voidsubmitReport(ReportMap report)Accepts information about a completed plot that was drawn with input from this specifier.-
Methods inherited from class uk.ac.starlink.ttools.plot2.config.SpecifierPanel
addActionListener, fireAction, getActionForwarder, getChangeForwarder, getComponent, isXFill, removeActionListener
-
-
-
-
Constructor Detail
-
ComboBoxSpecifier
public ComboBoxSpecifier(java.lang.Class<V> clazz, javax.swing.JComboBox comboBox, boolean customStringify, boolean allowAny)
Constructs a specifier with a given combo box, and optional custom labelling and setting restrictions.- Parameters:
clazz- value type for this specifiercomboBox- combo box instance with appropriate options (must all be assignable from V)customStringify- if true, this object'sstringifymethod is used to provide combo box textallowAny- if true, then thesetSpecifiedValuemethod is allowed to set any value; otherwise, it is restricted to the options in the combo box
-
ComboBoxSpecifier
public ComboBoxSpecifier(java.lang.Class<V> clazz, javax.swing.JComboBox comboBox)
Constructs a specifier with a given combo box and default options.- Parameters:
clazz- value type for this specifiercomboBox- combo box instance with appropriate options (must all be assignable from V)
-
ComboBoxSpecifier
public ComboBoxSpecifier(java.lang.Class<V> clazz, java.util.Collection<V> options)
Constructs a specifier selecting from a given collection of options.- Parameters:
clazz- value type for this specifieroptions- options
-
ComboBoxSpecifier
public ComboBoxSpecifier(V[] options)
Constructs a specifier selecting from a given array of options.- Parameters:
options- options
-
-
Method Detail
-
stringify
public java.lang.String stringify(V value)
May be used to turn typed values into text labels for the combo box. The default implementation uses toString; subclasses may override it.- Parameters:
value- typed value- Returns:
- string representation
-
createComponent
protected javax.swing.JComponent createComponent()
Description copied from class:SpecifierPanelAbstract method called lazily duringgetComponentto obtain the graphical component used by this specifier. It will be called a maximum of once. It is not necessary that the component actually be created in this method, for instance it may be created at construction time if that's more convenient.- Specified by:
createComponentin classSpecifierPanel<V>- Returns:
- graphical component
-
getSpecifiedValue
public V getSpecifiedValue()
Description copied from interface:SpecifierReturns the typed value currently specified by the graphical component.- Returns:
- specified value
-
setSpecifiedValue
public void setSpecifiedValue(V value)
Description copied from interface:SpecifierSets the typed value represented by the graphical component. Calling this method ought to make it clear to the user what value it is set at; in any case a subsequent call ofgetSpecifiedValueshould yield the same result.However if a value is set which is of the correct type but cannot be represented by this specifier, results are unpredictable.
- Parameters:
value- new value
-
submitReport
public void submitReport(ReportMap report)
Description copied from interface:SpecifierAccepts information about a completed plot that was drawn with input from this specifier. In many cases, the implementation of this method will be a no-op, but it gives this object a chance to update its state or its component's appearance based on the way the plot was actually drawn, which may provide information not otherwise available to this object.- Parameters:
report- report of a plot partially specified by this object
-
getComboBox
public javax.swing.JComboBox getComboBox()
Returns this specifier's combo box.- Returns:
- combo box doing the work
-
-