use of com.sldeditor.ui.detail.config.base.MultiOptionGroup in project sldeditor by robward-scisys.
the class RasterSymbolizerDetails method populate.
/**
* Populate.
*
* @param selectedSymbol the selected symbol
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.selectedsymbol.SelectedSymbol)
*/
@Override
public void populate(SelectedSymbol selectedSymbol) {
if (selectedSymbol != null) {
RasterSymbolizer rasterSymbolizer = (RasterSymbolizer) selectedSymbol.getSymbolizer();
if (rasterSymbolizer != null) {
populateStandardData(rasterSymbolizer);
// Opacity
fieldConfigVisitor.populateField(FieldIdEnum.RASTER_OPACITY, rasterSymbolizer.getOpacity());
// Contrast enhancement
ContrastEnhancement contrast = rasterSymbolizer.getContrastEnhancement();
GroupConfigInterface group = getGroup(GroupIdEnum.RASTER_CONTRAST);
if (group != null) {
group.enable(contrast != null);
}
if (contrast != null) {
Expression gammaValue = contrast.getGammaValue();
fieldConfigVisitor.populateField(FieldIdEnum.RASTER_CONTRAST_GAMMAVALUE, gammaValue);
populateContrastMethod(contrast, GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD);
}
// Channel selection
group = getGroup(GroupIdEnum.RASTER_CHANNELSELECTION);
if (group != null) {
MultiOptionGroup channelSelectionGroup = (MultiOptionGroup) group;
ChannelSelection channelSelection = rasterSymbolizer.getChannelSelection();
boolean enableChannelSelection = false;
if (channelSelection != null) {
SelectedChannelType[] rgbChannels = channelSelection.getRGBChannels();
enableChannelSelection = ((channelSelection.getGrayChannel() != null) || (rgbChannels[0] != null) || (rgbChannels[1] != null) || (rgbChannels[2] != null));
}
channelSelectionGroup.enable(enableChannelSelection);
if (enableChannelSelection) {
SelectedChannelType greyChannel = channelSelection.getGrayChannel();
if (greyChannel != null) {
channelSelectionGroup.setOption(GroupIdEnum.RASTER_GREY_CHANNEL_OPTION);
populateContrastEnhancementGroup(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, greyChannel);
} else {
SelectedChannelType[] rgbChannels = channelSelection.getRGBChannels();
channelSelectionGroup.setOption(GroupIdEnum.RASTER_RGB_CHANNEL_OPTION);
populateContrastEnhancementGroup(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, rgbChannels[0]);
populateContrastEnhancementGroup(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, rgbChannels[1]);
populateContrastEnhancementGroup(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, rgbChannels[2]);
}
}
}
// Colour map
ColorMap colourMap = rasterSymbolizer.getColorMap();
fieldConfigVisitor.populateComboBoxField(FieldIdEnum.RASTER_COLOURMAP_TYPE, Integer.valueOf(colourMap.getType()).toString());
fieldConfigVisitor.populateColourMapField(FieldIdEnum.RASTER_COLOURMAP, colourMap);
// Shaded relief
ShadedRelief shadedRelief = rasterSymbolizer.getShadedRelief();
group = getGroup(GroupIdEnum.RASTER_SHADEDRELIEF);
if (group != null) {
group.enable(shadedRelief != null);
}
if (shadedRelief != null) {
fieldConfigVisitor.populateBooleanField(FieldIdEnum.RASTER_SHADEDRELIEF_BRIGHTNESS, shadedRelief.isBrightnessOnly());
fieldConfigVisitor.populateField(FieldIdEnum.RASTER_SHADEDRELIEF_FACTOR, shadedRelief.getReliefFactor());
}
// Overlap behaviour
OverlapBehavior overlapBehaviour = rasterSymbolizer.getOverlapBehavior();
group = getGroup(GroupIdEnum.RASTER_OVERLAP);
if (group != null) {
group.enable(overlapBehaviour != null);
}
if (overlapBehaviour != null) {
fieldConfigVisitor.populateComboBoxField(FieldIdEnum.RASTER_OVERLAP_BEHAVIOUR, overlapBehaviour.name());
}
if (vendorOptionRasterFactory != null) {
vendorOptionRasterFactory.populate(rasterSymbolizer);
}
}
}
}
use of com.sldeditor.ui.detail.config.base.MultiOptionGroup in project sldeditor by robward-scisys.
the class BasePanel method populateOptionGroup.
/**
* Populate option group.
*
* @param parent the parent
* @param optionGroupConfig the option group config
*/
private void populateOptionGroup(UpdateSymbolInterface parent, GroupConfig optionGroupConfig) {
List<FieldConfigBase> fieldList = optionGroupConfig.getFieldConfigList();
fieldConfigManager.addGroup(optionGroupConfig);
// Create field user interface
for (FieldConfigBase field : fieldList) {
addFieldConfig(field);
fieldConfigManager.addField(field);
}
// Register for notifications when data has changed
registerForSymbolUpdates(fieldList, parent);
for (GroupConfigInterface subOptionGroupConfig : optionGroupConfig.getSubGroupList()) {
if (subOptionGroupConfig instanceof GroupConfig) {
populateOptionGroup(parent, (GroupConfig) subOptionGroupConfig);
} else if (subOptionGroupConfig instanceof MultiOptionGroup) {
MultiOptionGroup multiOption = (MultiOptionGroup) subOptionGroupConfig;
fieldConfigManager.addMultiOptionGroup(multiOption);
for (OptionGroup optionGroup : multiOption.getGroupList()) {
for (GroupConfigInterface subMultiOptionGroupConfig : optionGroup.getGroupList()) {
if (subMultiOptionGroupConfig instanceof GroupConfig) {
populateOptionGroup(parent, (GroupConfig) subMultiOptionGroupConfig);
}
}
}
}
}
}
use of com.sldeditor.ui.detail.config.base.MultiOptionGroup in project sldeditor by robward-scisys.
the class GraphicPanelFieldManagerTest method testAddMultiOptionGroup.
/**
* Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#addMultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)}.
* Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#getMultiOptionGroup(java.lang.Class, com.sldeditor.common.xml.ui.GroupIdEnum)}.
*/
@Test
public void testAddMultiOptionGroup() {
Class<?> expectedPanelId = StrokeDetails.class;
GraphicPanelFieldManager mgr = new GraphicPanelFieldManager(expectedPanelId);
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(String.class, expectedFieldId, "test label", false), "button text");
mgr.addField(stringField);
MultiOptionGroup multiOption = new MultiOptionGroup();
GroupIdEnum expectedGroupId = GroupIdEnum.FILLSYMBOL;
multiOption.setId(expectedGroupId);
mgr.addMultiOptionGroup(multiOption);
MultiOptionGroup actualValue = mgr.getMultiOptionGroup(null, null);
assertNull(actualValue);
actualValue = mgr.getMultiOptionGroup(expectedPanelId, expectedGroupId);
assertEquals(multiOption, actualValue);
}
Aggregations