use of com.sldeditor.ui.detail.config.FieldConfigSlider in project sldeditor by robward-scisys.
the class ColourMapEntryPanel method createUI.
/**
* Creates the UI.
*
* @param panelId the panel id
*/
private void createUI(Class<?> panelId) {
TitledBorder title = BorderFactory.createTitledBorder(Localisation.getString(FieldConfigBase.class, "ColourMapEntryPanel.title"));
setBorder(title);
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
label = new FieldConfigString(new FieldConfigCommonData(panelId, FieldIdEnum.RASTER_COLOURMAP_ENTRY_LABEL, Localisation.getField(FieldConfigBase.class, "ColourMapEntryPanel.label"), true, true, true), null);
label.createUI();
label.addDataChangedListener(this);
fieldList.add(label);
add(label.getPanel());
colour = new FieldConfigColour(new FieldConfigCommonData(panelId, FieldIdEnum.RASTER_COLOURMAP_ENTRY_COLOUR, Localisation.getField(FieldConfigBase.class, "ColourMapEntryPanel.colour"), false, true, true));
colour.createUI();
colour.addDataChangedListener(this);
fieldList.add(colour);
add(colour.getPanel());
opacity = new FieldConfigSlider(new FieldConfigCommonData(panelId, FieldIdEnum.RASTER_COLOURMAP_ENTRY_OPACITY, Localisation.getField(FieldConfigBase.class, "ColourMapEntryPanel.opacity"), false, true, true));
opacity.createUI();
opacity.addDataChangedListener(this);
fieldList.add(opacity);
add(opacity.getPanel());
quantity = new FieldConfigDouble(new FieldConfigCommonData(panelId, FieldIdEnum.RASTER_COLOURMAP_ENTRY_QUANTITY, Localisation.getField(FieldConfigBase.class, "ColourMapEntryPanel.quantity"), false, true, true));
quantity.createUI();
quantity.addDataChangedListener(this);
fieldList.add(quantity);
add(quantity.getPanel());
JPanel buttonPanel = new JPanel();
//
// Apply button
//
applyButton = new JButton(Localisation.getString(FieldConfigBase.class, "common.apply"));
applyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (parentObj != null) {
ColourMapData data = new ColourMapData();
data.setLabel(label.getStringValue());
data.setColour(colour.getColourExpression());
data.setOpacity(opacity.getExpression());
data.setQuantity(quantity.getExpression());
parentObj.colourMapEntryUpdated(data);
}
}
});
buttonPanel.add(applyButton);
//
// Cancel button
//
cancelButton = new JButton(Localisation.getString(FieldConfigBase.class, "common.cancel"));
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});
buttonPanel.add(cancelButton);
add(buttonPanel);
}
use of com.sldeditor.ui.detail.config.FieldConfigSlider in project sldeditor by robward-scisys.
the class ColourMapEntryPanel method createUI.
/**
* Creates the UI.
*
* @param panelId the panel id
* @param suppressUndoEvents the suppress undo events
*/
private void createUI(Class<?> panelId, boolean suppressUndoEvents) {
TitledBorder title = BorderFactory.createTitledBorder(Localisation.getString(FieldConfigBase.class, "ColourMapEntryPanel.title"));
setBorder(title);
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
label = new FieldConfigString(new FieldConfigCommonData(panelId, FieldIdEnum.RASTER_COLOURMAP_ENTRY_LABEL, Localisation.getField(FieldConfigBase.class, "ColourMapEntryPanel.label"), true, true, true), null);
label.createUI();
label.addDataChangedListener(this);
fieldList.add(label);
add(label.getPanel());
colour = new FieldConfigColour(new FieldConfigCommonData(panelId, FieldIdEnum.RASTER_COLOURMAP_ENTRY_COLOUR, Localisation.getField(FieldConfigBase.class, "ColourMapEntryPanel.colour"), false, true, suppressUndoEvents));
colour.createUI();
colour.addDataChangedListener(this);
fieldList.add(colour);
add(colour.getPanel());
opacity = new FieldConfigSlider(new FieldConfigCommonData(panelId, FieldIdEnum.RASTER_COLOURMAP_ENTRY_OPACITY, Localisation.getField(FieldConfigBase.class, "ColourMapEntryPanel.opacity"), false, true, suppressUndoEvents));
opacity.createUI();
opacity.addDataChangedListener(this);
fieldList.add(opacity);
add(opacity.getPanel());
quantity = new FieldConfigDouble(new FieldConfigCommonData(panelId, FieldIdEnum.RASTER_COLOURMAP_ENTRY_QUANTITY, Localisation.getField(FieldConfigBase.class, "ColourMapEntryPanel.quantity"), false, true, suppressUndoEvents));
quantity.createUI();
quantity.addDataChangedListener(this);
fieldList.add(quantity);
add(quantity.getPanel());
JPanel buttonPanel = new JPanel();
//
// Apply button
//
applyButton = new JButton(Localisation.getString(FieldConfigBase.class, "common.apply"));
applyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (parentObj != null) {
ColourMapData data = new ColourMapData();
data.setLabel(label.getStringValue());
data.setColour(colour.getColourExpression());
data.setOpacity(opacity.getExpression());
data.setQuantity(quantity.getExpression());
parentObj.colourMapEntryUpdated(data);
}
}
});
buttonPanel.add(applyButton);
//
// Cancel button
//
JButton cancelButton = new JButton(Localisation.getString(FieldConfigBase.class, "common.cancel"));
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});
buttonPanel.add(cancelButton);
add(buttonPanel);
}
use of com.sldeditor.ui.detail.config.FieldConfigSlider in project sldeditor by robward-scisys.
the class InstantiateFields method addFieldSlider.
/**
* Adds the field slider.
*
* @param fieldData the field data
* @return the field config base
*/
private FieldConfigBase addFieldSlider(FieldData fieldData) {
XMLFieldConfigSlider xmlSlider = (XMLFieldConfigSlider) fieldData.getXmlFieldConfig();
FieldConfigSlider sliderConfig = new FieldConfigSlider(fieldData.getCommonData());
sliderConfig.setDefaultValue(xmlSlider.getDefaultValue());
Double defaultValueObj = ConfigDefaultFactory.getDouble(fieldData.getDefaultValue());
if (defaultValueObj != null) {
sliderConfig.setDefaultValue(defaultValueObj);
defaultFieldMap.put(fieldData.getId(), defaultValueObj);
}
return sliderConfig;
}
use of com.sldeditor.ui.detail.config.FieldConfigSlider in project sldeditor by robward-scisys.
the class FieldConfigWindBarbsTest method testGetValue.
/**
* Test method for {@link
* com.sldeditor.ui.detail.vendor.geoserver.marker.windbarb.FieldConfigWindBarbs#getValue(com.sldeditor.ui.detail.GraphicPanelFieldManager,
* org.opengis.filter.expression.Expression, boolean, boolean)}.
*/
@Test
public void testGetValue() {
// Test it with null values
boolean valueOnly = true;
FieldConfigWindBarbs field = new FieldConfigWindBarbs(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly, false), null, null, null);
field.createUI();
assertNull(field.getStringValue());
GraphicPanelFieldManager fieldConfigManager = null;
Expression symbolType = null;
List<GraphicalSymbol> actualValue = field.getValue(fieldConfigManager, symbolType, false, false);
assertTrue(actualValue.isEmpty());
Class<?> panelId = PointFillDetails.class;
fieldConfigManager = new GraphicPanelFieldManager(panelId);
String actualMarkerSymbol = "solid";
StyleBuilder styleBuilder = new StyleBuilder();
symbolType = styleBuilder.literalExpression(actualMarkerSymbol);
FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
FieldConfigColour colourField = new FieldConfigColour(new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
colourField.createUI();
String expectedColourValue = "#012345";
colourField.setTestValue(null, expectedColourValue);
double expectedOpacityValue = 0.72;
FieldConfigSlider opacityField = new FieldConfigSlider(new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
opacityField.createUI();
opacityField.populateField(expectedOpacityValue);
FieldConfigBase symbolSelectionField = new FieldConfigSymbolType(new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
symbolSelectionField.createUI();
fieldConfigManager.add(colourFieldId, colourField);
FieldIdEnum opacityFieldId = FieldIdEnum.OVERALL_OPACITY;
fieldConfigManager.add(opacityFieldId, opacityField);
FieldIdEnum symbolSelectionFieldId = FieldIdEnum.SYMBOL_TYPE;
fieldConfigManager.add(symbolSelectionFieldId, symbolSelectionField);
// Try without setting any fields
actualValue = field.getValue(fieldConfigManager, symbolType, false, false);
assertNotNull(actualValue);
assertEquals(1, actualValue.size());
Mark actualSymbol = (Mark) actualValue.get(0);
assertTrue(actualSymbol.getWellKnownName().toString().compareTo("windbarbs://default(0)[m/s]") == 0);
}
use of com.sldeditor.ui.detail.config.FieldConfigSlider in project sldeditor by robward-scisys.
the class FieldConfigMarkerTest method testPopulateFieldOverrideMap.
/**
* Test method for {@link
* com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker#populateFieldOverrideMap(java.lang.Class,
* com.sldeditor.ui.detail.FieldEnableState)}.
*/
@Test
public void testPopulateFieldOverrideMap() {
// Test it with non null values
FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
Class<?> panelId = PointFillDetails.class;
FieldConfigColour colourField = new FieldConfigColour(new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
colourField.createUI();
String expectedColourValue = "#012345";
colourField.setTestValue(null, expectedColourValue);
double expectedOpacityValue = 0.72;
FieldConfigSlider opacityField = new FieldConfigSlider(new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
opacityField.createUI();
opacityField.populateField(expectedOpacityValue);
FieldConfigBase symbolSelectionField = new FieldConfigSymbolType(new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
symbolSelectionField.createUI();
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(panelId);
fieldConfigManager.add(colourFieldId, colourField);
FieldIdEnum opacityFieldId = FieldIdEnum.OVERALL_OPACITY;
fieldConfigManager.add(opacityFieldId, opacityField);
FieldIdEnum symbolSelectionFieldId = FieldIdEnum.SYMBOL_TYPE;
fieldConfigManager.add(symbolSelectionFieldId, symbolSelectionField);
ColourFieldConfig strokeConfig = new ColourFieldConfig(GroupIdEnum.STROKE, FieldIdEnum.STROKE_STROKE_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_FILL_WIDTH);
boolean valueOnly = true;
ColourFieldConfig fillConfig = new ColourFieldConfig(GroupIdEnum.FILL, FieldIdEnum.FILL_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_WIDTH);
FieldConfigMarker field = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly, false), fillConfig, strokeConfig, null);
field.populateFieldOverrideMap(String.class, null);
field.populateFieldOverrideMap(PointSymbolizerDetails.class, null);
}
Aggregations