Class ConversionSpecifier<I,O>
- java.lang.Object
-
- uk.ac.starlink.ttools.plot2.config.ConversionSpecifier<I,O>
-
- All Implemented Interfaces:
Specifier<O>
public abstract class ConversionSpecifier<I,O> extends java.lang.Object implements Specifier<O>
Specifier implementation that adapts an existing one to dispense values of a different parameterised type. Implementations of methods to convert between the input (I) and output (O) types must be provided.- Since:
- 13 Feb 2014
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedConversionSpecifier(Specifier<I> baseSpec)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddActionListener(java.awt.event.ActionListener listener)Adds a listener which will be informed when the user interacts with the graphical component to cause a (potential) change in the value.javax.swing.JComponentgetComponent()Returns the graphical component that the user can interact with to supply a value.OgetSpecifiedValue()Returns the typed value currently specified by the graphical component.protected abstract OinToOut(I inValue)Converts a value from input (base) to output type.booleanisXFill()Whether the GUI component should fill the available width of a panel.protected abstract IoutToIn(O outValue)Converts a value from output to input (base) type.voidremoveActionListener(java.awt.event.ActionListener listener)Removes a listener previously added byaddActionListener.voidsetSpecifiedValue(O outValue)Sets the typed value represented by the graphical component.voidsubmitReport(ReportMap report)Accepts information about a completed plot that was drawn with input from this specifier.
-
-
-
Method Detail
-
inToOut
protected abstract O inToOut(I inValue)
Converts a value from input (base) to output type.- Parameters:
inValue- input type value- Returns:
- output type value
-
outToIn
protected abstract I outToIn(O outValue)
Converts a value from output to input (base) type.- Parameters:
outValue- output type value- Returns:
- input type value
-
getComponent
public javax.swing.JComponent getComponent()
Description copied from interface:SpecifierReturns the graphical component that the user can interact with to supply a value. It should be line-like (not tall).The returned component should preferably honour the JComponent
setEnabled/isEnabledmethods.- Specified by:
getComponentin interfaceSpecifier<I>- Returns:
- specifier component
-
getSpecifiedValue
public O getSpecifiedValue()
Description copied from interface:SpecifierReturns the typed value currently specified by the graphical component.- Specified by:
getSpecifiedValuein interfaceSpecifier<I>- Returns:
- specified value
-
setSpecifiedValue
public void setSpecifiedValue(O outValue)
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.
- Specified by:
setSpecifiedValuein interfaceSpecifier<I>- Parameters:
outValue- new value
-
addActionListener
public void addActionListener(java.awt.event.ActionListener listener)
Description copied from interface:SpecifierAdds a listener which will be informed when the user interacts with the graphical component to cause a (potential) change in the value.- Specified by:
addActionListenerin interfaceSpecifier<I>- Parameters:
listener- listener to add
-
removeActionListener
public void removeActionListener(java.awt.event.ActionListener listener)
Description copied from interface:SpecifierRemoves a listener previously added byaddActionListener.- Specified by:
removeActionListenerin interfaceSpecifier<I>- Parameters:
listener- listener to remove
-
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.- Specified by:
submitReportin interfaceSpecifier<I>- Parameters:
report- report of a plot partially specified by this object
-
isXFill
public boolean isXFill()
Description copied from interface:SpecifierWhether the GUI component should fill the available width of a panel. This rendering hint should on the whole this should be true for expandable components, and false for fixed size components. Components should have a fixed vertical size in any case.
-
-