Search in sources :

Example 1 with ColourButton

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

the class FieldConfigColour method createUI.

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

            @Override
            public void notify(String colourString, double opacity) {
                Color newValueObj = colourButton.getColour();
                UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
                oldValueObj = newValueObj;
                valueUpdated();
            }
        });
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) Color(java.awt.Color) ColourButton(com.sldeditor.ui.widgets.ColourButton) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) ColourNotifyInterface(com.sldeditor.ui.iface.ColourNotifyInterface)

Aggregations

UndoActionInterface (com.sldeditor.common.undo.UndoActionInterface)1 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 ColourNotifyInterface (com.sldeditor.ui.iface.ColourNotifyInterface)1 ColourButton (com.sldeditor.ui.widgets.ColourButton)1 FieldPanel (com.sldeditor.ui.widgets.FieldPanel)1 Color (java.awt.Color)1