use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class FieldConfigEnumTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigEnum#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigEnum#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
SymbolTypeConfig s1 = new SymbolTypeConfig(null);
s1.addOption("key1", "Value 1");
s1.addOption("key2", "Value 2");
s1.addOption("key3", "Value 3");
s1.addField(FieldIdEnum.ANCHOR_POINT_H, true);
s1.addField(FieldIdEnum.ANCHOR_POINT_V, false);
List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
configList.add(s1);
SymbolTypeConfig s2 = new SymbolTypeConfig(null);
s2.addOption("key4", "Value 4");
s2.addOption("key5", "Value 5");
s2.addOption("key6", "Value 6");
s2.addField(FieldIdEnum.ANGLE, true);
s2.addField(FieldIdEnum.DESCRIPTION, false);
configList.add(s2);
boolean valueOnly = true;
FieldConfigEnum field = new FieldConfigEnum(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
field.addConfig(null);
assertNull(field.getStringValue());
field.addConfig(configList);
// Now create the ui
field.createUI();
String expectedValue1 = "key2";
field.populateField(expectedValue1);
String expectedValue2 = "key6";
field.populateField(expectedValue2);
UndoManager.getInstance().undo();
String actualValueString = field.getStringValue();
assertTrue(expectedValue1.compareTo(actualValueString) == 0);
ValueComboBoxData actualValue = field.getEnumValue();
assertTrue(expectedValue1.compareTo(actualValue.getKey()) == 0);
UndoManager.getInstance().redo();
actualValueString = field.getStringValue();
assertTrue(expectedValue2.compareTo(actualValueString) == 0);
actualValue = field.getEnumValue();
assertTrue(expectedValue2.compareTo(actualValue.getKey()) == 0);
// Increase the code coverage
field.undoAction(null);
field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(23)));
field.redoAction(null);
field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(54)));
}
use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class FieldConfigMarkerTest method testAccept.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker#accept(org.opengis.style.GraphicalSymbol)}.
*/
@Test
public void testAccept() {
boolean valueOnly = true;
FieldConfigMarker field = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), null, null, null);
assertFalse(field.accept(null));
StyleBuilder styleBuilder = new StyleBuilder();
ExternalGraphicImpl externalGraphic = (ExternalGraphicImpl) styleBuilder.createExternalGraphic("test.tmp", "png");
assertFalse(field.accept(externalGraphic));
Mark marker = styleBuilder.createMark("triangle");
assertFalse(field.accept(marker));
List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();
dataList.add(new ValueComboBoxData("star", "Star", this.getClass()));
dataList.add(new ValueComboBoxData("square", "Square", this.getClass()));
dataList.add(new ValueComboBoxData("triangle", "Triangle", this.getClass()));
List<ValueComboBoxDataGroup> groupList = new ArrayList<ValueComboBoxDataGroup>();
groupList.add(new ValueComboBoxDataGroup(dataList));
field.populateSymbolList(String.class, groupList);
field.populateSymbolList(PointFillDetails.class, groupList);
assertTrue(field.accept(marker));
field.populateSymbolList(PointFillDetails.class, groupList);
assertTrue(field.accept(marker));
}
use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class FieldConfigSymbolTypeTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
UndoManager.getInstance().setPopulationCheck(Controller.getInstance());
boolean valueOnly = true;
FieldConfigSymbolType field = new FieldConfigSymbolType(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
field.undoAction(null);
field.redoAction(null);
field.createUI();
field.createUI();
FieldConfigMarker marker = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.ANGLE, "label", valueOnly), null, null, null);
marker.createUI();
List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();
dataList.add(new ValueComboBoxData("key 1", "Value 1", FieldConfigMarker.class));
dataList.add(new ValueComboBoxData("key 2", "Value 2", FieldConfigMarker.class));
dataList.add(new ValueComboBoxData("key 3", "Value 3", FieldConfigMarker.class));
List<ValueComboBoxDataGroup> combinedSymbolList = new ArrayList<ValueComboBoxDataGroup>();
combinedSymbolList.add(new ValueComboBoxDataGroup(dataList));
field.createUI();
field.addField(marker);
field.populate(null, combinedSymbolList);
String expectedValue2 = "key 2";
field.populateExpression(expectedValue2);
String actualValue2 = field.getStringValue();
assertTrue(actualValue2.compareTo(field.getStringValue()) == 0);
ValueComboBoxData actualValueObj2 = field.getEnumValue();
assertNotNull(actualValueObj2.getKey());
assertTrue(actualValueObj2.getKey().compareTo(expectedValue2) == 0);
String expectedValue3 = "key 1";
field.populateField(expectedValue3);
String actualValue3 = field.getStringValue();
assertTrue(expectedValue3.compareTo(actualValue3) == 0);
String expectedValue4 = "key 3";
field.populateField(expectedValue4);
String actualValue4 = field.getStringValue();
assertTrue(expectedValue4.compareTo(actualValue4) == 0);
UndoManager.getInstance().undo();
String actualValue = field.getStringValue();
assertTrue(expectedValue3.compareTo(actualValue) == 0);
UndoManager.getInstance().redo();
actualValue = field.getStringValue();
assertTrue(expectedValue4.compareTo(actualValue) == 0);
// Increase the code coverage
field.undoAction(null);
field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(23)));
field.redoAction(null);
field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(54)));
UndoManager.getInstance().setPopulationCheck(null);
}
use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class RasterSymbolizerDetails method updateSymbol.
/**
* Update symbol.
*/
private void updateSymbol() {
// Contrast enhancement
Expression gammaValueExpression = fieldConfigVisitor.getExpression(FieldIdEnum.RASTER_CONTRAST_GAMMAVALUE);
ContrastEnhancement contrastEnhancement = null;
GroupConfigInterface group = getGroup(GroupIdEnum.RASTER_CONTRAST);
if (group.isPanelEnabled()) {
String method = null;
group = getGroup(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD);
if (group != null) {
MultiOptionGroup contrastNormalizeMethodGroup = (MultiOptionGroup) group;
OptionGroup selectedOption = contrastNormalizeMethodGroup.getSelectedOptionGroup();
if (selectedOption != null) {
method = selectedOption.getLabel();
}
}
contrastEnhancement = (ContrastEnhancement) getStyleFactory().contrastEnhancement(gammaValueExpression, method);
}
// Colour map
ColorMap colorMap = fieldConfigVisitor.getColourMap(FieldIdEnum.RASTER_COLOURMAP);
ValueComboBoxData colourMapType = fieldConfigVisitor.getComboBox(FieldIdEnum.RASTER_COLOURMAP_TYPE);
colorMap.setType(Integer.valueOf(colourMapType.getKey()));
// Channel selection
ChannelSelection channelSelection = null;
group = getGroup(GroupIdEnum.RASTER_CHANNELSELECTION);
if (group != null) {
if (group.isPanelEnabled()) {
MultiOptionGroup contrastEnhancementGroup = (MultiOptionGroup) group;
OptionGroup selectedOption = contrastEnhancementGroup.getSelectedOptionGroup();
if (selectedOption.getId() == GroupIdEnum.RASTER_GREY_CHANNEL_OPTION) {
// Grey option group
SelectedChannelType greyChannel = extractContrastEnhancementGroup(GroupIdEnum.RASTER_GREY_CHANNEL, FieldIdEnum.RASTER_RGB_GREY_NAME, GroupIdEnum.RASTER_RGB_CHANNEL_GREY_CONTRAST, FieldIdEnum.RASTER_RGB_CHANNEL_GREY_CONTRAST_GAMMA, GroupIdEnum.RASTER_RGB_CHANNEL_GREY_CONTRAST_METHOD);
channelSelection = getStyleFactory().channelSelection(greyChannel);
} else {
SelectedChannelType redChannel = extractContrastEnhancementGroup(GroupIdEnum.RASTER_RGB_CHANNEL_RED, FieldIdEnum.RASTER_RGB_RED_NAME, GroupIdEnum.RASTER_RGB_CHANNEL_RED_CONTRAST, FieldIdEnum.RASTER_RGB_CHANNEL_RED_CONTRAST_GAMMA, GroupIdEnum.RASTER_RGB_CHANNEL_RED_CONTRAST_METHOD);
SelectedChannelType greenChannel = extractContrastEnhancementGroup(GroupIdEnum.RASTER_RGB_CHANNEL_GREEN, FieldIdEnum.RASTER_RGB_GREEN_NAME, GroupIdEnum.RASTER_RGB_CHANNEL_GREEN_CONTRAST, FieldIdEnum.RASTER_RGB_CHANNEL_GREEN_CONTRAST_GAMMA, GroupIdEnum.RASTER_RGB_CHANNEL_GREEN_CONTRAST_METHOD);
SelectedChannelType blueChannel = extractContrastEnhancementGroup(GroupIdEnum.RASTER_RGB_CHANNEL_BLUE, FieldIdEnum.RASTER_RGB_BLUE_NAME, GroupIdEnum.RASTER_RGB_CHANNEL_BLUE_CONTRAST, FieldIdEnum.RASTER_RGB_CHANNEL_BLUE_CONTRAST_GAMMA, GroupIdEnum.RASTER_RGB_CHANNEL_BLUE_CONTRAST_METHOD);
SelectedChannelType[] channels = new SelectedChannelType[3];
channels[0] = redChannel;
channels[1] = greenChannel;
channels[2] = blueChannel;
channelSelection = getStyleFactory().createChannelSelection(channels);
}
}
}
//
// Overlap
//
OverlapBehavior overlapBehavior = null;
group = getGroup(GroupIdEnum.RASTER_OVERLAP);
if (group.isPanelEnabled()) {
ValueComboBoxData overlapBehaviorValue = fieldConfigVisitor.getComboBox(FieldIdEnum.RASTER_OVERLAP_BEHAVIOUR);
overlapBehavior = OverlapBehavior.valueOf(overlapBehaviorValue.getKey());
}
//
// Shaded relief
//
ShadedRelief shadedRelief = null;
group = getGroup(GroupIdEnum.RASTER_SHADEDRELIEF);
if (group.isPanelEnabled()) {
shadedRelief = new ShadedReliefImpl();
shadedRelief.setBrightnessOnly(fieldConfigVisitor.getBoolean(FieldIdEnum.RASTER_SHADEDRELIEF_BRIGHTNESS));
shadedRelief.setReliefFactor(fieldConfigVisitor.getExpression(FieldIdEnum.RASTER_SHADEDRELIEF_FACTOR));
}
Symbolizer symbolizer = null;
StandardData standardData = getStandardData();
Expression opacityExpression = fieldConfigVisitor.getExpression(FieldIdEnum.RASTER_OPACITY);
// Geometry field
Expression geometryField = ExtractGeometryField.getGeometryField(fieldConfigVisitor);
RasterSymbolizer rasterSymbolizer = (RasterSymbolizer) getStyleFactory().rasterSymbolizer(standardData.name, geometryField, standardData.description, standardData.unit, opacityExpression, channelSelection, overlapBehavior, colorMap, contrastEnhancement, shadedRelief, symbolizer);
if (vendorOptionRasterFactory != null) {
vendorOptionRasterFactory.updateSymbol(rasterSymbolizer);
}
rasterSymbolizer.setOverlapBehavior(overlapBehavior);
SelectedSymbol.getInstance().replaceSymbolizer(rasterSymbolizer);
this.fireUpdateSymbol();
}
Aggregations