Search in sources :

Example 1 with DecimalSpinner

use of com.sldeditor.ui.widgets.DecimalSpinner in project sldeditor by robward-scisys.

the class FieldConfigRange method createRow.

/**
 * Creates the row.
 *
 * @param fieldPanel the field panel
 * @param xPos the x pos
 * @param y the y coordinate
 * @param rangeConfig the range config
 * @param label the label
 */
private void createRow(FieldPanel fieldPanel, int xPos, int y, RangeData rangeConfig, String label) {
    final UndoActionInterface parentObj = this;
    if (configurationSet) {
        rangeConfig.spinner = new DecimalSpinner(rangeConfig.minValue, rangeConfig.maxValue, rangeConfig.stepSize, rangeConfig.noOfDecimalPlaces);
    } else {
        rangeConfig.spinner = new DecimalSpinner();
    }
    JLabel lbl = new JLabel(label);
    lbl.setHorizontalAlignment(SwingConstants.TRAILING);
    lbl.setBounds(xPos, y, BasePanel.LABEL_WIDTH, BasePanel.WIDGET_HEIGHT);
    fieldPanel.add(lbl);
    rangeConfig.spinner.setBounds(xPos + BasePanel.WIDGET_X_START, y, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
    fieldPanel.add(rangeConfig.spinner);
    rangeConfig.includedCheckBox = new JCheckBox(Localisation.getString(FieldConfigBase.class, "FieldConfigRange.included"));
    rangeConfig.includedCheckBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            uiInteraction(parentObj);
        }
    });
    rangeConfig.includedCheckBox.setBounds(rangeConfig.spinner.getX() + rangeConfig.spinner.getWidth() + 5, y, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
    fieldPanel.add(rangeConfig.includedCheckBox);
    rangeConfig.spinner.registerObserver(new SpinnerNotifyInterface() {

        @Override
        public void notify(double oldValue, double newValue) {
            uiInteraction(parentObj);
        }
    });
}
Also used : JCheckBox(javax.swing.JCheckBox) SpinnerNotifyInterface(com.sldeditor.ui.iface.SpinnerNotifyInterface) DecimalSpinner(com.sldeditor.ui.widgets.DecimalSpinner) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface)

Example 2 with DecimalSpinner

use of com.sldeditor.ui.widgets.DecimalSpinner in project sldeditor by robward-scisys.

the class FieldConfigDouble method createUI.

/**
 * Creates the ui.
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
     */
@Override
public void createUI() {
    if (spinner == null) {
        final UndoActionInterface parentObj = this;
        int xPos = getXPos();
        FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
        if (configurationSet) {
            spinner = new DecimalSpinner(minValue, maxValue, stepSize, noOfDecimalPlaces);
        } else {
            spinner = new DecimalSpinner();
        }
        spinner.setBounds(xPos + BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
        fieldPanel.add(spinner);
        if (!isValueOnly()) {
            setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(Double.class, this, isRasterSymbol()));
        }
        spinner.registerObserver(new SpinnerNotifyInterface() {

            @Override
            public void notify(double oldValue, double newValue) {
                Double oldValueObj = Double.valueOf(oldValue);
                Double newValueObj = Double.valueOf(newValue);
                UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
                valueUpdated();
            }
        });
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) SpinnerNotifyInterface(com.sldeditor.ui.iface.SpinnerNotifyInterface) DecimalSpinner(com.sldeditor.ui.widgets.DecimalSpinner) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface)

Aggregations

UndoActionInterface (com.sldeditor.common.undo.UndoActionInterface)2 SpinnerNotifyInterface (com.sldeditor.ui.iface.SpinnerNotifyInterface)2 DecimalSpinner (com.sldeditor.ui.widgets.DecimalSpinner)2 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 FieldPanel (com.sldeditor.ui.widgets.FieldPanel)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 JCheckBox (javax.swing.JCheckBox)1 JLabel (javax.swing.JLabel)1