Search in sources :

Example 1 with ColourRampConfigPanel

use of com.sldeditor.colourramp.ColourRampConfigPanel 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, this.isSuppressUndoEvents());
        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()) {
                    itemsSelected();
                }
            }
        });
        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
        // 
        JButton 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, isSuppressUndoEvents());
        colourMapEntryPanel.setBounds(xPos, getRowY(maxNoOfConfigRows + maxNoOfTableRows - 1), BasePanel.FIELD_PANEL_WIDTH, colourMapEntryPanel.getPanelHeight());
        fieldPanel.add(colourMapEntryPanel);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JButton(javax.swing.JButton) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) ColourRampConfigPanel(com.sldeditor.colourramp.ColourRampConfigPanel)

Aggregations

ColourRampConfigPanel (com.sldeditor.colourramp.ColourRampConfigPanel)1 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1 FieldPanel (com.sldeditor.ui.widgets.FieldPanel)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 JButton (javax.swing.JButton)1 JScrollPane (javax.swing.JScrollPane)1 JTable (javax.swing.JTable)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 ListSelectionListener (javax.swing.event.ListSelectionListener)1