Search in sources :

Example 6 with FieldPanel

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

the class FieldConfigFont method createUI.

/**
 * Creates the ui.
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
     */
@Override
public void createUI() {
    if (comboBox == null) {
        final UndoActionInterface parentObj = this;
        populateFontFamilyList();
        if (!fontFamilyList.isEmpty()) {
            defaultValue = fontFamilyList.get(0).getKey();
        }
        comboBox = new ValueComboBox();
        comboBox.initialiseSingle(fontFamilyList);
        int xPos = getXPos();
        comboBox.setBounds(xPos + BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
        FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
        fieldPanel.add(comboBox);
        comboBox.setSelectValueKey(defaultValue);
        comboBox.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                ValueComboBox comboBox = (ValueComboBox) e.getSource();
                if (comboBox.getSelectedItem() != null) {
                    Object newValueObj = comboBox.getSelectedValue().getKey();
                    if ((oldValueObj == null) && comboBox.getItemCount() > 0) {
                        oldValueObj = comboBox.getFirstItem().getKey();
                    }
                    UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
                    oldValueObj = newValueObj;
                    valueUpdated();
                }
            }
        });
        if (!isValueOnly()) {
            setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(Font.class, this, isRasterSymbol()));
        }
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) ValueComboBox(com.sldeditor.ui.widgets.ValueComboBox) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) Font(org.geotools.styling.Font)

Example 7 with FieldPanel

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

the class FieldConfigFontPreview method createUI.

/**
 * Creates the ui.
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
     */
@Override
public void createUI() {
    if (textField == null) {
        int xPos = getXPos();
        int height = getRowY(sampleTextLines);
        int width = BasePanel.WIDGET_EXTENDED_WIDTH * 2;
        textField = new JTextArea();
        textField.setBounds(xPos + BasePanel.WIDGET_X_START, 0, width, height);
        textField.setWrapStyleWord(true);
        textField.setLineWrap(false);
        textField.setText(sampleText);
        textField.setRows(sampleTextLines);
        JScrollPane scrollPane = new JScrollPane(textField);
        scrollPane.setBounds(xPos + BasePanel.WIDGET_X_START, 0, width, height);
        FieldPanel fieldPanel = createFieldPanel(xPos, height, getLabel());
        fieldPanel.add(scrollPane);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JTextArea(javax.swing.JTextArea) FieldPanel(com.sldeditor.ui.widgets.FieldPanel)

Example 8 with FieldPanel

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

the class FieldConfigColourMap method createUI.

/**
 * Creates the ui.
 */
@Override
public void createUI() {
    if (colourRampConfig == null) {
        int xPos = getXPos();
        int maxNoOfConfigRows = 7;
        int maxNoOfTableRows = 12;
        int totalRows = maxNoOfConfigRows + maxNoOfTableRows + ColourMapEntryPanel.getNoOfRows();
        FieldPanel fieldPanel = createFieldPanel(xPos, getRowY(totalRows), getLabel());
        colourRampConfig = new ColourRampConfigPanel(this, model);
        colourRampConfig.setBounds(xPos, 0, BasePanel.FIELD_PANEL_WIDTH, getRowY(maxNoOfConfigRows));
        fieldPanel.add(colourRampConfig);
        table = new JTable(model);
        table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        table.setBounds(xPos, getRowY(maxNoOfConfigRows), BasePanel.FIELD_PANEL_WIDTH, getRowY(totalRows - 2));
        table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    removeButton.setEnabled(true);
                    List<ColorMapEntry> entries;
                    if (table.getSelectedRowCount() == 1) {
                        ColorMapEntry entry = model.getColourMapEntry(table.getSelectedRow());
                        entries = new ArrayList<ColorMapEntry>();
                        entries.add(entry);
                    } else {
                        entries = model.getColourMapEntries(table.getSelectedRows());
                    }
                    colourMapEntryPanel.setSelectedEntry(entries);
                }
            }
        });
        model.setCellRenderer(table);
        JScrollPane scrollPanel = new JScrollPane(table);
        int endOfTableRow = maxNoOfConfigRows + maxNoOfTableRows - 2;
        scrollPanel.setBounds(xPos, getRowY(maxNoOfConfigRows), BasePanel.FIELD_PANEL_WIDTH, getRowY(endOfTableRow) - getRowY(maxNoOfConfigRows));
        fieldPanel.add(scrollPanel);
        int buttonY = getRowY(endOfTableRow);
        // 
        // Add button
        // 
        addButton = new JButton(Localisation.getString(FieldConfigBase.class, "FieldConfigColourMap.add"));
        addButton.setBounds(xPos + BasePanel.WIDGET_X_START, buttonY, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
        addButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                addEntry();
            }
        });
        fieldPanel.add(addButton);
        // 
        // Remove button
        // 
        removeButton = new JButton(Localisation.getString(FieldConfigBase.class, "FieldConfigColourMap.remove"));
        removeButton.setBounds(xPos + BasePanel.WIDGET_BUTTON_WIDTH + BasePanel.WIDGET_X_START + 10, buttonY, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
        removeButton.setEnabled(false);
        removeButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                removeEntry();
            }
        });
        fieldPanel.add(removeButton);
        colourMapEntryPanel = new ColourMapEntryPanel(getPanelId(), this);
        colourMapEntryPanel.setBounds(xPos, getRowY(maxNoOfConfigRows + maxNoOfTableRows - 1), BasePanel.FIELD_PANEL_WIDTH, colourMapEntryPanel.getPanelHeight());
        fieldPanel.add(colourMapEntryPanel);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ArrayList(java.util.ArrayList) JButton(javax.swing.JButton) ColorMapEntry(org.geotools.styling.ColorMapEntry) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) ArrayList(java.util.ArrayList) List(java.util.List) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) ColourRampConfigPanel(com.sldeditor.colourramp.ColourRampConfigPanel)

