# 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 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
`protected`
`ConversionSpecifier(Specifier<I> baseSpec)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`addActionListener(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.
`JComponent`
`getComponent()`
Returns the graphical component that the user can interact with to supply a value.
`O`
`getSpecifiedValue()`
Returns the typed value currently specified by the graphical component.
`protected abstract O`
`inToOut(I inValue)`
Converts a value from input (base) to output type.
`boolean`
`isXFill()`
Whether the GUI component should fill the available width of a panel.
`protected abstract I`
`outToIn(O outValue)`
Converts a value from output to input (base) type.
`void`
`removeActionListener(ActionListener listener)`
Removes a listener previously added by `addActionListener`.
`void`
`setSpecifiedValue(O outValue)`
Sets the typed value represented by the graphical component.
`void`
`submitReport(ReportMap report)`
Accepts information about a completed plot that was drawn with input from this specifier.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### ConversionSpecifier

protected ConversionSpecifier(Specifier<I> baseSpec)
Constructor.

Parameters:
  `baseSpec` - specifier on which this one is based

## Method Details

### 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 JComponent getComponent()
Description copied from interface: `Specifier`
Returns 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`/`isEnabled` methods.

Specified by:
  `getComponent` in interface `Specifier<I>`
Returns:
  specifier component

### getSpecifiedValue

public O getSpecifiedValue()
Description copied from interface: `Specifier`
Returns the typed value currently specified by the graphical component.

Specified by:
  `getSpecifiedValue` in interface `Specifier<I>`
Returns:
  specified value

### setSpecifiedValue

public void setSpecifiedValue(O outValue)
Description copied from interface: `Specifier`
Sets 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 of `getSpecifiedValue` should 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:
  `setSpecifiedValue` in interface `Specifier<I>`
Parameters:
  `outValue` - new value

### addActionListener

public void addActionListener(ActionListener listener)
Description copied from interface: `Specifier`
Adds a listener which will be informed when the user interacts with the graphical component to cause a (potential) change in the value.

Specified by:
  `addActionListener` in interface `Specifier<I>`
Parameters:
  `listener` - listener to add

### removeActionListener

public void removeActionListener(ActionListener listener)
Description copied from interface: `Specifier`
Removes a listener previously added by `addActionListener`.

Specified by:
  `removeActionListener` in interface `Specifier<I>`
Parameters:
  `listener` - listener to remove

### submitReport

public void submitReport(ReportMap report)
Description copied from interface: `Specifier`
Accepts 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:
  `submitReport` in interface `Specifier<I>`
Parameters:
  `report` - report of a plot partially specified by this object

### isXFill

public boolean isXFill()
Description copied from interface: `Specifier`
Whether 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.

Specified by:
  `isXFill` in interface `Specifier<I>`
Returns:
  true for horizontally expandable components