spinner component
Tom Schindl
tom.schindl at bestsolution.at
Sat Dec 17 00:20:29 PST 2011
really a biginteger? Wouldn't a long or even int be enough?
Tom
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.
>
> Properties:
> *- 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).
>
> Methods:
> *- public void decrease()
> * programatically select the previous value
> *
> - public void increase()
> * programatically select the next value
>
> Events
> *- ObjectProperty<EventHandler<CycleEvent>> onCycleProperty()
> * OnCycle method gets called when the spinners cycles (see cyclic
> property).
>
> 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
> value
>
> - *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
> http://code.google.com/p/jfxtras/source/browse/controls/src/main/java/jfxtras/scene/control/SpinnerX.java
> (screenshot attached to the email).
>
> Tom
>
>
>
--
B e s t S o l u t i o n . a t EDV Systemhaus GmbH
------------------------------------------------------------------------
tom schindl geschäftsführer/CEO
------------------------------------------------------------------------
eduard-bodem-gasse 5-7/1 A-6020 innsbruck fax ++43 512 935833
http://www.BestSolution.at phone ++43 512 935834
More information about the openjfx-dev
mailing list