Example 9 with FieldPanel

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

the class FieldConfigDSProperties method createUI.

/**
 * Creates the ui.
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
     */
@Override
public void createUI() {
    final UndoActionInterface parentObj = this;
    int xPos = getXPos();
    comboBox.setBounds(xPos + BasePanel.WIDGET_X_START, 0, isValueOnly() ? BasePanel.WIDGET_EXTENDED_WIDTH : BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
    FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
    fieldPanel.add(comboBox);
    comboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (isAttributeComboBoxPopulated()) {
                if (comboBox.getSelectedItem() != null) {
                    String newValueObj = new String((String) comboBox.getSelectedItem());
                    UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
                    oldValueObj = new String(newValueObj);
                    valueUpdated();
                }
            }
        }
    });
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface)

Example 10 with FieldPanel

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

the class FieldConfigEnum method createUI.

/**
 * Creates the ui.
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
     */
@Override
public void createUI() {
    if (comboBox == null) {
        final UndoActionInterface parentObj = this;
        List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();
        for (String key : keyList) {
            dataList.add(new ValueComboBoxData(key, valueMap.get(key), getPanelId()));
        }
        if (!dataList.isEmpty()) {
            defaultValue = dataList.get(0).getKey();
        }
        int xPos = getXPos();
        comboBox = new ValueComboBox();
        comboBox.initialiseSingle(dataList);
        comboBox.setBounds(xPos + BasePanel.WIDGET_X_START, 0, isValueOnly() ? BasePanel.WIDGET_EXTENDED_WIDTH : BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
        FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
        fieldPanel.add(comboBox);
        if (!isValueOnly()) {
            setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(String.class, this, isRasterSymbol()));
        }
        if (dataList != null) {
            for (ValueComboBoxData data : dataList) {
                this.comboDataMap.put(data.getKey(), data);
            }
        }
        comboBox.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                ValueComboBox comboBox = (ValueComboBox) e.getSource();
                if (comboBox.getSelectedItem() != null) {
                    Object newValueObj = comboBox.getSelectedValue().getKey();
                    if ((oldValueObj == null) && comboBox.getItemCount() > 0) {
                        oldValueObj = comboBox.getFirstItem().getKey();
                    }
                    UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
                    oldValueObj = newValueObj;
                    valueUpdated();
                }
            }
        });
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) ValueComboBox(com.sldeditor.ui.widgets.ValueComboBox) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Aggregations

FieldPanel (com.sldeditor.ui.widgets.FieldPanel)31 UndoActionInterface (com.sldeditor.common.undo.UndoActionInterface)13 UndoEvent (com.sldeditor.common.undo.UndoEvent)12 ActionEvent (java.awt.event.ActionEvent)12 ActionListener (java.awt.event.ActionListener)12 Dimension (java.awt.Dimension)9 BorderLayout (java.awt.BorderLayout)6 JButton (javax.swing.JButton)6 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)3 ValueComboBox (com.sldeditor.ui.widgets.ValueComboBox)3 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)3 ArrayList (java.util.ArrayList)3 JScrollPane (javax.swing.JScrollPane)3 ColourRampConfigPanel (com.sldeditor.colourramp.ColourRampConfigPanel)2 SpinnerNotifyInterface (com.sldeditor.ui.iface.SpinnerNotifyInterface)2 Geometry (com.vividsolutions.jts.geom.Geometry)2 JCheckBox (javax.swing.JCheckBox)2 JPanel (javax.swing.JPanel)2 JTextArea (javax.swing.JTextArea)2 ChangeEvent (javax.swing.event.ChangeEvent)2