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 FieldConfigSliderTest method testGenerateExpression.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSlider#generateExpression()}. Test method
* for
* {@link com.sldeditor.ui.detail.config.FieldConfigSlider#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSlider#populateField(java.lang.Double)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSlider#setTestValue(com.sldeditor.ui.detail.config.FieldId, double)}.
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigSlider#getDoubleValue()}.
*/
@Test
public void testGenerateExpression() {
boolean valueOnly = true;
FieldConfigSlider field = new FieldConfigSlider(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
double defaultDefaultValue = 0.5;
double expectedValue = 1.0;
field.populateField(expectedValue);
double actualValue = field.getDoubleValue();
assertTrue(Math.abs(actualValue - defaultDefaultValue) < 0.001);
field.setTestValue(null, expectedValue);
actualValue = field.getDoubleValue();
assertTrue(Math.abs(actualValue - defaultDefaultValue) < 0.001);
field.populateExpression(null);
actualValue = field.getDoubleValue();
assertTrue(Math.abs(actualValue - defaultDefaultValue) < 0.001);
field.createUI();
field.populateField(expectedValue);
actualValue = field.getDoubleValue();
assertTrue(Math.abs(actualValue - expectedValue) < 0.001);
double expectedValue2 = 0.14;
field.setTestValue(null, expectedValue2);
actualValue = field.getDoubleValue();
assertTrue(Math.abs(actualValue - expectedValue2) < 0.001);
Integer expectedValue3a = Integer.valueOf(1);
field.populateExpression(expectedValue3a);
actualValue = field.getDoubleValue();
assertTrue(Math.abs(actualValue - expectedValue3a) < 0.001);
Double expectedValue3c = Double.valueOf(0.4);
field.populateExpression(expectedValue3c);
actualValue = field.getDoubleValue();
assertTrue(Math.abs(actualValue - expectedValue3c) < 0.001);
double expectedValue3d = 0.87;
String expectedValue3dString = String.valueOf(expectedValue3d);
field.populateExpression(expectedValue3dString);
actualValue = field.getDoubleValue();
assertTrue(Math.abs(actualValue - expectedValue3d) < 0.001);
}
use of com.sldeditor.ui.detail.config.FieldConfigSlider in project sldeditor by robward-scisys.
the class FieldConfigSliderTest method testRevertToDefaultValue.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSlider#revertToDefaultValue()}. Test method
* for {@link com.sldeditor.ui.detail.config.FieldConfigSlider#setDefaultValue(double)}.
*/
@Test
public void testRevertToDefaultValue() {
boolean valueOnly = true;
FieldConfigSlider field = new FieldConfigSlider(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
double defaultDefaultValue = 0.5;
field.revertToDefaultValue();
assertTrue(Math.abs(field.getDoubleValue() - defaultDefaultValue) < 0.001);
field.createUI();
field.createUI();
Double expectedDefaultValue = 0.42;
field.setDefaultValue(expectedDefaultValue);
field.revertToDefaultValue();
assertTrue(Math.abs(field.getDoubleValue() - expectedDefaultValue) < 0.001);
assertTrue(String.valueOf(expectedDefaultValue).compareTo(field.getStringValue()) == 0);
}
use of com.sldeditor.ui.detail.config.FieldConfigSlider in project sldeditor by robward-scisys.
the class FieldConfigSliderTest method testAttributeSelection.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSlider#attributeSelection(java.lang.String)}.
*/
@Test
public void testAttributeSelection() {
boolean valueOnly = true;
FieldConfigSlider field = new FieldConfigSlider(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
field.attributeSelection(null);
// Do nothing
}
use of com.sldeditor.ui.detail.config.FieldConfigSlider in project sldeditor by robward-scisys.
the class FieldConfigMarkerTest method testSetValue.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker#setValue(com.sldeditor.ui.detail.GraphicPanelFieldManager, com.sldeditor.ui.detail.config.FieldConfigSymbolType, org.opengis.style.GraphicalSymbol)}.
*/
@Test
public void testSetValue() {
GraphicPanelFieldManager fieldConfigManager = null;
Class<?> panelId = PointFillDetails.class;
fieldConfigManager = new GraphicPanelFieldManager(panelId);
// Test it with non null values
FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
FieldConfigColour colourField = new FieldConfigColour(new FieldConfigCommonData(panelId, colourFieldId, "", false));
colourField.createUI();
String expectedColourValue = "#012345";
colourField.setTestValue(null, expectedColourValue);
double expectedOpacityValue = 0.72;
FieldConfigSlider opacityField = new FieldConfigSlider(new FieldConfigCommonData(panelId, colourFieldId, "", false));
opacityField.createUI();
opacityField.populateField(expectedOpacityValue);
FieldConfigBase symbolSelectionField = new FieldConfigSymbolType(new FieldConfigCommonData(panelId, colourFieldId, "", 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);
boolean valueOnly = true;
ColourFieldConfig fillConfig = new ColourFieldConfig(GroupIdEnum.FILL, FieldIdEnum.FILL_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_WIDTH);
ColourFieldConfig strokeConfig = new ColourFieldConfig(GroupIdEnum.STROKE, FieldIdEnum.STROKE_STROKE_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_FILL_WIDTH);
FieldConfigMarker field2 = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), fillConfig, strokeConfig, null);
field2.setValue(null, null, null, null, null);
field2.setValue(null, fieldConfigManager, null, null, null);
StyleBuilder styleBuilder = new StyleBuilder();
Mark marker = styleBuilder.createMark("star");
field2.setValue(null, null, null, null, marker);
field2.setValue(null, fieldConfigManager, null, null, marker);
}
Aggregations