Top Inners Fields Constructors Methods
com.dlsc.unitfx.skins

public Class QuantityInputFieldSkin<Q extends Quantity<Q>>

extends SkinBase<QuantityInputField<Q extends Quantity<Q>>>
Class Inheritance
Imports
com.dlsc.unitfx.DoubleInputField, .QuantityInputField, javafx.beans.InvalidationListener, javafx.beans.binding.Bindings, javafx.beans.property.BooleanProperty, .SimpleBooleanProperty, javafx.scene.control.ComboBox, .ContentDisplay, .Label, .Labeled, .ListCell, .SkinBase, javafx.scene.input.KeyCode, .KeyEvent, javafx.scene.layout.Region, javax.measure.Quantity, .Unit

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final DoubleInputField
private final Label
private final ComboBox<Unit<Q>>
private final Label

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private String
private static Label
decorateUnitLabel(Labeled unitLabel, BooleanProperty iconVisibleProperty)

protected void
layoutChildren(double
the x position
contentX
,
double
the y position
contentY
,
double
the width
contentWidth
,
double
the height
contentHeight
)

Overrides javafx.scene.control.SkinBase.layoutChildren.

Called during the layout pass of the scenegraph.

private void
Inherited from javafx.scene.control.SkinBase:
computeBaselineOffsetcomputeMaxHeightcomputeMaxWidthcomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthconsumeMouseEventsdisposeexecuteAccessibleActiongetChildrengetClassCssMetaDatagetCssMetaDatagetNodegetSkinnablelayoutInArealayoutInArealayoutInAreapositionInAreapositionInAreapseudoClassStateChangedqueryAccessibleAttributeregisterChangeListenerregisterInvalidationListenerregisterListChangeListenersnappedBottomInsetsnappedLeftInsetsnappedRightInsetsnappedTopInsetsnapPositionsnapPositionXsnapPositionYsnapSizesnapSizeXsnapSizeYsnapSpacesnapSpaceXsnapSpaceYunregisterChangeListenersunregisterInvalidationListenersunregisterListChangeListeners

Field Detail

editorback to summary
private final DoubleInputField editor
editorDisabledback to summary
private final Label editorDisabled
switcherback to summary
private final ComboBox<Unit<Q>> switcher
switcherDisabledback to summary
private final Label switcherDisabled

Constructor Detail

QuantityInputFieldSkinback to summary
public QuantityInputFieldSkin(QuantityInputField<Q> control)

Method Detail

convertUnitToStringback to summary
private String convertUnitToString(Unit<Q> unit)
decorateUnitLabelback to summary
private static Label decorateUnitLabel(Labeled unitLabel, BooleanProperty iconVisibleProperty)
layoutChildrenback to summary
protected void layoutChildren(double contentX, double contentY, double contentWidth, double contentHeight)

Overrides javafx.scene.control.SkinBase.layoutChildren.

Doc from javafx.scene.control.SkinBase.layoutChildren.

Called during the layout pass of the scenegraph.

Parameters
contentX:double

the x position

contentY:double

the y position

contentWidth:double

the width

contentHeight:double

the height

Annotations
@Override
updateChildrenback to summary
private void updateChildren()
com.dlsc.unitfx.skins back to summary

private Class QuantityInputFieldSkin.UnitListCell

extends ListCell<Unit<Q extends Quantity<Q>>>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Label
private final BooleanProperty

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected void
updateItem(Unit<Q>
The new item for the cell.
item
,
boolean
whether or not this cell represents data from the list. If it is empty, then it does not represent any domain data, but is a cell being used to render an "empty" row.
empty
)

Overrides javafx.scene.control.Cell.updateItem.

The updateItem method should not be called by developers, but it is the best method for developers to override to allow for them to customise the visuals of the cell.

Inherited from javafx.scene.control.ListCell:
cancelEditcommitEditcreateDefaultSkinexecuteAccessibleActiongetListViewlayoutChildrenlistViewPropertyqueryAccessibleAttributestartEditupdateListView

Field Detail

iconback to summary
private final Label icon
itemNoBaseUnitback to summary
private final BooleanProperty itemNoBaseUnit

Constructor Detail

UnitListCellback to summary
pack-priv UnitListCell()

Method Detail

updateItemback to summary
protected void updateItem(Unit<Q> item, boolean empty)

Overrides javafx.scene.control.Cell.updateItem.

Doc from javafx.scene.control.Cell.updateItem.

The updateItem method should not be called by developers, but it is the best method for developers to override to allow for them to customise the visuals of the cell. To clarify, developers should never call this method in their code (they should leave it up to the UI control, such as the javafx.scene.control.ListView control) to call this method. However, the purpose of having the updateItem method is so that developers, when specifying custom cell factories (again, like the ListView cell factory), the updateItem method can be overridden to allow for complete customisation of the cell.

It is very important that subclasses of Cell override the updateItem method properly, as failure to do so will lead to issues such as blank cells or cells with unexpected content appearing within them. Here is an example of how to properly override the updateItem method:

protected void updateItem(T item, boolean empty) {
    super.updateItem(item, empty);

    if (empty || item == null) {
        setText(null);
        setGraphic(null);
    } else {
        setText(item.toString());
    }
}

Note in this code sample two important points:

  1. We call the super.updateItem(T, boolean) method. If this is not done, the item and empty properties are not correctly set, and you are likely to end up with graphical issues.
  2. We test for the empty condition, and if true, we set the text and graphic properties to null. If we do not do this, it is almost guaranteed that end users will see graphical artifacts in cells unexpectedly.
Parameters
item:Unit<Q>

The new item for the cell.

empty:boolean

whether or not this cell represents data from the list. If it is empty, then it does not represent any domain data, but is a cell being used to render an "empty" row.

Annotations
@Override