tbee at tbee.org
Sat Dec 17 00:25:02 PST 2011
Yup. Since basically a year value is endless, if you want to support that situation, we need to use an endless value (me is purist).
The overhead performancewise of using a BigInteger is minimal compared to the whole of the UI. And for must end users the provided supporting classes will hide that that; there can be a ListDataProvider and the spinner can have a constructor which take a list as the parameter. There also can be a YearDataProvider, MonthDataProvider, etc.
On 17-12-2011 9:20, Tom Schindl wrote:
> really a biginteger? Wouldn't a long or even int be enough?
> Am 17.12.11 09:16, schrieb Tom Eugelink:
>> I would like to propose the addition of a spinner control to OpenJFX.
>> A spinner control for all means and purposes is a listview where only
>> one cell is visible (rendered) at a time. Moving to the next and
>> previous cell is done via clicking with the mouse on arrows or using
>> keyboard presses. The control's API could look like:
>> Class: *Spinner<T> extends Control*
>> T denotes the type it is holding; String, Integer, any bean.
>> *- ObjectProperty<T> valueProperty()
>> * The value property holds the currently displayed (selected) value
>> - ObjectProperty<Boolean> cyclicProperty()
>> * Cyclic means that the spinners cycles back to the beginning when the
>> end of the list of values is reached, e.g. december -> next -> januari,
>> or vice versa (januari -> previous -> december).
>> *- public void decrease()
>> * programatically select the previous value
>> - public void increase()
>> * programatically select the next value
>> *- ObjectProperty<EventHandler<CycleEvent>> onCycleProperty()
>> * OnCycle method gets called when the spinners cycles (see cyclic
>> A value change event is not needed, since registering to the value
>> property will take care of that. Detecting a cycle based on value
>> changes is cumbersome, so hence the OnCycle event.
>> Implementation considerations:
>> Since this actually is a list-with-just-one-cell, adopting a cell
>> factory may be a good idea.
>> Even though a spinner is a list-with-just-one-cell, using a list as its
>> data source is restrictive, because lists always have a lower and upper
>> bound. For example, take a spinner that selects a year: the value "year"
>> has no natural lower and upper bound. It could have in certain
>> situations, but as a concept it has not. Therefor I would like to
>> propose the usage of a data provider, in this case a
>> single-value-linear-data-provider. Such a data provider uses a
>> BigInteger to represent the current value and can increment or decrement.
>> Data provide API:
>> - *public BigInteger getPreviousIdx(BigInteger idx);*
>> Calculate the previous index given the provided one, returning null if
>> there is no previous. (Spinner may cycle.)
>> - *public BigInteger getNextIdx(BigInteger idx);*
>> Calculate the next index given the provided one, returning null if
>> there is no next. (Spinner may cycle.)
>> - *public T getValue(BigInteger idx);*
>> Return the value for the specified index, could return null as a valid
>> - *public BigInteger getIdx(T value);*
>> Return the idx for the specified value, returning null means the value
>> does not exist
>> The DataProvider can be based on an actual list, or on an implementation
>> allowing the endless selection of a year.
>> A initial (but fully working) implementation can be found at
>> (screenshot attached to the email).
More information about the openjfx-dev