Example usage for javax.swing SpinnerNumberModel getMinimum

List of usage examples for javax.swing SpinnerNumberModel getMinimum

Introduction

In this page you can find the example usage for javax.swing SpinnerNumberModel getMinimum.

Prototype

public Comparable<?> getMinimum() 

Source Link

Document

Returns the first number in this sequence.

Usage

From source file:org.eclipse.wb.internal.swing.model.property.editor.models.spinner.SpinnerModelPropertyEditor.java

/**
 * @return the text to display for given {@link Property}.
 *//*from   ww  w .ja v a  2s  .c o m*/
private String getText(Property property, boolean forTooltip) throws Exception {
    Object value = property.getValue();
    if (value instanceof SpinnerModel) {
        SpinnerModel model = (SpinnerModel) value;
        // analyze known models
        if (model instanceof SpinnerNumberModel) {
            SpinnerNumberModel numberModel = (SpinnerNumberModel) model;
            // prepare labels
            String typeLabel = forTooltip ? "type=" : "";
            String valueLabel = forTooltip ? " value=" : ", ";
            String startLabel = forTooltip ? " start=" : ", ";
            String endLabel = forTooltip ? " end=" : ", ";
            String stepLabel = forTooltip ? " step=" : ", ";
            // text
            String typeText = typeLabel + CodeUtils.getShortClass(numberModel.getValue().getClass().getName());
            String valueText = valueLabel + numberModel.getValue();
            String startText = startLabel + numberModel.getMinimum();
            String endText = endLabel + numberModel.getMaximum();
            String stepText = stepLabel + numberModel.getStepSize();
            return typeText + valueText + startText + endText + stepText;
        } else if (model instanceof SpinnerListModel) {
            SpinnerListModel listModel = (SpinnerListModel) model;
            String separator = forTooltip ? "\n" : ", ";
            return StringUtils.join(listModel.getList().iterator(), separator);
        } else if (model instanceof SpinnerDateModel) {
            SpinnerDateModel dateModel = (SpinnerDateModel) model;
            // prepare labels
            String valueLabel = forTooltip ? "value=" : "";
            String startLabel = forTooltip ? "\nstart=" : ", ";
            String endLabel = forTooltip ? "\nend=" : ", ";
            String stepLabel = forTooltip ? "\nstep=" : ", ";
            // text
            String valueText = valueLabel + getDateText(dateModel.getValue());
            String startText = startLabel + getDateText(dateModel.getStart());
            String endText = endLabel + getDateText(dateModel.getEnd());
            String stepText = stepLabel + getDateStep(dateModel.getCalendarField());
            return valueText + startText + endText + stepText;
        } else {
            return model.toString();
        }
    }
    // unknown value
    return null;
}