Search in sources :

Example 1 with ColourMapModel

use of com.sldeditor.ui.detail.config.colourmap.ColourMapModel in project sldeditor by robward-scisys.

the class ColourRampPanel method createFieldPanel.

/**
 * Creates the field panel.
 */
private void createFieldPanel() {
    JPanel tablePanel = new JPanel();
    tablePanel.setLayout(new BorderLayout());
    panel.add(tablePanel, BorderLayout.CENTER);
    JPanel dataPanel = new JPanel();
    tablePanel.add(dataPanel, BorderLayout.NORTH);
    dataPanel.setLayout(new BoxLayout(dataPanel, BoxLayout.Y_AXIS));
    minValueSpinner = new FieldConfigInteger(new FieldConfigCommonData(getClass(), FieldIdEnum.UNKNOWN, Localisation.getField(ColourRampConfigPanel.class, "ColourRampPanel.minValue"), true));
    minValueSpinner.createUI();
    FieldPanel fieldPanel = minValueSpinner.getPanel();
    dataPanel.add(fieldPanel);
    JButton resetValueButton = new JButton(Localisation.getString(ColourRampConfigPanel.class, "ColourRampPanel.reset"));
    minValueSpinner.addUI(resetValueButton, 20, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
    minValueSpinner.populateField(0);
    resetValueButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (parentObj != null) {
                ColourMapModel model = parentObj.getColourMapModel();
                populate(model.getColourMap());
            }
        }
    });
    maxValueSpinner = new FieldConfigInteger(new FieldConfigCommonData(getClass(), FieldIdEnum.UNKNOWN, Localisation.getField(ColourRampConfigPanel.class, "ColourRampPanel.maxValue"), true));
    maxValueSpinner.createUI();
    maxValueSpinner.populateField(100);
    dataPanel.add(maxValueSpinner.getPanel());
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
    buttonPanel.setSize(BasePanel.FIELD_PANEL_WIDTH, BasePanel.WIDGET_HEIGHT);
    JButton applyButton = new JButton(Localisation.getString(ColourRampConfigPanel.class, "common.apply"));
    applyButton.setPreferredSize(new Dimension(BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT));
    applyButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (parentObj != null) {
                ColourRampData data = new ColourRampData();
                data.setMaxValue(maxValueSpinner.getIntValue());
                data.setMinValue(minValueSpinner.getIntValue());
                data.setReverseColours(reverseCheckbox.isSelected());
                ValueComboBoxData selectedItem = (ValueComboBoxData) rampComboBox.getSelectedItem();
                ColourRamp colourRamp = colourRampCache.get(selectedItem.getKey());
                data.setColourRamp(colourRamp);
                parentObj.colourRampUpdate(data);
            }
        }
    });
    buttonPanel.add(applyButton);
    dataPanel.add(buttonPanel);
}
Also used : JPanel(javax.swing.JPanel) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) XMLTwoColourRamp(com.sldeditor.common.xml.ui.XMLTwoColourRamp) ColourRamp(com.sldeditor.colourramp.ColourRamp) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) ColourRampConfigPanel(com.sldeditor.colourramp.ColourRampConfigPanel) ColourMapModel(com.sldeditor.ui.detail.config.colourmap.ColourMapModel)

Aggregations

ColourRamp (com.sldeditor.colourramp.ColourRamp)1 ColourRampConfigPanel (com.sldeditor.colourramp.ColourRampConfigPanel)1 XMLTwoColourRamp (com.sldeditor.common.xml.ui.XMLTwoColourRamp)1 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)1 FieldConfigInteger (com.sldeditor.ui.detail.config.FieldConfigInteger)1 ColourMapModel (com.sldeditor.ui.detail.config.colourmap.ColourMapModel)1 FieldPanel (com.sldeditor.ui.widgets.FieldPanel)1 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)1 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 FlowLayout (java.awt.FlowLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 BoxLayout (javax.swing.BoxLayout)1 JButton (javax.swing.JButton)1 JPanel (javax.swing.JPanel)1