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);
}
Aggregations