use of com.sldeditor.ui.detail.config.base.MultiOptionGroup in project sldeditor by robward-scisys.
the class VOGeoServerContrastEnhancementNormalizeBlueTest method testVOGeoServerContrastEnhancementNormalizeBlue.
/**
* Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeBlue#VOGeoServerContrastEnhancementNormalizeBlue(java.lang.Class, com.sldeditor.ui.detail.RasterSymbolizerDetails)}.
* Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeBlue#getContrastEnhancement(com.sldeditor.common.xml.ui.GroupIdEnum, org.geotools.styling.ChannelSelection)}.
*/
@Test
public void testVOGeoServerContrastEnhancementNormalizeBlue() {
RasterSymbolizerDetails panel = new RasterSymbolizerDetails();
VOGeoServerContrastEnhancementNormalizeBlue testObj = new VOGeoServerContrastEnhancementNormalizeBlue(panel.getClass(), panel);
RasterSymbolizer rasterSymbolizer = null;
testObj.setParentPanel(panel);
testObj.populate(rasterSymbolizer);
testObj.updateSymbol(rasterSymbolizer);
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
rasterSymbolizer = styleFactory.createRasterSymbolizer();
GroupConfigInterface constrastMethodGroup = panel.getGroup(GroupIdEnum.RASTER_RGB_CHANNEL_BLUE_CONTRAST_METHOD);
assertNotNull(constrastMethodGroup);
MultiOptionGroup constrastMethodGroup2 = (MultiOptionGroup) constrastMethodGroup;
Box box = Box.createVerticalBox();
constrastMethodGroup2.createUI(panel.getFieldDataManager(), box, panel, panel.getPanelId());
constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_LOGARITHMIC);
ChannelSelection channelSelection = createChannelSelection(styleFactory, ContrastMethod.LOGARITHMIC);
rasterSymbolizer.setChannelSelection(channelSelection);
testObj.populate(rasterSymbolizer);
SelectedSymbol.getInstance().setSymbolizer(rasterSymbolizer);
Controller.getInstance().setPopulating(true);
panel.populate(SelectedSymbol.getInstance());
Controller.getInstance().setPopulating(false);
testObj.updateSymbol(rasterSymbolizer);
channelSelection = createChannelSelection(styleFactory, ContrastMethod.EXPONENTIAL);
rasterSymbolizer.setChannelSelection(channelSelection);
constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_EXPONENTIAL);
testObj.populate(rasterSymbolizer);
testObj.updateSymbol(rasterSymbolizer);
channelSelection = createChannelSelection(styleFactory, ContrastMethod.HISTOGRAM);
rasterSymbolizer.setChannelSelection(channelSelection);
constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_HISTOGRAM);
testObj.populate(rasterSymbolizer);
testObj.updateSymbol(rasterSymbolizer);
channelSelection = createChannelSelection(styleFactory, ContrastMethod.NORMALIZE);
constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_NORMALIZE);
rasterSymbolizer.setChannelSelection(channelSelection);
testObj.populate(rasterSymbolizer);
testObj.updateSymbol(rasterSymbolizer);
// Error
channelSelection = createChannelSelectionError(styleFactory, ContrastMethod.NORMALIZE);
rasterSymbolizer.setChannelSelection(channelSelection);
testObj.populate(rasterSymbolizer);
testObj.updateSymbol(rasterSymbolizer);
// Increase code coverage
testObj.populate((SelectedSymbol) null);
testObj.populate((TextSymbolizer) null);
testObj.populate((PolygonSymbolizer) null);
testObj.updateSymbol((TextSymbolizer) null);
testObj.updateSymbol((PolygonSymbolizer) null);
testObj.preLoadSymbol();
assertTrue(testObj.isDataPresent());
testObj.dataChanged(FieldIdEnum.DESCRIPTION);
}
use of com.sldeditor.ui.detail.config.base.MultiOptionGroup in project sldeditor by robward-scisys.
the class VOGeoServerContrastEnhancementNormalizeGreyTest method testVOGeoServerContrastEnhancementNormalizeGrey.
/**
* Test method for
* {@link com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGrey#VOGeoServerContrastEnhancementNormalizeGrey(java.lang.Class, com.sldeditor.ui.detail.RasterSymbolizerDetails)}.
* Test method for
* {@link com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGrey#getContrastEnhancement(com.sldeditor.common.xml.ui.GroupIdEnum, org.geotools.styling.ChannelSelection)}.
*/
@Test
public void testVOGeoServerContrastEnhancementNormalizeGrey() {
RasterSymbolizerDetails panel = new RasterSymbolizerDetails();
VOGeoServerContrastEnhancementNormalizeGrey testObj = new VOGeoServerContrastEnhancementNormalizeGrey(panel.getClass(), panel);
RasterSymbolizer rasterSymbolizer = null;
testObj.setParentPanel(panel);
testObj.populate(rasterSymbolizer);
testObj.updateSymbol(rasterSymbolizer);
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
rasterSymbolizer = styleFactory.createRasterSymbolizer();
GroupConfigInterface constrastMethodGroup = panel.getGroup(GroupIdEnum.RASTER_RGB_CHANNEL_GREY_CONTRAST_METHOD);
assertNotNull(constrastMethodGroup);
MultiOptionGroup constrastMethodGroup2 = (MultiOptionGroup) constrastMethodGroup;
Box box = Box.createVerticalBox();
constrastMethodGroup2.createUI(panel.getFieldDataManager(), box, panel, panel.getPanelId());
constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_LOGARITHMIC);
ChannelSelection channelSelection = createChannelSelection(styleFactory, ContrastMethod.LOGARITHMIC);
rasterSymbolizer.setChannelSelection(channelSelection);
testObj.populate(rasterSymbolizer);
SelectedSymbol.getInstance().setSymbolizer(rasterSymbolizer);
Controller.getInstance().setPopulating(true);
panel.populate(SelectedSymbol.getInstance());
Controller.getInstance().setPopulating(false);
testObj.updateSymbol(rasterSymbolizer);
channelSelection = createChannelSelection(styleFactory, ContrastMethod.EXPONENTIAL);
rasterSymbolizer.setChannelSelection(channelSelection);
constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_EXPONENTIAL);
testObj.populate(rasterSymbolizer);
testObj.updateSymbol(rasterSymbolizer);
channelSelection = createChannelSelection(styleFactory, ContrastMethod.HISTOGRAM);
rasterSymbolizer.setChannelSelection(channelSelection);
constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_HISTOGRAM);
testObj.populate(rasterSymbolizer);
testObj.updateSymbol(rasterSymbolizer);
channelSelection = createChannelSelection(styleFactory, ContrastMethod.NORMALIZE);
constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_NORMALIZE);
rasterSymbolizer.setChannelSelection(channelSelection);
testObj.populate(rasterSymbolizer);
testObj.updateSymbol(rasterSymbolizer);
// Error
channelSelection = createChannelSelectionError(styleFactory, ContrastMethod.NORMALIZE);
rasterSymbolizer.setChannelSelection(channelSelection);
testObj.populate(rasterSymbolizer);
testObj.updateSymbol(rasterSymbolizer);
// Increase code coverage
testObj.populate((SelectedSymbol) null);
testObj.populate((TextSymbolizer) null);
testObj.populate((PolygonSymbolizer) null);
testObj.updateSymbol((TextSymbolizer) null);
testObj.updateSymbol((PolygonSymbolizer) null);
testObj.preLoadSymbol();
assertTrue(testObj.isDataPresent());
testObj.dataChanged(FieldIdEnum.DESCRIPTION);
}
use of com.sldeditor.ui.detail.config.base.MultiOptionGroup in project sldeditor by robward-scisys.
the class RasterSymbolizerDetails method populateContrastMethod.
/**
* Populate contrast method.
*
* @param contrastEnhancement the contrast enhancement
* @param contrastMethodGroup the contrast method group
*/
private void populateContrastMethod(ContrastEnhancement contrastEnhancement, GroupIdEnum contrastMethodGroup) {
GroupConfigInterface group = getGroup(contrastMethodGroup);
if (group != null) {
GroupIdEnum selectedNormalizeMethod = GroupIdEnum.UNKNOWN;
MultiOptionGroup contrastNormalizeMethodGroup = (MultiOptionGroup) group;
if (contrastEnhancement != null) {
ContrastMethod contrastMethod = contrastEnhancement.getMethod();
if (contrastMethod != null) {
String contrastMethodString = contrastMethod.name();
for (OptionGroup option : contrastNormalizeMethodGroup.getGroupList()) {
if (option.getLabel().compareToIgnoreCase(contrastMethodString) == 0) {
selectedNormalizeMethod = option.getId();
}
}
}
}
contrastNormalizeMethodGroup.setOption(selectedNormalizeMethod);
}
}
use of com.sldeditor.ui.detail.config.base.MultiOptionGroup 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();
}
use of com.sldeditor.ui.detail.config.base.MultiOptionGroup in project sldeditor by robward-scisys.
the class RasterSymbolizerDetails method extractContrastEnhancementGroup.
/**
* Extract contrast enhancement group.
*
* @param channelGroup the channel group
* @param nameField the name field
* @param contrastGroup the contrast group
* @param gammaField the gamma field
* @param contrastMethod the contrast method
* @return the selected channel type
*/
private SelectedChannelType extractContrastEnhancementGroup(GroupIdEnum channelGroup, FieldIdEnum nameField, GroupIdEnum contrastGroup, FieldIdEnum gammaField, GroupIdEnum contrastMethod) {
SelectedChannelType channelType = null;
GroupConfigInterface group = getGroup(channelGroup);
if (group.isPanelEnabled()) {
String channelName = fieldConfigVisitor.getText(nameField);
GroupConfigInterface contrastGrp = getGroup(contrastGroup);
ContrastEnhancement contrastEnhancement = null;
if (contrastGrp.isPanelEnabled()) {
Expression gammaExpression = fieldConfigVisitor.getExpression(gammaField);
GroupConfigInterface constrastMethodGroup = getGroup(contrastMethod);
if (constrastMethodGroup != null) {
String method = null;
MultiOptionGroup constrastMethodGroup2 = (MultiOptionGroup) constrastMethodGroup;
OptionGroup selectedOption = constrastMethodGroup2.getSelectedOptionGroup();
if (selectedOption != null) {
method = selectedOption.getLabel();
}
contrastEnhancement = (ContrastEnhancement) getStyleFactory().contrastEnhancement(gammaExpression, method);
}
}
channelType = getStyleFactory().createSelectedChannelType(channelName, contrastEnhancement);
}
return channelType;
}
Aggregations